3 //_________________________________________________________________________
4 ///////////////////////////////////////////////////////////////////////////
6 // class AliJetParticlesReader
8 // loizides@ikf.uni-frankfurt.de
9 ///////////////////////////////////////////////////////////////////////////
11 #include <TObjArray.h>
12 #include <TClonesArray.h>
15 #include <TObjString.h>
17 #include "AliJetEventParticles.h"
18 #include "AliJetParticlesReader.h"
21 ClassImp(AliJetParticlesReader)
23 AliJetParticlesReader::AliJetParticlesReader()
33 fPtMin(0),fPtMax(1000),
34 fEtaMin(-1),fEtaMax(1),
35 fPhiMin(0),fPhiMax(2*TMath::Pi())
39 AliJetParticlesReader::AliJetParticlesReader(TObjArray *dirs)
49 fPtMin(0),fPtMax(1000),
50 fEtaMin(-1),fEtaMax(1),
51 fPhiMin(0),fPhiMax(2*TMath::Pi())
55 AliJetParticlesReader::~AliJetParticlesReader()
57 if((fOwner) && (fEventParticles)) delete fEventParticles;
60 Int_t AliJetParticlesReader::Next()
64 //if asked to read up to event nb. fLast,
65 //and it is overcome, report no more events
66 if ((fNEventsRead > fLast) && (fLast > 0) ) return kFALSE;
68 do //if asked to read from event fFirst, rewind to it
70 if ( ReadNext() == kFALSE)
71 return kFALSE; //if no more evets, return it
72 } while (fNEventsRead < fFirst);
79 TString& AliJetParticlesReader::GetDirName(Int_t entry)
81 //returns directory name of entry to read
83 TString* retval;//return value
86 retval = new TString(".");
90 if ((entry>fDirs->GetEntries()) || (entry<0))
91 //if out of bounds return empty string
92 //note that entry==0 is accepted even if array is empty (size=0)
94 Error("GetDirName","Entry out of bounds");
95 retval = new TString();
99 if (fDirs->GetEntries() == 0)
101 retval = new TString(".");
105 TClass *objclass = fDirs->At(entry)->IsA();
106 TClass *stringclass = TObjString::Class();
108 TObjString *dir = (TObjString*)objclass->DynamicCast(stringclass,fDirs->At(entry));
111 Error("GetDirName","Object in TObjArray is not a TObjString");
112 retval = new TString();
116 //Info("GetDirName","Returned ok %s",dir->String().Data());
117 return dir->String();
122 /*************************************************************************************/
124 void AliHBTReader::AddParticleCut(AliHBTParticleCut* cut)
128 if (!cut) //if cut is NULL return with error
130 Error("AddParticleType","NULL pointers are not accepted any more.\nIf You want to accept all particles of this type, set an empty cut ");
133 AliHBTParticleCut *c = (AliHBTParticleCut*)cut->Clone();
136 /********************************************************************/
138 AliHBTEvent* AliHBTReader::GetParticleEvent(Int_t n)
140 //returns Nth event with simulated particles
141 if (ReadsParticles() == kFALSE)
143 Error("GetParticleEvent","This reader is not able to provide simulated particles.");
149 if (ReadsParticles() && (fParticles == 0x0)) fParticles = new AliHBTRun();
150 if (ReadsTracks() && (fTracks == 0x0)) fTracks = new AliHBTRun();
152 if (Read(fParticles,fTracks))
154 Error("GetParticleEvent","Error in reading");
157 else fIsRead = kTRUE;
159 return fParticles->GetEvent(n);
161 /********************************************************************/
163 AliHBTEvent* AliHBTReader::GetTrackEvent(Int_t n)
165 //returns Nth event with reconstructed tracks
166 if (ReadsTracks() == kFALSE)
168 Error("GetTrackEvent","This reader is not able to provide recosntructed tracks.");
173 if (ReadsParticles() && (fParticles == 0x0)) fParticles = new AliHBTRun();
174 if (ReadsTracks() && (fTracks == 0x0)) fTracks = new AliHBTRun();
176 if(Read(fParticles,fTracks))
178 Error("GetTrackEvent","Error in reading");
181 else fIsRead = kTRUE;
183 return fTracks->GetEvent(n);
185 /********************************************************************/
187 Int_t AliHBTReader::GetNumberOfPartEvents()
189 //returns number of events of particles
190 if (ReadsParticles() == kFALSE)
192 Error("GetNumberOfPartEvents","This reader is not able to provide simulated particles.");
198 if (ReadsParticles() && (fParticles == 0x0)) fParticles = new AliHBTRun();
199 if (ReadsTracks() && (fTracks == 0x0)) fTracks = new AliHBTRun();
201 if (Read(fParticles,fTracks))
203 Error("GetNumberOfPartEvents","Error in reading");
206 else fIsRead = kTRUE;
208 return fParticles->GetNumberOfEvents();
210 /********************************************************************/
212 Int_t AliHBTReader::GetNumberOfTrackEvents()
214 //returns number of events of tracks
215 if (ReadsTracks() == kFALSE)
217 Error("GetNumberOfTrackEvents","This reader is not able to provide recosntructed tracks.");
222 if (ReadsParticles() && (fParticles == 0x0)) fParticles = new AliHBTRun();
223 if (ReadsTracks() && (fTracks == 0x0)) fTracks = new AliHBTRun();
225 if(Read(fParticles,fTracks))
227 Error("GetNumberOfTrackEvents","Error in reading");
230 else fIsRead = kTRUE;
232 return fTracks->GetNumberOfEvents();
234 /********************************************************************/
236 Int_t AliHBTReader::Read(AliHBTRun* particles, AliHBTRun *tracks)
238 //reads data and puts put to the particles and tracks objects
239 //reurns 0 if everything is OK
243 if ( ReadsParticles() && (particles == 0x0) ) //check if an object is instatiated
245 Error("Read"," particles object must be instatiated before passing it to the reader");
248 if ( ReadsTracks() && (tracks == 0x0) ) //check if an object is instatiated
250 Error("Read"," tracks object must be instatiated before passing it to the reader");
254 if (ReadsParticles()) particles->Reset();//clear runs == delete all old events
255 if (ReadsTracks()) tracks->Reset();
260 while(Next() == kFALSE)
262 if (ReadsTracks()) tracks->SetEvent(i,fTracksEvent);
263 if (ReadsParticles()) particles->SetEvent(i,fParticlesEvent);
268 /*************************************************************************************/
270 Bool_t AliHBTReader::Pass(AliHBTParticle* p)
272 //Method examines whether particle meets all cut and particle type criteria
274 if(p==0x0)//of corse we not pass NULL pointers
276 Warning("Pass()","No Pasaran! We never accept NULL pointers");
279 //if no particle is specified, we pass all particles
280 //excluding NULL pointers, of course
281 if ( fCuts->GetEntriesFast() == 0 ) return kFALSE; //if no cut specified accept all particles
282 for(Int_t i=0; i<fCuts->GetEntriesFast(); i++)
284 AliHBTParticleCut &cut = *((AliHBTParticleCut*)fCuts->At(i));
285 if(!cut.Pass(p)) return kFALSE; //accepted
288 return kTRUE;//not accepted
290 /*************************************************************************************/
292 Bool_t AliHBTReader::Pass(Int_t pid)
294 //this method checks if any of existing cuts accepts this pid particles
295 //or any cuts accepts all particles
300 if ( fCuts->GetEntriesFast() == 0 ) return kFALSE; //if no cut specified accept all particles
302 for(Int_t i=0; i<fCuts->GetEntriesFast(); i++)
304 AliHBTParticleCut &cut = *((AliHBTParticleCut*)fCuts->At(i));
305 //if some of cuts accepts all particles or some accepts particles of this type, accept
306 if ( (cut.GetPID() == 0) || (cut.GetPID() == pid) ) return kFALSE;