Corrected sintax of the commands in ProcessLine (Yves)
[u/mrichter/AliRoot.git] / ANALYSIS / AliAODPairCut.cxx
CommitLineData
073745bc 1#include "AliAODPairCut.h"
78d7c6d3 2/* $Id$ */
0206ddfb 3
78d7c6d3 4/////////////////////////////////////////////////////////////////////////
5//
6// Class AliAODPairCut:
78d7c6d3 7// implements cut on the pair of particles
c7ffd78f 8// more info: http://aliweb.cern.ch/people/skowron/analyzer/index.html
78d7c6d3 9// Author: Piotr.Skowronski@cern.ch
10//-------------------------------------------------------------------
0206ddfb 11
78d7c6d3 12#include "AliAODPair.h"
13#include "AliAODParticleCut.h"
0206ddfb 14//#include "AliTrackPoints.h"
15//#include "AliClusterMap.h"
78d7c6d3 16
17ClassImp(AliAODPairCut)
18const Int_t AliAODPairCut::fgkMaxCuts = 50;
19/**********************************************************/
20
21AliAODPairCut::AliAODPairCut():
af250cbf 22 fFirstPartCut(new AliAODParticleEmptyCut()), //empty cuts
23 fSecondPartCut(new AliAODParticleEmptyCut()), //empty cuts
24 fCuts(new AliAODPairBaseCut*[fgkMaxCuts]),
78d7c6d3 25 fNCuts(0)
26{
27 //constructor
78d7c6d3 28
78d7c6d3 29 for (Int_t i = 0;i<fNCuts;i++)
30 {
31 fCuts[i] = 0x0;
32 }
33}
34/**********************************************************/
35
36AliAODPairCut::AliAODPairCut(const AliAODPairCut& in):
af250cbf 37 TNamed(in),
38 fFirstPartCut((AliAODParticleCut*)in.fFirstPartCut->Clone()),
39 fSecondPartCut((AliAODParticleCut*)in.fSecondPartCut->Clone()),
40 fCuts(new AliAODPairBaseCut*[fgkMaxCuts]),
41 fNCuts(in.fNCuts)
78d7c6d3 42{
43 //copy constructor
78d7c6d3 44
78d7c6d3 45
46 for (Int_t i = 0;i<fNCuts;i++)
47 {
b4fb427e 48 fCuts[i] = (AliAODPairBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
78d7c6d3 49 }
50}
51/**********************************************************/
52
53AliAODPairCut& AliAODPairCut::operator=(const AliAODPairCut& in)
54{
55 //assignment operator
b4fb427e 56 fCuts = new AliAODPairBaseCut*[fgkMaxCuts];
78d7c6d3 57 fNCuts = in.fNCuts;
58
59 fFirstPartCut = (AliAODParticleCut*)in.fFirstPartCut->Clone();
60 fSecondPartCut = (AliAODParticleCut*)in.fSecondPartCut->Clone();
61
62 for (Int_t i = 0;i<fNCuts;i++)
63 {
b4fb427e 64 fCuts[i] = (AliAODPairBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
78d7c6d3 65 }
66 return * this;
67}
68/**********************************************************/
69
70AliAODPairCut::~AliAODPairCut()
71{
72 //destructor
73 if (fFirstPartCut != fSecondPartCut)
74 {
75 delete fSecondPartCut;
76 }
77 delete fFirstPartCut;
78 for (Int_t i = 0;i<fNCuts;i++)
79 {
80 delete fCuts[i];
81 }
82 delete []fCuts;
83}
84/**********************************************************/
85
86/**********************************************************/
87
b4fb427e 88void AliAODPairCut::AddBasePairCut(AliAODPairBaseCut* basecut)
78d7c6d3 89{
90 //adds the base pair cut (cut on one value)
91
92 if (!basecut) return;
93 if( fNCuts == (fgkMaxCuts-1) )
94 {
95 Warning("AddBasePairCut","Not enough place for another cut");
96 return;
97 }
98 fCuts[fNCuts++]=basecut;
99}
100/**********************************************************/
101
cea0a066 102Bool_t AliAODPairCut::Rejected(AliAODPair* pair) const
78d7c6d3 103{
104 //methods which checks if given pair meets all criteria of the cut
105 //if it meets returns FALSE
106 //if NOT returns TRUE
107 if(!pair)
108 {
109 Warning("Pass","No Pasaran! We never accept NULL pointers");
110 return kTRUE;
111 }
112
113 //check particle's cuts
cea0a066 114 if( ( fFirstPartCut->Rejected( pair->Particle1()) ) ||
115 ( fSecondPartCut->Rejected(pair->Particle2()) ) )
78d7c6d3 116 {
117 return kTRUE;
118 }
119 return PassPairProp(pair);
120}
121/**********************************************************/
122
123Bool_t AliAODPairCut::PassPairProp(AliAODPair* pair) const
124{
125 //methods which checks if given pair meets all criteria of the cut
126 //if it meets returns FALSE
127 //if NOT returns TRUE
128 //examine all base pair cuts
129 for (Int_t i = 0;i<fNCuts;i++)
130 {
cea0a066 131 if ( (fCuts[i]->Rejected(pair)) ) return kTRUE; //if one of the cuts reject, then reject
78d7c6d3 132 }
133 return kFALSE;
134}
135/**********************************************************/
136
137void AliAODPairCut::Print()
138{
139 //Prints the cut
140 for (Int_t i = 0;i<fNCuts;i++)
141 {
142 fCuts[i]->Dump();
143 }
144}
145/**********************************************************/
146
147void AliAODPairCut::SetFirstPartCut(AliAODParticleCut* cut)
148{
149 // set cut for the first particle
150 if(!cut)
151 {
152 Error("SetFirstPartCut","argument is NULL");
153 return;
154 }
155 delete fFirstPartCut;
156 fFirstPartCut = (AliAODParticleCut*)cut->Clone();
157
158}
159/**********************************************************/
160
161void AliAODPairCut::SetSecondPartCut(AliAODParticleCut* cut)
162{
163 // set cut for the second particle
164 if(!cut)
165 {
166 Error("SetSecondPartCut","argument is NULL");
167 return;
168 }
169 delete fSecondPartCut;
170 fSecondPartCut = (AliAODParticleCut*)cut->Clone();
171}
172/**********************************************************/
173
174void AliAODPairCut::SetPartCut(AliAODParticleCut* cut)
175{
176 //sets the the same cut on both particles
177 if(!cut)
178 {
179 Error("SetFirstPartCut","argument is NULL");
180 return;
181 }
182 if (fFirstPartCut == fSecondPartCut) fSecondPartCut = 0x0;
183
184 delete fFirstPartCut;
185 fFirstPartCut = (AliAODParticleCut*)cut->Clone();
186
187 delete fSecondPartCut; //even if null should not be harmful
188 fSecondPartCut = fFirstPartCut;
189}
190/**********************************************************/
191
192void AliAODPairCut::SetQInvRange(Double_t min, Double_t max)
193{
194 // set range of accepted invariant masses
073745bc 195 AliAODQInvCut* cut= (AliAODQInvCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropQInv);
78d7c6d3 196 if(cut) cut->SetRange(min,max);
197 else fCuts[fNCuts++] = new AliAODQInvCut(min,max);
198}
199/**********************************************************/
5c9d56e2 200
e6375609 201void AliAODPairCut::SetQOutLCMSRange(Double_t min, Double_t max)
78d7c6d3 202{
203 // set range of accepted QOut in CMS
073745bc 204 AliAODQOutLCMSCut* cut= (AliAODQOutLCMSCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropQOutLCMS);
78d7c6d3 205 if(cut) cut->SetRange(min,max);
206 else fCuts[fNCuts++] = new AliAODQOutLCMSCut(min,max);
207}
78d7c6d3 208/**********************************************************/
5c9d56e2 209
e6375609 210void AliAODPairCut::SetQSideLCMSRange(Double_t min, Double_t max)
78d7c6d3 211{
212 // set range of accepted QSide in CMS
073745bc 213 AliAODQSideLCMSCut* cut= (AliAODQSideLCMSCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropQSideLCMS);
78d7c6d3 214 if(cut) cut->SetRange(min,max);
215 else fCuts[fNCuts++] = new AliAODQSideLCMSCut(min,max);
216}
217
218/**********************************************************/
5c9d56e2 219
e6375609 220void AliAODPairCut::SetQLongLCMSRange(Double_t min, Double_t max)
78d7c6d3 221{
222 // set range of accepted QLong in CMS
073745bc 223 AliAODQLongLCMSCut* cut= (AliAODQLongLCMSCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropQLongLCMS);
78d7c6d3 224 if(cut) cut->SetRange(min,max);
225 else fCuts[fNCuts++] = new AliAODQLongLCMSCut(min,max);
226}
5c9d56e2 227/**********************************************************/
78d7c6d3 228
5c9d56e2 229void AliAODPairCut::SetDeltaERange(Double_t min, Double_t max)
230{
231 // set range of accepted DeltaE
232 AliAODKtCut* cut= (AliAODKtCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropDeltaE);
233 if(cut) cut->SetRange(min,max);
234 else fCuts[fNCuts++] = new AliAODDeltaECut(min,max);
235}
236/**********************************************************/
237
238void AliAODPairCut::SetDeltaPRange(Double_t min, Double_t max)
239{
240 // set range of accepted DeltaP
241 AliAODKtCut* cut= (AliAODKtCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropDeltaP);
242 if(cut) cut->SetRange(min,max);
243 else fCuts[fNCuts++] = new AliAODDeltaPCut(min,max);
244}
78d7c6d3 245/**********************************************************/
246
247void AliAODPairCut::SetKtRange(Double_t min, Double_t max)
248{
5c9d56e2 249 // set range of accepted Kt (avarage transverse pair momentum)
073745bc 250 AliAODKtCut* cut= (AliAODKtCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropKt);
78d7c6d3 251 if(cut) cut->SetRange(min,max);
252 else fCuts[fNCuts++] = new AliAODKtCut(min,max);
253}
254/**********************************************************/
255
256void AliAODPairCut::SetKStarRange(Double_t min, Double_t max)
257{
5c9d56e2 258 // set range of accepted KStar (invariant pair momentum difference (fourvector))
073745bc 259 AliAODKStarCut* cut= (AliAODKStarCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropKStar);
78d7c6d3 260 if(cut) cut->SetRange(min,max);
261 else fCuts[fNCuts++] = new AliAODKStarCut(min,max);
262}
263/**********************************************************/
264
fe3f2f54 265void AliAODPairCut::SetKStarOutRange(Double_t min, Double_t max)
266{
267 // set range of accepted KStar (invariant pair momentum difference (fourvector))
268 AliAODKStarOutCut* cut= (AliAODKStarOutCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropKStarOut);
269 if(cut) cut->SetRange(min,max);
270 else fCuts[fNCuts++] = new AliAODKStarOutCut(min,max);
271}
272/**********************************************************/
273
274void AliAODPairCut::SetKStarSideRange(Double_t min, Double_t max)
275{
276 // set range of accepted KStar (invariant pair momentum difference (fourvector))
277 AliAODKStarSideCut* cut= (AliAODKStarSideCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropKStarSide);
278 if(cut) cut->SetRange(min,max);
279 else fCuts[fNCuts++] = new AliAODKStarSideCut(min,max);
280}
281/**********************************************************/
282
283void AliAODPairCut::SetKStarLongRange(Double_t min, Double_t max)
284{
285 // set range of accepted KStar (invariant pair momentum difference (fourvector))
286 AliAODKStarLongCut* cut= (AliAODKStarLongCut*)FindCut(AliAODPairBaseCut::kHbtPairCutPropKStarLong);
287 if(cut) cut->SetRange(min,max);
288 else fCuts[fNCuts++] = new AliAODKStarLongCut(min,max);
289}
290/**********************************************************/
291
78d7c6d3 292void AliAODPairCut::SetAvSeparationRange(Double_t min, Double_t max)
293{
294 //sets avarage separation cut ->Anti-Merging cut
073745bc 295 AliAODPairBaseCut* cut= FindCut(AliAODPairBaseCut::kHbtPairCutPropAvSepar);
78d7c6d3 296 if(cut) cut->SetRange(min,max);
297 else fCuts[fNCuts++] = new AliAODAvSeparationCut(min,max);
298}
299/**********************************************************/
300
301void AliAODPairCut::SetITSSeparation(Int_t layer, Double_t drphi, Double_t dz)
302{
303 //Anti-Merging Cut for first pixel layer
073745bc 304 AliAODITSSeparationCut* cut= dynamic_cast<AliAODITSSeparationCut*>(FindCut(AliAODPairBaseCut::kHbtPairCutPropPixelSepar));
78d7c6d3 305 if(cut)
306 {
307 if (layer == cut->GetLayer())
308 {
309 cut->SetRange(drphi,dz);//In this cut fMin is drphi, and fMax dz
310 return;
311 }
312 }
313 fCuts[fNCuts++] = new AliAODITSSeparationCut(layer,drphi,dz);
314// Info("SetITSSeparation","Added %d at address %#x",fNCuts-1,fCuts[fNCuts-1]);
315}
316/**********************************************************/
317
318void AliAODPairCut::SetClusterOverlapRange(Double_t min,Double_t max)
319{
320 //sets cluster overlap factor cut ->Anti-Splitting cut
321 //cluster overlap factor ranges between
322 // -0.5 (in all padrows both tracks have cluters)
323 // and 1 (in all padrows one track has cluter and second has not)
324 // When Overlap Factor is 1 this pair of tracks in highly probable to be
325 // splitted track: one particle that is recontructed twise
326 // STAR uses range from -0.5 to 0.6
327
073745bc 328 AliAODPairBaseCut* cut= FindCut(AliAODPairBaseCut::kHbtPairCutPropClOverlap);
78d7c6d3 329 if(cut) cut->SetRange(min,max);
330 else fCuts[fNCuts++] = new AliAODCluterOverlapCut(min,max);
331}
332/**********************************************************/
333
073745bc 334AliAODPairBaseCut* AliAODPairCut::FindCut(AliAODPairBaseCut::EAODPairCutProperty property)
78d7c6d3 335{
336 // Find the cut corresponding to "property"
337 for (Int_t i = 0;i<fNCuts;i++)
338 {
339 if (fCuts[i]->GetProperty() == property)
340 return fCuts[i]; //we found the cut we were searching for
341 }
342
343 return 0x0; //we did not found this cut
344
345}
346/**********************************************************/
347
348void AliAODPairCut::Streamer(TBuffer &b)
349{
350 // Stream all objects in the array to or from the I/O buffer.
351
352 UInt_t R__s, R__c;
353 if (b.IsReading())
354 {
355 Version_t v = b.ReadVersion(&R__s, &R__c);
356 if (v > -1)
357 {
358 delete fFirstPartCut;
359 delete fSecondPartCut;
360 fFirstPartCut = 0x0;
361 fSecondPartCut = 0x0;
362 TObject::Streamer(b);
363 b >> fFirstPartCut;
364 b >> fSecondPartCut;
365 b >> fNCuts;
366 for (Int_t i = 0;i<fNCuts;i++)
367 {
368 b >> fCuts[i];
369 }
370 }
371 b.CheckByteCount(R__s, R__c,AliAODPairCut::IsA());
372 }
373 else
374 {
375 R__c = b.WriteVersion(AliAODPairCut::IsA(), kTRUE);
376 TObject::Streamer(b);
377
378// printf("Streamer Cut 1 %#x Cut 2 %#x\n",fFirstPartCut,fSecondPartCut);
379// this->Dump();
380// fFirstPartCut->Dump();
381
382 b << fFirstPartCut;
383 b << fSecondPartCut;
384 b << fNCuts;
385 for (Int_t i = 0;i<fNCuts;i++)
386 {
387 b << fCuts[i];
388 }
389 b.SetByteCount(R__c, kTRUE);
390 }
391}
392/******************************************************************/
393
b4fb427e 394ClassImp(AliAODPairEmptyCut)
78d7c6d3 395
b4fb427e 396void AliAODPairEmptyCut::Streamer(TBuffer &b)
78d7c6d3 397{
398//streamer for empty pair cut
399 AliAODPairCut::Streamer(b);
400}
401/******************************************************************/
402