cut included
[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>
7#include <iostream.h>
8
1b446896 9#include "AliHBTParticleCut.h"
10
11
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)
59 {
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
69
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
77
78 }
79/*************************************************************************************/
80
81Bool_t AliHBTReader::Pass(Int_t pid)
82{
83//this method checks if any of existing cuts accepts this pid particles
84//or any cuts accepts all particles
85
86 if(pid == 0)
87 return kTRUE;
88
89 for(Int_t i=0; i<fCuts->GetEntriesFast(); i++)
90 {
91 AliHBTParticleCut &cut = *((AliHBTParticleCut*)fCuts->At(i));
92 //if some of cuts accepts all particles or some accepts particles of this type, accept
93 if ( (cut.GetPID() == 0) || (cut.GetPID() == pid) ) return kFALSE;
94 }
95 return kTRUE;
96}
97/*************************************************************************************/
0fdcc83d 98
99TString& AliHBTReader::GetDirName(Int_t entry)
100 {
101 TString* retval;//return value
102 if (fDirs == 0x0)
103 {
104 retval = new TString(".");
105 return *retval;
106 }
107
108 if ( (entry>fDirs->GetEntries()) || (entry<0))//if out of bounds return empty string
109 { //note that entry==0 is accepted even if array is empty (size=0)
110 Error("GetDirName","Name out of bounds");
111 retval = new TString();
112 return *retval;
113 }
114
115 if (fDirs->GetEntries() == 0)
116 {
117 retval = new TString(".");
118 return *retval;
119 }
120
121 TClass *objclass = fDirs->At(entry)->IsA();
122 TClass *stringclass = TObjString::Class();
123
124 TObjString *dir = (TObjString*)objclass->DynamicCast(stringclass,fDirs->At(entry));
125
126 if(dir == 0x0)
127 {
128 Error("GetDirName","Object in TObjArray is not a TObjString or its descendant");
129 retval = new TString();
130 return *retval;
131 }
132 if (gDebug > 0) cout<<"Returned ok "<<dir->String().Data()<<endl;
133 return dir->String();
134 }
135