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);
256 AliHbtBasePairCut* AliHBTPairCut::FindCut(AliHBTPairCutProperty property)
258 // Find the cut corresponding to "property"
259 for (Int_t i = 0;i<fNCuts;i++)
261 if (fCuts[i]->GetProperty() == property)
262 return fCuts[i]; //we found the cut we were searching for
265 return 0x0; //we did not found this cut
268 /**********************************************************/
270 void AliHBTPairCut::Streamer(TBuffer &b)
272 // Stream all objects in the array to or from the I/O buffer.
277 Version_t v = b.ReadVersion(&R__s, &R__c);
280 delete fFirstPartCut;
281 delete fSecondPartCut;
283 fSecondPartCut = 0x0;
284 TObject::Streamer(b);
288 for (Int_t i = 0;i<fNCuts;i++)
293 b.CheckByteCount(R__s, R__c,AliHBTPairCut::IsA());
297 R__c = b.WriteVersion(AliHBTPairCut::IsA(), kTRUE);
298 TObject::Streamer(b);
300 // printf("Streamer Cut 1 %#x Cut 2 %#x\n",fFirstPartCut,fSecondPartCut);
302 // fFirstPartCut->Dump();
307 for (Int_t i = 0;i<fNCuts;i++)
311 b.SetByteCount(R__c, kTRUE);
314 /******************************************************************/
316 ClassImp(AliHBTEmptyPairCut)
318 void AliHBTEmptyPairCut::Streamer(TBuffer &b)
320 //streamer for empty pair cut
321 AliHBTPairCut::Streamer(b);
323 /******************************************************************/
325 ClassImp(AliHbtBasePairCut)
326 ClassImp(AliHBTQInvCut)
327 ClassImp(AliHBTKtCut)
328 ClassImp(AliHBTQSideCMSLCCut)
329 ClassImp(AliHBTQOutCMSLCCut)
330 ClassImp(AliHBTQLongCMSLCCut)
332 /******************************************************************/
333 ClassImp(AliHBTAvSeparationCut)
335 Double_t AliHBTAvSeparationCut::GetValue(AliHBTPair* pair) const
337 //chacks if avarage distance of two tracks is in given range
338 AliHBTTrackPoints* tpts1 = pair->Particle1()->GetTrackPoints();
340 {//it could be simulated pair
341 // Warning("GetValue","Track 1 does not have Track Points. Pair NOT Passed.");
345 AliHBTTrackPoints* tpts2 = pair->Particle2()->GetTrackPoints();
348 // Warning("GetValue","Track 2 does not have Track Points. Pair NOT Passed.");
352 return tpts1->AvarageDistance(*tpts2);
354 /******************************************************************/
356 ClassImp(AliHBTCluterOverlapCut)
358 Double_t AliHBTCluterOverlapCut::GetValue(AliHBTPair* pair) const
360 //Returns Cluter Overlap Factor
361 //It ranges between -0.5 (in all padrows both tracks have cluters)
362 // and 1 (in all padrows one track has cluter and second has not)
363 // When Overlap Factor is 1 this pair of tracks in highly probable to be
364 // splitted track: one particle that is recontructed twise
366 AliHBTClusterMap* cm1 = pair->Particle1()->GetClusterMap();
369 Warning("GetValue","Track 1 does not have Cluster Map. Returning -0.5.");
373 AliHBTClusterMap* cm2 = pair->Particle2()->GetClusterMap();
376 Warning("GetValue","Track 2 does not have Cluster Map. Returning -0.5.");
379 return cm1->GetOverlapFactor(*cm2);
381 /******************************************************************/
383 ClassImp( AliHBTLogicalOperPairCut )
385 AliHBTLogicalOperPairCut::AliHBTLogicalOperPairCut():
386 AliHbtBasePairCut(-10e10,10e10,kHbtPairCutPropNone),
387 fFirst(new AliHBTDummyBasePairCut),
388 fSecond(new AliHBTDummyBasePairCut)
392 /******************************************************************/
394 AliHBTLogicalOperPairCut::AliHBTLogicalOperPairCut(AliHbtBasePairCut* first, AliHbtBasePairCut* second):
395 AliHbtBasePairCut(-10e10,10e10,kHbtPairCutPropNone),
396 fFirst((first)?(AliHbtBasePairCut*)first->Clone():0x0),
397 fSecond((second)?(AliHbtBasePairCut*)second->Clone():0x0)
400 //note that base cuts are copied, not just pointers assigned
401 if ( (fFirst && fSecond) == kFALSE)
403 Fatal("AliHBTLogicalOperPairCut","One of parameters is NULL!");
406 /******************************************************************/
408 AliHBTLogicalOperPairCut::~AliHBTLogicalOperPairCut()
414 /******************************************************************/
416 Bool_t AliHBTLogicalOperPairCut::AliHBTDummyBasePairCut::Pass(AliHBTPair* /*pair*/) const
418 //checks if particles passes properties defined by this cut
419 Warning("Pass","You are using dummy base cut! Probobly some logical cut is not set up properly");
420 return kFALSE;//accept
422 /******************************************************************/
424 void AliHBTLogicalOperPairCut::Streamer(TBuffer &b)
426 // Stream all objects in the array to or from the I/O buffer.
435 b.ReadVersion(&R__s, &R__c);
436 TObject::Streamer(b);
439 b.CheckByteCount(R__s, R__c,AliHBTLogicalOperPairCut::IsA());
443 R__c = b.WriteVersion(AliHBTLogicalOperPairCut::IsA(), kTRUE);
444 TObject::Streamer(b);
447 b.SetByteCount(R__c, kTRUE);
451 /******************************************************************/
452 ClassImp(AliHBTOrPairCut)
454 Bool_t AliHBTOrPairCut::Pass(AliHBTPair * p) const
456 //returns true when rejected
457 //AND operation is a little bit misleading but is correct
458 //User wants to build logical cuts with natural (positive) logic
459 //while HBTAN use inernally reverse (returns true when rejected)
460 if (fFirst->Pass(p) && fSecond->Pass(p) ) return kTRUE;//rejected (both rejected, returned kTRUE)
461 return kFALSE;//accepted, at least one accepted (returned kFALSE)
463 /******************************************************************/
465 ClassImp(AliHBTAndPairCut)
467 Bool_t AliHBTAndPairCut::Pass(AliHBTPair * p) const
469 //returns true when rejected
470 //OR operation is a little bit misleading but is correct
471 //User wants to build logical cuts with natural (positive) logic
472 //while HBTAN use inernally reverse (returns true when rejected)
473 if (fFirst->Pass(p) || fSecond->Pass(p)) return kTRUE;//rejected (any of two rejected(returned kTRUE) )
474 return kFALSE;//accepted (both accepted (returned kFALSE))
476 /******************************************************************/