2 //____________________________________
3 /////////////////////////////////////////////////////////////////////////
5 // Class AliAODPairCut:
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 "AliAODPairCut.h"
13 #include "AliAODPair.h"
14 #include "AliAODParticleCut.h"
15 #include "AliTrackPoints.h"
16 #include "AliClusterMap.h"
18 ClassImp(AliAODPairCut)
19 const Int_t AliAODPairCut::fgkMaxCuts = 50;
20 /**********************************************************/
22 AliAODPairCut::AliAODPairCut():
26 fFirstPartCut = new AliAODParticleEmptyCut(); //empty cuts
27 fSecondPartCut= new AliAODParticleEmptyCut(); //empty cuts
29 fCuts = new AliAODPairBaseCut*[fgkMaxCuts];
30 for (Int_t i = 0;i<fNCuts;i++)
35 /**********************************************************/
37 AliAODPairCut::AliAODPairCut(const AliAODPairCut& in):
41 fCuts = new AliAODPairBaseCut*[fgkMaxCuts];
44 fFirstPartCut = (AliAODParticleCut*)in.fFirstPartCut->Clone();
45 fSecondPartCut = (AliAODParticleCut*)in.fSecondPartCut->Clone();
47 for (Int_t i = 0;i<fNCuts;i++)
49 fCuts[i] = (AliAODPairBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
52 /**********************************************************/
54 AliAODPairCut& AliAODPairCut::operator=(const AliAODPairCut& in)
57 fCuts = new AliAODPairBaseCut*[fgkMaxCuts];
60 fFirstPartCut = (AliAODParticleCut*)in.fFirstPartCut->Clone();
61 fSecondPartCut = (AliAODParticleCut*)in.fSecondPartCut->Clone();
63 for (Int_t i = 0;i<fNCuts;i++)
65 fCuts[i] = (AliAODPairBaseCut*)in.fCuts[i]->Clone();//create new object (clone) and rember pointer to it
69 /**********************************************************/
71 AliAODPairCut::~AliAODPairCut()
74 if (fFirstPartCut != fSecondPartCut)
76 delete fSecondPartCut;
79 for (Int_t i = 0;i<fNCuts;i++)
85 /**********************************************************/
87 /**********************************************************/
89 void AliAODPairCut::AddBasePairCut(AliAODPairBaseCut* basecut)
91 //adds the base pair cut (cut on one value)
94 if( fNCuts == (fgkMaxCuts-1) )
96 Warning("AddBasePairCut","Not enough place for another cut");
99 fCuts[fNCuts++]=basecut;
101 /**********************************************************/
103 Bool_t AliAODPairCut::Pass(AliAODPair* pair) const
105 //methods which checks if given pair meets all criteria of the cut
106 //if it meets returns FALSE
107 //if NOT returns TRUE
110 Warning("Pass","No Pasaran! We never accept NULL pointers");
114 //check particle's cuts
115 if( ( fFirstPartCut->Pass( pair->Particle1()) ) ||
116 ( fSecondPartCut->Pass(pair->Particle2()) ) )
120 return PassPairProp(pair);
122 /**********************************************************/
124 Bool_t AliAODPairCut::PassPairProp(AliAODPair* pair) const
126 //methods which checks if given pair meets all criteria of the cut
127 //if it meets returns FALSE
128 //if NOT returns TRUE
129 //examine all base pair cuts
130 for (Int_t i = 0;i<fNCuts;i++)
132 if ( (fCuts[i]->Pass(pair)) ) return kTRUE; //if one of the cuts reject, then reject
136 /**********************************************************/
138 void AliAODPairCut::Print()
141 for (Int_t i = 0;i<fNCuts;i++)
146 /**********************************************************/
148 void AliAODPairCut::SetFirstPartCut(AliAODParticleCut* cut)
150 // set cut for the first particle
153 Error("SetFirstPartCut","argument is NULL");
156 delete fFirstPartCut;
157 fFirstPartCut = (AliAODParticleCut*)cut->Clone();
160 /**********************************************************/
162 void AliAODPairCut::SetSecondPartCut(AliAODParticleCut* cut)
164 // set cut for the second particle
167 Error("SetSecondPartCut","argument is NULL");
170 delete fSecondPartCut;
171 fSecondPartCut = (AliAODParticleCut*)cut->Clone();
173 /**********************************************************/
175 void AliAODPairCut::SetPartCut(AliAODParticleCut* cut)
177 //sets the the same cut on both particles
180 Error("SetFirstPartCut","argument is NULL");
183 if (fFirstPartCut == fSecondPartCut) fSecondPartCut = 0x0;
185 delete fFirstPartCut;
186 fFirstPartCut = (AliAODParticleCut*)cut->Clone();
188 delete fSecondPartCut; //even if null should not be harmful
189 fSecondPartCut = fFirstPartCut;
191 /**********************************************************/
193 void AliAODPairCut::SetQInvRange(Double_t min, Double_t max)
195 // set range of accepted invariant masses
196 AliAODQInvCut* cut= (AliAODQInvCut*)FindCut(kHbtPairCutPropQInv);
197 if(cut) cut->SetRange(min,max);
198 else fCuts[fNCuts++] = new AliAODQInvCut(min,max);
200 /**********************************************************/
201 void AliAODPairCut::SetQOutCMSLRange(Double_t min, Double_t max)
203 // set range of accepted QOut in CMS
204 AliAODQOutLCMSCut* cut= (AliAODQOutLCMSCut*)FindCut(kHbtPairCutPropQOutLCMS);
205 if(cut) cut->SetRange(min,max);
206 else fCuts[fNCuts++] = new AliAODQOutLCMSCut(min,max);
209 /**********************************************************/
210 void AliAODPairCut::SetQSideCMSLRange(Double_t min, Double_t max)
212 // set range of accepted QSide in CMS
213 AliAODQSideLCMSCut* cut= (AliAODQSideLCMSCut*)FindCut(kHbtPairCutPropQSideLCMS);
214 if(cut) cut->SetRange(min,max);
215 else fCuts[fNCuts++] = new AliAODQSideLCMSCut(min,max);
218 /**********************************************************/
219 void AliAODPairCut::SetQLongCMSLRange(Double_t min, Double_t max)
221 // set range of accepted QLong in CMS
222 AliAODQLongLCMSCut* cut= (AliAODQLongLCMSCut*)FindCut(kHbtPairCutPropQLongLCMS);
223 if(cut) cut->SetRange(min,max);
224 else fCuts[fNCuts++] = new AliAODQLongLCMSCut(min,max);
227 /**********************************************************/
229 void AliAODPairCut::SetKtRange(Double_t min, Double_t max)
231 // set range of accepted Kt (?)
232 AliAODKtCut* cut= (AliAODKtCut*)FindCut(kHbtPairCutPropKt);
233 if(cut) cut->SetRange(min,max);
234 else fCuts[fNCuts++] = new AliAODKtCut(min,max);
236 /**********************************************************/
238 void AliAODPairCut::SetKStarRange(Double_t min, Double_t max)
240 // set range of accepted KStar (?)
241 AliAODKStarCut* cut= (AliAODKStarCut*)FindCut(kHbtPairCutPropKStar);
242 if(cut) cut->SetRange(min,max);
243 else fCuts[fNCuts++] = new AliAODKStarCut(min,max);
245 /**********************************************************/
247 void AliAODPairCut::SetAvSeparationRange(Double_t min, Double_t max)
249 //sets avarage separation cut ->Anti-Merging cut
250 AliAODPairBaseCut* cut= FindCut(kHbtPairCutPropAvSepar);
251 if(cut) cut->SetRange(min,max);
252 else fCuts[fNCuts++] = new AliAODAvSeparationCut(min,max);
254 /**********************************************************/
256 void AliAODPairCut::SetITSSeparation(Int_t layer, Double_t drphi, Double_t dz)
258 //Anti-Merging Cut for first pixel layer
259 AliAODITSSeparationCut* cut= dynamic_cast<AliAODITSSeparationCut*>(FindCut(kHbtPairCutPropPixelSepar));
262 if (layer == cut->GetLayer())
264 cut->SetRange(drphi,dz);//In this cut fMin is drphi, and fMax dz
268 fCuts[fNCuts++] = new AliAODITSSeparationCut(layer,drphi,dz);
269 // Info("SetITSSeparation","Added %d at address %#x",fNCuts-1,fCuts[fNCuts-1]);
271 /**********************************************************/
273 void AliAODPairCut::SetClusterOverlapRange(Double_t min,Double_t max)
275 //sets cluster overlap factor cut ->Anti-Splitting cut
276 //cluster overlap factor ranges between
277 // -0.5 (in all padrows both tracks have cluters)
278 // and 1 (in all padrows one track has cluter and second has not)
279 // When Overlap Factor is 1 this pair of tracks in highly probable to be
280 // splitted track: one particle that is recontructed twise
281 // STAR uses range from -0.5 to 0.6
283 AliAODPairBaseCut* cut= FindCut(kHbtPairCutPropClOverlap);
284 if(cut) cut->SetRange(min,max);
285 else fCuts[fNCuts++] = new AliAODCluterOverlapCut(min,max);
287 /**********************************************************/
289 AliAODPairBaseCut* AliAODPairCut::FindCut(AliAODPairCutProperty property)
291 // Find the cut corresponding to "property"
292 for (Int_t i = 0;i<fNCuts;i++)
294 if (fCuts[i]->GetProperty() == property)
295 return fCuts[i]; //we found the cut we were searching for
298 return 0x0; //we did not found this cut
301 /**********************************************************/
303 void AliAODPairCut::Streamer(TBuffer &b)
305 // Stream all objects in the array to or from the I/O buffer.
310 Version_t v = b.ReadVersion(&R__s, &R__c);
313 delete fFirstPartCut;
314 delete fSecondPartCut;
316 fSecondPartCut = 0x0;
317 TObject::Streamer(b);
321 for (Int_t i = 0;i<fNCuts;i++)
326 b.CheckByteCount(R__s, R__c,AliAODPairCut::IsA());
330 R__c = b.WriteVersion(AliAODPairCut::IsA(), kTRUE);
331 TObject::Streamer(b);
333 // printf("Streamer Cut 1 %#x Cut 2 %#x\n",fFirstPartCut,fSecondPartCut);
335 // fFirstPartCut->Dump();
340 for (Int_t i = 0;i<fNCuts;i++)
344 b.SetByteCount(R__c, kTRUE);
347 /******************************************************************/
349 ClassImp(AliAODPairEmptyCut)
351 void AliAODPairEmptyCut::Streamer(TBuffer &b)
353 //streamer for empty pair cut
354 AliAODPairCut::Streamer(b);
356 /******************************************************************/
358 ClassImp(AliAODPairBaseCut)
359 ClassImp(AliAODQInvCut)
360 ClassImp(AliAODKtCut)
361 ClassImp(AliAODQSideLCMSCut)
362 ClassImp(AliAODQOutLCMSCut)
363 ClassImp(AliAODQLongLCMSCut)
365 /******************************************************************/
366 ClassImp(AliAODAvSeparationCut)
368 Double_t AliAODAvSeparationCut::GetValue(AliAODPair* pair) const
370 //chacks if avarage distance of two tracks is in given range
371 AliTrackPoints* tpts1 = pair->Particle1()->GetTPCTrackPoints();
373 {//it could be simulated pair
374 // Warning("GetValue","Track 1 does not have Track Points. Pair NOT Passed.");
378 AliTrackPoints* tpts2 = pair->Particle2()->GetTPCTrackPoints();
381 // Warning("GetValue","Track 2 does not have Track Points. Pair NOT Passed.");
385 return tpts1->AvarageDistance(*tpts2);
387 /******************************************************************/
388 ClassImp(AliAODSeparationCut)
390 Double_t AliAODSeparationCut::GetValue(AliAODPair* pair) const
392 //chacks if avarage distance of two tracks is in given range
393 AliTrackPoints* tpts1 = pair->Particle1()->GetTPCTrackPoints();
395 {//it could be simulated pair
396 // Warning("GetValue","Track 1 does not have Track Points. Pair NOT Passed.");
400 AliTrackPoints* tpts2 = pair->Particle2()->GetTPCTrackPoints();
403 // Warning("GetValue","Track 2 does not have Track Points. Pair NOT Passed.");
406 Float_t x1=0,y1=0,z1=0;
407 Float_t x2=0,y2=0,z2=0;
409 tpts1->PositionAt(fPoint,x1,y1,z1);
410 tpts2->PositionAt(fPoint,x2,y2,z2);
411 Double_t dx1 = x1 - x2;
412 Double_t dy1 = y1 - y2;
413 Double_t dz1 = z1 - z2;
414 Double_t d = TMath::Sqrt(dx1*dx1 + dy1*dy1 + dz1*dz1);
417 /******************************************************************/
419 ClassImp(AliAODITSSeparationCut)
421 Bool_t AliAODITSSeparationCut::Pass(AliAODPair* pair) const
423 //Checks if two tracks do not cross first pixels too close to each other
424 //If two tracks use the same cluster in pixels they are given
425 //the same position what skews theta angles (both are the same)
426 //These guys create artificial correlation in non-id analyses
427 //which is positive for identical polar angles (Qlong=0)
428 //and negative for a little bit different theta angle (Qlong=epsilon)
429 //Such tracks "attracks" each other.
431 AliTrackPoints* tpts1 = pair->Particle1()->GetITSTrackPoints();
433 {//it could be simulated pair
434 Warning("Pass","Track 1 does not have ITS Track Points. Pair NOT Passed.");
435 return kTRUE;//reject
438 AliTrackPoints* tpts2 = pair->Particle2()->GetITSTrackPoints();
441 Warning("Pass","Track 2 does not have ITS Track Points. Pair NOT Passed.");
442 return kTRUE;//reject
444 Float_t x1=0.0,y1=0.0,z1=0.0,x2=0.0,y2=0.0,z2=0.0;
445 tpts1->PositionAt(fLayer,x1,y1,z1);
446 tpts2->PositionAt(fLayer,x2,y2,z2);
448 // Info("Pass","rphi %f z %f",fMin,fMax);
449 // Info("Pass","P1: %f %f %f", x1,y1,z1);
450 // Info("Pass","P2: %f %f %f", x2,y2,z2);
452 Double_t dz = TMath::Abs(z1-z2);
454 //fMax encodes treshold valaue of distance in Z
455 if (dz > fMax) return kFALSE;//pair accepted
457 Double_t drphi = TMath::Hypot(x1-x2,y1-y2);
459 //fMin encodes treshold valaue of distance in r-phi
460 if (drphi > fMin) return kFALSE;
462 return kTRUE;//they are too close, rejected
464 /******************************************************************/
466 ClassImp(AliAODCluterOverlapCut)
468 Double_t AliAODCluterOverlapCut::GetValue(AliAODPair* pair) const
470 //Returns Cluter Overlap Factor
471 //It ranges between -0.5 (in all padrows both tracks have cluters)
472 // and 1 (in all padrows one track has cluter and second has not)
473 // When Overlap Factor is 1 this pair of tracks in highly probable to be
474 // splitted track: one particle that is recontructed twise
476 AliClusterMap* cm1 = pair->Particle1()->GetClusterMap();
479 Warning("GetValue","Track 1 does not have Cluster Map. Returning -0.5.");
483 AliClusterMap* cm2 = pair->Particle2()->GetClusterMap();
486 Warning("GetValue","Track 2 does not have Cluster Map. Returning -0.5.");
489 return cm1->GetOverlapFactor(*cm2);
491 /******************************************************************/
492 ClassImp(AliAODOutSideSameSignCut)
494 Bool_t AliAODOutSideSameSignCut::Pass(AliAODPair *p) const
496 //returns kTRUE if pair DO NOT meet cut criteria
498 if ( p->GetQOutLCMS()*p->GetQSideLCMS() > 0 )
500 return kFALSE;//accpeted
503 return kTRUE ;//rejected
505 /******************************************************************/
506 ClassImp(AliAODOutSideDiffSignCut)
508 Bool_t AliAODOutSideDiffSignCut::Pass(AliAODPair *p) const
510 //returns kTRUE if pair DO NOT meet cut criteria
512 if ( p->GetQOutLCMS()*p->GetQSideLCMS() > 0 )
514 return kTRUE;//rejected
517 return kFALSE;//accepted
519 /******************************************************************/
520 ClassImp( AliAODLogicalOperPairCut )
522 AliAODLogicalOperPairCut::AliAODLogicalOperPairCut():
523 AliAODPairBaseCut(-10e10,10e10,kHbtPairCutPropNone),
524 fFirst(new AliAODDummyBasePairCut),
525 fSecond(new AliAODDummyBasePairCut)
529 /******************************************************************/
531 AliAODLogicalOperPairCut::AliAODLogicalOperPairCut(AliAODPairBaseCut* first, AliAODPairBaseCut* second):
532 AliAODPairBaseCut(-10e10,10e10,kHbtPairCutPropNone),
533 fFirst((first)?(AliAODPairBaseCut*)first->Clone():0x0),
534 fSecond((second)?(AliAODPairBaseCut*)second->Clone():0x0)
537 //note that base cuts are copied, not just pointers assigned
538 if ( (fFirst && fSecond) == kFALSE)
540 Fatal("AliAODLogicalOperPairCut","One of parameters is NULL!");
543 /******************************************************************/
545 AliAODLogicalOperPairCut::~AliAODLogicalOperPairCut()
551 /******************************************************************/
553 Bool_t AliAODLogicalOperPairCut::AliAODDummyBasePairCut::Pass(AliAODPair* /*pair*/) const
555 //checks if particles passes properties defined by this cut
556 Warning("Pass","You are using dummy base cut! Probobly some logical cut is not set up properly");
557 return kFALSE;//accept
559 /******************************************************************/
561 void AliAODLogicalOperPairCut::Streamer(TBuffer &b)
563 // Stream all objects in the array to or from the I/O buffer.
572 b.ReadVersion(&R__s, &R__c);
573 TObject::Streamer(b);
576 b.CheckByteCount(R__s, R__c,AliAODLogicalOperPairCut::IsA());
580 R__c = b.WriteVersion(AliAODLogicalOperPairCut::IsA(), kTRUE);
581 TObject::Streamer(b);
584 b.SetByteCount(R__c, kTRUE);
588 /******************************************************************/
589 ClassImp(AliAODOrPairCut)
591 Bool_t AliAODOrPairCut::Pass(AliAODPair * p) const
593 //returns true when rejected
594 //AND operation is a little bit misleading but is correct
595 //User wants to build logical cuts with natural (positive) logic
596 //while ALIAN use inernally reverse (returns true when rejected)
597 if (fFirst->Pass(p) && fSecond->Pass(p) ) return kTRUE;//rejected (both rejected, returned kTRUE)
598 return kFALSE;//accepted, at least one accepted (returned kFALSE)
600 /******************************************************************/
602 ClassImp(AliAODAndPairCut)
604 Bool_t AliAODAndPairCut::Pass(AliAODPair * p) const
606 //returns true when rejected
607 //OR operation is a little bit misleading but is correct
608 //User wants to build logical cuts with natural (positive) logic
609 //while ALIAN use inernally reverse (returns true when rejected)
610 if (fFirst->Pass(p) || fSecond->Pass(p)) return kTRUE;//rejected (any of two rejected(returned kTRUE) )
611 return kFALSE;//accepted (both accepted (returned kFALSE))
613 /******************************************************************/