//______________________________________________________________________________
AliAODHandler::AliAODHandler() :
AliVEventHandler(),
+ fIsStandard(kTRUE),
fAODEvent(NULL),
fTreeA(NULL),
fFileA(NULL),
//______________________________________________________________________________
AliAODHandler::AliAODHandler(const char* name, const char* title):
AliVEventHandler(name, title),
+ fIsStandard(kTRUE),
fAODEvent(NULL),
fTreeA(NULL),
fFileA(NULL),
//______________________________________________________________________________
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;
}
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()
// 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();
+}