]>
Commit | Line | Data |
---|---|---|
81f7fe9f | 1 | #include "AliHBTReaderKineTree.h" |
eb828ce0 | 2 | //_______________________________________________________________________ |
3 | ///////////////////////////////////////////////////////////////////////// | |
4 | // | |
5 | // class AliHBTReaderKineTree | |
6 | // | |
7 | // Reader for Kinematics | |
8 | // | |
9 | // Piotr.Skowronski@cern.ch | |
10 | // | |
11 | ///////////////////////////////////////////////////////////////////////// | |
81f7fe9f | 12 | |
81f7fe9f | 13 | #include <TString.h> |
81f7fe9f | 14 | #include <TParticle.h> |
15 | ||
88cb7938 | 16 | #include <AliRunLoader.h> |
81f7fe9f | 17 | #include <AliStack.h> |
81f7fe9f | 18 | |
81f7fe9f | 19 | #include "AliHBTEvent.h" |
20 | #include "AliHBTParticle.h" | |
81f7fe9f | 21 | |
22 | ClassImp(AliHBTReaderKineTree) | |
23 | /**********************************************************/ | |
88cb7938 | 24 | const TString AliHBTReaderKineTree::fgkEventFolderName("HBTReaderKineTree"); |
81f7fe9f | 25 | |
bed069a4 | 26 | AliHBTReaderKineTree::AliHBTReaderKineTree(): |
27 | fFileName("galice.root"), | |
28 | fRunLoader(0x0) | |
81f7fe9f | 29 | { |
bed069a4 | 30 | //ctor |
81f7fe9f | 31 | } |
bed069a4 | 32 | /**********************************************************/ |
81f7fe9f | 33 | |
bed069a4 | 34 | AliHBTReaderKineTree::AliHBTReaderKineTree(TString& fname): |
35 | fFileName(fname), | |
36 | fRunLoader(0x0) | |
81f7fe9f | 37 | { |
bed069a4 | 38 | //ctor |
81f7fe9f | 39 | } |
81f7fe9f | 40 | /**********************************************************/ |
bed069a4 | 41 | |
42 | AliHBTReaderKineTree::AliHBTReaderKineTree(TObjArray* dirs,const Char_t *filename): | |
43 | AliHBTReader(dirs), | |
44 | fFileName(filename), | |
45 | fRunLoader(0x0) | |
81f7fe9f | 46 | { |
bed069a4 | 47 | //ctor |
81f7fe9f | 48 | } |
eb828ce0 | 49 | |
50 | /**********************************************************/ | |
51 | AliHBTReaderKineTree::AliHBTReaderKineTree(const AliHBTReaderKineTree& in): | |
52 | AliHBTReader(in), | |
53 | fFileName(in.fFileName), | |
54 | fRunLoader(0x0) | |
55 | { | |
56 | //cpy ctor | |
57 | } | |
58 | ||
81f7fe9f | 59 | /**********************************************************/ |
60 | ||
bed069a4 | 61 | AliHBTReaderKineTree::~AliHBTReaderKineTree() |
62 | { | |
63 | //dtor | |
64 | delete fRunLoader; | |
65 | } | |
66 | /**********************************************************/ | |
eb828ce0 | 67 | AliHBTReaderKineTree& AliHBTReaderKineTree::operator=(const AliHBTReaderKineTree& in) |
68 | { | |
69 | //Assiment operator | |
70 | if (this == &in) return *this; | |
71 | AliHBTReader::operator=(in); | |
72 | delete fRunLoader; | |
73 | fRunLoader = 0x0; | |
74 | return * this; | |
75 | } | |
76 | /**********************************************************/ | |
81f7fe9f | 77 | |
bed069a4 | 78 | void AliHBTReaderKineTree::Rewind() |
79 | { | |
eb828ce0 | 80 | //Rewinds to the beginning |
bed069a4 | 81 | delete fRunLoader; |
82 | fRunLoader = 0x0; | |
83 | fCurrentDir = 0; | |
84 | fNEventsRead= 0; | |
85 | } | |
81f7fe9f | 86 | /**********************************************************/ |
bed069a4 | 87 | |
88 | Int_t AliHBTReaderKineTree::ReadNext() | |
bdec021f | 89 | { |
90 | //Reads Kinematics Tree | |
91 | ||
92 | Info("Read",""); | |
bed069a4 | 93 | if (fParticlesEvent == 0x0) fParticlesEvent = new AliHBTEvent(); |
94 | fParticlesEvent->Reset(); | |
81f7fe9f | 95 | |
96 | do //do{}while; is OK even if 0 dirs specified. In that case we try to read from "./" | |
97 | { | |
bed069a4 | 98 | if (fRunLoader == 0x0) |
99 | if (OpenNextFile()) | |
100 | { | |
101 | fCurrentDir++; | |
102 | continue; | |
103 | } | |
104 | ||
105 | if (fCurrentEvent == fRunLoader->GetNumberOfEvents()) | |
81f7fe9f | 106 | { |
bed069a4 | 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 | |
81f7fe9f | 112 | } |
bed069a4 | 113 | |
114 | Info("ReadNext","Reading Event %d",fCurrentEvent); | |
115 | ||
116 | fRunLoader->GetEvent(fCurrentEvent); | |
81f7fe9f | 117 | |
bed069a4 | 118 | AliStack* stack = fRunLoader->Stack(); |
119 | if (!stack) | |
81f7fe9f | 120 | { |
bed069a4 | 121 | Error("ReadNext","Can not get stack for event %d",fCurrentEvent); |
122 | continue; | |
123 | } | |
124 | Int_t npart = stack->GetNtrack(); | |
125 | for (Int_t i = 0;i<npart; i++) | |
126 | { | |
81f7fe9f | 127 | TParticle * p = stack->Particle(i); |
88cb7938 | 128 | // if (p->GetFirstMother() >= 0) continue; do not apply with pythia etc |
81f7fe9f | 129 | |
130 | if(Pass(p->GetPdgCode())) continue; //check if we are intersted with particles of this type | |
88cb7938 | 131 | //if not take next partilce |
81f7fe9f | 132 | |
8089a083 | 133 | AliHBTParticle* part = new AliHBTParticle(*p,i); |
81f7fe9f | 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 | |
bed069a4 | 136 | fParticlesEvent->AddParticle(part);//put particle in event |
137 | } | |
138 | Info("ReadNext","Read %d particles from event %d (event %d in dir %d).", | |
139 | fParticlesEvent->GetNumberOfParticles(), | |
140 | fNEventsRead,fCurrentEvent,fCurrentDir); | |
141 | ||
142 | fCurrentEvent++; | |
143 | fNEventsRead++; | |
144 | return 0; | |
145 | }while(fCurrentDir < GetNumberOfDirs());//end of loop over directories specified in fDirs Obj Array | |
146 | ||
147 | return 1; | |
81f7fe9f | 148 | } |
bed069a4 | 149 | /**********************************************************/ |
81f7fe9f | 150 | |
bed069a4 | 151 | Int_t AliHBTReaderKineTree::OpenNextFile() |
81f7fe9f | 152 | { |
153 | //opens file with kine tree | |
bed069a4 | 154 | Info("OpenNextFile","________________________________________________________"); |
155 | ||
c99861ef | 156 | const TString& dirname = GetDirName(fCurrentDir); |
81f7fe9f | 157 | if (dirname == "") |
158 | { | |
bed069a4 | 159 | Error("OpenNextFile","Can not get directory name"); |
160 | return 1; | |
81f7fe9f | 161 | } |
162 | TString filename = dirname +"/"+ fFileName; | |
88cb7938 | 163 | |
bed069a4 | 164 | fRunLoader = AliRunLoader::Open(filename.Data(),fgkEventFolderName,"READ"); |
81f7fe9f | 165 | |
bed069a4 | 166 | if ( fRunLoader == 0x0) |
81f7fe9f | 167 | { |
bed069a4 | 168 | Error("OpenNextFile","Can't open session from file %s",filename.Data()); |
cabe893a | 169 | return 1; |
81f7fe9f | 170 | } |
bed069a4 | 171 | |
172 | if (fRunLoader->GetNumberOfEvents() <= 0) | |
173 | { | |
174 | Error("OpenNextFile","There is no events in this directory."); | |
175 | delete fRunLoader; | |
176 | fRunLoader = 0x0; | |
cabe893a | 177 | return 2; |
bed069a4 | 178 | } |
179 | ||
180 | if (fRunLoader->LoadKinematics()) | |
181 | { | |
182 | Error("OpenNextFile","Error occured while loading kinematics."); | |
cabe893a | 183 | return 3; |
bed069a4 | 184 | } |
185 | ||
186 | fCurrentEvent = 0; | |
187 | return 0; | |
81f7fe9f | 188 | } |