]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTReaderITSv1.cxx
Too Fast -> ESD modifications not yet commited
[u/mrichter/AliRoot.git] / HBTAN / AliHBTReaderITSv1.cxx
CommitLineData
16f9289f 1//____________________________________________________________________
2//////////////////////////////////////////////////////////////////////
3// //
4// class AliHBTReaderITSv1 //
5// //
6// Reader for ITSv1 tracks. Not maintained since v1 is not //
7// supposed to be used //
8// //
9//////////////////////////////////////////////////////////////////////
1b446896 10
64e553ff 11#include "AliHBTReaderITSv1.h"
64e553ff 12#include "AliHBTRun.h"
13#include "AliHBTParticle.h"
14#include "AliHBTParticleCut.h"
1b446896 15
d0c23b58 16#include <Riostream.h>
64e553ff 17
64e553ff 18#include <TTree.h>
19#include <TBranch.h>
20#include <TObjArray.h>
21#include <TParticle.h>
22#include <TString.h>
64e553ff 23
24#include <AliRun.h>
16f9289f 25#include <AliStack.h>
64e553ff 26#include <AliMagF.h>
27#include <AliKalmanTrack.h>
28#include <AliITSIOTrack.h>
1b446896 29
64e553ff 30ClassImp(AliHBTReaderITSv1)
31/********************************************************************/
1b446896 32
a8a66f34 33AliHBTReaderITSv1::AliHBTReaderITSv1(const Char_t* tracksfilename,const Char_t* galicefilename):
34 fITSTracksFileName(tracksfilename),
35 fGAliceFileName(galicefilename)
36{
37 //ctor
38}
64e553ff 39/********************************************************************/
40
a8a66f34 41AliHBTReaderITSv1::AliHBTReaderITSv1(TObjArray* dirs, const Char_t* tracksfilename,const Char_t* galicefilename):
42 AliHBTReader(dirs),
43 fITSTracksFileName(tracksfilename),
44 fGAliceFileName(galicefilename)
45{
46//ctor
47}
64e553ff 48/********************************************************************/
49
50AliHBTReaderITSv1::~AliHBTReaderITSv1()
1b446896 51{
a8a66f34 52//dtor
1b446896 53}
64e553ff 54/********************************************************************/
55
1b446896 56
57Int_t AliHBTReaderITSv1::Read(AliHBTRun* particles, AliHBTRun *tracks)
64e553ff 58{
a8a66f34 59//Reads data
60 Int_t nevents = 0;
64e553ff 61 AliITSIOTrack *iotrack=new AliITSIOTrack;
62 Int_t currentdir = 0;
a8a66f34 63 Int_t ndirs;
64 Int_t totalnevents = 0;
b0d56759 65
64e553ff 66 if (fDirs)
67 {
a8a66f34 68 ndirs = fDirs->GetEntries();
64e553ff 69 }
70 else
71 {
a8a66f34 72 ndirs = 0;
64e553ff 73 }
74
75 do //do while is good even if
76 {
77 TFile* gAliceFile = OpenGAliceFile(currentdir);
78 if(gAliceFile == 0x0)
1b446896 79 {
64e553ff 80 Error("Read","Can not open the file with gAlice");
81 delete iotrack;
82 return 1;
1b446896 83 }
64e553ff 84 if (gAlice->TreeE())//check if tree E exists
85 {
a8a66f34 86 nevents = (Int_t)gAlice->TreeE()->GetEntries();//if yes get number of events in gAlice
64e553ff 87 cout<<"________________________________________________________\n";
a8a66f34 88 cout<<"Found "<<nevents<<" event(s) in directory "<<GetDirName(currentdir)<<endl;
64e553ff 89 cout<<"Setting Magnetic Field. Factor is "<<gAlice->Field()->Factor()<<endl;
90 AliKalmanTrack::SetConvConst(100/0.299792458/0.2/gAlice->Field()->Factor());
91 }
92 else
93 {//if not return an error
94 Error("Read","Can not find Header tree (TreeE) in gAlice");
95 delete iotrack;
96 return 4;
97 }
0f14cc3e 98
99 TFile *file = OpenTrackFile(currentdir);
100 if(file == 0x0)
101 {
102 Error("Read","Can not open the file with ITS tracks V1");
103 delete iotrack;
104 return 2;
105 }
b0d56759 106
107 Int_t naccepted = 0;
64e553ff 108 char tname[30];
b0d56759 109
a8a66f34 110 for (Int_t currentEvent = 0; currentEvent < nevents; currentEvent++)
64e553ff 111 {
b0d56759 112 cout<<"Reading Event "<<currentEvent;
64e553ff 113
114 sprintf(tname,"TreeT%d",currentEvent);
115 file->cd();
116 TTree *tracktree=(TTree*)file->Get(tname);
117 TBranch *tbranch=tracktree->GetBranch("ITStracks");
118 tbranch->SetAddress(&iotrack);
119
120 gAliceFile->cd();
121 gAlice->GetEvent(currentEvent);
16f9289f 122 gAlice->Stack()->Particles();
1b446896 123
64e553ff 124 Int_t nentr=(Int_t)tracktree->GetEntries();
b0d56759 125
126 cout<<". Found "<<nentr<<" tracks.";
127 fflush(0);
128
64e553ff 129 for (Int_t i=0; i<nentr; i++)
130 {
1b446896 131
64e553ff 132 tracktree->GetEvent(i);
133 if(!iotrack) continue;
134 Int_t label = iotrack->GetLabel();
135 if (label < 0)
136 {
6440fe71 137 continue;
64e553ff 138 }
0f14cc3e 139
16f9289f 140 TParticle *p = (TParticle*)gAlice->Stack()->Particle(label);
64e553ff 141 if(!p)
142 {
143 Warning("Read","Can not get particle with label &d",label);
144 continue;
145 }
146 if(Pass(p->GetPdgCode())) continue; //check if we are intersted with particles of this type
147 //if not take next partilce
1b446896 148
8089a083 149 AliHBTParticle* part = new AliHBTParticle(*p,i);
64e553ff 150 if(Pass(part)) { delete part; continue;}//check if meets all criteria of any of our cuts
151 //if it does not delete it and take next good track
152
153 Double_t px=iotrack->GetPx();
154 Double_t py=iotrack->GetPy();
155 Double_t pz=iotrack->GetPz();
156 Double_t mass = p->GetMass();
157 Double_t tEtot = TMath::Sqrt(px*px + py*py + pz*pz + mass*mass);//total energy of the track
158
159 Double_t x= iotrack->GetX();
160 Double_t y= iotrack->GetY();
161 Double_t z= iotrack->GetZ();
162
88cb7938 163 AliHBTParticle* track = new AliHBTParticle(p->GetPdgCode(), i, px, py , pz, tEtot, x, y, z, 0.);
64e553ff 164 if(Pass(track)) { delete track;continue;}//check if meets all criteria of any of our cuts
165 //if it does not delete it and take next good track
1b446896 166
a8a66f34 167 particles->AddParticle(totalnevents,part);//put track and particle on the run
168 tracks->AddParticle(totalnevents,track);
b0d56759 169 naccepted++;
64e553ff 170 }//end loop over tracks in the event
1b446896 171
a8a66f34 172 totalnevents++;
b0d56759 173 cout<<" Accepted "<<naccepted<<" tracks"<<endl;
64e553ff 174 }//end of loop over events in current directory
175
176 gAliceFile->Close();
177 delete gAliceFile;
178 gAliceFile = 0;
179
180 file->Close();
181 delete file;
182 file = 0;
429f368c 183 currentdir++;
a8a66f34 184 }while(currentdir < ndirs);//end of loop over directories specified in fDirs Obj Array
1b446896 185
1b446896 186
64e553ff 187 delete iotrack;
188 fIsRead = kTRUE;
189 return 0;
190
1b446896 191 }
64e553ff 192/********************************************************************/
1b446896 193
64e553ff 194TFile* AliHBTReaderITSv1::OpenTrackFile(Int_t ndir)
195{
196//opens files to be read for given directoru nomber in fDirs Array
197 const TString& dirname = GetDirName(ndir);
198 if (dirname == "")
199 {
200 Error("OpenGAliceFile","Can not get directory name");
201 return 0x0;
202 }
203 TString filename = dirname + "/" + fITSTracksFileName;
f20bcaaa 204
205 TFile *file = TFile::Open(filename.Data());
64e553ff 206 if (!file)
207 {
208 Error("Read","Can not open file %s",filename.Data());
209 return 0x0;
210 }
211 if (!file->IsOpen())
212 {
213 Error("Read","Can not open file %s",filename.Data());
214 return 0x0;
215 }
216
217 return file;
218}
1b446896 219
220
64e553ff 221/********************************************************************/
222TFile* AliHBTReaderITSv1::OpenGAliceFile(Int_t ndir)
223{
a8a66f34 224//Opens galice.root file
64e553ff 225 const TString& dirname = GetDirName(ndir);
226 if (dirname == "")
227 {
228 Error("OpenGAliceFile","Can not get directory name");
229 return 0x0;
230 }
1b446896 231
64e553ff 232 TString filename = dirname + "/" + fGAliceFileName;
233
234 TFile* gAliceFile = TFile::Open(filename.Data());
235 if ( gAliceFile== 0x0)
1b446896 236 {
64e553ff 237 Error("OpenFiles","Can't open file named %s",filename.Data());
238 return 0x0;
1b446896 239 }
64e553ff 240 if (!gAliceFile->IsOpen())
1b446896 241 {
64e553ff 242 Error("OpenFiles","Can't open file named %s",filename.Data());
243 return 0x0;
1b446896 244 }
1b446896 245
64e553ff 246 if (!(gAlice=(AliRun*)gAliceFile->Get("gAlice")))
247 {
248 Error("OpenFiles","gAlice have not been found on %s !\n",filename.Data());
249 gAliceFile->Close();
250 delete gAliceFile;
251 return 0x0;
252 }
253
254 return gAliceFile;
255}
256
257/********************************************************************/
258/********************************************************************/
259
260