1 //____________________________________________________________________
2 //////////////////////////////////////////////////////////////////////
4 // class AliHBTReaderITSv1 //
6 // Reader for ITSv1 tracks. Not maintained since v1 is not //
7 // supposed to be used //
9 //////////////////////////////////////////////////////////////////////
11 #include <Riostream.h>
14 #include <TObjArray.h>
15 #include <TParticle.h>
19 #include "AliHBTParticle.h"
20 #include "AliHBTParticleCut.h"
21 #include "AliHBTReaderITSv1.h"
22 #include "AliHBTRun.h"
23 #include "AliITSIOTrack.h"
24 #include "AliKalmanTrack.h"
29 ClassImp(AliHBTReaderITSv1)
30 /********************************************************************/
32 AliHBTReaderITSv1::AliHBTReaderITSv1(const Char_t* tracksfilename,const Char_t* galicefilename):
33 fITSTracksFileName(tracksfilename),
34 fGAliceFileName(galicefilename)
38 /********************************************************************/
40 AliHBTReaderITSv1::AliHBTReaderITSv1(TObjArray* dirs, const Char_t* tracksfilename,const Char_t* galicefilename):
42 fITSTracksFileName(tracksfilename),
43 fGAliceFileName(galicefilename)
47 /********************************************************************/
49 AliHBTReaderITSv1::~AliHBTReaderITSv1()
53 /********************************************************************/
56 Int_t AliHBTReaderITSv1::Read(AliHBTRun* particles, AliHBTRun *tracks)
60 AliITSIOTrack *iotrack=new AliITSIOTrack;
63 Int_t totalnevents = 0;
67 ndirs = fDirs->GetEntries();
74 do //do while is good even if
76 TFile* gAliceFile = OpenGAliceFile(currentdir);
79 Error("Read","Can not open the file with gAlice");
83 if (gAlice->TreeE())//check if tree E exists
85 nevents = (Int_t)gAlice->TreeE()->GetEntries();//if yes get number of events in gAlice
86 cout<<"________________________________________________________\n";
87 cout<<"Found "<<nevents<<" event(s) in directory "<<GetDirName(currentdir)<<endl;
88 cout<<"Setting Magnetic Field. Factor is "<<gAlice->Field()->Factor()<<endl;
89 AliKalmanTrack::SetConvConst(100/0.299792458/0.2/gAlice->Field()->Factor());
92 {//if not return an error
93 Error("Read","Can not find Header tree (TreeE) in gAlice");
98 TFile *file = OpenTrackFile(currentdir);
101 Error("Read","Can not open the file with ITS tracks V1");
109 for (Int_t currentEvent = 0; currentEvent < nevents; currentEvent++)
111 cout<<"Reading Event "<<currentEvent;
113 sprintf(tname,"TreeT%d",currentEvent);
115 TTree *tracktree=(TTree*)file->Get(tname);
116 TBranch *tbranch=tracktree->GetBranch("ITStracks");
117 tbranch->SetAddress(&iotrack);
120 gAlice->GetEvent(currentEvent);
121 gAlice->Stack()->Particles();
123 Int_t nentr=(Int_t)tracktree->GetEntries();
125 cout<<". Found "<<nentr<<" tracks.";
128 for (Int_t i=0; i<nentr; i++)
131 tracktree->GetEvent(i);
132 if(!iotrack) continue;
133 Int_t label = iotrack->GetLabel();
139 TParticle *p = (TParticle*)gAlice->Stack()->Particle(label);
142 Warning("Read","Can not get particle with label &d",label);
145 if(Pass(p->GetPdgCode())) continue; //check if we are intersted with particles of this type
146 //if not take next partilce
148 AliHBTParticle* part = new AliHBTParticle(*p,i);
149 if(Pass(part)) { delete part; continue;}//check if meets all criteria of any of our cuts
150 //if it does not delete it and take next good track
152 Double_t px=iotrack->GetPx();
153 Double_t py=iotrack->GetPy();
154 Double_t pz=iotrack->GetPz();
155 Double_t mass = p->GetMass();
156 Double_t tEtot = TMath::Sqrt(px*px + py*py + pz*pz + mass*mass);//total energy of the track
158 Double_t x= iotrack->GetX();
159 Double_t y= iotrack->GetY();
160 Double_t z= iotrack->GetZ();
162 AliHBTParticle* track = new AliHBTParticle(p->GetPdgCode(), i, px, py , pz, tEtot, x, y, z, 0.);
163 if(Pass(track)) { delete track;continue;}//check if meets all criteria of any of our cuts
164 //if it does not delete it and take next good track
166 particles->AddParticle(totalnevents,part);//put track and particle on the run
167 tracks->AddParticle(totalnevents,track);
169 }//end loop over tracks in the event
172 cout<<" Accepted "<<naccepted<<" tracks"<<endl;
173 }//end of loop over events in current directory
183 }while(currentdir < ndirs);//end of loop over directories specified in fDirs Obj Array
191 /********************************************************************/
193 TFile* AliHBTReaderITSv1::OpenTrackFile(Int_t ndir)
195 //opens files to be read for given directoru nomber in fDirs Array
196 const TString& dirname = GetDirName(ndir);
199 Error("OpenGAliceFile","Can not get directory name");
202 TString filename = dirname + "/" + fITSTracksFileName;
204 TFile *file = TFile::Open(filename.Data());
207 Error("Read","Can not open file %s",filename.Data());
212 Error("Read","Can not open file %s",filename.Data());
220 /********************************************************************/
221 TFile* AliHBTReaderITSv1::OpenGAliceFile(Int_t ndir)
223 //Opens galice.root file
224 const TString& dirname = GetDirName(ndir);
227 Error("OpenGAliceFile","Can not get directory name");
231 TString filename = dirname + "/" + fGAliceFileName;
233 TFile* gAliceFile = TFile::Open(filename.Data());
234 if ( gAliceFile== 0x0)
236 Error("OpenFiles","Can't open file named %s",filename.Data());
239 if (!gAliceFile->IsOpen())
241 Error("OpenFiles","Can't open file named %s",filename.Data());
245 if (!(gAlice=(AliRun*)gAliceFile->Get("gAlice")))
247 Error("OpenFiles","gAlice have not been found on %s !\n",filename.Data());
256 /********************************************************************/
257 /********************************************************************/