]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTParticleCut.cxx
Compiler Warning Removed
[u/mrichter/AliRoot.git] / HBTAN / AliHBTParticleCut.cxx
CommitLineData
87fcb86d 1//__________________________________________________________________________
2////////////////////////////////////////////////////////////////////////////
3// //
4// class AliHBTParticleCut //
5// //
6// Classes for single particle cuts //
7// User should use only AliHBTParticleCut, eventually //
8// EmptyCut which passes all particles //
9// There is all interface for setting cuts on all particle properties //
10// The main method is Pass - which returns //
11// True to reject particle //
12// False in case it meets all the criteria of the given cut //
13// //
14// User should create (and also destroy) cuts himself //
15// and then pass them to the Analysis And Function by a proper method //
16// //
17// //
18// more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html //
19// resonsible: Piotr Skowronski@cern.ch //
20// //
21////////////////////////////////////////////////////////////////////////////
1b446896 22#include "AliHBTParticleCut.h"
23
d0c23b58 24#include <Riostream.h>
1b446896 25
26ClassImp(AliHBTParticleCut)
87fcb86d 27const Int_t AliHBTParticleCut::fgkMaxCuts = 50;
1b446896 28/******************************************************************/
29
30AliHBTParticleCut::AliHBTParticleCut()
31 {
87fcb86d 32 //default ctor
33 fCuts = new AliHbtBaseCut* [fgkMaxCuts];//last property in the property
1b446896 34 //property enum => defines number of properties
35 fNCuts = 0;
36 fPID = 0;
37 }
38/******************************************************************/
39
bed069a4 40AliHBTParticleCut::AliHBTParticleCut(const AliHBTParticleCut& in):
87fcb86d 41 TObject(in)
1b446896 42{
87fcb86d 43 //cpy ctor
44 fCuts = new AliHbtBaseCut* [fgkMaxCuts];//last property in the property
1b446896 45 //property enum => defines number of properties
46 fNCuts = in.fNCuts;
47 fPID = in.fPID;
48 for (Int_t i = 0;i<fNCuts;i++)
49 {
50 fCuts[i] = (AliHbtBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
51 }
52}
53/******************************************************************/
87fcb86d 54const AliHBTParticleCut& AliHBTParticleCut::operator = (const AliHBTParticleCut& in)
55{
56 //assigment operator
57 for (Int_t i = 0;i<fNCuts;i++)
58 {
59 delete fCuts[i];
60 }
1b446896 61
87fcb86d 62 fNCuts = in.fNCuts;
63 fPID = in.fPID;
64 for (Int_t i = 0;i<fNCuts;i++)
65 {
66 fCuts[i] = (AliHbtBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
67 }
68 return *this;
69}
70
71/******************************************************************/
1b446896 72AliHBTParticleCut::~AliHBTParticleCut()
73{
87fcb86d 74 //dtor
1b446896 75 for (Int_t i = 0;i<fNCuts;i++)
76 {
77 delete fCuts[i];
78 }
79 delete []fCuts;
80}
81/******************************************************************/
82
83Bool_t AliHBTParticleCut::Pass(AliHBTParticle* p)
84{
85//method checks all the cuts that are set (in the list)
86//If any of the baseCuts rejects particle False(rejection) is returned
87 if(!p)
88 {
89 Warning("Pass()","No Pasaran! We never accept NULL pointers");
90 return kTRUE;
91 }
92 if( (p->GetPdgCode() != fPID) && ( fPID != 0)) return kTRUE;
93
94 for (Int_t i = 0;i<fNCuts;i++)
95 {
96 if ( (fCuts[i]->Pass(p)) ) return kTRUE; //if one of the cuts rejects, then reject
97 }
98 return kFALSE;
99}
100/******************************************************************/
101
102void AliHBTParticleCut::AddBasePartCut(AliHbtBaseCut* basecut)
103{
104 //adds the base pair cut (cut on one value)
105
106 if (!basecut) return;
87fcb86d 107 if( fNCuts == (fgkMaxCuts-1) )
1b446896 108 {
109 Warning("AddBasePartCut","Not enough place for another cut");
110 return;
111 }
112 fCuts[fNCuts++]=basecut;
113
114}
115
116/******************************************************************/
117AliHbtBaseCut* AliHBTParticleCut::FindCut(AliHBTCutProperty property)
118{
87fcb86d 119 //returns pointer to the cut checking the given property
1b446896 120 for (Int_t i = 0;i<fNCuts;i++)
121 {
122 if (fCuts[i]->GetProperty() == property)
123 return fCuts[i]; //we found the cut we were searching for
124 }
125
126 return 0x0; //we did not found this cut
127
128}
129/******************************************************************/
130
131void AliHBTParticleCut::SetMomentumRange(Double_t min, Double_t max)
132{
87fcb86d 133 //Sets momentum range
1b446896 134 AliHBTMomentumCut* cut= (AliHBTMomentumCut*)FindCut(kHbtP);
135 if(cut) cut->SetRange(min,max);
136 else fCuts[fNCuts++] = new AliHBTMomentumCut(min,max);
137}
138/******************************************************************/
139
140
141void AliHBTParticleCut::SetPtRange(Double_t min, Double_t max)
142{
87fcb86d 143 //name self descriptive
1b446896 144 AliHBTPtCut* cut= (AliHBTPtCut*)FindCut(kHbtPt);
145 if(cut) cut->SetRange(min,max);
146 else fCuts[fNCuts++] = new AliHBTPtCut(min,max);
147
148}
149/******************************************************************/
150
151void AliHBTParticleCut::SetEnergyRange(Double_t min, Double_t max)
152{
87fcb86d 153 //name self descriptive
1b446896 154 AliHBTEnergyCut* cut= (AliHBTEnergyCut*)FindCut(kHbtE);
155 if(cut) cut->SetRange(min,max);
156 else fCuts[fNCuts++] = new AliHBTEnergyCut(min,max);
157
158}
159/******************************************************************/
160
161void AliHBTParticleCut::SetRapidityRange(Double_t min, Double_t max)
162{
87fcb86d 163 //name self descriptive
1b446896 164 AliHbtBaseCut* cut = FindCut(kHbtRapidity);
165 if(cut) cut->SetRange(min,max);
166 else fCuts[fNCuts++] = new AliHBTRapidityCut(min,max);
167
168}
169/******************************************************************/
170
171void AliHBTParticleCut::SetPseudoRapidityRange(Double_t min, Double_t max)
172{
87fcb86d 173 //name self descriptive
1b446896 174 AliHbtBaseCut* cut = FindCut(kHbtPseudoRapidity);
175 if(cut) cut->SetRange(min,max);
176 else fCuts[fNCuts++] = new AliHBTPseudoRapidityCut(min,max);
177
178}
179/******************************************************************/
180
181void AliHBTParticleCut::SetPxRange(Double_t min, Double_t max)
182{
87fcb86d 183 //name self descriptive
1b446896 184 AliHbtBaseCut* cut = FindCut(kHbtPx);
185 if(cut) cut->SetRange(min,max);
186 else fCuts[fNCuts++] = new AliHBTPxCut(min,max);
187}
188/******************************************************************/
189
190void AliHBTParticleCut::SetPyRange(Double_t min, Double_t max)
191{
87fcb86d 192 //name self descriptive
1b446896 193 AliHbtBaseCut* cut = FindCut(kHbtPy);
194 if(cut) cut->SetRange(min,max);
195 else fCuts[fNCuts++] = new AliHBTPyCut(min,max);
196}
197/******************************************************************/
198
199void AliHBTParticleCut::SetPzRange(Double_t min, Double_t max)
200{
87fcb86d 201 //name self descriptive
1b446896 202 AliHbtBaseCut* cut = FindCut(kHbtPz);
203 if(cut) cut->SetRange(min,max);
204 else fCuts[fNCuts++] = new AliHBTPzCut(min,max);
205}
206/******************************************************************/
207
208void AliHBTParticleCut::SetPhiRange(Double_t min, Double_t max)
209{
87fcb86d 210 //name self descriptive
1b446896 211 AliHbtBaseCut* cut = FindCut(kHbtPhi);
212 if(cut) cut->SetRange(min,max);
213 else fCuts[fNCuts++] = new AliHBTPhiCut(min,max);
214}
215/******************************************************************/
216
217void AliHBTParticleCut::SetThetaRange(Double_t min, Double_t max)
218{
87fcb86d 219 //name self descriptive
1b446896 220 AliHbtBaseCut* cut = FindCut(kHbtTheta);
221 if(cut) cut->SetRange(min,max);
222 else fCuts[fNCuts++] = new AliHBTThetaCut(min,max);
223}
224/******************************************************************/
225
226void AliHBTParticleCut::SetVxRange(Double_t min, Double_t max)
227{
87fcb86d 228 //name self descriptive
1b446896 229 AliHbtBaseCut* cut = FindCut(kHbtVx);
230 if(cut) cut->SetRange(min,max);
231 else fCuts[fNCuts++] = new AliHBTVxCut(min,max);
232}
233/******************************************************************/
234
235void AliHBTParticleCut::SetVyRange(Double_t min, Double_t max)
236{
87fcb86d 237 //name self descriptive
1b446896 238 AliHbtBaseCut* cut = FindCut(kHbtVy);
239 if(cut) cut->SetRange(min,max);
240 else fCuts[fNCuts++] = new AliHBTVyCut(min,max);
241}
242/******************************************************************/
243
244void AliHBTParticleCut::SetVzRange(Double_t min, Double_t max)
245{
87fcb86d 246 //name self descriptive
1b446896 247 AliHbtBaseCut* cut = FindCut(kHbtVz);
248 if(cut) cut->SetRange(min,max);
249 else fCuts[fNCuts++] = new AliHBTVzCut(min,max);
250}
251
252/******************************************************************/
253void AliHBTParticleCut::Streamer(TBuffer &b)
254{
87fcb86d 255 // Stream all objects in the array to or from the I/O buffer.
1b446896 256
257 UInt_t R__s, R__c;
258 if (b.IsReading())
259 {
e9b3bfa8 260 Int_t i;
261 for (i = 0;i<fNCuts;i++) delete fCuts[i];
262 b.ReadVersion(&R__s, &R__c);
1b446896 263 TObject::Streamer(b);
264 b >> fPID;
265 b >> fNCuts;
e9b3bfa8 266 for (i = 0;i<fNCuts;i++)
1b446896 267 {
e9b3bfa8 268 b >> fCuts[i];
1b446896 269 }
270 b.CheckByteCount(R__s, R__c,AliHBTParticleCut::IsA());
271 }
272 else
273 {
274 R__c = b.WriteVersion(AliHBTParticleCut::IsA(), kTRUE);
275 TObject::Streamer(b);
276 b << fPID;
277 b << fNCuts;
278 for (Int_t i = 0;i<fNCuts;i++)
279 {
280 b << fCuts[i];
281 }
282 b.SetByteCount(R__c, kTRUE);
283 }
284}
87fcb86d 285/******************************************************************/
1b446896 286
87fcb86d 287void AliHBTParticleCut::Print(void) const
1b446896 288{
87fcb86d 289 //prints all information about the cut to stdout
1b446896 290 cout<<"Printing AliHBTParticleCut, this = "<<this<<endl;
291 cout<<"fPID "<<fPID<<endl;
292 cout<<"fNCuts "<<fNCuts <<endl;
293 for (Int_t i = 0;i<fNCuts;i++)
294 {
295 cout<<" fCuts["<<i<<"] "<<fCuts[i]<<endl<<" ";
296 fCuts[i]->Print();
297 }
298}
299
300/******************************************************************/
301/******************************************************************/
302
303ClassImp(AliHBTEmptyParticleCut)
304void AliHBTEmptyParticleCut::Streamer(TBuffer &b)
305 {
87fcb86d 306 //stramer
1b446896 307 AliHBTParticleCut::Streamer(b);
308 }
309/******************************************************************/
310/******************************************************************/
311/******************************************************************/
312
313/******************************************************************/
314/******************************************************************/
315/******************************************************************/
316
317ClassImp(AliHbtBaseCut)
87fcb86d 318void AliHbtBaseCut::Print(void) const
1b446896 319{
87fcb86d 320 // prints the information anout the base cut to stdout
1b446896 321 cout<<"fMin="<<fMin <<", fMax=" <<fMax<<" ";
322 PrintProperty();
323}
87fcb86d 324/******************************************************************/
325
326void AliHbtBaseCut::PrintProperty(void) const
1b446896 327{
87fcb86d 328 //prints the property name
1b446896 329 switch (fProperty)
330 {
331 case kHbtP:
332 cout<<"kHbtP"; break;
333 case kHbtPt:
334 cout<<"kHbtPt"; break;
335 case kHbtE:
336 cout<<"kHbtE"; break;
337 case kHbtRapidity:
338 cout<<"kHbtRapidity"; break;
339 case kHbtPseudoRapidity:
340 cout<<"kHbtPseudoRapidity"; break;
341 case kHbtPx:
342 cout<<"kHbtPx"; break;
343 case kHbtPy:
344 cout<<"kHbtPy"; break;
345 case kHbtPz:
346 cout<<"kHbtPz"; break;
347 case kHbtPhi:
348 cout<<"kHbtPhi"; break;
349 case kHbtTheta:
350 cout<<"kHbtTheta"; break;
351 case kHbtVx:
352 cout<<"kHbtVx"; break;
353 case kHbtVy:
354 cout<<"kHbtVy"; break;
355 case kHbtVz:
356 cout<<"kHbtVz"; break;
357 case kHbtNone:
358 cout<<"kHbtNone"; break;
359 default:
360 cout<<"Property Not Found";
361 }
362 cout<<endl;
363}
364ClassImp( AliHBTMomentumCut )
365
366ClassImp( AliHBTPtCut )
367ClassImp( AliHBTEnergyCut )
368ClassImp( AliHBTRapidityCut )
369ClassImp( AliHBTPseudoRapidityCut )
370ClassImp( AliHBTPxCut )
371ClassImp( AliHBTPyCut )
372ClassImp( AliHBTPzCut )
373ClassImp( AliHBTPhiCut )
374ClassImp( AliHBTThetaCut )
375ClassImp( AliHBTVxCut )
376ClassImp( AliHBTVyCut )
377ClassImp( AliHBTVzCut )
378
4617f71a 379ClassImp( AliHBTPIDCut )
1b446896 380
4617f71a 381ClassImp( AliHBTLogicalOperCut )
382
383AliHBTLogicalOperCut::AliHBTLogicalOperCut():
384 AliHbtBaseCut(-10e10,10e10,kHbtNone),
385 fFirst(new AliHBTDummyBaseCut),
386 fSecond(new AliHBTDummyBaseCut)
387{
87fcb86d 388 //ctor
4617f71a 389}
390/******************************************************************/
391
392AliHBTLogicalOperCut::AliHBTLogicalOperCut(AliHbtBaseCut* first, AliHbtBaseCut* second):
393 AliHbtBaseCut(-10e10,10e10,kHbtNone),
394 fFirst((first)?(AliHbtBaseCut*)first->Clone():0x0),
395 fSecond((second)?(AliHbtBaseCut*)second->Clone():0x0)
396{
87fcb86d 397 //ctor
4617f71a 398 if ( (fFirst && fSecond) == kFALSE)
399 {
400 Fatal("AliHBTLogicalOperCut","One of parameters is NULL!");
401 }
402}
403/******************************************************************/
404
405AliHBTLogicalOperCut::~AliHBTLogicalOperCut()
406{
87fcb86d 407 //destructor
4617f71a 408 delete fFirst;
409 delete fSecond;
410}
411/******************************************************************/
412
bed069a4 413Bool_t AliHBTLogicalOperCut::AliHBTDummyBaseCut::Pass(AliHBTParticle* /*part*/)
4617f71a 414{
87fcb86d 415 //checks if particles passes properties defined by this cut
4617f71a 416 Warning("Pass","You are using dummy base cut! Probobly some logical cut is not set up properly");
417 return kFALSE;//accept
418}
419/******************************************************************/
420
421void AliHBTLogicalOperCut::Streamer(TBuffer &b)
422{
423 // Stream all objects in the array to or from the I/O buffer.
424 UInt_t R__s, R__c;
425 if (b.IsReading())
426 {
427 delete fFirst;
428 delete fSecond;
429 fFirst = 0x0;
430 fSecond = 0x0;
431
432 b.ReadVersion(&R__s, &R__c);
433 TObject::Streamer(b);
434 b >> fFirst;
435 b >> fSecond;
436 b.CheckByteCount(R__s, R__c,AliHBTLogicalOperCut::IsA());
437 }
438 else
439 {
440 R__c = b.WriteVersion(AliHBTLogicalOperCut::IsA(), kTRUE);
441 TObject::Streamer(b);
442 b << fFirst;
443 b << fSecond;
444 b.SetByteCount(R__c, kTRUE);
445 }
446}
447
448/******************************************************************/
449ClassImp(AliHBTOrCut)
450
451Bool_t AliHBTOrCut::Pass(AliHBTParticle * p)
452{
453 //returns true when rejected
454 //AND operation is a little bit misleading but is correct
455 //User wants to build logical cuts with natural (positive) logic
456 //while HBTAN use inernally reverse (returns true when rejected)
457 if (fFirst->Pass(p) && fSecond->Pass(p)) return kTRUE;//rejected (both rejected, returned kTRUE)
458 return kFALSE;//accepted, at least one accepted (returned kFALSE)
459}
460/******************************************************************/
461
462ClassImp(AliHBTAndCut)
463
464Bool_t AliHBTAndCut::Pass(AliHBTParticle * p)
465{
466 //returns true when rejected
467 //OR operation is a little bit misleading but is correct
468 //User wants to build logical cuts with natural (positive) logic
469 //while HBTAN use inernally reverse (returns true when rejected)
470 if (fFirst->Pass(p) || fSecond->Pass(p)) return kTRUE;//rejected (any of two rejected(returned kTRUE) )
471 return kFALSE;//accepted (both accepted (returned kFALSE))
472}
473/******************************************************************/