X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliAODHandler.cxx;h=4716e6bb242b60639e1167361f8769d8a999c95e;hb=6c7808779bf02a21532a8335106f4ab6260c8812;hp=543c802bde04fffe043610678149fc7b63b89d0c;hpb=80a8335a1015e516363755da609325f10244e3db;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliAODHandler.cxx b/STEER/AliAODHandler.cxx index 543c802bde0..4716e6bb242 100644 --- a/STEER/AliAODHandler.cxx +++ b/STEER/AliAODHandler.cxx @@ -32,6 +32,7 @@ ClassImp(AliAODHandler) //______________________________________________________________________________ AliAODHandler::AliAODHandler() : AliVEventHandler(), + fIsStandard(kTRUE), fAODEvent(NULL), fTreeA(NULL), fFileA(NULL), @@ -43,6 +44,7 @@ AliAODHandler::AliAODHandler() : //______________________________________________________________________________ AliAODHandler::AliAODHandler(const char* name, const char* title): AliVEventHandler(name, title), + fIsStandard(kTRUE), fAODEvent(NULL), fTreeA(NULL), fFileA(NULL), @@ -53,39 +55,49 @@ AliAODHandler::AliAODHandler(const char* name, const char* title): //______________________________________________________________________________ AliAODHandler::~AliAODHandler() { -// destructor + delete fAODEvent; + if(fFileA){ + // is already handled in TerminateIO + fFileA->Close(); + delete fFileA; + } + delete fTreeA; + delete fName; + // destructor } -Bool_t AliAODHandler::InitIO(Option_t* opt) +Bool_t AliAODHandler::Init(Option_t* opt) { - // Initialize IO - // - // Create the AODevent object + // Initialize IO + // + // Create the AODevent object + if(!fAODEvent){ fAODEvent = new AliAODEvent(); - fAODEvent->CreateStdContent(); - // - // File opening according to execution mode - - if (!(strcmp(opt, "proof"))) { - // proof - } else { - // local and grid - fFileA = new TFile(fName, "RECREATE"); - } - // - // Create the output tree - CreateTree(); - - return kTRUE; + if (fIsStandard) fAODEvent->CreateStdContent(); + } + // + // File opening according to execution mode + + if (!(strcmp(opt, "proof"))) { + // proof + CreateTree(0); + } else { + // local and grid + TDirectory *owd = gDirectory; + fFileA = new TFile(fName, "RECREATE"); + CreateTree(1); + owd->cd(); + } + return kTRUE; } Bool_t AliAODHandler::FinishEvent() { // Fill data structures + fAODEvent->MakeEntriesReferencable(); FillTree(); - fAODEvent->ClearStd(); - + if (fIsStandard) fAODEvent->ResetStd(); return kTRUE; } @@ -99,16 +111,21 @@ Bool_t AliAODHandler::Terminate() Bool_t AliAODHandler::TerminateIO() { // Terminate IO - fFileA->Close(); + if (fFileA) { + fFileA->ls(); + fFileA->Close(); + delete fFileA; + } return kTRUE; } -void AliAODHandler::CreateTree() +void AliAODHandler::CreateTree(Int_t flag) { // Creates the AOD Tree fTreeA = new TTree("aodTree", "AliAOD tree"); fTreeA->Branch(fAODEvent->GetList()); + if (flag == 0) fTreeA->SetDirectory(0); } void AliAODHandler::FillTree() @@ -123,3 +140,15 @@ void AliAODHandler::AddAODtoTreeUserInfo() // Add aod event to tree user info fTreeA->GetUserInfo()->Add(fAODEvent); } + +void AliAODHandler::AddBranch(const char* cname, TObject* addobj) +{ + // Add a new branch to the aod + TDirectory *owd = gDirectory; + if (fFileA) { + fFileA->cd(); + } + fTreeA->Branch(addobj->GetName(), cname, &addobj); + fAODEvent->AddObject(addobj); + owd->cd(); +}