]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTReader.cxx
Removed ASV version in AliL3FileHandler by another effective i/o method using index...
[u/mrichter/AliRoot.git] / HBTAN / AliHBTReader.cxx
CommitLineData
1b446896 1#include "AliHBTReader.h"
2
0fdcc83d 3#include <TString.h>
4#include <TObjString.h>
5#include <TObjArray.h>
6#include <TClass.h>
d0c23b58 7#include <Riostream.h>
0fdcc83d 8
1b446896 9#include "AliHBTParticleCut.h"
10
88cb7938 11
1b446896 12ClassImp(AliHBTReader)
13//pure virtual
14
15/*************************************************************************************/
16
17AliHBTReader::AliHBTReader()
18{
19//constructor
20 fCuts = new TObjArray();
0fdcc83d 21 fDirs = 0x0;
1b446896 22}
23
24/*************************************************************************************/
0fdcc83d 25AliHBTReader::AliHBTReader(TObjArray* dirs)
26 {
27 fCuts = new TObjArray();
28 fDirs = dirs;
29 }
1b446896 30
31AliHBTReader::~AliHBTReader()
32{
33//destructor
36ee4bd5 34 if(fCuts)
35 {
36 fCuts->SetOwner();
37 delete fCuts;
38 }
1b446896 39}
40
41/*************************************************************************************/
42
43void AliHBTReader::AddParticleCut(AliHBTParticleCut* cut)
44{
45 //sets the new cut
46
47 if (!cut) //if cut is NULL return with error
48 {
49 Error("AddParticleType","NULL pointers are not accepted any more.\nIf You want to accept all particles of this type, set an empty cut ");
50 return;
51 }
52 AliHBTParticleCut *c = (AliHBTParticleCut*)cut->Clone();
53 fCuts->Add(c);
54}
55
56/*************************************************************************************/
57
58Bool_t AliHBTReader::Pass(AliHBTParticle* p)
88cb7938 59{
1b446896 60 //Method examines whether particle meets all cut and particle type criteria
61
62 if(p==0x0)//of corse we not pass NULL pointers
63 {
64 Warning("Pass()","No Pasaran! We never accept NULL pointers");
65 return kTRUE;
66 }
67 //if no particle is specified, we pass all particles
68 //excluding NULL pointers, of course
e526d37c 69 if ( fCuts->GetEntriesFast() == 0 ) return kFALSE; //if no cut specified accept all particles
1b446896 70 for(Int_t i=0; i<fCuts->GetEntriesFast(); i++)
71 {
72 AliHBTParticleCut &cut = *((AliHBTParticleCut*)fCuts->At(i));
73 if(!cut.Pass(p)) return kFALSE; //accepted
74 }
75
76 return kTRUE;//not accepted
88cb7938 77}
1b446896 78/*************************************************************************************/
79
80Bool_t AliHBTReader::Pass(Int_t pid)
81{
82//this method checks if any of existing cuts accepts this pid particles
83//or any cuts accepts all particles
84
85 if(pid == 0)
86 return kTRUE;
e526d37c 87
88 if ( fCuts->GetEntriesFast() == 0 ) return kFALSE; //if no cut specified accept all particles
1b446896 89
90 for(Int_t i=0; i<fCuts->GetEntriesFast(); i++)
91 {
92 AliHBTParticleCut &cut = *((AliHBTParticleCut*)fCuts->At(i));
93 //if some of cuts accepts all particles or some accepts particles of this type, accept
94 if ( (cut.GetPID() == 0) || (cut.GetPID() == pid) ) return kFALSE;
95 }
96 return kTRUE;
97}
98/*************************************************************************************/
0fdcc83d 99
100TString& AliHBTReader::GetDirName(Int_t entry)
101 {
102 TString* retval;//return value
103 if (fDirs == 0x0)
104 {
105 retval = new TString(".");
106 return *retval;
107 }
108
109 if ( (entry>fDirs->GetEntries()) || (entry<0))//if out of bounds return empty string
110 { //note that entry==0 is accepted even if array is empty (size=0)
111 Error("GetDirName","Name out of bounds");
112 retval = new TString();
113 return *retval;
114 }
115
116 if (fDirs->GetEntries() == 0)
117 {
118 retval = new TString(".");
119 return *retval;
120 }
121
122 TClass *objclass = fDirs->At(entry)->IsA();
123 TClass *stringclass = TObjString::Class();
124
125 TObjString *dir = (TObjString*)objclass->DynamicCast(stringclass,fDirs->At(entry));
126
127 if(dir == 0x0)
128 {
129 Error("GetDirName","Object in TObjArray is not a TObjString or its descendant");
130 retval = new TString();
131 return *retval;
132 }
133 if (gDebug > 0) cout<<"Returned ok "<<dir->String().Data()<<endl;
134 return dir->String();
135 }
136