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 "AliHBTRun.h"
13 #include "AliHBTParticle.h"
14 #include "AliHBTParticleCut.h"
16 #include <Riostream.h>
20 #include <TObjArray.h>
21 #include <TParticle.h>
27 #include <AliKalmanTrack.h>
28 #include <AliITSIOTrack.h>
30 ClassImp(AliHBTReaderITSv1)
31 /********************************************************************/
33 AliHBTReaderITSv1::AliHBTReaderITSv1(const Char_t* tracksfilename,const Char_t* galicefilename):
34 fITSTracksFileName(tracksfilename),
35 fGAliceFileName(galicefilename)
39 /********************************************************************/
41 AliHBTReaderITSv1::AliHBTReaderITSv1(TObjArray* dirs, const Char_t* tracksfilename,const Char_t* galicefilename):
43 fITSTracksFileName(tracksfilename),
44 fGAliceFileName(galicefilename)
48 /********************************************************************/
50 AliHBTReaderITSv1::~AliHBTReaderITSv1()
54 /********************************************************************/
57 Int_t AliHBTReaderITSv1::Read(AliHBTRun* particles, AliHBTRun *tracks)
61 AliITSIOTrack *iotrack=new AliITSIOTrack;
64 Int_t totalnevents = 0;
68 ndirs = fDirs->GetEntries();
75 do //do while is good even if
77 TFile* gAliceFile = OpenGAliceFile(currentdir);
80 Error("Read","Can not open the file with gAlice");
84 if (gAlice->TreeE())//check if tree E exists
86 nevents = (Int_t)gAlice->TreeE()->GetEntries();//if yes get number of events in gAlice
87 cout<<"________________________________________________________\n";
88 cout<<"Found "<<nevents<<" event(s) in directory "<<GetDirName(currentdir)<<endl;
89 cout<<"Setting Magnetic Field. Factor is "<<gAlice->Field()->Factor()<<endl;
90 AliKalmanTrack::SetConvConst(100/0.299792458/0.2/gAlice->Field()->Factor());
93 {//if not return an error
94 Error("Read","Can not find Header tree (TreeE) in gAlice");
99 TFile *file = OpenTrackFile(currentdir);
102 Error("Read","Can not open the file with ITS tracks V1");
110 for (Int_t currentEvent = 0; currentEvent < nevents; currentEvent++)
112 cout<<"Reading Event "<<currentEvent;
114 sprintf(tname,"TreeT%d",currentEvent);
116 TTree *tracktree=(TTree*)file->Get(tname);
117 TBranch *tbranch=tracktree->GetBranch("ITStracks");
118 tbranch->SetAddress(&iotrack);
121 gAlice->GetEvent(currentEvent);
122 gAlice->Stack()->Particles();
124 Int_t nentr=(Int_t)tracktree->GetEntries();
126 cout<<". Found "<<nentr<<" tracks.";
129 for (Int_t i=0; i<nentr; i++)
132 tracktree->GetEvent(i);
133 if(!iotrack) continue;
134 Int_t label = iotrack->GetLabel();
140 TParticle *p = (TParticle*)gAlice->Stack()->Particle(label);
143 Warning("Read","Can not get particle with label &d",label);
146 if(Pass(p->GetPdgCode())) continue; //check if we are intersted with particles of this type
147 //if not take next partilce
149 AliHBTParticle* part = new AliHBTParticle(*p,i);
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
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
159 Double_t x= iotrack->GetX();
160 Double_t y= iotrack->GetY();
161 Double_t z= iotrack->GetZ();
163 AliHBTParticle* track = new AliHBTParticle(p->GetPdgCode(), i, px, py , pz, tEtot, x, y, z, 0.);
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
167 particles->AddParticle(totalnevents,part);//put track and particle on the run
168 tracks->AddParticle(totalnevents,track);
170 }//end loop over tracks in the event
173 cout<<" Accepted "<<naccepted<<" tracks"<<endl;
174 }//end of loop over events in current directory
184 }while(currentdir < ndirs);//end of loop over directories specified in fDirs Obj Array
192 /********************************************************************/
194 TFile* AliHBTReaderITSv1::OpenTrackFile(Int_t ndir)
196 //opens files to be read for given directoru nomber in fDirs Array
197 const TString& dirname = GetDirName(ndir);
200 Error("OpenGAliceFile","Can not get directory name");
203 TString filename = dirname + "/" + fITSTracksFileName;
205 TFile *file = TFile::Open(filename.Data());
208 Error("Read","Can not open file %s",filename.Data());
213 Error("Read","Can not open file %s",filename.Data());
221 /********************************************************************/
222 TFile* AliHBTReaderITSv1::OpenGAliceFile(Int_t ndir)
224 //Opens galice.root file
225 const TString& dirname = GetDirName(ndir);
228 Error("OpenGAliceFile","Can not get directory name");
232 TString filename = dirname + "/" + fGAliceFileName;
234 TFile* gAliceFile = TFile::Open(filename.Data());
235 if ( gAliceFile== 0x0)
237 Error("OpenFiles","Can't open file named %s",filename.Data());
240 if (!gAliceFile->IsOpen())
242 Error("OpenFiles","Can't open file named %s",filename.Data());
246 if (!(gAlice=(AliRun*)gAliceFile->Get("gAlice")))
248 Error("OpenFiles","gAlice have not been found on %s !\n",filename.Data());
257 /********************************************************************/
258 /********************************************************************/