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() :
37 fNeedsHeaderReplication(kFALSE),
43 // default constructor
46 //______________________________________________________________________________
47 AliAODHandler::AliAODHandler(const char* name, const char* title):
48 AliVEventHandler(name, title),
50 fNeedsHeaderReplication(kFALSE),
58 //______________________________________________________________________________
59 AliAODHandler::~AliAODHandler()
63 // is already handled in TerminateIO
71 //______________________________________________________________________________
72 Bool_t AliAODHandler::Init(Option_t* opt)
76 // Create the AODevent object
78 fAODEvent = new AliAODEvent();
79 if (fIsStandard) fAODEvent->CreateStdContent();
82 // File opening according to execution mode
85 if (option.Contains("proof")) {
87 if (option.Contains("special")) {
88 // File for tree already opened on slave -> merging via files
97 TDirectory *owd = gDirectory;
98 fFileA = new TFile(fFileName.Data(), "RECREATE");
105 Bool_t AliAODHandler::FinishEvent()
107 // Fill data structures
108 fAODEvent->MakeEntriesReferencable();
110 if (fIsStandard) fAODEvent->ResetStd();
114 //______________________________________________________________________________
115 Bool_t AliAODHandler::Terminate()
118 AddAODtoTreeUserInfo();
122 //______________________________________________________________________________
123 Bool_t AliAODHandler::TerminateIO()
133 //______________________________________________________________________________
134 void AliAODHandler::CreateTree(Int_t flag)
136 // Creates the AOD Tree
137 fTreeA = new TTree("aodTree", "AliAOD tree");
138 fTreeA->Branch(fAODEvent->GetList());
139 if (flag == 0) fTreeA->SetDirectory(0);
142 //______________________________________________________________________________
143 void AliAODHandler::FillTree()
149 //______________________________________________________________________________
150 void AliAODHandler::AddAODtoTreeUserInfo()
152 // Add aod event to tree user info
153 fTreeA->GetUserInfo()->Add(fAODEvent);
156 //______________________________________________________________________________
157 void AliAODHandler::AddBranch(const char* cname, void* addobj)
159 // Add a new branch to the aod
160 TDirectory *owd = gDirectory;
164 char** apointer = (char**) addobj;
165 TObject* obj = (TObject*) *apointer;
166 fTreeA->Branch(obj->GetName(), cname, addobj);
167 fAODEvent->AddObject(obj);
171 //______________________________________________________________________________
172 void AliAODHandler::SetOutputFileName(const char* fname)
178 //______________________________________________________________________________
179 const char *AliAODHandler::GetOutputFileName()
182 return fFileName.Data();