2 //____________________________________
3 /////////////////////////////////////////////////////////////////////////
5 // Class AliHBTPairCut:
7 // implements cut on the pair of particles
8 // more info: http://alisoft.cern.ch/people/skowron/analyzer/index.html
9 // Author: Piotr.Skowronski@cern.ch
10 //-------------------------------------------------------------------
12 #include "AliHBTPairCut.h"
13 #include "AliHBTPair.h"
14 #include "AliHBTParticleCut.h"
15 #include "AliHBTTrackPoints.h"
16 #include "AliHBTClusterMap.h"
18 ClassImp(AliHBTPairCut)
19 const Int_t AliHBTPairCut::fgkMaxCuts = 50;
20 /**********************************************************/
22 AliHBTPairCut::AliHBTPairCut():
26 fFirstPartCut = new AliHBTEmptyParticleCut(); //empty cuts
27 fSecondPartCut= new AliHBTEmptyParticleCut(); //empty cuts
29 fCuts = new AliHbtBasePairCut*[fgkMaxCuts];
31 /**********************************************************/
33 AliHBTPairCut::AliHBTPairCut(const AliHBTPairCut& in):
37 fCuts = new AliHbtBasePairCut*[fgkMaxCuts];
40 fFirstPartCut = (AliHBTParticleCut*)in.fFirstPartCut->Clone();
41 fSecondPartCut = (AliHBTParticleCut*)in.fSecondPartCut->Clone();
43 for (Int_t i = 0;i<fNCuts;i++)
45 fCuts[i] = (AliHbtBasePairCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
48 /**********************************************************/
50 AliHBTPairCut& AliHBTPairCut::operator=(const AliHBTPairCut& in)
53 fCuts = new AliHbtBasePairCut*[fgkMaxCuts];
56 fFirstPartCut = (AliHBTParticleCut*)in.fFirstPartCut->Clone();
57 fSecondPartCut = (AliHBTParticleCut*)in.fSecondPartCut->Clone();
59 for (Int_t i = 0;i<fNCuts;i++)
61 fCuts[i] = (AliHbtBasePairCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
65 /**********************************************************/
67 AliHBTPairCut::~AliHBTPairCut()
70 if (fFirstPartCut != fSecondPartCut)
72 delete fSecondPartCut;
75 for (Int_t i = 0;i<fNCuts;i++)
81 /**********************************************************/
83 /**********************************************************/
85 void AliHBTPairCut::AddBasePairCut(AliHbtBasePairCut* basecut)
87 //adds the base pair cut (cut on one value)
90 if( fNCuts == (fgkMaxCuts-1) )
92 Warning("AddBasePairCut","Not enough place for another cut");
95 fCuts[fNCuts++]=basecut;
97 /**********************************************************/
99 Bool_t AliHBTPairCut::Pass(AliHBTPair* pair) const
101 //methods which checks if given pair meets all criteria of the cut
102 //if it meets returns FALSE
103 //if NOT returns TRUE
106 Warning("Pass","No Pasaran! We never accept NULL pointers");
110 //check particle's cuts
111 if( ( fFirstPartCut->Pass( pair->Particle1()) ) ||
112 ( fSecondPartCut->Pass(pair->Particle2()) ) )
116 return PassPairProp(pair);
118 /**********************************************************/
120 Bool_t AliHBTPairCut::PassPairProp(AliHBTPair* pair) const
122 //methods which checks if given pair meets all criteria of the cut
123 //if it meets returns FALSE
124 //if NOT returns TRUE
125 //examine all base pair cuts
126 for (Int_t i = 0;i<fNCuts;i++)
128 if ( (fCuts[i]->Pass(pair)) ) return kTRUE; //if one of the cuts reject, then reject
132 /**********************************************************/
134 void AliHBTPairCut::Print()
137 for (Int_t i = 0;i<fNCuts;i++)
142 /**********************************************************/
144 void AliHBTPairCut::SetFirstPartCut(AliHBTParticleCut* cut)
146 // set cut for the first particle
149 Error("SetFirstPartCut","argument is NULL");
152 delete fFirstPartCut;
153 fFirstPartCut = (AliHBTParticleCut*)cut->Clone();
156 /**********************************************************/
158 void AliHBTPairCut::SetSecondPartCut(AliHBTParticleCut* cut)
160 // set cut for the second particle
163 Error("SetSecondPartCut","argument is NULL");
166 delete fSecondPartCut;
167 fSecondPartCut = (AliHBTParticleCut*)cut->Clone();
169 /**********************************************************/
171 void AliHBTPairCut::SetPartCut(AliHBTParticleCut* cut)
173 //sets the the same cut on both particles
176 Error("SetFirstPartCut","argument is NULL");
179 if (fFirstPartCut == fSecondPartCut) fSecondPartCut = 0x0;
181 delete fFirstPartCut;
182 fFirstPartCut = (AliHBTParticleCut*)cut->Clone();
184 delete fSecondPartCut; //even if null should not be harmful
185 fSecondPartCut = fFirstPartCut;
187 /**********************************************************/
189 void AliHBTPairCut::SetQInvRange(Double_t min, Double_t max)
191 // set range of accepted invariant masses
192 AliHBTQInvCut* cut= (AliHBTQInvCut*)FindCut(kHbtPairCutPropQInv);
193 if(cut) cut->SetRange(min,max);
194 else fCuts[fNCuts++] = new AliHBTQInvCut(min,max);
196 /**********************************************************/
197 void AliHBTPairCut::SetQOutCMSLRange(Double_t min, Double_t max)
199 // set range of accepted QOut in CMS
200 AliHBTQOutCMSLCCut* cut= (AliHBTQOutCMSLCCut*)FindCut(kHbtPairCutPropQOutCMSLC);
201 if(cut) cut->SetRange(min,max);
202 else fCuts[fNCuts++] = new AliHBTQOutCMSLCCut(min,max);
205 /**********************************************************/
206 void AliHBTPairCut::SetQSideCMSLRange(Double_t min, Double_t max)
208 // set range of accepted QSide in CMS
209 AliHBTQSideCMSLCCut* cut= (AliHBTQSideCMSLCCut*)FindCut(kHbtPairCutPropQSideCMSLC);
210 if(cut) cut->SetRange(min,max);
211 else fCuts[fNCuts++] = new AliHBTQSideCMSLCCut(min,max);
214 /**********************************************************/
215 void AliHBTPairCut::SetQLongCMSLRange(Double_t min, Double_t max)
217 // set range of accepted QLong in CMS
218 AliHBTQLongCMSLCCut* cut= (AliHBTQLongCMSLCCut*)FindCut(kHbtPairCutPropQLongCMSLC);
219 if(cut) cut->SetRange(min,max);
220 else fCuts[fNCuts++] = new AliHBTQLongCMSLCCut(min,max);
223 /**********************************************************/
225 void AliHBTPairCut::SetKtRange(Double_t min, Double_t max)
227 // set range of accepted Kt (?)
228 AliHBTKtCut* cut= (AliHBTKtCut*)FindCut(kHbtPairCutPropKt);
229 if(cut) cut->SetRange(min,max);
230 else fCuts[fNCuts++] = new AliHBTKtCut(min,max);
232 /**********************************************************/
234 void AliHBTPairCut::SetKStarRange(Double_t min, Double_t max)
236 // set range of accepted KStar (?)
237 AliHBTKStarCut* cut= (AliHBTKStarCut*)FindCut(kHbtPairCutPropKStar);
238 if(cut) cut->SetRange(min,max);
239 else fCuts[fNCuts++] = new AliHBTKStarCut(min,max);
241 /**********************************************************/
243 void AliHBTPairCut::SetAvSeparationRange(Double_t min, Double_t max)
245 //sets avarage separation cut ->Anti-Merging cut
246 AliHbtBasePairCut* cut= FindCut(kHbtPairCutPropAvSepar);
247 if(cut) cut->SetRange(min,max);
248 else fCuts[fNCuts++] = new AliHBTAvSeparationCut(min,max);
250 /**********************************************************/
252 void AliHBTPairCut::SetPixelSeparation(Double_t drphi, Double_t dz)
254 //Anti-Merging Cut for first pixel layer
255 AliHbtBasePairCut* cut= FindCut(kHbtPairCutPropPixelSepar);
256 if(cut) cut->SetRange(drphi,dz);//In this cut fMin is drphi, and fMax dz
257 else fCuts[fNCuts++] = new AliHBTPixelSeparationCut(drphi,dz);
259 /**********************************************************/
261 void AliHBTPairCut::SetClusterOverlapRange(Double_t min,Double_t max)
263 //sets cluster overlap factor cut ->Anti-Splitting cut
264 //cluster overlap factor ranges between
265 // -0.5 (in all padrows both tracks have cluters)
266 // and 1 (in all padrows one track has cluter and second has not)
267 // When Overlap Factor is 1 this pair of tracks in highly probable to be
268 // splitted track: one particle that is recontructed twise
269 // STAR uses range from -0.5 to 0.6
271 AliHbtBasePairCut* cut= FindCut(kHbtPairCutPropClOverlap);
272 if(cut) cut->SetRange(min,max);
273 else fCuts[fNCuts++] = new AliHBTCluterOverlapCut(min,max);
275 /**********************************************************/
277 AliHbtBasePairCut* AliHBTPairCut::FindCut(AliHBTPairCutProperty property)
279 // Find the cut corresponding to "property"
280 for (Int_t i = 0;i<fNCuts;i++)
282 if (fCuts[i]->GetProperty() == property)
283 return fCuts[i]; //we found the cut we were searching for
286 return 0x0; //we did not found this cut
289 /**********************************************************/
291 void AliHBTPairCut::Streamer(TBuffer &b)
293 // Stream all objects in the array to or from the I/O buffer.
298 Version_t v = b.ReadVersion(&R__s, &R__c);
301 delete fFirstPartCut;
302 delete fSecondPartCut;
304 fSecondPartCut = 0x0;
305 TObject::Streamer(b);
309 for (Int_t i = 0;i<fNCuts;i++)
314 b.CheckByteCount(R__s, R__c,AliHBTPairCut::IsA());
318 R__c = b.WriteVersion(AliHBTPairCut::IsA(), kTRUE);
319 TObject::Streamer(b);
321 // printf("Streamer Cut 1 %#x Cut 2 %#x\n",fFirstPartCut,fSecondPartCut);
323 // fFirstPartCut->Dump();
328 for (Int_t i = 0;i<fNCuts;i++)
332 b.SetByteCount(R__c, kTRUE);
335 /******************************************************************/
337 ClassImp(AliHBTEmptyPairCut)
339 void AliHBTEmptyPairCut::Streamer(TBuffer &b)
341 //streamer for empty pair cut
342 AliHBTPairCut::Streamer(b);
344 /******************************************************************/
346 ClassImp(AliHbtBasePairCut)
347 ClassImp(AliHBTQInvCut)
348 ClassImp(AliHBTKtCut)
349 ClassImp(AliHBTQSideCMSLCCut)
350 ClassImp(AliHBTQOutCMSLCCut)
351 ClassImp(AliHBTQLongCMSLCCut)
353 /******************************************************************/
354 ClassImp(AliHBTAvSeparationCut)
356 Double_t AliHBTAvSeparationCut::GetValue(AliHBTPair* pair) const
358 //chacks if avarage distance of two tracks is in given range
359 AliHBTTrackPoints* tpts1 = pair->Particle1()->GetTrackPoints();
361 {//it could be simulated pair
362 // Warning("GetValue","Track 1 does not have Track Points. Pair NOT Passed.");
366 AliHBTTrackPoints* tpts2 = pair->Particle2()->GetTrackPoints();
369 // Warning("GetValue","Track 2 does not have Track Points. Pair NOT Passed.");
373 return tpts1->AvarageDistance(*tpts2);
375 /******************************************************************/
376 ClassImp(AliHBTSeparationCut)
378 Double_t AliHBTSeparationCut::GetValue(AliHBTPair* pair) const
380 //chacks if avarage distance of two tracks is in given range
381 AliHBTTrackPoints* tpts1 = pair->Particle1()->GetTrackPoints();
383 {//it could be simulated pair
384 // Warning("GetValue","Track 1 does not have Track Points. Pair NOT Passed.");
388 AliHBTTrackPoints* tpts2 = pair->Particle2()->GetTrackPoints();
391 // Warning("GetValue","Track 2 does not have Track Points. Pair NOT Passed.");
394 Float_t x1=0,y1=0,z1=0;
395 Float_t x2=0,y2=0,z2=0;
397 tpts1->PositionAt(fPoint,x1,y1,z1);
398 tpts2->PositionAt(fPoint,x2,y2,z2);
399 Double_t dx1 = x1 - x2;
400 Double_t dy1 = y1 - y2;
401 Double_t dz1 = z1 - z2;
402 Double_t d = TMath::Sqrt(dx1*dx1 + dy1*dy1 + dz1*dz1);
405 /******************************************************************/
407 ClassImp(AliHBTPixelSeparationCut)
409 Bool_t AliHBTPixelSeparationCut::Pass(AliHBTPair* pair) const
411 //Checks if two tracks do not cross first pixels too close to each other
412 //If two tracks use the same cluster in pixels they are given
413 //the same position what skews theta angles (both are the same)
414 //These guys create artificial correlation in non-id analyses
415 //which is positive for identical polar angles (Qlong=0)
416 //and negative for a little bit different theta angle (Qlong=epsilon)
417 //Such tracks "attracks" each other.
419 AliHBTTrackPoints* tpts1 = pair->Particle1()->GetITSTrackPoints();
421 {//it could be simulated pair
422 Warning("Pass","Track 1 does not have ITS Track Points. Pair NOT Passed.");
423 return kTRUE;//reject
426 AliHBTTrackPoints* tpts2 = pair->Particle2()->GetITSTrackPoints();
429 Warning("Pass","Track 2 does not have ITS Track Points. Pair NOT Passed.");
430 return kTRUE;//reject
432 Float_t x1=0.0,y1=0.0,z1=0.0,x2=0.0,y2=0.0,z2=0.0;
433 tpts1->PositionAt(0,x1,y1,z1);
434 tpts2->PositionAt(0,x2,y2,z2);
436 // Info("Pass","rphi %f z %f",fMin,fMax);
437 // Info("Pass","P1: %f %f %f", x1,y1,z1);
438 // Info("Pass","P2: %f %f %f", x2,y2,z2);
440 Double_t dz = TMath::Abs(z1-z2);
442 //fMax encodes treshold valaue of distance in Z
443 if (dz > fMax) return kFALSE;//pair accepted
445 Double_t drphi = TMath::Hypot(x1-x2,y1-y2);
447 //fMin encodes treshold valaue of distance in r-phi
448 if (drphi > fMin) return kFALSE;
450 return kTRUE;//they are too close, rejected
452 /******************************************************************/
454 ClassImp(AliHBTCluterOverlapCut)
456 Double_t AliHBTCluterOverlapCut::GetValue(AliHBTPair* pair) const
458 //Returns Cluter Overlap Factor
459 //It ranges between -0.5 (in all padrows both tracks have cluters)
460 // and 1 (in all padrows one track has cluter and second has not)
461 // When Overlap Factor is 1 this pair of tracks in highly probable to be
462 // splitted track: one particle that is recontructed twise
464 AliHBTClusterMap* cm1 = pair->Particle1()->GetClusterMap();
467 Warning("GetValue","Track 1 does not have Cluster Map. Returning -0.5.");
471 AliHBTClusterMap* cm2 = pair->Particle2()->GetClusterMap();
474 Warning("GetValue","Track 2 does not have Cluster Map. Returning -0.5.");
477 return cm1->GetOverlapFactor(*cm2);
479 /******************************************************************/
480 ClassImp(AliHBTOutSideSameSignCut)
482 Bool_t AliHBTOutSideSameSignCut::Pass(AliHBTPair *p) const
484 //returns kTRUE if pair DO NOT meet cut criteria
486 if ( p->GetQOutCMSLC()*p->GetQSideCMSLC() > 0 )
488 return kFALSE;//accpeted
491 return kTRUE ;//rejected
493 /******************************************************************/
494 ClassImp(AliHBTOutSideDiffSignCut)
496 Bool_t AliHBTOutSideDiffSignCut::Pass(AliHBTPair *p) const
498 //returns kTRUE if pair DO NOT meet cut criteria
500 if ( p->GetQOutCMSLC()*p->GetQSideCMSLC() > 0 )
502 return kTRUE;//rejected
505 return kFALSE;//accepted
507 /******************************************************************/
508 ClassImp( AliHBTLogicalOperPairCut )
510 AliHBTLogicalOperPairCut::AliHBTLogicalOperPairCut():
511 AliHbtBasePairCut(-10e10,10e10,kHbtPairCutPropNone),
512 fFirst(new AliHBTDummyBasePairCut),
513 fSecond(new AliHBTDummyBasePairCut)
517 /******************************************************************/
519 AliHBTLogicalOperPairCut::AliHBTLogicalOperPairCut(AliHbtBasePairCut* first, AliHbtBasePairCut* second):
520 AliHbtBasePairCut(-10e10,10e10,kHbtPairCutPropNone),
521 fFirst((first)?(AliHbtBasePairCut*)first->Clone():0x0),
522 fSecond((second)?(AliHbtBasePairCut*)second->Clone():0x0)
525 //note that base cuts are copied, not just pointers assigned
526 if ( (fFirst && fSecond) == kFALSE)
528 Fatal("AliHBTLogicalOperPairCut","One of parameters is NULL!");
531 /******************************************************************/
533 AliHBTLogicalOperPairCut::~AliHBTLogicalOperPairCut()
539 /******************************************************************/
541 Bool_t AliHBTLogicalOperPairCut::AliHBTDummyBasePairCut::Pass(AliHBTPair* /*pair*/) const
543 //checks if particles passes properties defined by this cut
544 Warning("Pass","You are using dummy base cut! Probobly some logical cut is not set up properly");
545 return kFALSE;//accept
547 /******************************************************************/
549 void AliHBTLogicalOperPairCut::Streamer(TBuffer &b)
551 // Stream all objects in the array to or from the I/O buffer.
560 b.ReadVersion(&R__s, &R__c);
561 TObject::Streamer(b);
564 b.CheckByteCount(R__s, R__c,AliHBTLogicalOperPairCut::IsA());
568 R__c = b.WriteVersion(AliHBTLogicalOperPairCut::IsA(), kTRUE);
569 TObject::Streamer(b);
572 b.SetByteCount(R__c, kTRUE);
576 /******************************************************************/
577 ClassImp(AliHBTOrPairCut)
579 Bool_t AliHBTOrPairCut::Pass(AliHBTPair * p) const
581 //returns true when rejected
582 //AND operation is a little bit misleading but is correct
583 //User wants to build logical cuts with natural (positive) logic
584 //while HBTAN use inernally reverse (returns true when rejected)
585 if (fFirst->Pass(p) && fSecond->Pass(p) ) return kTRUE;//rejected (both rejected, returned kTRUE)
586 return kFALSE;//accepted, at least one accepted (returned kFALSE)
588 /******************************************************************/
590 ClassImp(AliHBTAndPairCut)
592 Bool_t AliHBTAndPairCut::Pass(AliHBTPair * p) const
594 //returns true when rejected
595 //OR operation is a little bit misleading but is correct
596 //User wants to build logical cuts with natural (positive) logic
597 //while HBTAN use inernally reverse (returns true when rejected)
598 if (fFirst->Pass(p) || fSecond->Pass(p)) return kTRUE;//rejected (any of two rejected(returned kTRUE) )
599 return kFALSE;//accepted (both accepted (returned kFALSE))
601 /******************************************************************/