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