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 **************************************************************************/
16 /* $Id: AliESDInputHandler.cxx 24521 2008-03-14 16:43:54Z morsch $ */
18 //-------------------------------------------------------------------------
19 // Event handler for ESD input reading the RecPoint Trees in parallel
20 // Author: Andreas Morsch, CERN
21 //-------------------------------------------------------------------------
27 #include <TObjString.h>
28 #include <TProcessID.h>
30 #include "AliESDInputHandlerRP.h"
31 #include "AliESDEvent.h"
35 ClassImp(AliESDInputHandlerRP)
37 //______________________________________________________________________________
38 AliESDInputHandlerRP::AliESDInputHandlerRP() :
48 fPathName(new TString("./"))
50 // default constructor
53 //______________________________________________________________________________
54 AliESDInputHandlerRP::~AliESDInputHandlerRP()
59 //______________________________________________________________________________
60 AliESDInputHandlerRP::AliESDInputHandlerRP(const char* name, const char* title):
61 AliESDInputHandler(name, title),
70 fPathName(new TString("./"))
75 Bool_t AliESDInputHandlerRP::Init(Option_t* opt)
80 if (!(strcmp(opt, "proof")) || !(strcmp(opt, "local"))) return kTRUE;
84 file = TFile::Open(Form("%sTPC.RecPoints.root", fPathName->Data()));
85 if (!file) AliFatal(Form("AliESDInputHandlerRP: TPC.RecPoints.root not found in %s ! \n", fPathName->Data()));
87 fEventsPerFile = file->GetNkeys() - file->GetNProcessIDs();
88 // Reset the event number
91 fNEvent = fTree->GetEntries();
93 printf("AliESDInputHandler::Init() %d\n",__LINE__);
97 Bool_t AliESDInputHandlerRP::BeginEvent(Long64_t entry)
99 // Begin the next event
100 // Delegate to base class
101 AliESDInputHandler::BeginEvent(entry);
105 entry = fEventNumber;
107 fEventNumber = entry;
110 if (entry >= fNEvent) {
111 AliWarning(Form("AliESDInputHandlerRP: Event number out of range %5d %5d\n", entry, fNEvent));
114 return LoadEvent(entry);
117 Bool_t AliESDInputHandlerRP::LoadEvent(Int_t iev)
119 // Load the event number iev
121 // Calculate the file number
122 Int_t inew = iev / fEventsPerFile;
123 if (inew != fFileNumber) {
125 if (!OpenFile(fFileNumber)){
131 sprintf(folder, "Event%d", iev);
133 TFile* file = (TFile*) (fRFiles->At(0));
135 file->GetObject(folder, fDirR);
137 AliWarning(Form("AliESDInputHandlerRP: Event #%5d not found\n", iev));
142 fDirR ->GetObject("TreeR", tree);
149 Bool_t AliESDInputHandlerRP::OpenFile(Int_t i)
154 fExtension = Form("%d", i);
161 file = TFile::Open(Form("%sTPC.RecPoints%s.root", fPathName->Data(), fExtension));
163 AliFatal(Form("AliESDInputHandlerRP: TPC.RecPoints.root not found in %s ! \n", fPathName->Data()));
169 Bool_t AliESDInputHandlerRP::Notify(const char *path)
171 // Notify about directory change
172 // The directory is taken from the 'path' argument
174 TString fileName(path);
175 if(fileName.Contains("AliESDs.root")){
176 fileName.ReplaceAll("AliESDs.root", "");
179 *fPathName = fileName;
181 printf("AliESDInputHandlerRP::Notify() Path: %s\n", fPathName->Data());
189 Bool_t AliESDInputHandlerRP::FinishEvent()
191 // Clean-up after each event
192 delete fDirR; fDirR = 0;
193 AliESDInputHandler::FinishEvent();
197 void AliESDInputHandlerRP::ResetIO()
199 // Delete trees and files