X-Git-Url: http://git.uio.no/git/?a=blobdiff_plain;f=STEER%2FAliAODHandler.cxx;h=cb7a5126ecf9d7bec834bb2c683d1fb21ae28119;hb=a90a332e10e07160edec30aab4dd5e518d3cb10a;hp=6c53a2e08240f881c10da731171aa81e0f77cb19;hpb=ec4af4c158e4b3881ceac43632b458daea955187;p=u%2Fmrichter%2FAliRoot.git diff --git a/STEER/AliAODHandler.cxx b/STEER/AliAODHandler.cxx index 6c53a2e0824..cb7a5126ecf 100644 --- a/STEER/AliAODHandler.cxx +++ b/STEER/AliAODHandler.cxx @@ -20,8 +20,11 @@ // Author: Andreas Morsch, CERN //------------------------------------------------------------------------- -#include + #include +#include +#include + #include "AliAODHandler.h" #include "AliAODEvent.h" @@ -29,50 +32,86 @@ ClassImp(AliAODHandler) //______________________________________________________________________________ AliAODHandler::AliAODHandler() : - AliVirtualEventHandler(), + AliVEventHandler(), + fIsStandard(kTRUE), + fNeedsHeaderReplication(kFALSE), fAODEvent(NULL), - fAODFile(NULL) + fTreeA(NULL), + fFileA(NULL), + fFileName("") { // default constructor } //______________________________________________________________________________ AliAODHandler::AliAODHandler(const char* name, const char* title): - AliVirtualEventHandler(name, title), + AliVEventHandler(name, title), + fIsStandard(kTRUE), + fNeedsHeaderReplication(kFALSE), fAODEvent(NULL), - fAODFile(NULL) + fTreeA(NULL), + fFileA(NULL), + fFileName("") { } //______________________________________________________________________________ AliAODHandler::~AliAODHandler() { -// destructor + delete fAODEvent; + if(fFileA){ + // is already handled in TerminateIO + fFileA->Close(); + delete fFileA; + } + delete fTreeA; + // destructor } - -Bool_t AliAODHandler::InitIO() +//______________________________________________________________________________ +Bool_t AliAODHandler::Init(Option_t* opt) { - // Initialize IO + // Initialize IO + // + // Create the AODevent object + if(!fAODEvent){ fAODEvent = new AliAODEvent(); - fAODEvent->CreateStdContent(); -// fAODFile = new TFile("aod.root", "recreate"); - CreateTree(); - - return kTRUE; + if (fIsStandard) fAODEvent->CreateStdContent(); + } + // + // File opening according to execution mode + TString option(opt); + option.ToLower(); + if (option.Contains("proof")) { + // proof + if (option.Contains("special")) { + // File for tree already opened on slave -> merging via files + fFileA = gFile; + CreateTree(1); + } else { + // Merging in memory + CreateTree(0); + } + } else { + // local and grid + TDirectory *owd = gDirectory; + fFileA = new TFile(fFileName.Data(), "RECREATE"); + CreateTree(1); + owd->cd(); + } + return kTRUE; } -Bool_t AliAODHandler::Fill() +Bool_t AliAODHandler::FinishEvent() { // Fill data structures - printf(">>>>>>>>>>> AliAODHandler::Fill()\n"); - + fAODEvent->MakeEntriesReferencable(); FillTree(); - fAODEvent->ClearStd(); - + if (fIsStandard) fAODEvent->ResetStd(); return kTRUE; } +//______________________________________________________________________________ Bool_t AliAODHandler::Terminate() { // Terminate @@ -80,34 +119,65 @@ Bool_t AliAODHandler::Terminate() return kTRUE; } +//______________________________________________________________________________ Bool_t AliAODHandler::TerminateIO() { // Terminate IO - -// fAODFile->cd(); -// fTreeA->Write(); -// fAODFile->Close(); - + if (fFileA) { + fFileA->Close(); + delete fFileA; + } return kTRUE; } - -void AliAODHandler::CreateTree() +//______________________________________________________________________________ +void AliAODHandler::CreateTree(Int_t flag) { // Creates the AOD Tree - fTreeA = new TTree("AOD", "AliAOD tree"); + fTreeA = new TTree("aodTree", "AliAOD tree"); fTreeA->Branch(fAODEvent->GetList()); + if (flag == 0) fTreeA->SetDirectory(0); } +//______________________________________________________________________________ void AliAODHandler::FillTree() { // Fill the AOD Tree fTreeA->Fill(); } - +//______________________________________________________________________________ void AliAODHandler::AddAODtoTreeUserInfo() { // Add aod event to tree user info fTreeA->GetUserInfo()->Add(fAODEvent); } + +//______________________________________________________________________________ +void AliAODHandler::AddBranch(const char* cname, void* addobj) +{ + // Add a new branch to the aod + TDirectory *owd = gDirectory; + if (fFileA) { + fFileA->cd(); + } + char** apointer = (char**) addobj; + TObject* obj = (TObject*) *apointer; + fTreeA->Branch(obj->GetName(), cname, addobj); + fAODEvent->AddObject(obj); + owd->cd(); +} + +//______________________________________________________________________________ +void AliAODHandler::SetOutputFileName(const char* fname) +{ +// Set file name. + fFileName = fname; +} + +//______________________________________________________________________________ +const char *AliAODHandler::GetOutputFileName() +{ +// Get file name. + return fFileName.Data(); +}