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"
36 ClassImp(AliESDHandler)
38 //______________________________________________________________________________
39 AliESDHandler::AliESDHandler() :
44 fFileName("AliESDfriends_v1.root"),
45 fIsEventSelectedForFriends(kFALSE)
48 // default constructor
51 //______________________________________________________________________________
52 AliESDHandler::AliESDHandler(const char* name, const char* title):
53 AliVEventHandler(name, title),
57 fFileName("AliESDfriends_v1.root"),
58 fIsEventSelectedForFriends(kFALSE)
61 // constructor with name and title
65 //______________________________________________________________________________
66 AliESDHandler::~AliESDHandler()
71 // is already handled in TerminateIO
78 //______________________________________________________________________________
79 Bool_t AliESDHandler::Init(Option_t* opt)
85 // File opening according to execution mode
88 TDirectory *owd = gDirectory;
90 fesdf = new AliESDfriend();
92 // Open the file with friends
93 if (option.Contains("proof")) {
95 // Merging via files. Need to access analysis manager via interpreter.
96 gROOT->ProcessLine(Form("AliAnalysisManager::GetAnalysisManager()->OpenProofFile(\"%s\", \"RECREATE\");", fFileName.Data()));
97 gROOT->ProcessLine(Form("AliAnalysisManager::GetAnalysisManager()->GetCommonOutputContainer()->SetFile((TFile*)0x%p);", gFile));
101 fFileEF = new TFile(fFileName.Data(), "RECREATE");
104 // Create the friends tree
106 fTreeEF = new TTree("esdFriendTree", "Tree with ESD friends");
107 fTreeEF->Branch("ESDfriend.","AliESDfriend", &fesdf);
115 //______________________________________________________________________________
116 Bool_t AliESDHandler::FinishEvent()
125 if (fesdf) fesdf->~AliESDfriend();
126 new(fesdf) AliESDfriend();
130 //______________________________________________________________________________
131 Bool_t AliESDHandler::Terminate()
140 //______________________________________________________________________________
141 Bool_t AliESDHandler::TerminateIO()
158 //______________________________________________________________________________
159 void AliESDHandler::FillTree()
164 if (fIsEventSelectedForFriends){
165 AliDebug(2,Form("number of friend tracks = %d\n",fesdf->GetNumberOfTracks()));
168 fesdf->SetSkipBit(kTRUE);
170 AliDebug(2,Form("friend = %p",fesdf));