]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDInputHandler.cxx
change TH1 status bit for expert, QA and image that were overlapping with other TH1...
[u/mrichter/AliRoot.git] / STEER / AliESDInputHandler.cxx
CommitLineData
d3dd3d14 1/**************************************************************************
2 * Copyright(c) 1998-2007, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
16/* $Id$ */
17
18//-------------------------------------------------------------------------
19// Event handler for ESD input
20// Author: Andreas Morsch, CERN
21//-------------------------------------------------------------------------
22
933fd60f 23#include <TTree.h>
1aa09fd1 24#include <TChain.h>
25#include <TFile.h>
26#include <TArchiveFile.h>
27#include <TObjArray.h>
28#include <TSystem.h>
300d5701 29#include <TString.h>
30#include <TObjString.h>
80e1b60a 31#include <TProcessID.h>
d3dd3d14 32
33#include "AliESDInputHandler.h"
34#include "AliESDEvent.h"
35#include "AliESD.h"
1aa09fd1 36#include "AliRunTag.h"
37#include "AliEventTag.h"
300d5701 38#include "AliLog.h"
d3dd3d14 39
40ClassImp(AliESDInputHandler)
41
c2b6979d 42static Option_t *gESDDataType = "ESD";
43
d3dd3d14 44//______________________________________________________________________________
6989bff3 45AliESDInputHandler::AliESDInputHandler() :
46 AliInputEventHandler(),
0cd61c1d 47 fEvent(0x0),
1aa09fd1 48 fAnalysisType(0),
4d2a7370 49 fNEvents(0),
6ccd727b 50 fHLTEvent(0x0),
51 fHLTTree(0x0),
52 fUseHLT(kFALSE),
1aa09fd1 53 fUseTags(kFALSE),
54 fChainT(0),
55 fTreeT(0),
56 fRunTag(0)
d3dd3d14 57{
58 // default constructor
59}
60
61//______________________________________________________________________________
62AliESDInputHandler::~AliESDInputHandler()
63{
1aa09fd1 64 // destructor
6989bff3 65 // delete fEvent;
d3dd3d14 66}
67
68//______________________________________________________________________________
69AliESDInputHandler::AliESDInputHandler(const char* name, const char* title):
f16ba708 70 AliInputEventHandler(name, title), fEvent(0x0), fAnalysisType(0),
6ccd727b 71 fNEvents(0), fHLTEvent(0x0), fHLTTree(0x0), fUseHLT(kFALSE), fUseTags(kFALSE), fChainT(0), fTreeT(0), fRunTag(0)
d3dd3d14 72{
e12e402c 73 // Constructor
d3dd3d14 74}
75
1aa09fd1 76Bool_t AliESDInputHandler::Init(TTree* tree, Option_t* opt)
d3dd3d14 77{
300d5701 78 // Initialisation necessary for each new tree
1aa09fd1 79 fAnalysisType = opt;
80 fTree = tree;
300d5701 81
6073f8c9 82 if (!fTree) return kFALSE;
6ccd727b 83 fTree->GetEntry(0);
84
d3dd3d14 85 // Get pointer to ESD event
300d5701 86 SwitchOffBranches();
3858dd64 87 SwitchOnBranches();
300d5701 88
efea3f54 89 if (!fEvent) fEvent = new AliESDEvent();
60996693 90 fEvent->ReadFromTree(fTree);
4d2a7370 91 fNEvents = fTree->GetEntries();
6ccd727b 92
50aaaf00 93
d3dd3d14 94 return kTRUE;
95}
96
6ccd727b 97Bool_t AliESDInputHandler::BeginEvent(Long64_t entry)
d3dd3d14 98{
99 // Copy from old to new format if necessary
d7749dec 100 AliESD* old = ((AliESDEvent*) fEvent)->GetAliESDOld();
101 if (old) {
d3dd3d14 102 ((AliESDEvent*)fEvent)->CopyFromOldESD();
103 old->Reset();
d7749dec 104 }
6ccd727b 105
106 if (fHLTTree) {
107 fHLTTree->GetEntry(entry);
108 }
109
d7749dec 110 return kTRUE;
d3dd3d14 111}
112
e12e402c 113Bool_t AliESDInputHandler::FinishEvent()
114{
115 // Finish the event
116 if(fEvent)fEvent->Reset();
117 return kTRUE;
6989bff3 118}
119
1aa09fd1 120Bool_t AliESDInputHandler::Notify(const char* path)
121{
122 // Notify a directory change
a5112f7d 123 AliInfo(Form("Directory change %s \n", path));
124 //
50aaaf00 125 if (fUseHLT) {
126 // Get HLTesdTree from current file
127 TTree* cTree = fTree;
128 if (fTree->GetTree()) cTree = fTree->GetTree();
129 TFile* cFile = cTree->GetCurrentFile();
130 cFile->GetObject("HLTesdTree", fHLTTree);
131
132 if (fHLTTree) {
133 if (!fHLTEvent) fHLTEvent = new AliESDEvent();
134 fHLTEvent->ReadFromTree(fHLTTree);
135 }
136 }
137
1aa09fd1 138 if (!fUseTags) return (kTRUE);
139
140 Bool_t zip = kFALSE;
141
142 TString fileName(path);
143 if(fileName.Contains("#AliESDs.root")){
1aa09fd1 144 zip = kTRUE;
145 }
146 else if (fileName.Contains("AliESDs.root")){
147 fileName.ReplaceAll("AliESDs.root", "");
148 }
149 else if(fileName.Contains("#AliAOD.root")){
1aa09fd1 150 zip = kTRUE;
151 }
152 else if(fileName.Contains("AliAOD.root")){
153 fileName.ReplaceAll("AliAOD.root", "");
154 }
155 else if(fileName.Contains("#galice.root")){
156 // For running with galice and kinematics alone...
1aa09fd1 157 zip = kTRUE;
158 }
159 else if(fileName.Contains("galice.root")){
160 // For running with galice and kinematics alone...
161 fileName.ReplaceAll("galice.root", "");
162 }
163
1aa09fd1 164
be4763e2 165 TString pathName("./");
166 if (fileName.Length() != 0) {
167 pathName = fileName;
168 }
169
170 printf("AliESDInputHandler::Notify() Path: %s\n", pathName.Data());
6ccd727b 171
1aa09fd1 172 if (fRunTag) {
173 fRunTag->Clear();
174 } else {
175 fRunTag = new AliRunTag();
176 }
177
178 delete fTreeT; fTreeT = 0;
6ccd727b 179
1aa09fd1 180 if (fChainT) {
181 delete fChainT;
182 fChainT = 0;
183 }
184
185 if (!fChainT) {
186 fChainT = new TChain("T");
187 }
188
189
190
191 const char* tagPattern = "ESD.tag.root";
192 const char* name = 0x0;
193 TString tagFilename;
194 if (zip) {
8ac5c1d7 195 TFile* file = fTree->GetCurrentFile();
1aa09fd1 196 TArchiveFile* arch = file->GetArchive();
197 TObjArray* arr = arch->GetMembers();
198 TIter next(arr);
199
7cec0871 200 while ((file = (TFile*) next())) {
1aa09fd1 201 name = file->GetName();
202 if (strstr(name,tagPattern)) {
be4763e2 203 tagFilename = pathName.Data();
1aa09fd1 204 tagFilename += "#";
205 tagFilename += name;
206 fChainT->Add(tagFilename);
207 AliInfo(Form("Adding %s to tag chain \n", tagFilename.Data()));
208 }//pattern check
209 } // archive file loop
210 } else {
be4763e2 211 void * dirp = gSystem->OpenDirectory(pathName.Data());
1aa09fd1 212 while((name = gSystem->GetDirEntry(dirp))) {
213 if (strstr(name,tagPattern)) {
be4763e2 214 tagFilename = pathName.Data();
1aa09fd1 215 tagFilename += "/";
216 tagFilename += name;
217 fChainT->Add(tagFilename);
218 AliInfo(Form("Adding %s to tag chain \n", tagFilename.Data()));
219 }//pattern check
220 }//directory loop
221 }
222 fChainT->SetBranchAddress("AliTAG",&fRunTag);
223 fChainT->GetEntry(0);
224 return kTRUE;
225}
226
227
c2b6979d 228
229Option_t *AliESDInputHandler::GetDataType() const
230{
231// Returns handled data type.
232 return gESDDataType;
233}