Catching up to NewIO -> Particle stores all passible PID and their probabilities
[u/mrichter/AliRoot.git] / HBTAN / AliHBTParticleCut.cxx
CommitLineData
1b446896 1#include "AliHBTParticleCut.h"
2
d0c23b58 3#include <Riostream.h>
1b446896 4
5ClassImp(AliHBTParticleCut)
6const Int_t AliHBTParticleCut::fkgMaxCuts = 50;
7/******************************************************************/
8
9AliHBTParticleCut::AliHBTParticleCut()
10 {
11 fCuts = new AliHbtBaseCut* [fkgMaxCuts];//last property in the property
12 //property enum => defines number of properties
13 fNCuts = 0;
14 fPID = 0;
15 }
16/******************************************************************/
17
18AliHBTParticleCut::AliHBTParticleCut(const AliHBTParticleCut& in)
19{
20 fCuts = new AliHbtBaseCut* [fkgMaxCuts];//last property in the property
21 //property enum => defines number of properties
22 fNCuts = in.fNCuts;
23 fPID = in.fPID;
24 for (Int_t i = 0;i<fNCuts;i++)
25 {
26 fCuts[i] = (AliHbtBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
27 }
28}
29/******************************************************************/
30
31AliHBTParticleCut::~AliHBTParticleCut()
32{
33 for (Int_t i = 0;i<fNCuts;i++)
34 {
35 delete fCuts[i];
36 }
37 delete []fCuts;
38}
39/******************************************************************/
40
41Bool_t AliHBTParticleCut::Pass(AliHBTParticle* p)
42{
43//method checks all the cuts that are set (in the list)
44//If any of the baseCuts rejects particle False(rejection) is returned
45 if(!p)
46 {
47 Warning("Pass()","No Pasaran! We never accept NULL pointers");
48 return kTRUE;
49 }
50 if( (p->GetPdgCode() != fPID) && ( fPID != 0)) return kTRUE;
51
52 for (Int_t i = 0;i<fNCuts;i++)
53 {
54 if ( (fCuts[i]->Pass(p)) ) return kTRUE; //if one of the cuts rejects, then reject
55 }
56 return kFALSE;
57}
58/******************************************************************/
59
60void AliHBTParticleCut::AddBasePartCut(AliHbtBaseCut* basecut)
61{
62 //adds the base pair cut (cut on one value)
63
64 if (!basecut) return;
65 if( fNCuts == (fkgMaxCuts-1) )
66 {
67 Warning("AddBasePartCut","Not enough place for another cut");
68 return;
69 }
70 fCuts[fNCuts++]=basecut;
71
72}
73
74/******************************************************************/
75AliHbtBaseCut* AliHBTParticleCut::FindCut(AliHBTCutProperty property)
76{
77
78 for (Int_t i = 0;i<fNCuts;i++)
79 {
80 if (fCuts[i]->GetProperty() == property)
81 return fCuts[i]; //we found the cut we were searching for
82 }
83
84 return 0x0; //we did not found this cut
85
86}
87/******************************************************************/
88
89void AliHBTParticleCut::SetMomentumRange(Double_t min, Double_t max)
90{
91 AliHBTMomentumCut* cut= (AliHBTMomentumCut*)FindCut(kHbtP);
92 if(cut) cut->SetRange(min,max);
93 else fCuts[fNCuts++] = new AliHBTMomentumCut(min,max);
94}
95/******************************************************************/
96
97
98void AliHBTParticleCut::SetPtRange(Double_t min, Double_t max)
99{
100 AliHBTPtCut* cut= (AliHBTPtCut*)FindCut(kHbtPt);
101 if(cut) cut->SetRange(min,max);
102 else fCuts[fNCuts++] = new AliHBTPtCut(min,max);
103
104}
105/******************************************************************/
106
107void AliHBTParticleCut::SetEnergyRange(Double_t min, Double_t max)
108{
109 AliHBTEnergyCut* cut= (AliHBTEnergyCut*)FindCut(kHbtE);
110 if(cut) cut->SetRange(min,max);
111 else fCuts[fNCuts++] = new AliHBTEnergyCut(min,max);
112
113}
114/******************************************************************/
115
116void AliHBTParticleCut::SetRapidityRange(Double_t min, Double_t max)
117{
118 AliHbtBaseCut* cut = FindCut(kHbtRapidity);
119 if(cut) cut->SetRange(min,max);
120 else fCuts[fNCuts++] = new AliHBTRapidityCut(min,max);
121
122}
123/******************************************************************/
124
125void AliHBTParticleCut::SetPseudoRapidityRange(Double_t min, Double_t max)
126{
127 AliHbtBaseCut* cut = FindCut(kHbtPseudoRapidity);
128 if(cut) cut->SetRange(min,max);
129 else fCuts[fNCuts++] = new AliHBTPseudoRapidityCut(min,max);
130
131}
132/******************************************************************/
133
134void AliHBTParticleCut::SetPxRange(Double_t min, Double_t max)
135{
136 AliHbtBaseCut* cut = FindCut(kHbtPx);
137 if(cut) cut->SetRange(min,max);
138 else fCuts[fNCuts++] = new AliHBTPxCut(min,max);
139}
140/******************************************************************/
141
142void AliHBTParticleCut::SetPyRange(Double_t min, Double_t max)
143{
144 AliHbtBaseCut* cut = FindCut(kHbtPy);
145 if(cut) cut->SetRange(min,max);
146 else fCuts[fNCuts++] = new AliHBTPyCut(min,max);
147}
148/******************************************************************/
149
150void AliHBTParticleCut::SetPzRange(Double_t min, Double_t max)
151{
152 AliHbtBaseCut* cut = FindCut(kHbtPz);
153 if(cut) cut->SetRange(min,max);
154 else fCuts[fNCuts++] = new AliHBTPzCut(min,max);
155}
156/******************************************************************/
157
158void AliHBTParticleCut::SetPhiRange(Double_t min, Double_t max)
159{
160 AliHbtBaseCut* cut = FindCut(kHbtPhi);
161 if(cut) cut->SetRange(min,max);
162 else fCuts[fNCuts++] = new AliHBTPhiCut(min,max);
163}
164/******************************************************************/
165
166void AliHBTParticleCut::SetThetaRange(Double_t min, Double_t max)
167{
168 AliHbtBaseCut* cut = FindCut(kHbtTheta);
169 if(cut) cut->SetRange(min,max);
170 else fCuts[fNCuts++] = new AliHBTThetaCut(min,max);
171}
172/******************************************************************/
173
174void AliHBTParticleCut::SetVxRange(Double_t min, Double_t max)
175{
176 AliHbtBaseCut* cut = FindCut(kHbtVx);
177 if(cut) cut->SetRange(min,max);
178 else fCuts[fNCuts++] = new AliHBTVxCut(min,max);
179}
180/******************************************************************/
181
182void AliHBTParticleCut::SetVyRange(Double_t min, Double_t max)
183{
184 AliHbtBaseCut* cut = FindCut(kHbtVy);
185 if(cut) cut->SetRange(min,max);
186 else fCuts[fNCuts++] = new AliHBTVyCut(min,max);
187}
188/******************************************************************/
189
190void AliHBTParticleCut::SetVzRange(Double_t min, Double_t max)
191{
192 AliHbtBaseCut* cut = FindCut(kHbtVz);
193 if(cut) cut->SetRange(min,max);
194 else fCuts[fNCuts++] = new AliHBTVzCut(min,max);
195}
196
197/******************************************************************/
198void AliHBTParticleCut::Streamer(TBuffer &b)
199{
200 // Stream all objects in the array to or from the I/O buffer.
201
202 UInt_t R__s, R__c;
203 if (b.IsReading())
204 {
e9b3bfa8 205 Int_t i;
206 for (i = 0;i<fNCuts;i++) delete fCuts[i];
207 b.ReadVersion(&R__s, &R__c);
1b446896 208 TObject::Streamer(b);
209 b >> fPID;
210 b >> fNCuts;
e9b3bfa8 211 for (i = 0;i<fNCuts;i++)
1b446896 212 {
e9b3bfa8 213 b >> fCuts[i];
1b446896 214 }
215 b.CheckByteCount(R__s, R__c,AliHBTParticleCut::IsA());
216 }
217 else
218 {
219 R__c = b.WriteVersion(AliHBTParticleCut::IsA(), kTRUE);
220 TObject::Streamer(b);
221 b << fPID;
222 b << fNCuts;
223 for (Int_t i = 0;i<fNCuts;i++)
224 {
225 b << fCuts[i];
226 }
227 b.SetByteCount(R__c, kTRUE);
228 }
229}
230
231void AliHBTParticleCut::Print(void)
232{
233 cout<<"Printing AliHBTParticleCut, this = "<<this<<endl;
234 cout<<"fPID "<<fPID<<endl;
235 cout<<"fNCuts "<<fNCuts <<endl;
236 for (Int_t i = 0;i<fNCuts;i++)
237 {
238 cout<<" fCuts["<<i<<"] "<<fCuts[i]<<endl<<" ";
239 fCuts[i]->Print();
240 }
241}
242
243/******************************************************************/
244/******************************************************************/
245
246ClassImp(AliHBTEmptyParticleCut)
247void AliHBTEmptyParticleCut::Streamer(TBuffer &b)
248 {
249 AliHBTParticleCut::Streamer(b);
250 }
251/******************************************************************/
252/******************************************************************/
253/******************************************************************/
254
255/******************************************************************/
256/******************************************************************/
257/******************************************************************/
258
259ClassImp(AliHbtBaseCut)
260void AliHbtBaseCut::Print(void)
261{
262 cout<<"fMin="<<fMin <<", fMax=" <<fMax<<" ";
263 PrintProperty();
264}
265void AliHbtBaseCut::PrintProperty(void)
266{
267 switch (fProperty)
268 {
269 case kHbtP:
270 cout<<"kHbtP"; break;
271 case kHbtPt:
272 cout<<"kHbtPt"; break;
273 case kHbtE:
274 cout<<"kHbtE"; break;
275 case kHbtRapidity:
276 cout<<"kHbtRapidity"; break;
277 case kHbtPseudoRapidity:
278 cout<<"kHbtPseudoRapidity"; break;
279 case kHbtPx:
280 cout<<"kHbtPx"; break;
281 case kHbtPy:
282 cout<<"kHbtPy"; break;
283 case kHbtPz:
284 cout<<"kHbtPz"; break;
285 case kHbtPhi:
286 cout<<"kHbtPhi"; break;
287 case kHbtTheta:
288 cout<<"kHbtTheta"; break;
289 case kHbtVx:
290 cout<<"kHbtVx"; break;
291 case kHbtVy:
292 cout<<"kHbtVy"; break;
293 case kHbtVz:
294 cout<<"kHbtVz"; break;
295 case kHbtNone:
296 cout<<"kHbtNone"; break;
297 default:
298 cout<<"Property Not Found";
299 }
300 cout<<endl;
301}
302ClassImp( AliHBTMomentumCut )
303
304ClassImp( AliHBTPtCut )
305ClassImp( AliHBTEnergyCut )
306ClassImp( AliHBTRapidityCut )
307ClassImp( AliHBTPseudoRapidityCut )
308ClassImp( AliHBTPxCut )
309ClassImp( AliHBTPyCut )
310ClassImp( AliHBTPzCut )
311ClassImp( AliHBTPhiCut )
312ClassImp( AliHBTThetaCut )
313ClassImp( AliHBTVxCut )
314ClassImp( AliHBTVyCut )
315ClassImp( AliHBTVzCut )
316
317