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::SetFirstPartCut(AliHBTParticleCut* cut)
136 // set cut for the first particle
139 Error("SetFirstPartCut","argument is NULL");
142 delete fFirstPartCut;
143 fFirstPartCut = (AliHBTParticleCut*)cut->Clone();
146 /**********************************************************/
148 void AliHBTPairCut::SetSecondPartCut(AliHBTParticleCut* cut)
150 // set cut for the second particle
153 Error("SetSecondPartCut","argument is NULL");
156 delete fSecondPartCut;
157 fSecondPartCut = (AliHBTParticleCut*)cut->Clone();
159 /**********************************************************/
161 void AliHBTPairCut::SetPartCut(AliHBTParticleCut* cut)
163 //sets the the same cut on both particles
166 Error("SetFirstPartCut","argument is NULL");
169 if (fFirstPartCut == fSecondPartCut) fSecondPartCut = 0x0;
171 delete fFirstPartCut;
172 fFirstPartCut = (AliHBTParticleCut*)cut->Clone();
174 delete fSecondPartCut; //even if null should not be harmful
175 fSecondPartCut = fFirstPartCut;
177 /**********************************************************/
179 void AliHBTPairCut::SetQInvRange(Double_t min, Double_t max)
181 // set range of accepted invariant masses
182 AliHBTQInvCut* cut= (AliHBTQInvCut*)FindCut(kHbtPairCutPropQInv);
183 if(cut) cut->SetRange(min,max);
184 else fCuts[fNCuts++] = new AliHBTQInvCut(min,max);
186 /**********************************************************/
187 void AliHBTPairCut::SetQOutCMSLRange(Double_t min, Double_t max)
189 // set range of accepted QOut in CMS
190 AliHBTQOutCMSLCCut* cut= (AliHBTQOutCMSLCCut*)FindCut(kHbtPairCutPropQOutCMSLC);
191 if(cut) cut->SetRange(min,max);
192 else fCuts[fNCuts++] = new AliHBTQOutCMSLCCut(min,max);
195 /**********************************************************/
196 void AliHBTPairCut::SetQSideCMSLRange(Double_t min, Double_t max)
198 // set range of accepted QSide in CMS
199 AliHBTQSideCMSLCCut* cut= (AliHBTQSideCMSLCCut*)FindCut(kHbtPairCutPropQSideCMSLC);
200 if(cut) cut->SetRange(min,max);
201 else fCuts[fNCuts++] = new AliHBTQSideCMSLCCut(min,max);
204 /**********************************************************/
205 void AliHBTPairCut::SetQLongCMSLRange(Double_t min, Double_t max)
207 // set range of accepted QLong in CMS
208 AliHBTQLongCMSLCCut* cut= (AliHBTQLongCMSLCCut*)FindCut(kHbtPairCutPropQLongCMSLC);
209 if(cut) cut->SetRange(min,max);
210 else fCuts[fNCuts++] = new AliHBTQLongCMSLCCut(min,max);
213 /**********************************************************/
215 void AliHBTPairCut::SetKtRange(Double_t min, Double_t max)
217 // set range of accepted Kt (?)
218 AliHBTKtCut* cut= (AliHBTKtCut*)FindCut(kHbtPairCutPropKt);
219 if(cut) cut->SetRange(min,max);
220 else fCuts[fNCuts++] = new AliHBTKtCut(min,max);
222 /**********************************************************/
224 void AliHBTPairCut::SetKStarRange(Double_t min, Double_t max)
226 // set range of accepted KStar (?)
227 AliHBTKStarCut* cut= (AliHBTKStarCut*)FindCut(kHbtPairCutPropKStar);
228 if(cut) cut->SetRange(min,max);
229 else fCuts[fNCuts++] = new AliHBTKStarCut(min,max);
231 /**********************************************************/
232 void AliHBTPairCut::SetAvSeparationRange(Double_t min, Double_t max)
234 //sets avarage separation cut ->Anti-Merging cut
235 AliHbtBasePairCut* cut= FindCut(kHbtPairCutPropAvSepar);
236 if(cut) cut->SetRange(min,max);
237 else fCuts[fNCuts++] = new AliHBTAvSeparationCut(min,max);
239 /**********************************************************/
241 void AliHBTPairCut::SetClusterOverlapRange(Double_t min,Double_t max)
243 //sets cluster overlap factor cut ->Anti-Splitting cut
244 //cluster overlap factor ranges between
245 // -0.5 (in all padrows both tracks have cluters)
246 // and 1 (in all padrows one track has cluter and second has not)
247 // When Overlap Factor is 1 this pair of tracks in highly probable to be
248 // splitted track: one particle that is recontructed twise
249 // STAR uses range from -0.5 to 0.6
251 AliHbtBasePairCut* cut= FindCut(kHbtPairCutPropClOverlap);
252 if(cut) cut->SetRange(min,max);
253 else fCuts[fNCuts++] = new AliHBTCluterOverlapCut(min,max);
255 /**********************************************************/
257 AliHbtBasePairCut* AliHBTPairCut::FindCut(AliHBTPairCutProperty property)
259 // Find the cut corresponding to "property"
260 for (Int_t i = 0;i<fNCuts;i++)
262 if (fCuts[i]->GetProperty() == property)
263 return fCuts[i]; //we found the cut we were searching for
266 return 0x0; //we did not found this cut
269 /**********************************************************/
271 void AliHBTPairCut::Streamer(TBuffer &b)
273 // Stream all objects in the array to or from the I/O buffer.
278 Version_t v = b.ReadVersion(&R__s, &R__c);
281 delete fFirstPartCut;
282 delete fSecondPartCut;
284 fSecondPartCut = 0x0;
285 TObject::Streamer(b);
289 for (Int_t i = 0;i<fNCuts;i++)
294 b.CheckByteCount(R__s, R__c,AliHBTPairCut::IsA());
298 R__c = b.WriteVersion(AliHBTPairCut::IsA(), kTRUE);
299 TObject::Streamer(b);
301 // printf("Streamer Cut 1 %#x Cut 2 %#x\n",fFirstPartCut,fSecondPartCut);
303 // fFirstPartCut->Dump();
308 for (Int_t i = 0;i<fNCuts;i++)
312 b.SetByteCount(R__c, kTRUE);
315 /******************************************************************/
317 ClassImp(AliHBTEmptyPairCut)
319 void AliHBTEmptyPairCut::Streamer(TBuffer &b)
321 //streamer for empty pair cut
322 AliHBTPairCut::Streamer(b);
324 /******************************************************************/
326 ClassImp(AliHbtBasePairCut)
327 ClassImp(AliHBTQInvCut)
328 ClassImp(AliHBTKtCut)
329 ClassImp(AliHBTQSideCMSLCCut)
330 ClassImp(AliHBTQOutCMSLCCut)
331 ClassImp(AliHBTQLongCMSLCCut)
333 /******************************************************************/
334 ClassImp(AliHBTAvSeparationCut)
336 Double_t AliHBTAvSeparationCut::GetValue(AliHBTPair* pair) const
338 //chacks if avarage distance of two tracks is in given range
339 AliHBTTrackPoints* tpts1 = pair->Particle1()->GetTrackPoints();
341 {//it could be simulated pair
342 // Warning("GetValue","Track 1 does not have Track Points. Pair NOT Passed.");
346 AliHBTTrackPoints* tpts2 = pair->Particle2()->GetTrackPoints();
349 // Warning("GetValue","Track 2 does not have Track Points. Pair NOT Passed.");
353 return tpts1->AvarageDistance(*tpts2);
355 /******************************************************************/
357 ClassImp(AliHBTCluterOverlapCut)
359 Double_t AliHBTCluterOverlapCut::GetValue(AliHBTPair* pair) const
361 //Returns Cluter Overlap Factor
362 //It ranges between -0.5 (in all padrows both tracks have cluters)
363 // and 1 (in all padrows one track has cluter and second has not)
364 // When Overlap Factor is 1 this pair of tracks in highly probable to be
365 // splitted track: one particle that is recontructed twise
367 AliHBTClusterMap* cm1 = pair->Particle1()->GetClusterMap();
370 Warning("GetValue","Track 1 does not have Cluster Map. Returning -0.5.");
374 AliHBTClusterMap* cm2 = pair->Particle2()->GetClusterMap();
377 Warning("GetValue","Track 2 does not have Cluster Map. Returning -0.5.");
380 return cm1->GetOverlapFactor(*cm2);
382 /******************************************************************/
383 ClassImp(AliHBTOutSideSameSignCut)
385 Bool_t AliHBTOutSideSameSignCut::Pass(AliHBTPair *p) const
387 //returns kTRUE if pair DO NOT meet cut criteria
389 if ( p->GetQOutCMSLC()*p->GetQSideCMSLC() > 0 )
391 return kFALSE;//accpeted
394 return kTRUE ;//rejected
396 /******************************************************************/
397 ClassImp(AliHBTOutSideDiffSignCut)
399 Bool_t AliHBTOutSideDiffSignCut::Pass(AliHBTPair *p) const
401 //returns kTRUE if pair DO NOT meet cut criteria
403 if ( p->GetQOutCMSLC()*p->GetQSideCMSLC() > 0 )
405 return kTRUE;//rejected
408 return kFALSE;//accepted
410 /******************************************************************/
411 ClassImp( AliHBTLogicalOperPairCut )
413 AliHBTLogicalOperPairCut::AliHBTLogicalOperPairCut():
414 AliHbtBasePairCut(-10e10,10e10,kHbtPairCutPropNone),
415 fFirst(new AliHBTDummyBasePairCut),
416 fSecond(new AliHBTDummyBasePairCut)
420 /******************************************************************/
422 AliHBTLogicalOperPairCut::AliHBTLogicalOperPairCut(AliHbtBasePairCut* first, AliHbtBasePairCut* second):
423 AliHbtBasePairCut(-10e10,10e10,kHbtPairCutPropNone),
424 fFirst((first)?(AliHbtBasePairCut*)first->Clone():0x0),
425 fSecond((second)?(AliHbtBasePairCut*)second->Clone():0x0)
428 //note that base cuts are copied, not just pointers assigned
429 if ( (fFirst && fSecond) == kFALSE)
431 Fatal("AliHBTLogicalOperPairCut","One of parameters is NULL!");
434 /******************************************************************/
436 AliHBTLogicalOperPairCut::~AliHBTLogicalOperPairCut()
442 /******************************************************************/
444 Bool_t AliHBTLogicalOperPairCut::AliHBTDummyBasePairCut::Pass(AliHBTPair* /*pair*/) const
446 //checks if particles passes properties defined by this cut
447 Warning("Pass","You are using dummy base cut! Probobly some logical cut is not set up properly");
448 return kFALSE;//accept
450 /******************************************************************/
452 void AliHBTLogicalOperPairCut::Streamer(TBuffer &b)
454 // Stream all objects in the array to or from the I/O buffer.
463 b.ReadVersion(&R__s, &R__c);
464 TObject::Streamer(b);
467 b.CheckByteCount(R__s, R__c,AliHBTLogicalOperPairCut::IsA());
471 R__c = b.WriteVersion(AliHBTLogicalOperPairCut::IsA(), kTRUE);
472 TObject::Streamer(b);
475 b.SetByteCount(R__c, kTRUE);
479 /******************************************************************/
480 ClassImp(AliHBTOrPairCut)
482 Bool_t AliHBTOrPairCut::Pass(AliHBTPair * p) const
484 //returns true when rejected
485 //AND operation is a little bit misleading but is correct
486 //User wants to build logical cuts with natural (positive) logic
487 //while HBTAN use inernally reverse (returns true when rejected)
488 if (fFirst->Pass(p) && fSecond->Pass(p) ) return kTRUE;//rejected (both rejected, returned kTRUE)
489 return kFALSE;//accepted, at least one accepted (returned kFALSE)
491 /******************************************************************/
493 ClassImp(AliHBTAndPairCut)
495 Bool_t AliHBTAndPairCut::Pass(AliHBTPair * p) const
497 //returns true when rejected
498 //OR operation is a little bit misleading but is correct
499 //User wants to build logical cuts with natural (positive) logic
500 //while HBTAN use inernally reverse (returns true when rejected)
501 if (fFirst->Pass(p) || fSecond->Pass(p)) return kTRUE;//rejected (any of two rejected(returned kTRUE) )
502 return kFALSE;//accepted (both accepted (returned kFALSE))
504 /******************************************************************/