1 #include "AliAODParticleCut.h"
2 //__________________________________________________________________________
3 ////////////////////////////////////////////////////////////////////////////
5 // class AliAODParticleCut //
7 // Classes for single particle cuts //
8 // User should use only AliAODParticleCut, 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 // responsible: Piotr Skowronski@cern.ch //
22 ////////////////////////////////////////////////////////////////////////////
24 #include <Riostream.h>
27 ClassImp(AliAODParticleCut)
28 const Int_t AliAODParticleCut::fgkMaxCuts = 50;
29 /******************************************************************/
31 AliAODParticleCut::AliAODParticleCut():
32 fCuts(new AliAODParticleBaseCut* [fgkMaxCuts]),//last property in the property enum => defines number of properties
38 /******************************************************************/
40 AliAODParticleCut::AliAODParticleCut(const AliAODParticleCut& in):
44 fCuts = new AliAODParticleBaseCut* [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] = (AliAODParticleBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
53 /******************************************************************/
54 AliAODParticleCut& AliAODParticleCut::operator=(const AliAODParticleCut& 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] = (AliAODParticleBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
72 /******************************************************************/
73 AliAODParticleCut::~AliAODParticleCut()
76 for (Int_t i = 0;i<fNCuts;i++)
82 /******************************************************************/
84 Bool_t AliAODParticleCut::Pass(AliVAODParticle* 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)) )
100 // fCuts[i]->Print();
101 return kTRUE; //if one of the cuts rejects, then reject
106 /******************************************************************/
108 void AliAODParticleCut::AddBasePartCut(AliAODParticleBaseCut* basecut)
110 //adds the base pair cut (cut on one value)
112 if (!basecut) return;
113 if( fNCuts == (fgkMaxCuts-1) )
115 Warning("AddBasePartCut","Not enough place for another cut");
118 fCuts[fNCuts++]=basecut;
122 /******************************************************************/
123 AliAODParticleBaseCut* AliAODParticleCut::FindCut(EAODCutProperty property)
125 //returns pointer to the cut checking the given property
126 for (Int_t i = 0;i<fNCuts;i++)
128 if (fCuts[i]->GetProperty() == property)
129 return fCuts[i]; //we found the cut we were searching for
132 return 0x0; //we did not found this cut
135 /******************************************************************/
137 void AliAODParticleCut::SetMomentumRange(Double_t min, Double_t max)
139 //Sets momentum range
140 AliAODMomentumCut* cut= (AliAODMomentumCut*)FindCut(kAODP);
141 if(cut) cut->SetRange(min,max);
142 else fCuts[fNCuts++] = new AliAODMomentumCut(min,max);
144 /******************************************************************/
147 void AliAODParticleCut::SetPtRange(Double_t min, Double_t max)
149 //name self descriptive
150 AliAODPtCut* cut= (AliAODPtCut*)FindCut(kAODPt);
151 if(cut) cut->SetRange(min,max);
152 else fCuts[fNCuts++] = new AliAODPtCut(min,max);
155 /******************************************************************/
157 void AliAODParticleCut::SetEnergyRange(Double_t min, Double_t max)
159 //name self descriptive
160 AliAODEnergyCut* cut= (AliAODEnergyCut*)FindCut(kAODE);
161 if(cut) cut->SetRange(min,max);
162 else fCuts[fNCuts++] = new AliAODEnergyCut(min,max);
165 /******************************************************************/
167 void AliAODParticleCut::SetRapidityRange(Double_t min, Double_t max)
169 //name self descriptive
170 AliAODParticleBaseCut* cut = FindCut(kAODRapidity);
171 if(cut) cut->SetRange(min,max);
172 else fCuts[fNCuts++] = new AliAODRapidityCut(min,max);
175 /******************************************************************/
177 void AliAODParticleCut::SetPseudoRapidityRange(Double_t min, Double_t max)
179 //name self descriptive
180 AliAODParticleBaseCut* cut = FindCut(kAODPseudoRapidity);
181 if(cut) cut->SetRange(min,max);
182 else fCuts[fNCuts++] = new AliAODPseudoRapidityCut(min,max);
185 /******************************************************************/
187 void AliAODParticleCut::SetPxRange(Double_t min, Double_t max)
189 //name self descriptive
190 AliAODParticleBaseCut* cut = FindCut(kAODPx);
191 if(cut) cut->SetRange(min,max);
192 else fCuts[fNCuts++] = new AliAODPxCut(min,max);
194 /******************************************************************/
196 void AliAODParticleCut::SetPyRange(Double_t min, Double_t max)
198 //name self descriptive
199 AliAODParticleBaseCut* cut = FindCut(kAODPy);
200 if(cut) cut->SetRange(min,max);
201 else fCuts[fNCuts++] = new AliAODPyCut(min,max);
203 /******************************************************************/
205 void AliAODParticleCut::SetPzRange(Double_t min, Double_t max)
207 //name self descriptive
208 AliAODParticleBaseCut* cut = FindCut(kAODPz);
209 if(cut) cut->SetRange(min,max);
210 else fCuts[fNCuts++] = new AliAODPzCut(min,max);
212 /******************************************************************/
214 void AliAODParticleCut::SetPhiRange(Double_t min, Double_t max)
216 //name self descriptive
217 AliAODParticleBaseCut* cut = FindCut(kAODPhi);
218 if(cut) cut->SetRange(min,max);
219 else fCuts[fNCuts++] = new AliAODPhiCut(min,max);
221 /******************************************************************/
223 void AliAODParticleCut::SetThetaRange(Double_t min, Double_t max)
225 //name self descriptive
226 AliAODParticleBaseCut* cut = FindCut(kAODTheta);
227 if(cut) cut->SetRange(min,max);
228 else fCuts[fNCuts++] = new AliAODThetaCut(min,max);
230 /******************************************************************/
232 void AliAODParticleCut::SetVxRange(Double_t min, Double_t max)
234 //name self descriptive
235 AliAODParticleBaseCut* cut = FindCut(kAODVx);
236 if(cut) cut->SetRange(min,max);
237 else fCuts[fNCuts++] = new AliAODVxCut(min,max);
239 /******************************************************************/
241 void AliAODParticleCut::SetVyRange(Double_t min, Double_t max)
243 //name self descriptive
244 AliAODParticleBaseCut* cut = FindCut(kAODVy);
245 if(cut) cut->SetRange(min,max);
246 else fCuts[fNCuts++] = new AliAODVyCut(min,max);
248 /******************************************************************/
250 void AliAODParticleCut::SetVzRange(Double_t min, Double_t max)
252 //name self descriptive
253 AliAODParticleBaseCut* cut = FindCut(kAODVz);
254 if(cut) cut->SetRange(min,max);
255 else fCuts[fNCuts++] = new AliAODVzCut(min,max);
258 /******************************************************************/
259 void AliAODParticleCut::Streamer(TBuffer &b)
261 // Stream all objects in the array to or from the I/O buffer.
267 for (i = 0;i<fNCuts;i++) delete fCuts[i];
268 b.ReadVersion(&R__s, &R__c);
269 TObject::Streamer(b);
272 for (i = 0;i<fNCuts;i++)
276 b.CheckByteCount(R__s, R__c,AliAODParticleCut::IsA());
280 R__c = b.WriteVersion(AliAODParticleCut::IsA(), kTRUE);
281 TObject::Streamer(b);
284 for (Int_t i = 0;i<fNCuts;i++)
288 b.SetByteCount(R__c, kTRUE);
291 /******************************************************************/
293 void AliAODParticleCut::Print(void) const
295 //prints all information about the cut to stdout
296 cout<<"Printing AliAODParticleCut, this = "<<this<<endl;
297 cout<<"fPID "<<fPID<<endl;
298 cout<<"fNCuts "<<fNCuts <<endl;
299 for (Int_t i = 0;i<fNCuts;i++)
301 cout<<" fCuts["<<i<<"] "<<fCuts[i]<<endl<<" ";
306 /******************************************************************/
307 /******************************************************************/
309 ClassImp(AliAODParticleEmptyCut)
310 void AliAODParticleEmptyCut::Streamer(TBuffer &b)
313 AliAODParticleCut::Streamer(b);
315 /******************************************************************/
316 /******************************************************************/
317 /******************************************************************/
319 /******************************************************************/
320 /******************************************************************/
321 /******************************************************************/
323 ClassImp(AliAODParticleBaseCut)
324 void AliAODParticleBaseCut::Print(void) const
326 // prints the information anout the base cut to stdout
327 cout<<"fMin="<<fMin <<", fMax=" <<fMax<<" ";
330 /******************************************************************/
332 void AliAODParticleBaseCut::PrintProperty(void) const
334 //prints the property name
338 cout<<"kAODP"; break;
340 cout<<"kAODPt"; break;
342 cout<<"kAODE"; break;
344 cout<<"kAODRapidity"; break;
345 case kAODPseudoRapidity:
346 cout<<"kAODPseudoRapidity"; break;
348 cout<<"kAODPx"; break;
350 cout<<"kAODPy"; break;
352 cout<<"kAODPz"; break;
354 cout<<"kAODPhi"; break;
356 cout<<"kAODTheta"; break;
358 cout<<"kAODVx"; break;
360 cout<<"kAODVy"; break;
362 cout<<"kAODVz"; break;
364 cout<<"kAODPid"; break;
366 cout<<"kAODNone"; break;
368 cout<<"Property Not Found";
372 ClassImp( AliAODMomentumCut )
374 ClassImp( AliAODPtCut )
375 ClassImp( AliAODEnergyCut )
376 ClassImp( AliAODRapidityCut )
377 ClassImp( AliAODPseudoRapidityCut )
378 ClassImp( AliAODPxCut )
379 ClassImp( AliAODPyCut )
380 ClassImp( AliAODPzCut )
381 ClassImp( AliAODPhiCut )
382 ClassImp( AliAODThetaCut )
383 ClassImp( AliAODVxCut )
384 ClassImp( AliAODVyCut )
385 ClassImp( AliAODVzCut )
387 ClassImp( AliAODPIDCut )
389 void AliAODPIDCut::Print(void) const
391 cout<<"PID "<<fPID<<" ";
392 AliAODParticleBaseCut::Print();
395 ClassImp( AliAODLogicalOperCut )
397 AliAODLogicalOperCut::AliAODLogicalOperCut():
398 AliAODParticleBaseCut(-10e10,10e10,kAODNone),
399 fFirst(new AliAODDummyBaseCut),
400 fSecond(new AliAODDummyBaseCut)
404 /******************************************************************/
406 AliAODLogicalOperCut::AliAODLogicalOperCut(AliAODParticleBaseCut* first, AliAODParticleBaseCut* second):
407 AliAODParticleBaseCut(-10e10,10e10,kAODNone),
408 fFirst((first)?(AliAODParticleBaseCut*)first->Clone():0x0),
409 fSecond((second)?(AliAODParticleBaseCut*)second->Clone():0x0)
412 if ( (fFirst && fSecond) == kFALSE)
414 Fatal("AliAODLogicalOperCut","One of parameters is NULL!");
417 /******************************************************************/
419 AliAODLogicalOperCut::~AliAODLogicalOperCut()
425 /******************************************************************/
427 Bool_t AliAODLogicalOperCut::AliAODDummyBaseCut::Pass(AliVAODParticle* /*part*/) const
429 //checks if particles passes properties defined by this cut
430 Warning("Pass","You are using dummy base cut! Probobly some logical cut is not set up properly");
431 return kFALSE;//accept
433 /******************************************************************/
435 void AliAODLogicalOperCut::Streamer(TBuffer &b)
437 // Stream all objects in the array to or from the I/O buffer.
446 b.ReadVersion(&R__s, &R__c);
447 TObject::Streamer(b);
450 b.CheckByteCount(R__s, R__c,AliAODLogicalOperCut::IsA());
454 R__c = b.WriteVersion(AliAODLogicalOperCut::IsA(), kTRUE);
455 TObject::Streamer(b);
458 b.SetByteCount(R__c, kTRUE);
462 /******************************************************************/
463 ClassImp(AliAODOrCut)
465 Bool_t AliAODOrCut::Pass(AliVAODParticle * p) const
467 //returns true when rejected
468 //AND operation is a little bit misleading but is correct
469 //User wants to build logical cuts with natural (positive) logic
470 //while AODAN use inernally reverse (returns true when rejected)
471 if (fFirst->Pass(p) && fSecond->Pass(p)) return kTRUE;//rejected (both rejected, returned kTRUE)
472 return kFALSE;//accepted, at least one accepted (returned kFALSE)
474 /******************************************************************/
476 ClassImp(AliAODAndCut)
478 Bool_t AliAODAndCut::Pass(AliVAODParticle * p) const
480 //returns true when rejected
481 //OR operation is a little bit misleading but is correct
482 //User wants to build logical cuts with natural (positive) logic
483 //while AODAN use inernally reverse (returns true when rejected)
484 if (fFirst->Pass(p) || fSecond->Pass(p)) return kTRUE;//rejected (any of two rejected(returned kTRUE) )
485 return kFALSE;//accepted (both accepted (returned kFALSE))
487 /******************************************************************/