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 // Event handler for ESD input
20 // Author: Andreas Morsch, CERN
21 //-------------------------------------------------------------------------
26 #include <TArchiveFile.h>
27 #include <TObjArray.h>
30 #include <TObjString.h>
31 #include <TProcessID.h>
33 #include "AliESDInputHandler.h"
34 #include "AliESDEvent.h"
36 #include "AliRunTag.h"
37 #include "AliEventTag.h"
40 ClassImp(AliESDInputHandler)
42 static Option_t *gESDDataType = "ESD";
44 //______________________________________________________________________________
45 AliESDInputHandler::AliESDInputHandler() :
46 AliInputEventHandler(),
55 // default constructor
58 //______________________________________________________________________________
59 AliESDInputHandler::~AliESDInputHandler()
65 //______________________________________________________________________________
66 AliESDInputHandler::AliESDInputHandler(const char* name, const char* title):
67 AliInputEventHandler(name, title), fEvent(0x0), fAnalysisType(0),
68 fNEvents(0), fUseTags(kFALSE), fChainT(0), fTreeT(0), fRunTag(0)
73 Bool_t AliESDInputHandler::Init(TTree* tree, Option_t* opt)
75 // Initialisation necessary for each new tree
79 if (!fTree) return kFALSE;
80 // Get pointer to ESD event
88 fEvent = new AliESDEvent();
90 fEvent->ReadFromTree(fTree);
91 fNEvents = fTree->GetEntries();
95 Bool_t AliESDInputHandler::BeginEvent(Long64_t /*entry*/)
97 // Copy from old to new format if necessary
98 AliESD* old = ((AliESDEvent*) fEvent)->GetAliESDOld();
100 ((AliESDEvent*)fEvent)->CopyFromOldESD();
106 Bool_t AliESDInputHandler::FinishEvent()
109 if(fEvent)fEvent->Reset();
113 Bool_t AliESDInputHandler::Notify(const char* path)
115 // Notify a directory change
116 AliInfo(Form("Directory change %s \n", path));
118 if (!fUseTags) return (kTRUE);
122 TString fileName(path);
123 if(fileName.Contains("#AliESDs.root")){
126 else if (fileName.Contains("AliESDs.root")){
127 fileName.ReplaceAll("AliESDs.root", "");
129 else if(fileName.Contains("#AliAOD.root")){
132 else if(fileName.Contains("AliAOD.root")){
133 fileName.ReplaceAll("AliAOD.root", "");
135 else if(fileName.Contains("#galice.root")){
136 // For running with galice and kinematics alone...
139 else if(fileName.Contains("galice.root")){
140 // For running with galice and kinematics alone...
141 fileName.ReplaceAll("galice.root", "");
145 TString pathName("./");
146 if (fileName.Length() != 0) {
150 printf("AliESDInputHandler::Notify() Path: %s\n", pathName.Data());
155 fRunTag = new AliRunTag();
158 delete fTreeT; fTreeT = 0;
166 fChainT = new TChain("T");
171 const char* tagPattern = "ESD.tag.root";
172 const char* name = 0x0;
175 TFile* file = fTree->GetCurrentFile();
176 TArchiveFile* arch = file->GetArchive();
177 TObjArray* arr = arch->GetMembers();
180 while ((file = (TFile*) next())) {
181 name = file->GetName();
182 if (strstr(name,tagPattern)) {
183 tagFilename = pathName.Data();
186 fChainT->Add(tagFilename);
187 AliInfo(Form("Adding %s to tag chain \n", tagFilename.Data()));
189 } // archive file loop
191 void * dirp = gSystem->OpenDirectory(pathName.Data());
192 while((name = gSystem->GetDirEntry(dirp))) {
193 if (strstr(name,tagPattern)) {
194 tagFilename = pathName.Data();
197 fChainT->Add(tagFilename);
198 AliInfo(Form("Adding %s to tag chain \n", tagFilename.Data()));
202 fChainT->SetBranchAddress("AliTAG",&fRunTag);
203 fChainT->GetEntry(0);
209 Option_t *AliESDInputHandler::GetDataType() const
211 // Returns handled data type.