]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - ANALYSIS/AliReaderESDTree.cxx
From Alexandru: removed files.
[u/mrichter/AliRoot.git] / ANALYSIS / AliReaderESDTree.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, 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// class AliReaderESDTree
20// Reader for MUON ESD Tree (only for rec)
21// finck@subatech.in2p3.fr
22//***********************************************************************
23
24#include <TString.h>
25#include <TTree.h>
26#include <TFile.h>
27
28#include "AliAOD.h"
29#include "AliESD.h"
30#include "AliLog.h"
31#include "AliReaderESDTree.h"
32#include "AliRunLoader.h"
33
34
35ClassImp(AliReaderESDTree)
36
37AliReaderESDTree::AliReaderESDTree(const Char_t* esdfilename, const Char_t* galfilename):
38 AliReaderESD(esdfilename,galfilename),
39 fTree(0x0)
40{
41//ctor
42}
43
44/********************************************************************/
45AliReaderESDTree::~AliReaderESDTree()
46{
47//dtor
48 delete fTree;
49}
50
51/**********************************************************/
52Int_t AliReaderESDTree::ReadNext()
53{
54//reads next event from fFile
55//fRunLoader is for reading Kine
56
57 AliDebug(1,"Entered");
58
59 if (fEventSim == 0x0) fEventSim = new AliAOD();
60 if (fEventRec == 0x0) fEventRec = new AliAOD();
61
62 fEventSim->Reset();
63 fEventRec->Reset();
64
65 do //do{}while; is OK even if 0 dirs specified. In that case we try to read from "./"
66 {
67 if (fFile == 0x0)
68 {
69 fFile = OpenFile(fCurrentDir);//rl is opened here
70 if (fFile == 0x0)
71 {
72 Error("ReadNext","Cannot get fFile for dir no. %d",fCurrentDir);
73 fCurrentDir++;
74 continue;
75 }
76 fCurrentEvent = 0;
77 }
78
79 static AliESD* esd = 0x0;
80 fTree->SetBranchAddress("ESD", &esd);
81 Int_t status = fTree->GetEvent(fCurrentEvent);
82
83 if (!status)
84 {
85 AliDebug(2,Form("Cannot find event# %d in Tree", fCurrentEvent));
86 fCurrentDir++;
87 delete fTree;
88 fTree = 0x0;
89 delete fFile;//we have to assume there is no more ESD objects in the fFile
90 fFile = 0x0;
91 delete fRunLoader;
92 fRunLoader = 0x0;
93 continue;
94 }
95
96 ReadESD(esd);
97
98 fCurrentEvent++;
99 fNEventsRead++;
100 return 0;//success -> read one event
101 }while(fCurrentDir < GetNumberOfDirs());//end of loop over directories specified in fDirs Obj Array
102
103 return 1; //no more directories to read
104}
105
106/**********************************************************/
107TFile* AliReaderESDTree::OpenFile(Int_t n)
108{
109//opens fFile with kine tree
110
111 const TString& dirname = GetDirName(n);
112 if (dirname == "")
113 {
114 Error("OpenFiles","Can not get directory name");
115 return 0x0;
116 }
117 TString filename = dirname +"/"+ fESDFileName;
118 TFile *ret = TFile::Open(filename.Data());
119
120 if (ret == 0x0)
121 {
122 Error("OpenFiles","Can't open fFile %s",filename.Data());
123 return 0x0;
124 }
125 if (!ret->IsOpen())
126 {
127 Error("OpenFiles","Can't open fFile %s",filename.Data());
128 return 0x0;
129 }
130
131 TString esdname = "esdTree";
132 fTree = dynamic_cast<TTree*> (ret->Get(esdname));
133
134 if (!fTree)
135 {
136 Error("OpenFiles","Can't open ESD Tree %s",esdname.Data());
137 delete ret;
138 return 0x0;
139
140 }
141
142 if (fReadSim )
143 {
144 fRunLoader = AliRunLoader::Open(dirname +"/"+ fGAlFileName);
145 if (fRunLoader == 0x0)
146 {
147 Error("OpenFiles","Can't get RunLoader for directory %s",dirname.Data());
148 delete fTree;
149 delete ret;
150 return 0x0;
151 }
152
153 fRunLoader->LoadHeader();
154 if (fRunLoader->LoadKinematics())
155 {
156 Error("Next","Error occured while loading kinematics.");
157 delete fRunLoader;
158 delete fTree;
159 delete ret;
160 return 0x0;
161 }
162 }
163
164 return ret;
165}