]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HBTAN/AliHBTParticleCut.cxx
Macro to plot pathlengths of back-to-back jets. (A. Dainese)
[u/mrichter/AliRoot.git] / HBTAN / AliHBTParticleCut.cxx
CommitLineData
c0956fc6 1#include "AliHBTParticleCut.h"
87fcb86d 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////////////////////////////////////////////////////////////////////////////
1b446896 23
d0c23b58 24#include <Riostream.h>
1b446896 25
c0956fc6 26
1b446896 27ClassImp(AliHBTParticleCut)
87fcb86d 28const Int_t AliHBTParticleCut::fgkMaxCuts = 50;
1b446896 29/******************************************************************/
30
c0956fc6 31AliHBTParticleCut::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}
1b446896 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/******************************************************************/
c0956fc6 54AliHBTParticleCut& AliHBTParticleCut::operator=(const AliHBTParticleCut& in)
87fcb86d 55{
56 //assigment operator
c0956fc6 57 Info("operator=","operator=operator=operator=operator=\noperator=operator=operator=operator=");
87fcb86d 58 for (Int_t i = 0;i<fNCuts;i++)
59 {
60 delete fCuts[i];
61 }
1b446896 62
87fcb86d 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/******************************************************************/
1b446896 73AliHBTParticleCut::~AliHBTParticleCut()
74{
87fcb86d 75 //dtor
1b446896 76 for (Int_t i = 0;i<fNCuts;i++)
77 {
78 delete fCuts[i];
79 }
80 delete []fCuts;
81}
82/******************************************************************/
83
c0956fc6 84Bool_t AliHBTParticleCut::Pass(AliHBTParticle* p) const
1b446896 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
c0956fc6 88
1b446896 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
104void AliHBTParticleCut::AddBasePartCut(AliHbtBaseCut* basecut)
105{
106 //adds the base pair cut (cut on one value)
107
108 if (!basecut) return;
87fcb86d 109 if( fNCuts == (fgkMaxCuts-1) )
1b446896 110 {
111 Warning("AddBasePartCut","Not enough place for another cut");
112 return;
113 }
114 fCuts[fNCuts++]=basecut;
115
116}
117
118/******************************************************************/
119AliHbtBaseCut* AliHBTParticleCut::FindCut(AliHBTCutProperty property)
120{
87fcb86d 121 //returns pointer to the cut checking the given property
1b446896 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
133void AliHBTParticleCut::SetMomentumRange(Double_t min, Double_t max)
134{
87fcb86d 135 //Sets momentum range
1b446896 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
143void AliHBTParticleCut::SetPtRange(Double_t min, Double_t max)
144{
87fcb86d 145 //name self descriptive
1b446896 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
153void AliHBTParticleCut::SetEnergyRange(Double_t min, Double_t max)
154{
87fcb86d 155 //name self descriptive
1b446896 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
163void AliHBTParticleCut::SetRapidityRange(Double_t min, Double_t max)
164{
87fcb86d 165 //name self descriptive
1b446896 166 AliHbtBaseCut* cut = FindCut(kHbtRapidity);
167 if(cut) cut->SetRange(min,max);
168 else fCuts[fNCuts++] = new AliHBTRapidityCut(min,max);
169
170}
171/******************************************************************/
172
173void AliHBTParticleCut::SetPseudoRapidityRange(Double_t min, Double_t max)
174{
87fcb86d 175 //name self descriptive
1b446896 176 AliHbtBaseCut* cut = FindCut(kHbtPseudoRapidity);
177 if(cut) cut->SetRange(min,max);
178 else fCuts[fNCuts++] = new AliHBTPseudoRapidityCut(min,max);
179
180}
181/******************************************************************/
182
183void AliHBTParticleCut::SetPxRange(Double_t min, Double_t max)
184{
87fcb86d 185 //name self descriptive
1b446896 186 AliHbtBaseCut* cut = FindCut(kHbtPx);
187 if(cut) cut->SetRange(min,max);
188 else fCuts[fNCuts++] = new AliHBTPxCut(min,max);
189}
190/******************************************************************/
191
192void AliHBTParticleCut::SetPyRange(Double_t min, Double_t max)
193{
87fcb86d 194 //name self descriptive
1b446896 195 AliHbtBaseCut* cut = FindCut(kHbtPy);
196 if(cut) cut->SetRange(min,max);
197 else fCuts[fNCuts++] = new AliHBTPyCut(min,max);
198}
199/******************************************************************/
200
201void AliHBTParticleCut::SetPzRange(Double_t min, Double_t max)
202{
87fcb86d 203 //name self descriptive
1b446896 204 AliHbtBaseCut* cut = FindCut(kHbtPz);
205 if(cut) cut->SetRange(min,max);
206 else fCuts[fNCuts++] = new AliHBTPzCut(min,max);
207}
208/******************************************************************/
209
210void AliHBTParticleCut::SetPhiRange(Double_t min, Double_t max)
211{
87fcb86d 212 //name self descriptive
1b446896 213 AliHbtBaseCut* cut = FindCut(kHbtPhi);
214 if(cut) cut->SetRange(min,max);
215 else fCuts[fNCuts++] = new AliHBTPhiCut(min,max);
216}
217/******************************************************************/
218
219void AliHBTParticleCut::SetThetaRange(Double_t min, Double_t max)
220{
87fcb86d 221 //name self descriptive
1b446896 222 AliHbtBaseCut* cut = FindCut(kHbtTheta);
223 if(cut) cut->SetRange(min,max);
224 else fCuts[fNCuts++] = new AliHBTThetaCut(min,max);
225}
226/******************************************************************/
227
228void AliHBTParticleCut::SetVxRange(Double_t min, Double_t max)
229{
87fcb86d 230 //name self descriptive
1b446896 231 AliHbtBaseCut* cut = FindCut(kHbtVx);
232 if(cut) cut->SetRange(min,max);
233 else fCuts[fNCuts++] = new AliHBTVxCut(min,max);
234}
235/******************************************************************/
236
237void AliHBTParticleCut::SetVyRange(Double_t min, Double_t max)
238{
87fcb86d 239 //name self descriptive
1b446896 240 AliHbtBaseCut* cut = FindCut(kHbtVy);
241 if(cut) cut->SetRange(min,max);
242 else fCuts[fNCuts++] = new AliHBTVyCut(min,max);
243}
244/******************************************************************/
245
246void AliHBTParticleCut::SetVzRange(Double_t min, Double_t max)
247{
87fcb86d 248 //name self descriptive
1b446896 249 AliHbtBaseCut* cut = FindCut(kHbtVz);
250 if(cut) cut->SetRange(min,max);
251 else fCuts[fNCuts++] = new AliHBTVzCut(min,max);
252}
253
254/******************************************************************/
255void AliHBTParticleCut::Streamer(TBuffer &b)
256{
87fcb86d 257 // Stream all objects in the array to or from the I/O buffer.
1b446896 258
259 UInt_t R__s, R__c;
260 if (b.IsReading())
261 {
e9b3bfa8 262 Int_t i;
263 for (i = 0;i<fNCuts;i++) delete fCuts[i];
264 b.ReadVersion(&R__s, &R__c);
1b446896 265 TObject::Streamer(b);
266 b >> fPID;
267 b >> fNCuts;
e9b3bfa8 268 for (i = 0;i<fNCuts;i++)
1b446896 269 {
e9b3bfa8 270 b >> fCuts[i];
1b446896 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}
87fcb86d 287/******************************************************************/
1b446896 288
87fcb86d 289void AliHBTParticleCut::Print(void) const
1b446896 290{
87fcb86d 291 //prints all information about the cut to stdout
1b446896 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
305ClassImp(AliHBTEmptyParticleCut)
306void AliHBTEmptyParticleCut::Streamer(TBuffer &b)
307 {
87fcb86d 308 //stramer
1b446896 309 AliHBTParticleCut::Streamer(b);
310 }
311/******************************************************************/
312/******************************************************************/
313/******************************************************************/
314
315/******************************************************************/
316/******************************************************************/
317/******************************************************************/
318
319ClassImp(AliHbtBaseCut)
87fcb86d 320void AliHbtBaseCut::Print(void) const
1b446896 321{
87fcb86d 322 // prints the information anout the base cut to stdout
1b446896 323 cout<<"fMin="<<fMin <<", fMax=" <<fMax<<" ";
324 PrintProperty();
325}
87fcb86d 326/******************************************************************/
327
328void AliHbtBaseCut::PrintProperty(void) const
1b446896 329{
87fcb86d 330 //prints the property name
1b446896 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}
366ClassImp( AliHBTMomentumCut )
367
368ClassImp( AliHBTPtCut )
369ClassImp( AliHBTEnergyCut )
370ClassImp( AliHBTRapidityCut )
371ClassImp( AliHBTPseudoRapidityCut )
372ClassImp( AliHBTPxCut )
373ClassImp( AliHBTPyCut )
374ClassImp( AliHBTPzCut )
375ClassImp( AliHBTPhiCut )
376ClassImp( AliHBTThetaCut )
377ClassImp( AliHBTVxCut )
378ClassImp( AliHBTVyCut )
379ClassImp( AliHBTVzCut )
380
4617f71a 381ClassImp( AliHBTPIDCut )
1b446896 382
4617f71a 383ClassImp( AliHBTLogicalOperCut )
384
385AliHBTLogicalOperCut::AliHBTLogicalOperCut():
386 AliHbtBaseCut(-10e10,10e10,kHbtNone),
387 fFirst(new AliHBTDummyBaseCut),
388 fSecond(new AliHBTDummyBaseCut)
389{
87fcb86d 390 //ctor
4617f71a 391}
392/******************************************************************/
393
394AliHBTLogicalOperCut::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{
87fcb86d 399 //ctor
4617f71a 400 if ( (fFirst && fSecond) == kFALSE)
401 {
402 Fatal("AliHBTLogicalOperCut","One of parameters is NULL!");
403 }
404}
405/******************************************************************/
406
407AliHBTLogicalOperCut::~AliHBTLogicalOperCut()
408{
87fcb86d 409 //destructor
4617f71a 410 delete fFirst;
411 delete fSecond;
412}
413/******************************************************************/
414
c0956fc6 415Bool_t AliHBTLogicalOperCut::AliHBTDummyBaseCut::Pass(AliHBTParticle* /*part*/) const
4617f71a 416{
87fcb86d 417 //checks if particles passes properties defined by this cut
4617f71a 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
423void 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/******************************************************************/
451ClassImp(AliHBTOrCut)
452
c0956fc6 453Bool_t AliHBTOrCut::Pass(AliHBTParticle * p) const
4617f71a 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
464ClassImp(AliHBTAndCut)
465
c0956fc6 466Bool_t AliHBTAndCut::Pass(AliHBTParticle * p) const
4617f71a 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/******************************************************************/