1 #include "AliHBTReaderKineTree.h"
2 //_______________________________________________________________________
3 /////////////////////////////////////////////////////////////////////////
5 // class AliHBTReaderKineTree
7 // Reader for Kinematics
9 // Piotr.Skowronski@cern.ch
11 /////////////////////////////////////////////////////////////////////////
14 #include <TParticle.h>
16 #include <AliRunLoader.h>
19 #include "AliHBTEvent.h"
20 #include "AliHBTParticle.h"
22 ClassImp(AliHBTReaderKineTree)
23 /**********************************************************/
24 const TString AliHBTReaderKineTree::fgkEventFolderName("HBTReaderKineTree");
26 AliHBTReaderKineTree::AliHBTReaderKineTree():
27 fFileName("galice.root"),
32 /**********************************************************/
34 AliHBTReaderKineTree::AliHBTReaderKineTree(TString& fname):
40 /**********************************************************/
42 AliHBTReaderKineTree::AliHBTReaderKineTree(TObjArray* dirs,const Char_t *filename):
50 /**********************************************************/
51 AliHBTReaderKineTree::AliHBTReaderKineTree(const AliHBTReaderKineTree& in):
53 fFileName(in.fFileName),
59 /**********************************************************/
61 AliHBTReaderKineTree::~AliHBTReaderKineTree()
66 /**********************************************************/
67 AliHBTReaderKineTree& AliHBTReaderKineTree::operator=(const AliHBTReaderKineTree& in)
70 if (this == &in) return *this;
71 AliHBTReader::operator=(in);
76 /**********************************************************/
78 void AliHBTReaderKineTree::Rewind()
80 //Rewinds to the beginning
86 /**********************************************************/
88 Int_t AliHBTReaderKineTree::ReadNext()
90 //Reads Kinematics Tree
93 if (fParticlesEvent == 0x0) fParticlesEvent = new AliHBTEvent();
94 fParticlesEvent->Reset();
96 do //do{}while; is OK even if 0 dirs specified. In that case we try to read from "./"
98 if (fRunLoader == 0x0)
105 if (fCurrentEvent == fRunLoader->GetNumberOfEvents())
107 //read next directory
108 delete fRunLoader;//close current session
109 fRunLoader = 0x0;//assure pointer is null
110 fCurrentDir++;//go to next dir
111 continue;//directory counter is increased inside in case of error
114 Info("ReadNext","Reading Event %d",fCurrentEvent);
116 fRunLoader->GetEvent(fCurrentEvent);
118 AliStack* stack = fRunLoader->Stack();
121 Error("ReadNext","Can not get stack for event %d",fCurrentEvent);
124 Int_t npart = stack->GetNtrack();
125 for (Int_t i = 0;i<npart; i++)
127 TParticle * p = stack->Particle(i);
128 // if (p->GetFirstMother() >= 0) continue; do not apply with pythia etc
130 if(Pass(p->GetPdgCode())) continue; //check if we are intersted with particles of this type
131 //if not take next partilce
133 AliHBTParticle* part = new AliHBTParticle(*p,i);
134 if(Pass(part)) { delete part; continue;}//check if meets all criteria of any of our cuts
135 //if it does not delete it and take next good track
136 fParticlesEvent->AddParticle(part);//put particle in event
138 Info("ReadNext","Read %d particles from event %d (event %d in dir %d).",
139 fParticlesEvent->GetNumberOfParticles(),
140 fNEventsRead,fCurrentEvent,fCurrentDir);
145 }while(fCurrentDir < GetNumberOfDirs());//end of loop over directories specified in fDirs Obj Array
149 /**********************************************************/
151 Int_t AliHBTReaderKineTree::OpenNextFile()
153 //opens file with kine tree
154 Info("OpenNextFile","________________________________________________________");
156 const TString& dirname = GetDirName(fCurrentEvent);
159 Error("OpenNextFile","Can not get directory name");
162 TString filename = dirname +"/"+ fFileName;
164 fRunLoader = AliRunLoader::Open(filename.Data(),fgkEventFolderName,"READ");
166 if ( fRunLoader == 0x0)
168 Error("OpenNextFile","Can't open session from file %s",filename.Data());
172 if (fRunLoader->GetNumberOfEvents() <= 0)
174 Error("OpenNextFile","There is no events in this directory.");
180 if (fRunLoader->LoadKinematics())
182 Error("OpenNextFile","Error occured while loading kinematics.");