1 #include "AliHBTReader.h"
4 #include <TObjString.h>
9 #include "AliHBTParticleCut.h"
12 ClassImp(AliHBTReader)
15 /*************************************************************************************/
17 AliHBTReader::AliHBTReader()
20 fCuts = new TObjArray();
24 /*************************************************************************************/
25 AliHBTReader::AliHBTReader(TObjArray* dirs)
27 fCuts = new TObjArray();
31 AliHBTReader::~AliHBTReader()
41 /*************************************************************************************/
43 void AliHBTReader::AddParticleCut(AliHBTParticleCut* cut)
47 if (!cut) //if cut is NULL return with error
49 Error("AddParticleType","NULL pointers are not accepted any more.\nIf You want to accept all particles of this type, set an empty cut ");
52 AliHBTParticleCut *c = (AliHBTParticleCut*)cut->Clone();
56 /*************************************************************************************/
58 Bool_t AliHBTReader::Pass(AliHBTParticle* p)
60 //Method examines whether particle meets all cut and particle type criteria
62 if(p==0x0)//of corse we not pass NULL pointers
64 Warning("Pass()","No Pasaran! We never accept NULL pointers");
67 //if no particle is specified, we pass all particles
68 //excluding NULL pointers, of course
69 if ( fCuts->GetEntriesFast() == 0 ) return kFALSE; //if no cut specified accept all particles
70 for(Int_t i=0; i<fCuts->GetEntriesFast(); i++)
72 AliHBTParticleCut &cut = *((AliHBTParticleCut*)fCuts->At(i));
73 if(!cut.Pass(p)) return kFALSE; //accepted
76 return kTRUE;//not accepted
79 /*************************************************************************************/
81 Bool_t AliHBTReader::Pass(Int_t pid)
83 //this method checks if any of existing cuts accepts this pid particles
84 //or any cuts accepts all particles
89 if ( fCuts->GetEntriesFast() == 0 ) return kFALSE; //if no cut specified accept all particles
91 for(Int_t i=0; i<fCuts->GetEntriesFast(); i++)
93 AliHBTParticleCut &cut = *((AliHBTParticleCut*)fCuts->At(i));
94 //if some of cuts accepts all particles or some accepts particles of this type, accept
95 if ( (cut.GetPID() == 0) || (cut.GetPID() == pid) ) return kFALSE;
99 /*************************************************************************************/
101 TString& AliHBTReader::GetDirName(Int_t entry)
103 TString* retval;//return value
106 retval = new TString(".");
110 if ( (entry>fDirs->GetEntries()) || (entry<0))//if out of bounds return empty string
111 { //note that entry==0 is accepted even if array is empty (size=0)
112 Error("GetDirName","Name out of bounds");
113 retval = new TString();
117 if (fDirs->GetEntries() == 0)
119 retval = new TString(".");
123 TClass *objclass = fDirs->At(entry)->IsA();
124 TClass *stringclass = TObjString::Class();
126 TObjString *dir = (TObjString*)objclass->DynamicCast(stringclass,fDirs->At(entry));
130 Error("GetDirName","Object in TObjArray is not a TObjString or its descendant");
131 retval = new TString();
134 if (gDebug > 0) cout<<"Returned ok "<<dir->String().Data()<<endl;
135 return dir->String();