AliPhysics  vAN-20150827 (3e81cbb)
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros
AliRDHFCutsLctopK0sfromAODtracks.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-2010, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
7  * Permission to use, copy, modify and distribute this software and its *
8  * documentation strictly for non-commercial purposes is hereby granted *
9  * without fee, provided that the above copyright notice appears in all *
10  * copies and that both the copyright notice and this permission notice *
11  * appear in the supporting documentation. The authors make no claims *
12  * about the suitability of this software for any purpose. It is *
13  * provided "as is" without express or implied warranty. *
14  **************************************************************************/
15 
16 /* $Id$ */
17 
19 //
20 // Class for cuts on AOD reconstructed Lc->p+K0s
21 //
22 // Modified by Y.S Watanabe - wyosuke@cns.s.u-tokyo.ac.jp
23 //
25 
26 #include <Riostream.h>
27 
28 #include <TDatabasePDG.h>
29 #include <TMath.h>
30 
31 #include "AliAnalysisManager.h"
32 #include "AliInputEventHandler.h"
33 #include "AliPIDResponse.h"
35 #include "AliAODRecoCascadeHF.h"
36 #include "AliAODTrack.h"
37 #include "AliESDtrack.h"
38 #include "AliESDVertex.h"
39 #include "AliAODVertex.h"
40 #include "AliAODv0.h"
41 #include "AliAODcascade.h"
42 #include "AliESDv0.h"
43 
44 using std::cout;
45 using std::endl;
46 
50 
51 
52 //--------------------------------------------------------------------------
54 AliRDHFCuts(name),
55  fPIDStrategy(kNSigmaCuts),
56  fCombinedPIDThreshold(0.),
57  fUseOnTheFlyV0(kFALSE),
58  fProdTrackPtMin(0.3),
59  fProdTrackEtaRange(0.8),
60  fProdUseAODFilterBit(kTRUE),
61  fProdV0MassTolK0s(0.01),
62  fProdV0PtMin(0.5),
63  fProdV0CosPointingAngleToPrimVtxMin(0.99),
64  fProdV0DcaDaughtersMax(1.5),
65  fProdV0DaughterEtaRange(0.8),
66  fProdV0DaughterPtMin(0.0),
67  fProdV0DaughterTPCClusterMin(70),
68 fProdRoughMassTol(0.25),
69 fProdRoughPtMin(0.0)
70 {
71  //
72  // Default Constructor
73  //
74 
75  const Int_t nvars=7;
76  SetNVars(nvars);
77  TString varNames[nvars]={"Lc inv. mass [GeV/c2]", // 0
78  "Lc pT [GeV/c]", //1
79  "Bachelor pT [GeV/c]", //2
80  "Bachelor d0 [cm]", //3
81  "V0 d0 [cm]", //4
82  "K0s mass [GeV/c2]", //5
83  "Decay Length XY [cm]" //6
84  };
85 
86  Bool_t isUpperCut[nvars]={kTRUE, // 0
87  kFALSE, //1
88  kFALSE, //2
89  kTRUE, //3
90  kTRUE, //4
91  kTRUE, //5
92  kFALSE //6
93  };
94  SetVarNames(nvars,varNames,isUpperCut);
95  Bool_t forOpt[nvars]={kFALSE, // 0
96  kFALSE, //1
97  kTRUE, //2
98  kTRUE, //3
99  kTRUE, //4
100  kTRUE, //5
101  kTRUE //6
102  };
103  SetVarsForOpt(nvars,forOpt);
104 
105  Float_t limits[2]={0,999999999.};
106  SetPtBins(2,limits);
107 }
108 //--------------------------------------------------------------------------
110  AliRDHFCuts(source),
111  fPIDStrategy(source.fPIDStrategy),
112  fCombinedPIDThreshold(source.fCombinedPIDThreshold),
113  fUseOnTheFlyV0(source.fUseOnTheFlyV0),
114  fProdTrackPtMin(source.fProdTrackPtMin),
115  fProdTrackEtaRange(source.fProdTrackEtaRange),
116  fProdUseAODFilterBit(source.fProdUseAODFilterBit),
117  fProdV0MassTolK0s(source.fProdV0MassTolK0s),
118  fProdV0PtMin(source.fProdV0PtMin),
119  fProdV0CosPointingAngleToPrimVtxMin(source.fProdV0CosPointingAngleToPrimVtxMin),
120  fProdV0DcaDaughtersMax(source.fProdV0DcaDaughtersMax),
121  fProdV0DaughterEtaRange(source.fProdV0DaughterEtaRange),
122  fProdV0DaughterPtMin(source.fProdV0DaughterPtMin),
123  fProdV0DaughterTPCClusterMin(source.fProdV0DaughterTPCClusterMin),
124  fProdRoughMassTol(source.fProdRoughMassTol),
125  fProdRoughPtMin(source.fProdRoughPtMin)
126 {
127  //
128  // Copy constructor
129  //
130 }
131 //--------------------------------------------------------------------------
133 {
134  //
135  // assignment operator
136  //
137 
138  if (this != &source) {
139  AliRDHFCuts::operator=(source);
140  }
141 
142  fPIDStrategy = source.fPIDStrategy;
149  fProdV0PtMin = source.fProdV0PtMin;
157 
158 
159  return *this;
160 }
161 
162 //---------------------------------------------------------------------------
164  //
165  // Default Destructor
166  //
167 
168 }
169 
170 //---------------------------------------------------------------------------
171 void AliRDHFCutsLctopK0sfromAODtracks::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters) {
172  //
173  // Fills in vars the values of the variables
174  //
175 
176  if (pdgdaughters[0]==-9999) return; // dummy
177 
179  if(!dd){
180  AliError("No AliAODRecoCascadeHF object found\n");
181  return;
182  }
183 
184  if (nvars!=fnVarsForOpt) {
185  AliError("Cut object seems to have the wrong number of variables\n");
186  return;
187  }
188 
189  //Double_t ptD=d->Pt();
190  //Int_t ptbin=PtBin(ptD);
191  Int_t iter=-1;
192 
193  if(fVarsForOpt[0]){
194  iter++;
195  Double_t mlcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
196  vars[iter]= TMath::Abs(dd->InvMassLctoK0sP()-mlcPDG) ;
197  }
198  if(fVarsForOpt[1]){
199  iter++;
200  vars[iter]= dd->Pt();
201  }
202  if(fVarsForOpt[2]){
203  iter++;
204  AliAODTrack *part = dd->GetBachelor();
205  vars[iter]= part->Pt();
206  }
207  if(fVarsForOpt[3]){
208  iter++;
209  vars[iter]= dd->Getd0Prong(0);
210  }
211  if(fVarsForOpt[4]){
212  iter++;
213  vars[iter]= dd->Getd0Prong(1);
214  }
215  if(fVarsForOpt[5]){
216  iter++;
217  AliAODv0 *v0 = dd->Getv0();
218  vars[iter]= v0->MassK0Short();
219  }
220  if(fVarsForOpt[6]){
221  iter++;
222  vars[iter]= dd->DecayLengthXY();
223  }
224 
225  return;
226 }
227 
228 //---------------------------------------------------------------------------
229 Int_t AliRDHFCutsLctopK0sfromAODtracks::IsSelected(TObject* obj, Int_t selectionLevel) {
230  //
231  // Apply selection
232  //
233 
234  if (!fCutsRD) {
235  AliFatal("Cut matrix not inizialized. Exit...");
236  return 0;
237  }
238 
240  if(!d){
241  AliDebug(2,"AliAODRecoCascadeHF null");
242  return 0;
243  }
244 
245  Double_t ptD=d->Pt();
246  if(ptD<fMinPtCand) return 0;
247  if(ptD>fMaxPtCand) return 0;
248 
249  if (selectionLevel==AliRDHFCuts::kAll ||
250  selectionLevel==AliRDHFCuts::kTracks) {
251  //Performed in production stage
252  }
253 
254  Int_t returnvalueCuts=1;
255  // selection on candidate
256  if (selectionLevel==AliRDHFCuts::kAll ||
257  selectionLevel==AliRDHFCuts::kCandidate) {
258 
259  Double_t pt=d->Pt();
260  Int_t ptbin=PtBin(pt);
261  if (ptbin==-1) {
262  return 0;
263  }
264  Bool_t okcand=kTRUE;
265 
266  Double_t mlcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
267  Double_t mk0sPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
268  AliAODTrack *part = d->GetBachelor();
269  AliAODv0 *v0 = d->Getv0();
270 
271  if(TMath::Abs(d->InvMassLctoK0sP()-mlcPDG) > fCutsRD[GetGlobalIndex(0,ptbin)])
272  {
273  okcand = kFALSE;
274  }
275  if(d->Pt() < fCutsRD[GetGlobalIndex(1,ptbin)])
276  {
277  okcand = kFALSE;
278  }
279  if(part->Pt() < fCutsRD[GetGlobalIndex(2,ptbin)])
280  {
281  okcand = kFALSE;
282  }
283  if(TMath::Abs(d->Getd0Prong(0)) > fCutsRD[GetGlobalIndex(3,ptbin)])
284  {
285  okcand = kFALSE;
286  }
287  if(TMath::Abs(d->Getd0Prong(1)) > fCutsRD[GetGlobalIndex(4,ptbin)])
288  {
289  okcand = kFALSE;
290  }
291  if(TMath::Abs(v0->MassK0Short()-mk0sPDG) > fCutsRD[GetGlobalIndex(5,ptbin)])
292  {
293  okcand = kFALSE;
294  }
295  Double_t lccospaxy = CalculateLcCosPAXY(d);
296  if(d->DecayLengthXY() * lccospaxy < fCutsRD[GetGlobalIndex(6,ptbin)])
297  {
298  okcand = kFALSE;
299  }
300 
301  if(!okcand) return 0;
302  returnvalueCuts = 1;
303  }
304 
305  Int_t returnvaluePID=1;
306  if(selectionLevel==AliRDHFCuts::kAll ||
307  selectionLevel==AliRDHFCuts::kCandidate||
308  selectionLevel==AliRDHFCuts::kPID) {
309 
310  switch(fPIDStrategy){
311  case kNSigmaCuts:
312  returnvaluePID = IsSelectedPID(d);
313  break;
314  case kCombinedCuts:
315  returnvaluePID = IsSelectedCombinedPID(d);
316  break;
317  }
318  }
319 
320  Int_t returnvalue = 0;
321  if(returnvalueCuts==1 && returnvaluePID==1) returnvalue=1;
322 
323  return returnvalue;
324 }
325 
326 //---------------------------------------------------------------------------
328 {
329  //
330  // IsSelectedPID
331  //
332 
333  if(!fUsePID || !obj) return 1;
334 
336  AliAODTrack *part = dd->GetBachelor();
337 
338  Int_t returnvalue=1;
339 
340  if(fPidHF->GetPidResponse()==0x0){
341  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
342  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
343  AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
344  fPidHF->SetPidResponse(pidResp);
345  }
346 
347  Int_t isProton=fPidHF->MakeRawPid(part,4);
348  if(isProton<1) returnvalue = 0;
349 
350  return returnvalue;
351 }
352 
353 //---------------------------------------------------------------------------
355  //
356  // IsSelectedCombinedPID
357  //
358 
359  if(!fUsePID || !obj) {return 1;}
360 
362  AliAODTrack *part = dd->GetBachelor();
363  if(!part) return 0;
364 
365  Int_t returnvalue=1;
366  Double_t probProton = GetProtonProbabilityTPCTOF(part);
367  if(probProton<fCombinedPIDThreshold) returnvalue = 0;
368 
369  return returnvalue;
370 }
371 
372 //________________________________________________________________________
374 {
375  //
376  // Get Proton probability
377  //
378  if(!fPidHF->GetUseCombined()) return -9999.;
379  fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC+AliPIDResponse::kDetTOF);
380  Double_t prob1[AliPID::kSPECIES];
381  UInt_t detUsed1 = fPidHF->GetPidCombined()->ComputeProbabilities(trk, fPidHF->GetPidResponse(), prob1);
382  if (detUsed1 != (UInt_t)fPidHF->GetPidCombined()->GetDetectorMask() )
383  {
384  fPidHF->GetPidCombined()->SetDetectorMask(AliPIDResponse::kDetTPC);
385  detUsed1 = fPidHF->GetPidCombined()->ComputeProbabilities(trk, fPidHF->GetPidResponse(), prob1);
386  }
387  return prob1[AliPID::kProton];
388 }
389 
390 //________________________________________________________________________
392 {
393  //
394  // Single Track Cut to be applied before object creation
395  //
396 
397  if(trk->GetStatus()&AliESDtrack::kITSpureSA) return kFALSE;
398  if(!(trk->GetStatus()&AliESDtrack::kITSin)) return kFALSE;
399  if(fProdUseAODFilterBit && !trk->TestFilterMask(BIT(4))) return kFALSE;
400  if(fabs(trk->Eta())>fProdTrackEtaRange) return kFALSE;
401  if(trk->Pt()<fProdTrackPtMin) return kFALSE;
402 
403  if(fUsePID)
404  {
405  if(fPidHF->GetPidResponse()==0x0){
406  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
407  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
408  AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
409  fPidHF->SetPidResponse(pidResp);
410  }
411 
412  Int_t isProton=fPidHF->MakeRawPid(trk,4);
413  if(isProton<1) return kFALSE;
414  }
415 
416  return kTRUE;
417 }
418 //________________________________________________________________________
420 {
422  if(!lcobj){
423  AliError("No AliAODRecoCascadeHF object found\n");
424  return -9999.;
425  }
426  Double_t dvertx = lcobj->GetSecondaryVtx()->GetX()-lcobj->GetOwnPrimaryVtx()->GetX();
427  Double_t dverty = lcobj->GetSecondaryVtx()->GetY()-lcobj->GetOwnPrimaryVtx()->GetY();
428  Double_t px = lcobj->Px();
429  Double_t py = lcobj->Py();
430  if(TMath::Sqrt(dvertx*dvertx+dverty*dverty)==0) return -9999.;
431  if(TMath::Sqrt(px*px+py*py)==0) return -9999.;
432  Double_t cospaxy = (dvertx*px+dverty*py)/TMath::Sqrt(dvertx*dvertx+dverty*dverty)/TMath::Sqrt(px*px+py*py);
433  return (Float_t)cospaxy;
434 }
435 //________________________________________________________________________
436 Bool_t AliRDHFCutsLctopK0sfromAODtracks::SingleV0Cuts(AliAODv0 *v0, AliAODVertex *primVert)
437 {
438  //
439  // Single V0 Cut to be applied before object creation
440  //
441 
442  Bool_t onFlyV0 = v0->GetOnFlyStatus(); // on-the-flight V0s
443  if ( onFlyV0 && !fUseOnTheFlyV0 ) return kFALSE;
444 
445  AliAODTrack *cptrack = (AliAODTrack*)(v0->GetDaughter(0));
446  AliAODTrack *cntrack = (AliAODTrack*)(v0->GetDaughter(1));
447  if(!cptrack || !cntrack) return kFALSE;
448  if ( cptrack->Charge() == cntrack->Charge() ) return kFALSE;
449  if(!(cptrack->GetStatus() & AliESDtrack::kTPCrefit) ||
450  !(cntrack->GetStatus() & AliESDtrack::kTPCrefit)) return kFALSE;
451  AliAODVertex *maybeKinkPos = (AliAODVertex*)cptrack->GetProdVertex();
452  AliAODVertex *maybeKinkNeg = (AliAODVertex*)cntrack->GetProdVertex();
453  if (maybeKinkPos->GetType()==AliAODVertex::kKink || maybeKinkNeg->GetType()==AliAODVertex::kKink)
454  return kFALSE;
455 
456  if ( ( ( cptrack->GetTPCClusterInfo(2,1) ) < (Float_t)fProdV0DaughterTPCClusterMin ) ||
457  ( ( cntrack->GetTPCClusterInfo(2,1) ) < (Float_t)fProdV0DaughterTPCClusterMin) ) return kFALSE;
458 
459  Double_t massK0S = v0->MassK0Short();
460  Double_t mk0sPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
461  if(fabs(massK0S-mk0sPDG)>fProdV0MassTolK0s) return kFALSE;
462 
463 
464  if(TMath::Abs(v0->DcaV0Daughters())>fProdV0DcaDaughtersMax) return kFALSE;
465  Double_t posVtx[3] = {0.,0.,0.};
466  primVert->GetXYZ(posVtx);
467  Double_t cospav0 = v0->CosPointingAngle(posVtx);
468  if(cospav0<fProdV0CosPointingAngleToPrimVtxMin) return kFALSE;
469  if(v0->Pt()<fProdV0PtMin) return kFALSE;
470  if(fabs(cptrack->Eta())>fProdV0DaughterEtaRange) return kFALSE;
471  if(fabs(cntrack->Eta())>fProdV0DaughterEtaRange) return kFALSE;
472  if(cptrack->Pt()<fProdV0DaughterPtMin) return kFALSE;
473  if(cntrack->Pt()<fProdV0DaughterPtMin) return kFALSE;
474 
475  return kTRUE;
476 }
477 
478 //________________________________________________________________________
479 Bool_t AliRDHFCutsLctopK0sfromAODtracks::SelectWithRoughCuts(AliAODv0 *v0, AliAODTrack *part)
480 {
481  //
482  // Mass and pT Cut to be applied before object creation
483  //
484 
485  Double_t mprPDG = TDatabasePDG::Instance()->GetParticle(2212)->Mass();
486  Double_t mLcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
487 
488  Double_t pxpr_init = part->Px();
489  Double_t pypr_init = part->Py();
490  Double_t pzpr_init = part->Pz();
491  Double_t Epr_init = sqrt(pxpr_init*pxpr_init+pypr_init*pypr_init+pzpr_init*pzpr_init+mprPDG*mprPDG);
492 
493  Double_t pxv0_init = v0->Px();
494  Double_t pyv0_init = v0->Py();
495  Double_t pzv0_init = v0->Pz();
496  Double_t massv0_init = v0->MassK0Short();
497  Double_t Ev0_init = sqrt(pxv0_init*pxv0_init+pyv0_init*pyv0_init+pzv0_init*pzv0_init+massv0_init*massv0_init);
498 
499  Double_t pxlc_init = pxpr_init+pxv0_init;
500  Double_t pylc_init = pypr_init+pyv0_init;
501  Double_t pzlc_init = pzpr_init+pzv0_init;
502  Double_t Elc_init = Epr_init+Ev0_init;
503  Double_t lcmass_init = sqrt(Elc_init*Elc_init-pxlc_init*pxlc_init-pylc_init*pylc_init-pzlc_init*pzlc_init);
504 
505  if(lcmass_init<mLcPDG-fProdRoughMassTol || lcmass_init>mLcPDG+fProdRoughMassTol) return kFALSE;
506  if(sqrt(pxlc_init*pxlc_init+pylc_init*pylc_init)<fProdRoughPtMin) return kFALSE;
507 
508  return kTRUE;
509 }
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Double_t fProdV0DaughterTPCClusterMin
V0 Daughter pT min used before object creation.
Bool_t GetUseCombined()
Definition: AliAODPidHF.h:165
AliAODv0 * Getv0() const
void SetNVars(Int_t nVars)
Definition: AliRDHFCuts.h:361
AliRDHFCutsLctopK0sfromAODtracks & operator=(const AliRDHFCutsLctopK0sfromAODtracks &source)
Double_t fProdRoughPtMin
Mass cut for Lc used before object creation.
Double_t fProdTrackPtMin
Flag to check if we use on-the-fly v0.
AliRDHFCuts & operator=(const AliRDHFCuts &source)
Bool_t fUsePID
Definition: AliRDHFCuts.h:388
Double_t fProdV0DaughterEtaRange
Max DCA between V0 daughters used before object creation.
Double_t fProdV0MassTolK0s
Flag for AOD filter Bit used before object creation.
Bool_t SingleV0Cuts(AliAODv0 *v0, AliAODVertex *vert)
Double_t InvMassLctoK0sP() const
Double_t fProdV0CosPointingAngleToPrimVtxMin
Minimum K0s pT used before object creation.
Double_t fProdRoughMassTol
V0 daughter Minimum TPC cluster pT used before object creation.
Double_t fProdV0PtMin
K0s mass selection used before object creation.
Int_t fnVarsForOpt
Definition: AliRDHFCuts.h:383
AliPIDCombined * GetPidCombined() const
Definition: AliAODPidHF.h:161
Double_t fMaxPtCand
minimum pt of the candidate
Definition: AliRDHFCuts.h:410
Double_t CalculateLcCosPAXY(AliAODRecoDecayHF *obj)
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
Bool_t fUseOnTheFlyV0
Threshold used in IsSelectedCombinedPID.
AliAODTrack * GetBachelor() const
AliAODVertex * GetOwnPrimaryVtx() const
Double_t fProdV0DcaDaughtersMax
V0 pointing angle used before object creation.
virtual Int_t IsSelectedPID(AliAODRecoDecayHF *obj)
Int_t MakeRawPid(AliAODTrack *track, Int_t specie)
AliPIDResponse * GetPidResponse() const
Definition: AliAODPidHF.h:160
Float_t * fCutsRD
fnVars*fnPtBins
Definition: AliRDHFCuts.h:386
Bool_t fProdUseAODFilterBit
eta range used before object creation
Double_t fProdV0DaughterPtMin
V0Daughter eta range used before object creation.
void SetVarsForOpt(Int_t nVars, Bool_t *forOpt)
Double_t DecayLengthXY() const
void SetVarNames(Int_t nVars, TString *varNames, Bool_t *isUpperCut)
Bool_t * fVarsForOpt
number of cut vars to be optimized for candidates
Definition: AliRDHFCuts.h:384
Double_t fProdTrackEtaRange
Minimum Track pT used before object creation.
virtual void GetCutVarsForOpt(AliAODRecoDecayHF *d, Float_t *vars, Int_t nvars, Int_t *pdgdaughters)
AliRDHFCutsLctopK0sfromAODtracks(const char *name="CutsLctopK0s")
void SetPtBins(Int_t nPtBinLimits, Float_t *ptBinLimits)
Bool_t SelectWithRoughCuts(AliAODv0 *v0, AliAODTrack *trk1)
AliAODPidHF * fPidHF
enable AOD049 centrality cleanup
Definition: AliRDHFCuts.h:390
Int_t PtBin(Double_t pt) const
Int_t GetGlobalIndex(Int_t iVar, Int_t iPtBin) const
Double_t fMinPtCand
outcome of PID selection
Definition: AliRDHFCuts.h:409
void SetPidResponse(AliPIDResponse *pidResp)
Definition: AliAODPidHF.h:111