]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliESDInputHandler.cxx
Bug fix. Removed delete statement
[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),
1aa09fd1 50 fUseTags(kFALSE),
51 fChainT(0),
52 fTreeT(0),
53 fRunTag(0)
d3dd3d14 54{
55 // default constructor
56}
57
58//______________________________________________________________________________
59AliESDInputHandler::~AliESDInputHandler()
60{
1aa09fd1 61 // destructor
6989bff3 62 // delete fEvent;
d3dd3d14 63}
64
65//______________________________________________________________________________
66AliESDInputHandler::AliESDInputHandler(const char* name, const char* title):
f16ba708 67 AliInputEventHandler(name, title), fEvent(0x0), fAnalysisType(0),
361a8f3c 68 fNEvents(0), fUseTags(kFALSE), fChainT(0), fTreeT(0), fRunTag(0)
d3dd3d14 69{
e12e402c 70 // Constructor
d3dd3d14 71}
72
1aa09fd1 73Bool_t AliESDInputHandler::Init(TTree* tree, Option_t* opt)
d3dd3d14 74{
300d5701 75 // Initialisation necessary for each new tree
1aa09fd1 76 fAnalysisType = opt;
77 fTree = tree;
300d5701 78
6073f8c9 79 if (!fTree) return kFALSE;
d3dd3d14 80 // Get pointer to ESD event
300d5701 81 SwitchOffBranches();
3858dd64 82 SwitchOnBranches();
300d5701 83
60996693 84 if (fEvent) {
85 delete fEvent;
86 fEvent = 0;
6989bff3 87 }
60996693 88 fEvent = new AliESDEvent();
89
90 fEvent->ReadFromTree(fTree);
4d2a7370 91 fNEvents = fTree->GetEntries();
d3dd3d14 92 return kTRUE;
93}
94
ed97dc98 95Bool_t AliESDInputHandler::BeginEvent(Long64_t /*entry*/)
d3dd3d14 96{
97 // Copy from old to new format if necessary
d7749dec 98 AliESD* old = ((AliESDEvent*) fEvent)->GetAliESDOld();
99 if (old) {
d3dd3d14 100 ((AliESDEvent*)fEvent)->CopyFromOldESD();
101 old->Reset();
d7749dec 102 }
103 return kTRUE;
d3dd3d14 104}
105
e12e402c 106Bool_t AliESDInputHandler::FinishEvent()
107{
108 // Finish the event
109 if(fEvent)fEvent->Reset();
110 return kTRUE;
6989bff3 111}
112
1aa09fd1 113Bool_t AliESDInputHandler::Notify(const char* path)
114{
115 // Notify a directory change
a5112f7d 116 AliInfo(Form("Directory change %s \n", path));
117 //
1aa09fd1 118 if (!fUseTags) return (kTRUE);
119
120 Bool_t zip = kFALSE;
121
122 TString fileName(path);
123 if(fileName.Contains("#AliESDs.root")){
1aa09fd1 124 zip = kTRUE;
125 }
126 else if (fileName.Contains("AliESDs.root")){
127 fileName.ReplaceAll("AliESDs.root", "");
128 }
129 else if(fileName.Contains("#AliAOD.root")){
1aa09fd1 130 zip = kTRUE;
131 }
132 else if(fileName.Contains("AliAOD.root")){
133 fileName.ReplaceAll("AliAOD.root", "");
134 }
135 else if(fileName.Contains("#galice.root")){
136 // For running with galice and kinematics alone...
1aa09fd1 137 zip = kTRUE;
138 }
139 else if(fileName.Contains("galice.root")){
140 // For running with galice and kinematics alone...
141 fileName.ReplaceAll("galice.root", "");
142 }
143
1aa09fd1 144
be4763e2 145 TString pathName("./");
146 if (fileName.Length() != 0) {
147 pathName = fileName;
148 }
149
150 printf("AliESDInputHandler::Notify() Path: %s\n", pathName.Data());
1aa09fd1 151
152 if (fRunTag) {
153 fRunTag->Clear();
154 } else {
155 fRunTag = new AliRunTag();
156 }
157
158 delete fTreeT; fTreeT = 0;
159
160 if (fChainT) {
161 delete fChainT;
162 fChainT = 0;
163 }
164
165 if (!fChainT) {
166 fChainT = new TChain("T");
167 }
168
169
170
171 const char* tagPattern = "ESD.tag.root";
172 const char* name = 0x0;
173 TString tagFilename;
174 if (zip) {
8ac5c1d7 175 TFile* file = fTree->GetCurrentFile();
1aa09fd1 176 TArchiveFile* arch = file->GetArchive();
177 TObjArray* arr = arch->GetMembers();
178 TIter next(arr);
179
7cec0871 180 while ((file = (TFile*) next())) {
1aa09fd1 181 name = file->GetName();
182 if (strstr(name,tagPattern)) {
be4763e2 183 tagFilename = pathName.Data();
1aa09fd1 184 tagFilename += "#";
185 tagFilename += name;
186 fChainT->Add(tagFilename);
187 AliInfo(Form("Adding %s to tag chain \n", tagFilename.Data()));
188 }//pattern check
189 } // archive file loop
190 } else {
be4763e2 191 void * dirp = gSystem->OpenDirectory(pathName.Data());
1aa09fd1 192 while((name = gSystem->GetDirEntry(dirp))) {
193 if (strstr(name,tagPattern)) {
be4763e2 194 tagFilename = pathName.Data();
1aa09fd1 195 tagFilename += "/";
196 tagFilename += name;
197 fChainT->Add(tagFilename);
198 AliInfo(Form("Adding %s to tag chain \n", tagFilename.Data()));
199 }//pattern check
200 }//directory loop
201 }
202 fChainT->SetBranchAddress("AliTAG",&fRunTag);
203 fChainT->GetEntry(0);
204 return kTRUE;
205}
206
207
c2b6979d 208
209Option_t *AliESDInputHandler::GetDataType() const
210{
211// Returns handled data type.
212 return gESDDataType;
213}