1 /**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 //-------------------------------------------------------------------------
19 // Implementation of the Virtual Event Handler Interface for AOD
20 // Author: Andreas Morsch, CERN
21 //-------------------------------------------------------------------------
28 #include "AliAODHandler.h"
29 #include "AliAODEvent.h"
31 ClassImp(AliAODHandler)
33 //______________________________________________________________________________
34 AliAODHandler::AliAODHandler() :
42 // default constructor
45 //______________________________________________________________________________
46 AliAODHandler::AliAODHandler(const char* name, const char* title):
47 AliVEventHandler(name, title),
56 //______________________________________________________________________________
57 AliAODHandler::~AliAODHandler()
61 // is already handled in TerminateIO
69 //______________________________________________________________________________
70 Bool_t AliAODHandler::Init(Option_t* opt)
74 // Create the AODevent object
76 fAODEvent = new AliAODEvent();
77 if (fIsStandard) fAODEvent->CreateStdContent();
80 // File opening according to execution mode
83 if (option.Contains("proof")) {
85 if (option.Contains("special")) {
86 // File for tree already opened on slave -> merging via files
95 TDirectory *owd = gDirectory;
96 fFileA = new TFile(fFileName.Data(), "RECREATE");
103 Bool_t AliAODHandler::FinishEvent()
105 // Fill data structures
106 fAODEvent->MakeEntriesReferencable();
108 if (fIsStandard) fAODEvent->ResetStd();
112 //______________________________________________________________________________
113 Bool_t AliAODHandler::Terminate()
116 AddAODtoTreeUserInfo();
120 //______________________________________________________________________________
121 Bool_t AliAODHandler::TerminateIO()
131 //______________________________________________________________________________
132 void AliAODHandler::CreateTree(Int_t flag)
134 // Creates the AOD Tree
135 fTreeA = new TTree("aodTree", "AliAOD tree");
136 fTreeA->Branch(fAODEvent->GetList());
137 if (flag == 0) fTreeA->SetDirectory(0);
140 //______________________________________________________________________________
141 void AliAODHandler::FillTree()
147 //______________________________________________________________________________
148 void AliAODHandler::AddAODtoTreeUserInfo()
150 // Add aod event to tree user info
151 fTreeA->GetUserInfo()->Add(fAODEvent);
154 //______________________________________________________________________________
155 void AliAODHandler::AddBranch(const char* cname, void* addobj)
157 // Add a new branch to the aod
158 TDirectory *owd = gDirectory;
162 char** apointer = (char**) addobj;
163 TObject* obj = (TObject*) *apointer;
164 fTreeA->Branch(obj->GetName(), cname, addobj);
165 fAODEvent->AddObject(obj);
169 //______________________________________________________________________________
170 void AliAODHandler::SetOutputFileName(const char* fname)
176 //______________________________________________________________________________
177 const char *AliAODHandler::GetOutputFileName()
180 return fFileName.Data();