2 /**************************************************************************
3 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
5 * Author: The ALICE Off-line Project. *
6 * Contributors are mentioned in the code where appropriate. *
8 * Permission to use, copy, modify and distribute this software and its *
9 * documentation strictly for non-commercial purposes is hereby granted *
10 * without fee, provided that the above copyright notice appears in all *
11 * copies and that both the copyright notice and this permission notice *
12 * appear in the supporting documentation. The authors make no claims *
13 * about the suitability of this software for any purpose. It is *
14 * provided "as is" without express or implied warranty. *
15 **************************************************************************/
19 //-------------------------------------------------------------------------
21 // Implementation of the Virtual Event Handler Interface for ESD
23 //-------------------------------------------------------------------------
32 #include "AliESDHandler.h"
33 #include "AliESDEvent.h"
34 #include "AliESDfriend.h"
37 ClassImp(AliESDHandler)
39 //______________________________________________________________________________
40 AliESDHandler::AliESDHandler() :
49 // default constructor
52 //______________________________________________________________________________
53 AliESDHandler::AliESDHandler(const char* name, const char* title):
54 AliVEventHandler(name, title),
63 // constructor with name and title
67 //______________________________________________________________________________
68 AliESDHandler::~AliESDHandler()
74 // is already handled in TerminateIO
79 // is already handled in TerminateIO
86 //______________________________________________________________________________
87 Bool_t AliESDHandler::Init(Option_t* opt)
93 // File opening according to execution mode
96 TDirectory *owd = gDirectory;
97 if (option.Contains("proof")) {
99 // Merging via files. Need to access analysis manager via interpreter.
100 gROOT->ProcessLine(Form("AliAnalysisManager::GetAnalysisManager()->OpenProofFile(\"%s\", \"RECREATE\");", fFileName.Data()));
101 gROOT->ProcessLine(Form("AliAnalysisManager::GetAnalysisManager()->GetCommonOutputContainer()->SetFile((TFile*)0x%lx);", gFile));
105 fFileE = new TFile(fFileName.Data(), "RECREATE");
115 //______________________________________________________________________________
116 Bool_t AliESDHandler::FinishEvent()
126 fesdf->~AliESDfriend();
127 new(fesdf) AliESDfriend();
131 //______________________________________________________________________________
132 Bool_t AliESDHandler::Terminate()
138 AddESDtoTreeUserInfo();
142 //______________________________________________________________________________
143 Bool_t AliESDHandler::TerminateIO()
161 //______________________________________________________________________________
162 void AliESDHandler::CreateTree(Int_t /*flag*/)
165 // Creates the ESD Tree
168 fTreeE = new TTree("esdTree", "AliESD tree");
169 // Create the ESDevent object
171 fESDEvent = new AliESDEvent();
172 fESDEvent->CreateStdContent();
174 fESDEvent->WriteToTree(fTreeE);
176 //______________________________________________________________________________
177 void AliESDHandler::CreateFriends(Int_t /*flag*/)
179 fesdf = new AliESDfriend();
181 TBranch *br=fTreeE->Branch("ESDfriend.","AliESDfriend", &fesdf);
182 br->SetFile("AliESDfriends_v1.root");
183 fESDEvent->AddObject(fesdf);
186 //______________________________________________________________________________
187 void AliESDHandler::FillTree()
193 AliDebug(2,Form("number of friend tracks = %d\n",fesdf->GetNumberOfTracks()));
199 //______________________________________________________________________________
200 void AliESDHandler::AddESDtoTreeUserInfo()
203 // Add aod event to tree user info
206 fTreeE->GetUserInfo()->Add(fESDEvent);