1 #include "AliHBTReaderKineTree.h"
5 #include <TObjString.h>
11 #include <AliRunLoader.h>
13 #include <AliHeader.h>
15 #include "AliHBTRun.h"
16 #include "AliHBTEvent.h"
17 #include "AliHBTParticle.h"
18 #include "AliHBTParticleCut.h"
20 ClassImp(AliHBTReaderKineTree)
21 /**********************************************************/
22 const TString AliHBTReaderKineTree::fgkEventFolderName("HBTReaderKineTree");
24 AliHBTReaderKineTree::AliHBTReaderKineTree():fFileName("galice.root")
26 fParticles = new AliHBTRun();
30 AliHBTReaderKineTree::
31 AliHBTReaderKineTree(TString& fname):fFileName(fname)
33 fParticles = new AliHBTRun();
38 /**********************************************************/
39 AliHBTReaderKineTree::
40 AliHBTReaderKineTree(TObjArray* dirs,const Char_t *filename):AliHBTReader(dirs),fFileName(filename)
42 fParticles = new AliHBTRun();
45 /**********************************************************/
47 AliHBTEvent* AliHBTReaderKineTree::GetParticleEvent(Int_t n)
49 //returns Nth event with simulated particles
51 if(Read(fParticles,0x0))
53 Error("GetParticleEvent","Error in reading");
57 return fParticles->GetEvent(n);
60 /********************************************************************/
62 Int_t AliHBTReaderKineTree::GetNumberOfPartEvents()
64 //returns number of events of particles
66 if(Read(fParticles,0x0))
68 Error("GetNumberOfPartEvents","Error in reading");
71 return fParticles->GetNumberOfEvents();
75 /**********************************************************/
76 Int_t AliHBTReaderKineTree::
77 Read(AliHBTRun* particles, AliHBTRun *tracks)
79 cout<<"AliHBTReaderKineTree::Read()"<<endl;
80 if (!particles) //check if an object is instatiated
82 Error("Read"," particles object must instatiated before passing it to the reader");
85 particles->Reset();//clear runs == delete all old events
87 Int_t Ndirs;//total number of directories specified in fDirs array
88 Int_t Nevents; //number of events read in current directory
89 Int_t totalNevents = 0; //total number of read events
90 Int_t currentdir = 0; //number of current directory name is fDirs array
92 if (fDirs) //if array with directories is supplied by user
94 Ndirs = fDirs->GetEntries(); //get the number if directories
98 Ndirs = 0; //if the array is not supplied read only from current directory
101 do //do{}while; is OK even if 0 dirs specified. In that case we try to read from "./"
103 cout<<"________________________________________________________\n";
104 AliRunLoader * rl = OpenFile(currentdir);
108 Error("Read","Cannot open session");
112 rl->LoadKinematics("READ");
113 Nevents = rl->GetNumberOfEvents();
115 for(Int_t currentEvent =0; currentEvent<Nevents;currentEvent++)//loop over all events
117 // cout<<"processing event "<<currentEvent<<" in current dir."<<endl;
118 rl->GetEvent(currentEvent);
119 AliStack* stack = rl->Stack();
122 Error("Read","Can not get stack for event %d",currentEvent);
125 Int_t npart = stack->GetNtrack();
127 for (Int_t i = 0;i<npart; i++)
130 TParticle * p = stack->Particle(i);
131 // if (p->GetFirstMother() >= 0) continue; do not apply with pythia etc
133 if(Pass(p->GetPdgCode())) continue; //check if we are intersted with particles of this type
134 //if not take next partilce
136 AliHBTParticle* part = new AliHBTParticle(*p,i);
137 if(Pass(part)) { delete part; continue;}//check if meets all criteria of any of our cuts
138 //if it does not delete it and take next good track
139 particles->AddParticle(totalNevents,part);//put track and particle on the run
148 cout<<"Total read "<<nnn<<endl;
153 }while(currentdir < Ndirs);//end of loop over directories specified in fDirs Obj Array
158 AliRunLoader* AliHBTReaderKineTree::OpenFile(Int_t n)
160 //opens file with kine tree
162 const TString& dirname = GetDirName(n);
165 Error("OpenFiles","Can not get directory name");
168 TString filename = dirname +"/"+ fFileName;
170 AliRunLoader *ret = AliRunLoader::Open(filename.Data(),fgkEventFolderName,"READ");
174 Error("OpenFiles","Can't open session from file %s",filename.Data());