1 #include "AliAODParticleCut.h"
2 //__________________________________________________________________________
3 ////////////////////////////////////////////////////////////////////////////
5 // class AliAODParticleCut //
7 // Classes for single particle cuts. //
8 // User should use mainly AliAODParticleCut interface methods, //
9 // eventually EmptyCut which passes all particles. //
11 // There is all interface for setting cuts on all particle properties //
12 // The main method is Rejected - which returns //
13 // True to reject particle //
14 // False in case it meets all the criteria of the given cut //
16 // This class has the list of base particle cuts that perform check on //
17 // single property. Particle is rejected if any of cuts rejects it. //
18 // There are implemented logical base cuts that perform logical //
19 // operations on results of two other base cuts. Using them user can //
20 // create a tree structure of a base cuts that performs sophisticated //
23 // User can also implement a base cut that performs complicated //
24 // calculations, if it is only more convenient and/or efficint. //
26 // User should delete created cuts himself //
27 // because when setting a cut, other objects (functions,analyses, //
28 // readers, other cuts) make their own copy of a cut. //
30 // more info: http://aliweb.cern.ch/people/skowron/analyzer/index.html //
31 // responsible: Piotr Skowronski@cern.ch //
33 ////////////////////////////////////////////////////////////////////////////
35 #include <Riostream.h>
38 ClassImp(AliAODParticleCut)
39 const Int_t AliAODParticleCut::fgkMaxCuts = 50;
40 /******************************************************************/
42 AliAODParticleCut::AliAODParticleCut():
43 fCuts(new AliAODParticleBaseCut* [fgkMaxCuts]),//last property in the property enum => defines number of properties
49 /******************************************************************/
51 AliAODParticleCut::AliAODParticleCut(const AliAODParticleCut& in):
53 fCuts(new AliAODParticleBaseCut* [fgkMaxCuts]),//last property in the property
54 //property enum => defines number of properties
59 for (Int_t i = 0;i<fNCuts;i++)
61 fCuts[i] = (AliAODParticleBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
64 /******************************************************************/
65 AliAODParticleCut& AliAODParticleCut::operator=(const AliAODParticleCut& in)
68 Info("operator=","operator=operator=operator=operator=\noperator=operator=operator=operator=");
69 for (Int_t i = 0;i<fNCuts;i++)
76 for (Int_t i = 0;i<fNCuts;i++)
78 fCuts[i] = (AliAODParticleBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
83 /******************************************************************/
84 AliAODParticleCut::~AliAODParticleCut()
87 for (Int_t i = 0;i<fNCuts;i++)
93 /******************************************************************/
95 Bool_t AliAODParticleCut::Rejected(AliVAODParticle* p) const
97 //method checks all the cuts that are set (in the list)
98 //If any of the baseCuts rejects particle False(rejection) is returned
102 Warning("Rejected()","No Pasaran! We never accept NULL pointers");
105 if( (p->GetPdgCode() != fPID) && ( fPID != 0)) return kTRUE;
107 for (Int_t i = 0;i<fNCuts;i++)
109 if ( (fCuts[i]->Rejected(p)) )
111 // fCuts[i]->Print();
112 return kTRUE; //if one of the cuts rejects, then reject
117 /******************************************************************/
119 void AliAODParticleCut::AddBasePartCut(AliAODParticleBaseCut* basecut)
121 //adds the base pair cut (cut on one value)
123 if (!basecut) return;
124 if( fNCuts == (fgkMaxCuts-1) )
126 Warning("AddBasePartCut","Not enough place for another cut");
129 fCuts[fNCuts++]=basecut;
133 /******************************************************************/
134 AliAODParticleBaseCut* AliAODParticleCut::FindCut(AliAODParticleBaseCut::EAODCutProperty property)
136 //returns pointer to the cut checking the given property
137 for (Int_t i = 0;i<fNCuts;i++)
139 if (fCuts[i]->GetProperty() == property)
140 return fCuts[i]; //we found the cut we were searching for
143 return 0x0; //we did not found this cut
146 /******************************************************************/
148 void AliAODParticleCut::SetMomentumRange(Double_t min, Double_t max)
150 //Sets momentum range
151 AliAODMomentumCut* cut= (AliAODMomentumCut*)FindCut(AliAODParticleBaseCut::kAODP);
152 if(cut) cut->SetRange(min,max);
153 else fCuts[fNCuts++] = new AliAODMomentumCut(min,max);
155 /******************************************************************/
158 void AliAODParticleCut::SetPtRange(Double_t min, Double_t max)
160 //name self descriptive
161 AliAODPtCut* cut= (AliAODPtCut*)FindCut(AliAODParticleBaseCut::kAODPt);
162 if(cut) cut->SetRange(min,max);
163 else fCuts[fNCuts++] = new AliAODPtCut(min,max);
166 /******************************************************************/
168 void AliAODParticleCut::SetEnergyRange(Double_t min, Double_t max)
170 //name self descriptive
171 AliAODEnergyCut* cut= (AliAODEnergyCut*)FindCut(AliAODParticleBaseCut::kAODE);
172 if(cut) cut->SetRange(min,max);
173 else fCuts[fNCuts++] = new AliAODEnergyCut(min,max);
176 /******************************************************************/
178 void AliAODParticleCut::SetRapidityRange(Double_t min, Double_t max)
180 //name self descriptive
181 AliAODParticleBaseCut* cut = FindCut(AliAODParticleBaseCut::kAODRapidity);
182 if(cut) cut->SetRange(min,max);
183 else fCuts[fNCuts++] = new AliAODRapidityCut(min,max);
186 /******************************************************************/
188 void AliAODParticleCut::SetPseudoRapidityRange(Double_t min, Double_t max)
190 //name self descriptive
191 AliAODParticleBaseCut* cut = FindCut(AliAODParticleBaseCut::kAODPseudoRapidity);
192 if(cut) cut->SetRange(min,max);
193 else fCuts[fNCuts++] = new AliAODPseudoRapidityCut(min,max);
196 /******************************************************************/
198 void AliAODParticleCut::SetPxRange(Double_t min, Double_t max)
200 //name self descriptive
201 AliAODParticleBaseCut* cut = FindCut(AliAODParticleBaseCut::kAODPx);
202 if(cut) cut->SetRange(min,max);
203 else fCuts[fNCuts++] = new AliAODPxCut(min,max);
205 /******************************************************************/
207 void AliAODParticleCut::SetPyRange(Double_t min, Double_t max)
209 //name self descriptive
210 AliAODParticleBaseCut* cut = FindCut(AliAODParticleBaseCut::kAODPy);
211 if(cut) cut->SetRange(min,max);
212 else fCuts[fNCuts++] = new AliAODPyCut(min,max);
214 /******************************************************************/
216 void AliAODParticleCut::SetPzRange(Double_t min, Double_t max)
218 //name self descriptive
219 AliAODParticleBaseCut* cut = FindCut(AliAODParticleBaseCut::kAODPz);
220 if(cut) cut->SetRange(min,max);
221 else fCuts[fNCuts++] = new AliAODPzCut(min,max);
223 /******************************************************************/
225 void AliAODParticleCut::SetPhiRange(Double_t min, Double_t max)
227 //name self descriptive
228 AliAODParticleBaseCut* cut = FindCut(AliAODParticleBaseCut::kAODPhi);
229 if(cut) cut->SetRange(min,max);
230 else fCuts[fNCuts++] = new AliAODPhiCut(min,max);
232 /******************************************************************/
234 void AliAODParticleCut::SetThetaRange(Double_t min, Double_t max)
236 //name self descriptive
237 AliAODParticleBaseCut* cut = FindCut(AliAODParticleBaseCut::kAODTheta);
238 if(cut) cut->SetRange(min,max);
239 else fCuts[fNCuts++] = new AliAODThetaCut(min,max);
241 /******************************************************************/
243 void AliAODParticleCut::SetVxRange(Double_t min, Double_t max)
245 //name self descriptive
246 AliAODParticleBaseCut* cut = FindCut(AliAODParticleBaseCut::kAODVx);
247 if(cut) cut->SetRange(min,max);
248 else fCuts[fNCuts++] = new AliAODVxCut(min,max);
250 /******************************************************************/
252 void AliAODParticleCut::SetVyRange(Double_t min, Double_t max)
254 //name self descriptive
255 AliAODParticleBaseCut* cut = FindCut(AliAODParticleBaseCut::kAODVy);
256 if(cut) cut->SetRange(min,max);
257 else fCuts[fNCuts++] = new AliAODVyCut(min,max);
259 /******************************************************************/
261 void AliAODParticleCut::SetVzRange(Double_t min, Double_t max)
263 //name self descriptive
264 AliAODParticleBaseCut* cut = FindCut(AliAODParticleBaseCut::kAODVz);
265 if(cut) cut->SetRange(min,max);
266 else fCuts[fNCuts++] = new AliAODVzCut(min,max);
269 /******************************************************************/
270 void AliAODParticleCut::Streamer(TBuffer &b)
272 // Stream all objects in the array to or from the I/O buffer.
278 for (i = 0;i<fNCuts;i++) delete fCuts[i];
279 b.ReadVersion(&R__s, &R__c);
280 TObject::Streamer(b);
283 for (i = 0;i<fNCuts;i++)
287 b.CheckByteCount(R__s, R__c,AliAODParticleCut::IsA());
291 R__c = b.WriteVersion(AliAODParticleCut::IsA(), kTRUE);
292 TObject::Streamer(b);
295 for (Int_t i = 0;i<fNCuts;i++)
299 b.SetByteCount(R__c, kTRUE);
302 /******************************************************************/
304 void AliAODParticleCut::Print(const Option_t * /*opt*/) const
306 //prints all information about the cut to stdout
307 cout<<"Printing AliAODParticleCut, this = "<<this<<endl;
308 cout<<"fPID "<<fPID<<endl;
309 cout<<"fNCuts "<<fNCuts <<endl;
310 for (Int_t i = 0;i<fNCuts;i++)
312 cout<<" fCuts["<<i<<"] "<<fCuts[i]<<endl<<" ";
317 /******************************************************************/
318 /******************************************************************/
319 ClassImp(AliAODParticleEmptyCut)
321 void AliAODParticleEmptyCut::Streamer(TBuffer &b)
324 AliAODParticleCut::Streamer(b);
326 /******************************************************************/
327 /******************************************************************/
328 /******************************************************************/