1 #include "AliHBTParticleCut.h"
2 //__________________________________________________________________________
3 ////////////////////////////////////////////////////////////////////////////
5 // class AliHBTParticleCut //
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 //
15 // User should create (and also destroy) cuts himself //
16 // and then pass them to the Analysis And Function by a proper method //
19 // more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html //
20 // resonsible: Piotr Skowronski@cern.ch //
22 ////////////////////////////////////////////////////////////////////////////
24 #include <Riostream.h>
27 ClassImp(AliHBTParticleCut)
28 const Int_t AliHBTParticleCut::fgkMaxCuts = 50;
29 /******************************************************************/
31 AliHBTParticleCut::AliHBTParticleCut():
32 fCuts(new AliHbtBaseCut* [fgkMaxCuts]),//last property in the property enum => defines number of properties
38 /******************************************************************/
40 AliHBTParticleCut::AliHBTParticleCut(const AliHBTParticleCut& in):
44 fCuts = new AliHbtBaseCut* [fgkMaxCuts];//last property in the property
45 //property enum => defines number of properties
48 for (Int_t i = 0;i<fNCuts;i++)
50 fCuts[i] = (AliHbtBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
53 /******************************************************************/
54 AliHBTParticleCut& AliHBTParticleCut::operator=(const AliHBTParticleCut& in)
57 Info("operator=","operator=operator=operator=operator=\noperator=operator=operator=operator=");
58 for (Int_t i = 0;i<fNCuts;i++)
65 for (Int_t i = 0;i<fNCuts;i++)
67 fCuts[i] = (AliHbtBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
72 /******************************************************************/
73 AliHBTParticleCut::~AliHBTParticleCut()
76 for (Int_t i = 0;i<fNCuts;i++)
82 /******************************************************************/
84 Bool_t AliHBTParticleCut::Pass(AliHBTParticle* p) const
86 //method checks all the cuts that are set (in the list)
87 //If any of the baseCuts rejects particle False(rejection) is returned
91 Warning("Pass()","No Pasaran! We never accept NULL pointers");
94 if( (p->GetPdgCode() != fPID) && ( fPID != 0)) return kTRUE;
96 for (Int_t i = 0;i<fNCuts;i++)
98 if ( (fCuts[i]->Pass(p)) ) return kTRUE; //if one of the cuts rejects, then reject
102 /******************************************************************/
104 void AliHBTParticleCut::AddBasePartCut(AliHbtBaseCut* basecut)
106 //adds the base pair cut (cut on one value)
108 if (!basecut) return;
109 if( fNCuts == (fgkMaxCuts-1) )
111 Warning("AddBasePartCut","Not enough place for another cut");
114 fCuts[fNCuts++]=basecut;
118 /******************************************************************/
119 AliHbtBaseCut* AliHBTParticleCut::FindCut(AliHBTCutProperty property)
121 //returns pointer to the cut checking the given property
122 for (Int_t i = 0;i<fNCuts;i++)
124 if (fCuts[i]->GetProperty() == property)
125 return fCuts[i]; //we found the cut we were searching for
128 return 0x0; //we did not found this cut
131 /******************************************************************/
133 void AliHBTParticleCut::SetMomentumRange(Double_t min, Double_t max)
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);
140 /******************************************************************/
143 void AliHBTParticleCut::SetPtRange(Double_t min, Double_t max)
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);
151 /******************************************************************/
153 void AliHBTParticleCut::SetEnergyRange(Double_t min, Double_t max)
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);
161 /******************************************************************/
163 void AliHBTParticleCut::SetRapidityRange(Double_t min, Double_t max)
165 //name self descriptive
166 AliHbtBaseCut* cut = FindCut(kHbtRapidity);
167 if(cut) cut->SetRange(min,max);
168 else fCuts[fNCuts++] = new AliHBTRapidityCut(min,max);
171 /******************************************************************/
173 void AliHBTParticleCut::SetPseudoRapidityRange(Double_t min, Double_t max)
175 //name self descriptive
176 AliHbtBaseCut* cut = FindCut(kHbtPseudoRapidity);
177 if(cut) cut->SetRange(min,max);
178 else fCuts[fNCuts++] = new AliHBTPseudoRapidityCut(min,max);
181 /******************************************************************/
183 void AliHBTParticleCut::SetPxRange(Double_t min, Double_t max)
185 //name self descriptive
186 AliHbtBaseCut* cut = FindCut(kHbtPx);
187 if(cut) cut->SetRange(min,max);
188 else fCuts[fNCuts++] = new AliHBTPxCut(min,max);
190 /******************************************************************/
192 void AliHBTParticleCut::SetPyRange(Double_t min, Double_t max)
194 //name self descriptive
195 AliHbtBaseCut* cut = FindCut(kHbtPy);
196 if(cut) cut->SetRange(min,max);
197 else fCuts[fNCuts++] = new AliHBTPyCut(min,max);
199 /******************************************************************/
201 void AliHBTParticleCut::SetPzRange(Double_t min, Double_t max)
203 //name self descriptive
204 AliHbtBaseCut* cut = FindCut(kHbtPz);
205 if(cut) cut->SetRange(min,max);
206 else fCuts[fNCuts++] = new AliHBTPzCut(min,max);
208 /******************************************************************/
210 void AliHBTParticleCut::SetPhiRange(Double_t min, Double_t max)
212 //name self descriptive
213 AliHbtBaseCut* cut = FindCut(kHbtPhi);
214 if(cut) cut->SetRange(min,max);
215 else fCuts[fNCuts++] = new AliHBTPhiCut(min,max);
217 /******************************************************************/
219 void AliHBTParticleCut::SetThetaRange(Double_t min, Double_t max)
221 //name self descriptive
222 AliHbtBaseCut* cut = FindCut(kHbtTheta);
223 if(cut) cut->SetRange(min,max);
224 else fCuts[fNCuts++] = new AliHBTThetaCut(min,max);
226 /******************************************************************/
228 void AliHBTParticleCut::SetVxRange(Double_t min, Double_t max)
230 //name self descriptive
231 AliHbtBaseCut* cut = FindCut(kHbtVx);
232 if(cut) cut->SetRange(min,max);
233 else fCuts[fNCuts++] = new AliHBTVxCut(min,max);
235 /******************************************************************/
237 void AliHBTParticleCut::SetVyRange(Double_t min, Double_t max)
239 //name self descriptive
240 AliHbtBaseCut* cut = FindCut(kHbtVy);
241 if(cut) cut->SetRange(min,max);
242 else fCuts[fNCuts++] = new AliHBTVyCut(min,max);
244 /******************************************************************/
246 void AliHBTParticleCut::SetVzRange(Double_t min, Double_t max)
248 //name self descriptive
249 AliHbtBaseCut* cut = FindCut(kHbtVz);
250 if(cut) cut->SetRange(min,max);
251 else fCuts[fNCuts++] = new AliHBTVzCut(min,max);
254 /******************************************************************/
255 void AliHBTParticleCut::Streamer(TBuffer &b)
257 // Stream all objects in the array to or from the I/O buffer.
263 for (i = 0;i<fNCuts;i++) delete fCuts[i];
264 b.ReadVersion(&R__s, &R__c);
265 TObject::Streamer(b);
268 for (i = 0;i<fNCuts;i++)
272 b.CheckByteCount(R__s, R__c,AliHBTParticleCut::IsA());
276 R__c = b.WriteVersion(AliHBTParticleCut::IsA(), kTRUE);
277 TObject::Streamer(b);
280 for (Int_t i = 0;i<fNCuts;i++)
284 b.SetByteCount(R__c, kTRUE);
287 /******************************************************************/
289 void AliHBTParticleCut::Print(void) const
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++)
297 cout<<" fCuts["<<i<<"] "<<fCuts[i]<<endl<<" ";
302 /******************************************************************/
303 /******************************************************************/
305 ClassImp(AliHBTEmptyParticleCut)
306 void AliHBTEmptyParticleCut::Streamer(TBuffer &b)
309 AliHBTParticleCut::Streamer(b);
311 /******************************************************************/
312 /******************************************************************/
313 /******************************************************************/
315 /******************************************************************/
316 /******************************************************************/
317 /******************************************************************/
319 ClassImp(AliHbtBaseCut)
320 void AliHbtBaseCut::Print(void) const
322 // prints the information anout the base cut to stdout
323 cout<<"fMin="<<fMin <<", fMax=" <<fMax<<" ";
326 /******************************************************************/
328 void AliHbtBaseCut::PrintProperty(void) const
330 //prints the property name
334 cout<<"kHbtP"; break;
336 cout<<"kHbtPt"; break;
338 cout<<"kHbtE"; break;
340 cout<<"kHbtRapidity"; break;
341 case kHbtPseudoRapidity:
342 cout<<"kHbtPseudoRapidity"; break;
344 cout<<"kHbtPx"; break;
346 cout<<"kHbtPy"; break;
348 cout<<"kHbtPz"; break;
350 cout<<"kHbtPhi"; break;
352 cout<<"kHbtTheta"; break;
354 cout<<"kHbtVx"; break;
356 cout<<"kHbtVy"; break;
358 cout<<"kHbtVz"; break;
360 cout<<"kHbtNone"; break;
362 cout<<"Property Not Found";
366 ClassImp( AliHBTMomentumCut )
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 )
381 ClassImp( AliHBTPIDCut )
383 ClassImp( AliHBTLogicalOperCut )
385 AliHBTLogicalOperCut::AliHBTLogicalOperCut():
386 AliHbtBaseCut(-10e10,10e10,kHbtNone),
387 fFirst(new AliHBTDummyBaseCut),
388 fSecond(new AliHBTDummyBaseCut)
392 /******************************************************************/
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)
400 if ( (fFirst && fSecond) == kFALSE)
402 Fatal("AliHBTLogicalOperCut","One of parameters is NULL!");
405 /******************************************************************/
407 AliHBTLogicalOperCut::~AliHBTLogicalOperCut()
413 /******************************************************************/
415 Bool_t AliHBTLogicalOperCut::AliHBTDummyBaseCut::Pass(AliHBTParticle* /*part*/) const
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
421 /******************************************************************/
423 void AliHBTLogicalOperCut::Streamer(TBuffer &b)
425 // Stream all objects in the array to or from the I/O buffer.
434 b.ReadVersion(&R__s, &R__c);
435 TObject::Streamer(b);
438 b.CheckByteCount(R__s, R__c,AliHBTLogicalOperCut::IsA());
442 R__c = b.WriteVersion(AliHBTLogicalOperCut::IsA(), kTRUE);
443 TObject::Streamer(b);
446 b.SetByteCount(R__c, kTRUE);
450 /******************************************************************/
451 ClassImp(AliHBTOrCut)
453 Bool_t AliHBTOrCut::Pass(AliHBTParticle * p) const
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)
462 /******************************************************************/
464 ClassImp(AliHBTAndCut)
466 Bool_t AliHBTAndCut::Pass(AliHBTParticle * p) const
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))
475 /******************************************************************/