1 //____________________________________________________________________
2 //////////////////////////////////////////////////////////////////////
4 // class AliHBTReaderITSv1 //
6 // Reader for ITSv1 tracks. Not maintained since v1 is not //
7 // supposed to be used //
9 //////////////////////////////////////////////////////////////////////
11 #include "AliHBTReaderITSv1.h"
12 #include "AliHBTEvent.h"
13 #include "AliHBTRun.h"
14 #include "AliHBTParticle.h"
15 #include "AliHBTParticleCut.h"
17 #include <Riostream.h>
23 #include <TObjArray.h>
24 #include <TParticle.h>
26 #include <TObjString.h>
31 #include <AliKalmanTrack.h>
32 #include <AliITSIOTrack.h>
34 ClassImp(AliHBTReaderITSv1)
35 /********************************************************************/
38 AliHBTReaderITSv1(const Char_t* tracksfilename,const Char_t* galicefilename):
39 fITSTracksFileName(tracksfilename),fGAliceFileName(galicefilename)
41 fParticles = new AliHBTRun();
42 fTracks = new AliHBTRun();
45 /********************************************************************/
48 AliHBTReaderITSv1(TObjArray* dirs, const Char_t* tracksfilename,const Char_t* galicefilename):
50 fITSTracksFileName(tracksfilename),fGAliceFileName(galicefilename)
52 fParticles = new AliHBTRun();
53 fTracks = new AliHBTRun();
56 /********************************************************************/
58 AliHBTReaderITSv1::~AliHBTReaderITSv1()
63 /********************************************************************/
65 AliHBTEvent* AliHBTReaderITSv1::GetParticleEvent(Int_t n)
67 //returns Nth event with simulated particles
69 if(Read(fParticles,fTracks))
71 Error("GetParticleEvent","Error in reading");
75 return fParticles->GetEvent(n);
77 /********************************************************************/
79 AliHBTEvent* AliHBTReaderITSv1::GetTrackEvent(Int_t n)
81 //returns Nth event with reconstructed tracks
83 if(Read(fParticles,fTracks))
85 Error("GetTrackEvent","Error in reading");
88 return fTracks->GetEvent(n);
90 /********************************************************************/
92 Int_t AliHBTReaderITSv1::GetNumberOfPartEvents()
94 //returns number of events of particles
96 if(Read(fParticles,fTracks))
98 Error("GetNumberOfPartEvents","Error in reading");
101 return fParticles->GetNumberOfEvents();
104 /********************************************************************/
105 Int_t AliHBTReaderITSv1::GetNumberOfTrackEvents()
107 //returns number of events of tracks
109 if(Read(fParticles,fTracks))
111 Error("GetNumberOfTrackEvents","Error in reading");
114 return fTracks->GetNumberOfEvents();
116 /********************************************************************/
118 Int_t AliHBTReaderITSv1::Read(AliHBTRun* particles, AliHBTRun *tracks)
121 AliITSIOTrack *iotrack=new AliITSIOTrack;
122 Int_t currentdir = 0;
124 Int_t totalNevents = 0;
128 Ndirs = fDirs->GetEntries();
135 do //do while is good even if
137 TFile* gAliceFile = OpenGAliceFile(currentdir);
138 if(gAliceFile == 0x0)
140 Error("Read","Can not open the file with gAlice");
144 if (gAlice->TreeE())//check if tree E exists
146 Nevents = (Int_t)gAlice->TreeE()->GetEntries();//if yes get number of events in gAlice
147 cout<<"________________________________________________________\n";
148 cout<<"Found "<<Nevents<<" event(s) in directory "<<GetDirName(currentdir)<<endl;
149 cout<<"Setting Magnetic Field. Factor is "<<gAlice->Field()->Factor()<<endl;
150 AliKalmanTrack::SetConvConst(100/0.299792458/0.2/gAlice->Field()->Factor());
153 {//if not return an error
154 Error("Read","Can not find Header tree (TreeE) in gAlice");
159 TFile *file = OpenTrackFile(currentdir);
162 Error("Read","Can not open the file with ITS tracks V1");
170 for (Int_t currentEvent = 0; currentEvent < Nevents; currentEvent++)
172 cout<<"Reading Event "<<currentEvent;
174 sprintf(tname,"TreeT%d",currentEvent);
176 TTree *tracktree=(TTree*)file->Get(tname);
177 TBranch *tbranch=tracktree->GetBranch("ITStracks");
178 tbranch->SetAddress(&iotrack);
181 gAlice->GetEvent(currentEvent);
182 gAlice->Stack()->Particles();
184 Int_t nentr=(Int_t)tracktree->GetEntries();
186 cout<<". Found "<<nentr<<" tracks.";
189 for (Int_t i=0; i<nentr; i++)
192 tracktree->GetEvent(i);
193 if(!iotrack) continue;
194 Int_t label = iotrack->GetLabel();
200 TParticle *p = (TParticle*)gAlice->Stack()->Particle(label);
203 Warning("Read","Can not get particle with label &d",label);
206 if(Pass(p->GetPdgCode())) continue; //check if we are intersted with particles of this type
207 //if not take next partilce
209 AliHBTParticle* part = new AliHBTParticle(*p,i);
210 if(Pass(part)) { delete part; continue;}//check if meets all criteria of any of our cuts
211 //if it does not delete it and take next good track
213 Double_t px=iotrack->GetPx();
214 Double_t py=iotrack->GetPy();
215 Double_t pz=iotrack->GetPz();
216 Double_t mass = p->GetMass();
217 Double_t tEtot = TMath::Sqrt(px*px + py*py + pz*pz + mass*mass);//total energy of the track
219 Double_t x= iotrack->GetX();
220 Double_t y= iotrack->GetY();
221 Double_t z= iotrack->GetZ();
223 AliHBTParticle* track = new AliHBTParticle(p->GetPdgCode(), i, px, py , pz, tEtot, x, y, z, 0.);
224 if(Pass(track)) { delete track;continue;}//check if meets all criteria of any of our cuts
225 //if it does not delete it and take next good track
227 particles->AddParticle(totalNevents,part);//put track and particle on the run
228 tracks->AddParticle(totalNevents,track);
230 }//end loop over tracks in the event
233 cout<<" Accepted "<<naccepted<<" tracks"<<endl;
234 }//end of loop over events in current directory
244 }while(currentdir < Ndirs);//end of loop over directories specified in fDirs Obj Array
252 /********************************************************************/
254 TFile* AliHBTReaderITSv1::OpenTrackFile(Int_t ndir)
256 //opens files to be read for given directoru nomber in fDirs Array
257 const TString& dirname = GetDirName(ndir);
260 Error("OpenGAliceFile","Can not get directory name");
263 TString filename = dirname + "/" + fITSTracksFileName;
265 TFile *file = TFile::Open(filename.Data());
268 Error("Read","Can not open file %s",filename.Data());
273 Error("Read","Can not open file %s",filename.Data());
281 /********************************************************************/
282 TFile* AliHBTReaderITSv1::OpenGAliceFile(Int_t ndir)
284 const TString& dirname = GetDirName(ndir);
287 Error("OpenGAliceFile","Can not get directory name");
291 TString filename = dirname + "/" + fGAliceFileName;
293 TFile* gAliceFile = TFile::Open(filename.Data());
294 if ( gAliceFile== 0x0)
296 Error("OpenFiles","Can't open file named %s",filename.Data());
299 if (!gAliceFile->IsOpen())
301 Error("OpenFiles","Can't open file named %s",filename.Data());
305 if (!(gAlice=(AliRun*)gAliceFile->Get("gAlice")))
307 Error("OpenFiles","gAlice have not been found on %s !\n",filename.Data());
316 /********************************************************************/
317 /********************************************************************/