AliPhysics  f2694b8 (f2694b8)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
AliRDHFCutsLctoeleLambdafromAODtracks.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->e+Lambda
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 //--------------------------------------------------------------------------
53 AliRDHFCuts(name),
54  fPIDStrategy(kNSigmaCuts),
55  fCombinedPIDThreshold(0.),
56  fUseLambdaPID(kFALSE),
57  fPidObjProton(0),
58  fPidObjPion(0),
59  fUseOnTheFlyV0(kFALSE),
60  fBzkG(0),
61  fProdTrackTPCNclsPIDMin(0),
62  fProdTrackTPCNclsRatioMin(0.0),
63  fProdUseAODFilterBit(kTRUE),
64  fProdAODFilterBit(4),
65  fProdRejectTrackWithShared(kFALSE),
66  fProdV0KinkRejection(kTRUE),
67  fProdV0MassTolLambda(0.01),
68  fProdV0MassTolLambdaRough(0.01),
69  fProdV0PtMin(0.5),
70  fProdV0PtMax(9999.),
71  fProdV0CosPointingAngleToPrimVtxMin(0.99),
72  fProdV0DcaDaughtersMax(1.5),
73  fProdV0DaughterEtaRange(0.8),
74  fProdV0DaughterPtMin(0.0),
75  fProdV0DaughterTPCClusterMin(70),
76  fProdV0DaughterTPCCrossRatioMin(0.0),
77  fProdRfidMinV0(0.6),
78  fProdRfidMaxV0(100.0),
79  fProdDcaV0ToPrimVertexMin(0.),
80  fProdDcaV0PrToPrimVertexMin(0.),
81  fProdDcaV0PiToPrimVertexMin(0.),
82  fProdV0ProperDecayLengthMax(99999.),
83  fProdMassRejK0s(0.),
84  fProdV0EtaMin(-9999.),
85  fProdV0EtaMax(9999.),
86  fProdV0RapMin(-9999.),
87  fProdV0RapMax(9999.),
88  fProdRoughMassTol(0.25),
89  fProdRoughPtMin(0.0),
90  fExcludePionTPC(kFALSE),
91  fExcludeProtonTPC(kFALSE),
92  fExcludeKaonTPC(kFALSE),
93  fExcludenSigmaPionTPC(3.),
94  fExcludenSigmaProtonTPC(3.),
95  fExcludenSigmaKaonTPC(3.),
96  fSigmaElectronTPCMin(-9999.),
97  fSigmaElectronTPCPtDepPar0(-9999.),
98  fSigmaElectronTPCPtDepPar1(-9999.),
99  fSigmaElectronTPCPtDepPar2(0.),
100  fSigmaElectronTPCMax(9999.),
101  fSigmaElectronTOFMin(-9999.),
102  fSigmaElectronTOFMax(9999.),
103  fConversionMassMax(-1.)
104 {
105  //
106  // Default Constructor
107  //
108  for(Int_t i=0;i<3;i++){
109  fPrimVert[i] = 0.;
110  }
111 
112  const Int_t nvars=4;
113  SetNVars(nvars);
114  TString varNames[nvars]={
115  "InvMass [GeV/c2]", //0
116  "cos(Opening angle) [cos(rad)]", //1
117  "dPhiS", //2
118  "dEtaS" //3
119  };
120 
121  Bool_t isUpperCut[nvars]={
122  kTRUE, //0
123  kFALSE, //1
124  kFALSE, //2
125  kFALSE //3
126  };
127  SetVarNames(nvars,varNames,isUpperCut);
128  Bool_t forOpt[nvars]={
129  kTRUE, //0
130  kTRUE, //1
131  kTRUE, //2
132  kTRUE, //3
133  };
134  SetVarsForOpt(nvars,forOpt);
135 
136  Float_t limits[2]={0,999999999.};
137  SetPtBins(2,limits);
138 }
139 //--------------------------------------------------------------------------
141  AliRDHFCuts(source),
142  fPIDStrategy(source.fPIDStrategy),
143  fCombinedPIDThreshold(source.fCombinedPIDThreshold),
144  fUseLambdaPID(source.fUseLambdaPID),
145  fPidObjProton(source.fPidObjProton),
146  fPidObjPion(source.fPidObjPion),
147  fUseOnTheFlyV0(source.fUseOnTheFlyV0),
148  fBzkG(source.fBzkG),
149  fProdTrackTPCNclsPIDMin(source.fProdTrackTPCNclsPIDMin),
150  fProdTrackTPCNclsRatioMin(source.fProdTrackTPCNclsRatioMin),
151  fProdUseAODFilterBit(source.fProdUseAODFilterBit),
152  fProdAODFilterBit(source.fProdAODFilterBit),
153  fProdRejectTrackWithShared(source.fProdRejectTrackWithShared),
154  fProdV0KinkRejection(source.fProdV0KinkRejection),
155  fProdV0MassTolLambda(source.fProdV0MassTolLambda),
156  fProdV0MassTolLambdaRough(source.fProdV0MassTolLambdaRough),
157  fProdV0PtMin(source.fProdV0PtMin),
158  fProdV0PtMax(source.fProdV0PtMax),
159  fProdV0CosPointingAngleToPrimVtxMin(source.fProdV0CosPointingAngleToPrimVtxMin),
160  fProdV0DcaDaughtersMax(source.fProdV0DcaDaughtersMax),
161  fProdV0DaughterEtaRange(source.fProdV0DaughterEtaRange),
162  fProdV0DaughterPtMin(source.fProdV0DaughterPtMin),
163  fProdV0DaughterTPCClusterMin(source.fProdV0DaughterTPCClusterMin),
164  fProdV0DaughterTPCCrossRatioMin(source.fProdV0DaughterTPCCrossRatioMin),
165  fProdRfidMinV0(source.fProdRfidMinV0),
166  fProdRfidMaxV0(source.fProdRfidMaxV0),
167  fProdDcaV0ToPrimVertexMin(source.fProdDcaV0ToPrimVertexMin),
168  fProdDcaV0PrToPrimVertexMin(source.fProdDcaV0PrToPrimVertexMin),
169  fProdDcaV0PiToPrimVertexMin(source.fProdDcaV0PiToPrimVertexMin),
170  fProdV0ProperDecayLengthMax(source.fProdV0ProperDecayLengthMax),
171  fProdMassRejK0s(source.fProdMassRejK0s),
172  fProdV0EtaMin(source.fProdV0EtaMin),
173  fProdV0EtaMax(source.fProdV0EtaMax),
174  fProdV0RapMin(source.fProdV0RapMin),
175  fProdV0RapMax(source.fProdV0RapMax),
176  fProdRoughMassTol(source.fProdRoughMassTol),
177  fProdRoughPtMin(source.fProdRoughPtMin),
178  fExcludePionTPC(source.fExcludePionTPC),
179  fExcludeProtonTPC(source.fExcludeProtonTPC),
180  fExcludeKaonTPC(source.fExcludeKaonTPC),
181  fExcludenSigmaPionTPC(source.fExcludenSigmaPionTPC),
182  fExcludenSigmaProtonTPC(source.fExcludenSigmaProtonTPC),
183  fExcludenSigmaKaonTPC(source.fExcludenSigmaKaonTPC),
184  fSigmaElectronTPCMin(source.fSigmaElectronTPCMin),
185  fSigmaElectronTPCPtDepPar0(source.fSigmaElectronTPCPtDepPar0),
186  fSigmaElectronTPCPtDepPar1(source.fSigmaElectronTPCPtDepPar1),
187  fSigmaElectronTPCPtDepPar2(source.fSigmaElectronTPCPtDepPar2),
188  fSigmaElectronTPCMax(source.fSigmaElectronTPCMax),
189  fSigmaElectronTOFMin(source.fSigmaElectronTOFMin),
190  fSigmaElectronTOFMax(source.fSigmaElectronTOFMax),
191  fConversionMassMax(source.fConversionMassMax)
192 {
193  //
194  // Copy constructor
195  //
196  for(Int_t i=0;i<3;i++){
197  fPrimVert[i] = source.fPrimVert[i];
198  }
199 }
200 //--------------------------------------------------------------------------
202 {
203  //
204  // assignment operator
205  //
206 
207  if (this != &source) {
208  AliRDHFCuts::operator=(source);
209  }
210 
211  fPIDStrategy = source.fPIDStrategy;
213  fUseLambdaPID = source.fUseLambdaPID;
214  fPidObjProton = source.fPidObjProton;
215  fPidObjPion = source.fPidObjPion;
217  fBzkG = source.fBzkG;
226  fProdV0PtMin = source.fProdV0PtMin;
227  fProdV0PtMax = source.fProdV0PtMax;
241  fProdV0EtaMin = source.fProdV0EtaMin;
242  fProdV0EtaMax = source.fProdV0EtaMax;
243  fProdV0RapMin = source.fProdV0RapMin;
244  fProdV0RapMax = source.fProdV0RapMax;
261 
262  for(Int_t i=0;i<3;i++){
263  fPrimVert[i] = source.fPrimVert[i];
264  }
265 
266  return *this;
267 }
268 
269 //---------------------------------------------------------------------------
271  //
272  // Default Destructor
273  //
274 
275 }
276 
277 //---------------------------------------------------------------------------
278 void AliRDHFCutsLctoeleLambdafromAODtracks::GetCutVarsForOpt(AliAODRecoDecayHF *d,Float_t *vars,Int_t nvars,Int_t *pdgdaughters) {
279  //
280  // Fills in vars the values of the variables
281  //
282 
283  if (pdgdaughters[0]==-9999) return; // dummy
284 
286  if(!dd){
287  AliError("No AliAODRecoCascadeHF object found\n");
288  return;
289  }
290 
291  if (nvars!=fnVarsForOpt) {
292  AliError("Cut object seems to have the wrong number of variables\n");
293  return;
294  }
295 
296  //Double_t ptD=d->Pt();
297  //Int_t ptbin=PtBin(ptD);
298  Int_t iter=-1;
299 
300 
301  if(fVarsForOpt[0]){
302  iter++;
303  UInt_t pdgdg[2]={11,3122};
304  vars[iter]= dd->InvMass(2,pdgdg);
305  }
306  if(fVarsForOpt[1]){
307  iter++;
308  Double_t v0px = dd->PxProng(1);
309  Double_t v0py = dd->PyProng(1);
310  Double_t v0pz = dd->PzProng(1);
311  Double_t epx = dd->PxProng(0);
312  Double_t epy = dd->PyProng(0);
313  Double_t epz = dd->PzProng(0);
314  vars[iter]= (v0px*epx+v0py*epy+v0pz*epz)/sqrt(v0px*v0px+v0py*v0py+v0pz*v0pz)/sqrt(epx*epx+epy*epy+epz*epz);
315  }
316 
317  return;
318 }
319 
320 //---------------------------------------------------------------------------
321 Int_t AliRDHFCutsLctoeleLambdafromAODtracks::IsSelected(TObject* obj, Int_t selectionLevel) {
322  //
323  // Apply selection
324  //
325 
326  if (!fCutsRD) {
327  AliFatal("Cut matrix not inizialized. Exit...");
328  return 0;
329  }
330 
332  if(!d){
333  AliDebug(2,"AliAODRecoCascadeHF null");
334  return 0;
335  }
336 
337  Double_t ptD=d->Pt();
338  if(ptD<fMinPtCand) return 0;
339  if(ptD>fMaxPtCand) return 0;
340 
341  if (selectionLevel==AliRDHFCuts::kAll ||
342  selectionLevel==AliRDHFCuts::kTracks) {
343  //Performed in production stage
344  }
345 
346  Int_t returnvalueCuts=1;
347  // selection on candidate
348  if (selectionLevel==AliRDHFCuts::kAll ||
349  selectionLevel==AliRDHFCuts::kCandidate) {
350 
351  Double_t pt=d->Pt();
352  Int_t ptbin=PtBin(pt);
353  if (ptbin==-1) {
354  return 0;
355  }
356  Bool_t okcand=kTRUE;
357 
358  Double_t mlamPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
359  UInt_t pdgdg[2]={11,3122};
360  Double_t InvMassEleLambda = d->InvMass(2,pdgdg);
361 
362  Double_t v0px = d->PxProng(1);
363  Double_t v0py = d->PyProng(1);
364  Double_t v0pz = d->PzProng(1);
365  Double_t epx = d->PxProng(0);
366  Double_t epy = d->PyProng(0);
367  Double_t epz = d->PzProng(0);
368  Double_t cosoa = (v0px*epx+v0py*epy+v0pz*epz)/sqrt(v0px*v0px+v0py*v0py+v0pz*v0pz)/sqrt(epx*epx+epy*epy+epz*epz);
369 
370  Double_t dphis_e_pr, detas_e_pr, dphis_e_pi, detas_e_pi;
371  dphis_e_pr = 9999.;
372  detas_e_pr = 9999.;
373  dphis_e_pi = 9999.;
374  detas_e_pi = 9999.;
375  if(fCutsRD[GetGlobalIndex(2,ptbin)]>0 || fCutsRD[GetGlobalIndex(3,ptbin)]>0){
376  AliAODTrack *trke = (AliAODTrack*)d->GetDaughter(0);
377  AliAODv0 *v0 = (AliAODv0*)d->GetDaughter(1);
378  if(trke && v0){
379  Bool_t isparticle = kTRUE;
380  if(TMath::Abs(v0->MassAntiLambda()-mlamPDG)<fProdV0MassTolLambdaRough) isparticle = kFALSE;
381  AliAODTrack *cprtrk = 0;
382  AliAODTrack *cpitrk = 0;
383  if(isparticle){
384  cprtrk = (AliAODTrack*)v0->GetDaughter(0);
385  cpitrk = (AliAODTrack*)v0->GetDaughter(1);
386  }else{
387  cprtrk = (AliAODTrack*)v0->GetDaughter(1);
388  cpitrk = (AliAODTrack*)v0->GetDaughter(0);
389  }
390  if(cprtrk && cpitrk)
391  GetdPhiSdEtaSR125(trke,cprtrk,cpitrk,fBzkG,fPrimVert, dphis_e_pr,detas_e_pr,dphis_e_pi,detas_e_pi);
392  }
393  }
394 
395  if(InvMassEleLambda > fCutsRD[GetGlobalIndex(0,ptbin)])
396  {
397  okcand = kFALSE;
398  }
399  if(cosoa < fCutsRD[GetGlobalIndex(1,ptbin)])
400  {
401  okcand = kFALSE;
402  }
403  if(fabs(dphis_e_pr) < fCutsRD[GetGlobalIndex(2,ptbin)] && fabs(detas_e_pr) < fCutsRD[GetGlobalIndex(3,ptbin)])
404  {
405  okcand = kFALSE;
406  }
407  if(fabs(dphis_e_pi) < fCutsRD[GetGlobalIndex(2,ptbin)] && fabs(detas_e_pi) < fCutsRD[GetGlobalIndex(3,ptbin)])
408  {
409  okcand = kFALSE;
410  }
411 
412  if(!okcand) return 0;
413  returnvalueCuts = 1;
414  }
415 
416  Int_t returnvaluePID=1;
417  if(selectionLevel==AliRDHFCuts::kAll ||
418  selectionLevel==AliRDHFCuts::kCandidate||
419  selectionLevel==AliRDHFCuts::kPID) {
420  //Not used
421  }
422 
423  Int_t returnvalue = 0;
424  if(returnvalueCuts==1 && returnvaluePID==1) returnvalue=1;
425 
426  return returnvalue;
427 }
428 
429 //---------------------------------------------------------------------------
431 {
432  //
433  // IsSelectedPID (not used)
434  //
435 
436  if(!fUsePID || !obj) return 1;
437 
439  AliAODTrack *part = dd->GetBachelor();
440 
441  Int_t returnvalue=1;
442 
443  if(fPidHF->GetPidResponse()==0x0){
444  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
445  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
446  AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
447  fPidHF->SetPidResponse(pidResp);
448  }
449 
450  Int_t isElectron=fPidHF->MakeRawPid(part,0);
451  if(isElectron<1) returnvalue = 0;
452 
453  return returnvalue;
454 }
455 
456 //---------------------------------------------------------------------------
458  //
459  // IsSelectedCombinedPID (not used)
460  //
461 
462  if(!fUsePID || !obj) {return 1;}
463 
465  AliAODTrack *part = dd->GetBachelor();
466  if(!part) return 0;
467 
468  Int_t returnvalue=1;
469 
470  return returnvalue;
471 }
472 
473 //________________________________________________________________________
474 Bool_t AliRDHFCutsLctoeleLambdafromAODtracks::SingleTrkCuts(AliAODTrack *trk, AliAODTrack *trkpid, AliAODVertex *primVert)
475 {
476  //
477  // Single Track Cut to be applied before object creation
478  //
479 
480  //if(trk->GetStatus()&AliESDtrack::kITSpureSA) return kFALSE;
481  //if(!(trk->GetStatus()&AliESDtrack::kITSin)) return kFALSE;
482  //if(fProdUseAODFilterBit && !trk->TestFilterMask(BIT(fProdAODFilterBit))) return kFALSE;
483  if(fTrackCuts){
484  if(fProdAODFilterBit==7){
485  Float_t ptmin, ptmax, etamin, etamax;
486  fTrackCuts->GetPtRange(ptmin,ptmax);
487  fTrackCuts->GetEtaRange(etamin,etamax);
488  if(trk->Pt()<ptmin || trk->Pt()>ptmax) return kFALSE;
489  if(trk->Eta()<etamin || trk->Eta()>etamax) return kFALSE;
490  }else{
491  Double_t pos[3]; primVert->GetXYZ(pos);
492  Double_t cov[6]; primVert->GetCovarianceMatrix(cov);
493  const AliESDVertex vESD(pos,cov,100.,100);
494  if(!IsDaughterSelected(trk,&vESD,fTrackCuts)) return kFALSE;
495  }
496  }
497 
498  if(trkpid->GetTPCsignalN()<fProdTrackTPCNclsPIDMin) return kFALSE;
499  if(trk->GetTPCNclsF()>0){
500  Float_t tpcratio = (Float_t)trk->GetTPCncls()/(Float_t)trk->GetTPCNclsF();
501  if(tpcratio<fProdTrackTPCNclsRatioMin) return kFALSE;
502  }
503 
505  const TBits sharedMap = trk->GetTPCSharedMap();
506  if((sharedMap.CountBits()) >= 1){
507  return kFALSE;
508  }
509  }
510 
511  if(fUsePID)
512  {
513  if(fPidHF->GetPidResponse()==0x0){
514  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
515  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
516  AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
517  fPidHF->SetPidResponse(pidResp);
518  }
519 
520  switch(fPIDStrategy){
521  case kNSigmaCuts:
522  return IsSelectedeID(trkpid);
523  break;
525  return IsSelectedCustomizedeID(trkpid);
526  break;
528  return IsSelectedCustomizedPtDepeID(trk,trkpid);
529  break;
530  case kCombinedCuts:
531  return IsSelectedCombinedeID(trkpid);
532  break;
533  }
534 
535  }
536 
537  return kTRUE;
538 }
539 //________________________________________________________________________
540 Bool_t AliRDHFCutsLctoeleLambdafromAODtracks::SingleTrkCutsNoPID(AliAODTrack *trk, AliAODTrack *trkpid, AliAODVertex *primVert)
541 {
542  //
543  // Single Track Cut to be applied before object creation
544  //
545 
546  //if(trk->GetStatus()&AliESDtrack::kITSpureSA) return kFALSE;
547  //if(!(trk->GetStatus()&AliESDtrack::kITSin)) return kFALSE;
548  //if(fProdUseAODFilterBit && !trk->TestFilterMask(BIT(4))) return kFALSE;
549  if(fTrackCuts){
550  if(fProdAODFilterBit==7){
551  Float_t ptmin, ptmax, etamin, etamax;
552  fTrackCuts->GetPtRange(ptmin,ptmax);
553  fTrackCuts->GetEtaRange(etamin,etamax);
554  if(trk->Pt()<ptmin || trk->Pt()>ptmax) return kFALSE;
555  if(trk->Eta()<etamin || trk->Eta()>etamax) return kFALSE;
556  }else{
557  Double_t pos[3]; primVert->GetXYZ(pos);
558  Double_t cov[6]; primVert->GetCovarianceMatrix(cov);
559  const AliESDVertex vESD(pos,cov,100.,100);
560  if(!IsDaughterSelected(trk,&vESD,fTrackCuts)) return kFALSE;
561  }
562  }
563 
564  if(trkpid->GetTPCsignalN()<fProdTrackTPCNclsPIDMin) return kFALSE;
565  if(trk->GetTPCNclsF()>0){
566  Float_t tpcratio = (Float_t)trk->GetTPCncls()/(Float_t)trk->GetTPCNclsF();
567  if(tpcratio<fProdTrackTPCNclsRatioMin) return kFALSE;
568  }
569 
571  const TBits sharedMap = trk->GetTPCSharedMap();
572  if((sharedMap.CountBits()) >= 1){
573  return kFALSE;
574  }
575  }
576 
577  return kTRUE;
578 }
579 //________________________________________________________________________
581 {
582  //
583  // electron ID first shot
584  //
585 
586  Double_t nSigmaPion = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kPion);
587  if(fExcludePionTPC){
588  if(TMath::Abs(nSigmaPion)<fExcludenSigmaPionTPC){
589  return kFALSE;
590  }
591  }
592 
593  Double_t nSigmaProton = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kProton);
594  if(fExcludeProtonTPC){
595  if(TMath::Abs(nSigmaProton)<fExcludenSigmaProtonTPC){
596  return kFALSE;
597  }
598  }
599 
600  Double_t nSigmaKaon = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kKaon);
601  if(fExcludeKaonTPC){
602  if(TMath::Abs(nSigmaKaon)<fExcludenSigmaKaonTPC){
603  return kFALSE;
604  }
605  }
606 
607  Int_t isElectron=fPidHF->MakeRawPid(trk,0);
608  if(isElectron<1) return kFALSE;
609 
610  return kTRUE;
611 }
612 //________________________________________________________________________
614 {
615  //
616  // electron ID first shot
617  //
618 
619  Double_t nSigmaPion = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kPion);
620  if(fExcludePionTPC){
621  if(TMath::Abs(nSigmaPion)<fExcludenSigmaPionTPC){
622  return kFALSE;
623  }
624  }
625 
626  Double_t nSigmaProton = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kProton);
627  if(fExcludeProtonTPC){
628  if(TMath::Abs(nSigmaProton)<fExcludenSigmaProtonTPC){
629  return kFALSE;
630  }
631  }
632 
633  Double_t nSigmaKaon = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kKaon);
634  if(fExcludeKaonTPC){
635  if(TMath::Abs(nSigmaKaon)<fExcludenSigmaKaonTPC){
636  return kFALSE;
637  }
638  }
639 
640  Double_t nSigmaTPCele = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trk,AliPID::kElectron);
641  Double_t nSigmaTOFele = fPidHF->GetPidResponse()->NumberOfSigmasTOF(trk,AliPID::kElectron);
642 
643  if(nSigmaTPCele<fSigmaElectronTPCMin) return kFALSE;
644  if(nSigmaTPCele>fSigmaElectronTPCMax) return kFALSE;
645  if(nSigmaTOFele<fSigmaElectronTOFMin) return kFALSE;
646  if(nSigmaTOFele>fSigmaElectronTOFMax) return kFALSE;
647 
648  return kTRUE;
649 }
650 //________________________________________________________________________
651 Bool_t AliRDHFCutsLctoeleLambdafromAODtracks::IsSelectedCustomizedPtDepeID(AliAODTrack *trk, AliAODTrack *trkpid)
652 {
653  //
654  // electron ID first shot
655  //
656 
657  Double_t nSigmaPion = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trkpid,AliPID::kPion);
658  if(fExcludePionTPC){
659  if(TMath::Abs(nSigmaPion)<fExcludenSigmaPionTPC){
660  return kFALSE;
661  }
662  }
663 
664  Double_t nSigmaProton = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trkpid,AliPID::kProton);
665  if(fExcludeProtonTPC){
666  if(TMath::Abs(nSigmaProton)<fExcludenSigmaProtonTPC){
667  return kFALSE;
668  }
669  }
670 
671  Double_t nSigmaKaon = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trkpid,AliPID::kKaon);
672  if(fExcludeKaonTPC){
673  if(TMath::Abs(nSigmaKaon)<fExcludenSigmaKaonTPC){
674  return kFALSE;
675  }
676  }
677 
678  Double_t nSigmaTPCele = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trkpid,AliPID::kElectron);
679  Double_t nSigmaTOFele = fPidHF->GetPidResponse()->NumberOfSigmasTOF(trkpid,AliPID::kElectron);
680 
681  if(fabs(fSigmaElectronTOFMin)<999.|| fabs(fSigmaElectronTOFMax)<999.)
682  {
683  if(nSigmaTOFele<fSigmaElectronTOFMin) return kFALSE;
684  if(nSigmaTOFele>fSigmaElectronTOFMax) return kFALSE;
685  }
686 
687  Double_t pte = trk->Pt();
690  if(nSigmaTPCele<nsigmamin) return kFALSE;
691  if(nSigmaTPCele>fSigmaElectronTPCMax) return kFALSE;
692 
693  return kTRUE;
694 }
695 //________________________________________________________________________
697 {
698  //
699  // electron ID Basyian not implemented
700  //
701 
702  return kTRUE;
703 }
704 
705 //________________________________________________________________________
706 Bool_t AliRDHFCutsLctoeleLambdafromAODtracks::SingleV0Cuts(AliAODv0 *v0, AliAODVertex *primVert)
707 {
708  //
709  // Single V0 Cut to be applied before object creation
710  //
711 
712  Bool_t onFlyV0 = v0->GetOnFlyStatus(); // on-the-flight V0s
713  if ( onFlyV0 && !fUseOnTheFlyV0 ) return kFALSE;
714  if(!v0) return kFALSE;
715  if(!(v0->GetSecondaryVtx())) return kFALSE;
716 
717  AliAODTrack *cptrack = (AliAODTrack*)(v0->GetDaughter(0));
718  AliAODTrack *cntrack = (AliAODTrack*)(v0->GetDaughter(1));
719  if(!cptrack || !cntrack) return kFALSE;
720  if(cptrack->Charge()<0 && cntrack->Charge()>0){
721  //In case sign is wrong
722  cptrack = (AliAODTrack*)(v0->GetDaughter(1));
723  cntrack = (AliAODTrack*)(v0->GetDaughter(0));
724  }
725 
726  if ( cptrack->Charge() == cntrack->Charge() ) return kFALSE;
727  if(!(cptrack->GetStatus() & AliESDtrack::kTPCrefit) ||
728  !(cntrack->GetStatus() & AliESDtrack::kTPCrefit)) return kFALSE;
729  AliAODVertex *maybeKinkPos = (AliAODVertex*)cptrack->GetProdVertex();
730  AliAODVertex *maybeKinkNeg = (AliAODVertex*)cntrack->GetProdVertex();
731  if (fProdV0KinkRejection && (maybeKinkPos->GetType()==AliAODVertex::kKink || maybeKinkNeg->GetType()==AliAODVertex::kKink))
732  return kFALSE;
733 
734  if ( ( ( cptrack->GetTPCClusterInfo(2,1) ) < (Float_t)fProdV0DaughterTPCClusterMin ) ||
735  ( ( cntrack->GetTPCClusterInfo(2,1) ) < (Float_t)fProdV0DaughterTPCClusterMin) ) return kFALSE;
736 
737 
738  if((cptrack->GetTPCNclsF()>0)&&(cptrack->GetTPCClusterInfo(2,1)/cptrack->GetTPCNclsF()<fProdV0DaughterTPCCrossRatioMin)) return kFALSE;
739  if((cntrack->GetTPCNclsF()>0)&&(cntrack->GetTPCClusterInfo(2,1)/cntrack->GetTPCNclsF()<fProdV0DaughterTPCCrossRatioMin)) return kFALSE;
740 
741  Double_t massLambda = v0->MassLambda();
742  Double_t massAntiLambda = v0->MassAntiLambda();
743  Double_t mlamPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
744  Double_t mk0sPDG = TDatabasePDG::Instance()->GetParticle(310)->Mass();
745  if(!(fabs(massAntiLambda-mlamPDG)<fProdV0MassTolLambdaRough) && !(fabs(massLambda-mlamPDG)<fProdV0MassTolLambdaRough)) return kFALSE;
746 
747  Double_t massK0s = v0->MassK0Short();
748  if(TMath::Abs(massK0s-mk0sPDG)<fProdMassRejK0s)
749  return kFALSE;
750 
751  Bool_t isparticle = kTRUE;
752  if(TMath::Abs(massAntiLambda-mlamPDG)<fProdV0MassTolLambdaRough) isparticle = kFALSE;
753 
754 
755  if(TMath::Abs(v0->DcaV0Daughters())>fProdV0DcaDaughtersMax) return kFALSE;
756  Double_t posVtx[3] = {0.,0.,0.};
757  primVert->GetXYZ(posVtx);
758  Double_t cospav0 = v0->CosPointingAngle(posVtx);
759  if(cospav0<fProdV0CosPointingAngleToPrimVtxMin) return kFALSE;
760  if(v0->Pt()<fProdV0PtMin) return kFALSE;
761  if(v0->Pt()>fProdV0PtMax) return kFALSE;
762  if(fabs(cptrack->Eta())>fProdV0DaughterEtaRange) return kFALSE;
763  if(fabs(cntrack->Eta())>fProdV0DaughterEtaRange) return kFALSE;
764  if(cptrack->Pt()<fProdV0DaughterPtMin) return kFALSE;
765  if(cntrack->Pt()<fProdV0DaughterPtMin) return kFALSE;
766 
767  Double_t lDcaV0ToPrimVertex = v0->DcaV0ToPrimVertex();
768  Double_t lDcaPosToPrimVertex = v0->DcaPosToPrimVertex();
769  Double_t lDcaNegToPrimVertex = v0->DcaNegToPrimVertex();
770  if(lDcaV0ToPrimVertex < fProdDcaV0ToPrimVertexMin) return kFALSE;
771  if(isparticle){
772  if(lDcaPosToPrimVertex < fProdDcaV0PrToPrimVertexMin) return kFALSE;
773  if(lDcaNegToPrimVertex < fProdDcaV0PiToPrimVertexMin) return kFALSE;
774  }else{
775  if(lDcaPosToPrimVertex < fProdDcaV0PiToPrimVertexMin) return kFALSE;
776  if(lDcaNegToPrimVertex < fProdDcaV0PrToPrimVertexMin) return kFALSE;
777  }
778  Double_t lPosV0[3];
779  lPosV0[0] = v0->DecayVertexV0X();
780  lPosV0[1] = v0->DecayVertexV0Y();
781  lPosV0[2] = v0->DecayVertexV0Z();
782  Double_t decayvertV0 = TMath::Sqrt(lPosV0[0]*lPosV0[0]+lPosV0[1]*lPosV0[1]);
783 
784  if(decayvertV0<fProdRfidMinV0 || decayvertV0>fProdRfidMaxV0) return kFALSE;
785 
786  Double_t ptotlam = TMath::Sqrt(pow(v0->Px(),2)+pow(v0->Py(),2)+pow(v0->Pz(),2));
787  Double_t properdl = v0->DecayLengthV0(posVtx)*mlamPDG/ptotlam;
788  if(properdl>fProdV0ProperDecayLengthMax) return kFALSE;
789 
790 
791  if(fUseLambdaPID)
792  {
793  if(fPidObjProton->GetPidResponse()==0x0){
794  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
795  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
796  AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
797  fPidObjProton->SetPidResponse(pidResp);
798  }
799  if(fPidObjPion->GetPidResponse()==0x0){
800  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
801  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
802  AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
803  fPidObjPion->SetPidResponse(pidResp);
804  }
805 
806  Int_t isProton= 1;
807  Int_t isPion= 1;
808  Double_t nsigmatpc_proton = fPidObjProton->GetSigma(0);
809  Double_t nsigmatpc_pion = fPidObjPion->GetSigma(0);
810  Double_t nsigmatof_proton = fPidObjProton->GetSigma(3);
811  Double_t nsigmatof_pion = fPidObjPion->GetSigma(3);
812 
813  if(isparticle){
814  Double_t nSigmaTPCpr = fPidObjProton->GetPidResponse()->NumberOfSigmasTPC(cptrack,AliPID::kProton);
815  Double_t nSigmaTPCpi = fPidObjPion->GetPidResponse()->NumberOfSigmasTPC(cntrack,AliPID::kPion);
816  Double_t nSigmaTOFpr = fPidObjProton->GetPidResponse()->NumberOfSigmasTOF(cptrack,AliPID::kProton);
817  Double_t nSigmaTOFpi = fPidObjPion->GetPidResponse()->NumberOfSigmasTOF(cntrack,AliPID::kPion);
818  if(fabs(nSigmaTPCpr)>nsigmatpc_proton) isProton = 0;
819  if(fabs(nSigmaTPCpi)>nsigmatpc_pion) isPion = 0;
820  if(nsigmatof_proton>0.01 && nsigmatof_proton<999.){
821  if(fabs(nSigmaTOFpr)>nsigmatof_proton) isProton = 0;
822  }
823  if(nsigmatof_pion>0.01 && nsigmatof_pion<999.){
824  if(fabs(nSigmaTOFpi)>nsigmatof_pion) isPion = 0;
825  }
826  }else{
827  Double_t nSigmaTPCpr = fPidObjProton->GetPidResponse()->NumberOfSigmasTPC(cntrack,AliPID::kProton);
828  Double_t nSigmaTPCpi = fPidObjPion->GetPidResponse()->NumberOfSigmasTPC(cptrack,AliPID::kPion);
829  Double_t nSigmaTOFpr = fPidObjProton->GetPidResponse()->NumberOfSigmasTOF(cntrack,AliPID::kProton);
830  Double_t nSigmaTOFpi = fPidObjPion->GetPidResponse()->NumberOfSigmasTOF(cptrack,AliPID::kPion);
831  if(fabs(nSigmaTPCpr)>nsigmatpc_proton) isProton = 0;
832  if(fabs(nSigmaTPCpi)>nsigmatpc_pion) isPion = 0;
833  if(nsigmatof_proton>0.01 && nsigmatof_proton<999.){
834  if(fabs(nSigmaTOFpr)>nsigmatof_proton) isProton = 0;
835  }
836  if(nsigmatof_pion>0.01 && nsigmatof_pion<999.){
837  if(fabs(nSigmaTOFpi)>nsigmatof_pion) isPion = 0;
838  }
839  }
840  if(isProton<1) return kFALSE;
841  if(isPion<1) return kFALSE;
842  }
843 
844  Double_t RapLambda = v0->RapLambda();
845  if(RapLambda<fProdV0RapMin || RapLambda>fProdV0RapMax) return kFALSE;
846 
847  Double_t EtaLambda = v0->PseudoRapV0();
848  if(EtaLambda<fProdV0EtaMin || EtaLambda>fProdV0EtaMax) return kFALSE;
849 
851  const TBits sharedMap1 = cptrack->GetTPCSharedMap();
852  const TBits sharedMap2 = cntrack->GetTPCSharedMap();
853  if((sharedMap1.CountBits() >= 1) ||
854  (sharedMap2.CountBits() >= 1))
855  {
856  return kFALSE;
857  }
858  }
859 
860  return kTRUE;
861 }
862 
863 //________________________________________________________________________
864 Bool_t AliRDHFCutsLctoeleLambdafromAODtracks::SelectWithRoughCuts(AliAODv0 *v0, AliAODTrack *part)
865 {
866  //
867  // Mass and pT Cut to be applied before object creation
868  // Not used now
869  //
870  if(!v0) return kFALSE;
871  if(!part) return kFALSE;
872 
873  return kTRUE;
874 
875 }
876 
877 //________________________________________________________________________
879 {
880  Double_t mLPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
881  Double_t massL = v0->MassLambda();
882  if(TMath::Abs(massL-mLPDG)>fProdV0MassTolLambdaRough)
883  massL = v0->MassAntiLambda();
884 
885  if(TMath::Abs(massL-mLPDG)<fProdV0MassTolLambda)
886  return kTRUE;
887  return kFALSE;
888 }
889 
890 //________________________________________________________________________
892 {
893  Double_t mLPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
894  Double_t massL = v0->M();
895  if(TMath::Abs(massL-mLPDG)<fProdV0MassTolLambda)
896  return kTRUE;
897  return kFALSE;
898 }
899 
900 //________________________________________________________________________
902 {
903  Double_t mLPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
904  Double_t massL = v0->MassLambda();
905  if(TMath::Abs(massL-mLPDG)>fProdV0MassTolLambdaRough)
906  massL = v0->MassAntiLambda();
907 
908  Bool_t issideband = kFALSE;
909  if((massL-mLPDG)>fProdV0MassTolLambdaRough-fProdV0MassTolLambda) issideband = kTRUE;
910  if((massL-mLPDG)<-fProdV0MassTolLambdaRough+fProdV0MassTolLambda) issideband = kTRUE;
911  return issideband;
912 }
913 
914 //________________________________________________________________________
916 {
917  Double_t mLPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
918  Double_t massL = v0->M();
919  Bool_t issideband = kFALSE;
920  if((massL-mLPDG)>fProdV0MassTolLambdaRough-fProdV0MassTolLambda) issideband = kTRUE;
921  if((massL-mLPDG)<-fProdV0MassTolLambdaRough+fProdV0MassTolLambda) issideband = kTRUE;
922  return issideband;
923 }
924 
925 //________________________________________________________________________
926 Bool_t AliRDHFCutsLctoeleLambdafromAODtracks::TagConversions(AliAODTrack *etrk, Int_t *id2index, AliAODEvent *evt, Int_t ntrk, Double_t &minmass)
927 {
928  //
929  // Tag conversion electron tracks
930  //
931  if(fConversionMassMax<0.) return kFALSE;
932 
933  Bool_t isconv = kFALSE;
934  minmass = 9999.;
935  Int_t trkid = etrk->GetID();
936 
937  Double_t px1 = etrk->Px();
938  Double_t py1 = etrk->Py();
939  Double_t pz1 = etrk->Pz();
940  Double_t E1 = sqrt(px1*px1+py1*py1+pz1*pz1+0.000511*0.000511);
941 
942  for(Int_t it=0;it<ntrk;it++){
943  AliAODTrack *trk2 = (AliAODTrack*) evt->GetTrack(it);
944  if(!trk2) continue;
945  Int_t trkid2 = trk2->GetID();
946  if(abs(trkid)==abs(trkid2)) continue;
947  if(etrk->Charge()*trk2->Charge()>0) continue;
948  if(fProdAODFilterBit==7){
949  if(!trk2->TestFilterBit(BIT(fProdAODFilterBit))) continue;
950  }else{
951  if(!trk2->TestFilterMask(BIT(fProdAODFilterBit))) continue;
952  }
953 
954  Double_t nSigmaTPCele = 9999.;
955  if(fProdAODFilterBit==7){
956  if(-trkid2-1>=19000) continue;
957  if(-trkid2-1<0) continue;
958  Int_t index = id2index[-trkid2-1];
959  AliAODTrack *partpid = (AliAODTrack*)evt->GetTrack(index);
960  nSigmaTPCele = fPidHF->GetPidResponse()->NumberOfSigmasTPC(partpid,AliPID::kElectron);
961  }else{
962  nSigmaTPCele = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trk2,AliPID::kElectron);
963  }
964  if(fabs(nSigmaTPCele)>5.) continue;
965 
966  Double_t px2 = trk2->Px();
967  Double_t py2 = trk2->Py();
968  Double_t pz2 = trk2->Pz();
969  Double_t E2 = sqrt(px2*px2+py2*py2+pz2*pz2+0.000511*0.000511);
970 
971  Double_t mass = sqrt(pow(E1+E2,2)-pow(px1+px2,2)-pow(py1+py2,2)-pow(pz1+pz2,2));
972  //Double_t mass = CalculatePhotonMass(etrk,trk2);
973  if(mass<minmass) minmass = mass;
974  }
975 
976  if(minmass<fConversionMassMax) isconv = kTRUE;
977 
978  return isconv;
979 }
980 
981 //________________________________________________________________________
982 Bool_t AliRDHFCutsLctoeleLambdafromAODtracks::TagConversionsSameSign(AliAODTrack *etrk, Int_t *id2index, AliAODEvent *evt, Int_t ntrk, Double_t &minmass)
983 {
984  //
985  // Tag conversion electron tracks
986  //
987  if(fConversionMassMax<0.) return kFALSE;
988 
989  Bool_t isconv = kFALSE;
990  minmass = 9999.;
991 
992  Int_t trkid = etrk->GetID();
993  Double_t px1 = etrk->Px();
994  Double_t py1 = etrk->Py();
995  Double_t pz1 = etrk->Pz();
996  Double_t E1 = sqrt(px1*px1+py1*py1+pz1*pz1+0.000511*0.000511);
997 
998  for(Int_t it=0;it<ntrk;it++){
999  AliAODTrack *trk2 = (AliAODTrack*) evt->GetTrack(it);
1000  if(!trk2) continue;
1001  Int_t trkid2 = trk2->GetID();
1002  if(abs(trkid)==abs(trkid2)) continue;
1003  if(etrk->Charge()*trk2->Charge()<0) continue;
1004  if(fProdAODFilterBit==7){
1005  if(!trk2->TestFilterBit(BIT(fProdAODFilterBit))) continue;
1006  }else{
1007  if(!trk2->TestFilterMask(BIT(fProdAODFilterBit))) continue;
1008  }
1009 
1010  Double_t nSigmaTPCele = 9999.;
1011  if(fProdAODFilterBit==7){
1012  if(-trkid2-1>=19000) continue;
1013  if(-trkid2-1<0) continue;
1014  Int_t index = id2index[-trkid2-1];
1015  AliAODTrack *partpid = (AliAODTrack*)evt->GetTrack(index);
1016  nSigmaTPCele = fPidHF->GetPidResponse()->NumberOfSigmasTPC(partpid,AliPID::kElectron);
1017  }else{
1018  nSigmaTPCele = fPidHF->GetPidResponse()->NumberOfSigmasTPC(trk2,AliPID::kElectron);
1019  }
1020  if(fabs(nSigmaTPCele)>5.) continue;
1021 
1022  Double_t px2 = trk2->Px();
1023  Double_t py2 = trk2->Py();
1024  Double_t pz2 = trk2->Pz();
1025  Double_t E2 = sqrt(px2*px2+py2*py2+pz2*pz2+0.000511*0.000511);
1026 
1027  Double_t mass = sqrt(pow(E1+E2,2)-pow(px1+px2,2)-pow(py1+py2,2)-pow(pz1+pz2,2));
1028  if(mass<minmass) minmass = mass;
1029  }
1030 
1031  if(minmass<fConversionMassMax) isconv = kTRUE;
1032 
1033  return isconv;
1034 }
1035 
1036 //________________________________________________________________________
1037 void AliRDHFCutsLctoeleLambdafromAODtracks::SetSftPosR125(AliAODTrack *track,Double_t bfield,Double_t priVtx[3],Double_t *XSftR125)
1038 {
1039  //
1040  // Sets the spatial position of the track at the radius R=1.25m in the shifted coordinate system
1041  //
1042 
1043  // Initialize the array to something indicating there was no propagation
1044  XSftR125[0]=-9999.;
1045  XSftR125[1]=-9999.;
1046  XSftR125[2]=-9999.;
1047  // Make a copy of the track to not change parameters of the track
1048  AliExternalTrackParam etp;
1049  etp.CopyFromVTrack(track);
1050 
1051  // The global position of the the track
1052  Double_t xyz[3]={-9999.,-9999.,-9999.};
1053 
1054  // The radius we want to propagate to, squared
1055  const Float_t RSquaredWanted(125.*125.);
1056 
1057 
1058  // Propagation is done in local x of the track
1059  for (Float_t x = 58.;x<247.;x+=1.){
1060  // Starts at 83 / Sqrt(2) and goes outwards. 85/Sqrt(2) is the smallest local x
1061  // for global radius 85 cm. x = 245 is the outer radial limit of the TPC when
1062  // the track is straight, i.e. has inifinite pt and doesn't get bent.
1063  // If the track's momentum is smaller than infinite, it will develop a y-component,
1064  // which adds to the global radius
1065  // We don't change the propagation steps to not mess up things!
1066 
1067  // Stop if the propagation was not succesful. This can happen for low pt tracks
1068  // that don't reach outer radii
1069  if(!etp.PropagateTo(x,(Float_t)bfield))break;
1070  etp.GetXYZ(xyz); // GetXYZ returns global coordinates
1071 
1072  // Calculate the shifted radius we are at, squared.
1073  // Compare squared radii for faster code
1074  Float_t shiftedRadiusSquared = (xyz[0]-priVtx[0])*(xyz[0]-priVtx[0])
1075  + (xyz[1]-priVtx[1])*(xyz[1]-priVtx[1]);
1076 
1077  // Roughly reached the radius we want
1078  if(shiftedRadiusSquared > RSquaredWanted){
1079 
1080  // Bigger loop has bad precision, we're nearly one centimeter too far,
1081  // go back in small steps.
1082  while (shiftedRadiusSquared>RSquaredWanted){
1083  // Propagate a mm inwards
1084  x-=.1;
1085  if(!etp.PropagateTo(x,bfield)){
1086  // Propagation failed but we're already with a
1087  // cm precision at R=1.25m so we only break the
1088  // inner loop
1089  break;
1090  }
1091  // Get the global position
1092  etp.GetXYZ(xyz);
1093  // Calculate shifted radius, squared
1094  shiftedRadiusSquared = (xyz[0]-priVtx[0])*(xyz[0]-priVtx[0])
1095  + (xyz[1]-priVtx[1])*(xyz[1]-priVtx[1]);
1096  }
1097  // We reached R=1.25m with a precission of a cm to a mm,
1098  // set the spatial position
1099  XSftR125[0]=xyz[0]-priVtx[0];
1100  XSftR125[1]=xyz[1]-priVtx[1];
1101  XSftR125[2]=xyz[2]-priVtx[2];
1102  // Done
1103  return;
1104  } // End of if roughly reached radius
1105  } // End of coarse propagation loop
1106 }
1107 
1108 //________________________________________________________________________
1109 Double_t AliRDHFCutsLctoeleLambdafromAODtracks::dEtaSR125(Double_t *postrack1,Double_t *postrack2)
1110 {
1111  //
1112  // Returns the pseudorapidity star difference
1113  //
1114 
1115  // It is important to keep the calculations easy and separated.
1116  // The calculation of EtaS is straight forward, one just has to
1117  // do it step by step to not get confused.
1118  Double_t ThetaS1 = TMath::Pi()/2. - TMath::ATan(postrack1[2]/125.);
1119  Double_t ThetaS2 = TMath::Pi()/2. - TMath::ATan(postrack2[2]/125.);
1120  Double_t EtaS1 = -TMath::Log( TMath::Tan(ThetaS1/2.) );
1121  Double_t EtaS2 = -TMath::Log( TMath::Tan(ThetaS2/2.) );
1122 
1123  return EtaS1-EtaS2;
1124 }
1125 
1126 //________________________________________________________________________
1127 Double_t AliRDHFCutsLctoeleLambdafromAODtracks::dPhiSR125(Double_t *postrack1,Double_t *postrack2)
1128 {
1129  //
1130  // returns delta phi star at R=1.25m
1131  // position5 at R=1.2m is stored as second radius
1132  //
1133  //
1134  Double_t distSft= TMath::Sqrt(TMath::Power(postrack1[0] - postrack2[0],2)
1135  +TMath::Power(postrack1[1] - postrack2[1],2));
1136  return 2.0 * TMath::ATan(distSft/2./(125.));
1137 }
1138 
1139 //________________________________________________________________________
1140 Double_t AliRDHFCutsLctoeleLambdafromAODtracks::GetdPhiSdEtaSR125(AliAODTrack *tracke, AliAODTrack *trackp,
1141  AliAODTrack *trackn, Double_t bfield, Double_t priVtx[3], Double_t &dPhiS_ep, Double_t &dEtaS_ep,
1142  Double_t &dPhiS_en, Double_t &dEtaS_en)
1143 {
1144  //
1145  // Returns dPhi and dEta at R 125
1146  //
1147  Double_t XSftR125_e[3];
1148  SetSftPosR125(tracke,bfield,priVtx, XSftR125_e);
1149  Double_t XSftR125_p[3];
1150  SetSftPosR125(trackp,bfield,priVtx, XSftR125_p);
1151  Double_t XSftR125_n[3];
1152  SetSftPosR125(trackn,bfield,priVtx, XSftR125_n);
1153  dPhiS_ep = dPhiSR125(XSftR125_e,XSftR125_p);
1154  dEtaS_ep = dEtaSR125(XSftR125_e,XSftR125_p);
1155  dPhiS_en = dPhiSR125(XSftR125_e,XSftR125_n);
1156  dEtaS_en = dEtaSR125(XSftR125_e,XSftR125_n);
1157 }
1158 
1159 //---------------------------------------------------------------------------
1160 Int_t AliRDHFCutsLctoeleLambdafromAODtracks::IsSelected(TLorentzVector* vtrk, TLorentzVector *vv0, Double_t *cutvars, Int_t selectionLevel)
1161 {
1162  //
1163  // Apply selection on mixed event tracks
1164  //
1165 
1166  if (!fCutsRD) {
1167  AliFatal("Cut matrix not inizialized. Exit...");
1168  return 0;
1169  }
1170 
1171  Double_t ptD=sqrt(pow(vtrk->Px()+vv0->Px(),2)+pow(vtrk->Px()+vv0->Py(),2));
1172  if(ptD<fMinPtCand) return 0;
1173  if(ptD>fMaxPtCand) return 0;
1174 
1175  Double_t pt=ptD;
1176  Int_t ptbin=PtBin(pt);
1177  if (ptbin==-1) {
1178  return 0;
1179  }
1180 
1181  if (selectionLevel==AliRDHFCuts::kAll ||
1182  selectionLevel==AliRDHFCuts::kTracks) {
1183  //Performed in production stage
1184  }
1185 
1186  Int_t returnvalueCuts=1;
1187  // selection on candidate
1188  if (selectionLevel==AliRDHFCuts::kAll ||
1189  selectionLevel==AliRDHFCuts::kCandidate) {
1190 
1191  Bool_t okcand=kTRUE;
1192 
1193  Double_t mlcPDG = TDatabasePDG::Instance()->GetParticle(4122)->Mass();
1194  Double_t melePDG = TDatabasePDG::Instance()->GetParticle(11)->Mass();
1195  Double_t mlamPDG = TDatabasePDG::Instance()->GetParticle(3122)->Mass();
1196  Double_t v0px = vv0->Px();
1197  Double_t v0py = vv0->Py();
1198  Double_t v0pz = vv0->Pz();
1199  Double_t epx = vtrk->Px();
1200  Double_t epy = vtrk->Py();
1201  Double_t epz = vtrk->Pz();
1202  Double_t cosoa = (v0px*epx+v0py*epy+v0pz*epz)/sqrt(v0px*v0px+v0py*v0py+v0pz*v0pz)/sqrt(epx*epx+epy*epy+epz*epz);
1203 
1204  TLorentzVector vele, vlam,vlc;
1205  vele.SetXYZM(epx,epy,epz,melePDG);
1206  vlam.SetXYZM(v0px,v0py,v0pz,mlamPDG);
1207  vlc = vele + vlam;
1208 
1209  Double_t dphis_e_pr = 9999.;
1210  Double_t detas_e_pr = 9999.;
1211  Double_t dphis_e_pi = 9999.;
1212  Double_t detas_e_pi = 9999.;
1213  if(fCutsRD[GetGlobalIndex(2,ptbin)]>0 || fCutsRD[GetGlobalIndex(3,ptbin)]>0){
1214  Double_t xyzR125_e[3], xyzR125_pr[3], xyzR125_pi[3];
1215  xyzR125_e[0] = cutvars[0];
1216  xyzR125_e[1] = cutvars[1];
1217  xyzR125_e[2] = cutvars[2];
1218  xyzR125_pr[0] = cutvars[3];
1219  xyzR125_pr[1] = cutvars[4];
1220  xyzR125_pr[2] = cutvars[5];
1221  xyzR125_pi[0] = cutvars[6];
1222  xyzR125_pi[1] = cutvars[7];
1223  xyzR125_pi[2] = cutvars[8];
1224  dphis_e_pr = dPhiSR125(xyzR125_e,xyzR125_pr);
1225  detas_e_pr = dPhiSR125(xyzR125_e,xyzR125_pr);
1226  dphis_e_pi = dPhiSR125(xyzR125_e,xyzR125_pi);
1227  detas_e_pi = dPhiSR125(xyzR125_e,xyzR125_pi);
1228  }
1229 
1230  if(vlc.M() > fCutsRD[GetGlobalIndex(0,ptbin)])
1231  {
1232  okcand = kFALSE;
1233  }
1234  if(cosoa < fCutsRD[GetGlobalIndex(1,ptbin)])
1235  {
1236  okcand = kFALSE;
1237  }
1238  if(fabs(dphis_e_pr) < fCutsRD[GetGlobalIndex(2,ptbin)] && fabs(detas_e_pr) < fCutsRD[GetGlobalIndex(3,ptbin)])
1239  {
1240  okcand = kFALSE;
1241  }
1242  if(fabs(dphis_e_pi) < fCutsRD[GetGlobalIndex(2,ptbin)] && fabs(detas_e_pi) < fCutsRD[GetGlobalIndex(3,ptbin)])
1243  {
1244  okcand = kFALSE;
1245  }
1246 
1247  if(!okcand) return 0;
1248  returnvalueCuts = 1;
1249  }
1250 
1251  Int_t returnvaluePID=1;
1252  if(selectionLevel==AliRDHFCuts::kAll ||
1253  selectionLevel==AliRDHFCuts::kCandidate||
1254  selectionLevel==AliRDHFCuts::kPID) {
1255  }
1256 
1257  Int_t returnvalue = 0;
1258  if(returnvalueCuts==1 && returnvaluePID==1) returnvalue=1;
1259 
1260  return returnvalue;
1261 }
1262 //---------------------------------------------------------------------------
1263 Double_t AliRDHFCutsLctoeleLambdafromAODtracks::CalculatePhotonMass(AliAODTrack* trk1, AliAODTrack *trk2)
1264 {
1265  //
1266  // Calculate invariant mass of two tracks at the points where they are parallel
1267  //
1268  Double_t pol = 1.;
1269  if(fBzkG<0.) pol = -1.;
1270 
1271  Double_t xyz[3];
1272 
1273  Double_t mass = 9999.;
1274 
1275  Double_t Rcurv1 = trk1->Pt()/0.3/(0.1*fabs(fBzkG))*100.;
1276  Double_t charge1 = (Double_t) trk1->Charge();
1277  Double_t ux1 = trk1->Px()/trk1->Pt();
1278  Double_t uy1 = trk1->Py()/trk1->Pt();
1279  trk1->GetXYZ(xyz);
1280  Double_t x1 = xyz[0];
1281  Double_t y1 = xyz[1];
1282  Double_t xc1 = x1 + charge1*Rcurv1*(uy1)*pol;
1283  Double_t yc1 = y1 + charge1*Rcurv1*(-1.*ux1)*pol;
1284 
1285  Double_t Rcurv2 = trk2->Pt()/0.3/(0.1*fabs(fBzkG))*100.;
1286  Double_t charge2 = (Double_t) trk2->Charge();
1287  Double_t ux2 = trk2->Px()/trk2->Pt();
1288  Double_t uy2 = trk2->Py()/trk2->Pt();
1289  trk2->GetXYZ(xyz);
1290  Double_t x2 = xyz[0];
1291  Double_t y2 = xyz[1];
1292  Double_t xc2 = x2 + charge2*Rcurv2*(uy2)*pol;
1293  Double_t yc2 = y2 + charge2*Rcurv2*(-1.*ux2)*pol;
1294 
1295  if(fabs(sqrt((xc2-xc1)*(xc2-xc1)+(yc2-yc1)*(yc2-yc1))-(Rcurv1+Rcurv2))>5.) return 9999.;//not photon candidate
1296 
1297 
1298  Double_t dxc = xc2-xc1;
1299  Double_t dyc = yc2-yc1;
1300  Double_t nux = dyc/sqrt(dxc*dxc+dyc*dyc);
1301  Double_t nuy = -1.*dxc/sqrt(dxc*dxc+dyc*dyc);
1302  Double_t vertx1 = xc1 + (xc2-xc1)*Rcurv1/sqrt(dxc*dxc+dyc*dyc);
1303  Double_t verty1 = yc1 + (yc2-yc1)*Rcurv1/sqrt(dxc*dxc+dyc*dyc);
1304  Double_t vertx2 = xc2 + (xc1-xc2)*Rcurv2/sqrt(dxc*dxc+dyc*dyc);
1305  Double_t verty2 = yc2 + (yc1-yc2)*Rcurv2/sqrt(dxc*dxc+dyc*dyc);
1306  Double_t vertxmid = (vertx1+vertx2)/2.;
1307  Double_t vertymid = (verty1+verty2)/2.;
1308 
1309  if(vertxmid*nux+vertymid*nuy<0.) return 9999.;
1310 
1311  Double_t px1_new = trk1->Pt()*nux;
1312  Double_t py1_new = trk1->Pt()*nuy;
1313  Double_t pz1_new = trk1->Pz();
1314  Double_t E1_new = sqrt(px1_new*px1_new+py1_new*py1_new+pz1_new*pz1_new+0.000511);
1315  Double_t px2_new = trk2->Pt()*nux;
1316  Double_t py2_new = trk2->Pt()*nuy;
1317  Double_t pz2_new = trk2->Pz();
1318  Double_t E2_new = sqrt(px2_new*px2_new+py2_new*py2_new+pz2_new*pz2_new+0.000511);
1319 
1320 
1321  mass = sqrt(pow(E1_new+E2_new,2)-pow(px1_new+px2_new,2)-pow(py1_new+py2_new,2)-pow(pz1_new+pz2_new,2));
1322 
1323  //check
1324 // cout<<mass<<endl;
1325 // cout<<"Track 1: "<<charge1<<" "<<trk1->Px()<<" "<<trk1->Py()<<" "<<trk1->Pz()<<endl;
1326 // cout<<"Track 2: "<<charge2<<" "<<trk2->Px()<<" "<<trk2->Py()<<" "<<trk2->Pz()<<endl;
1327 // cout<<"Circle info 1: "<<Rcurv1<<" "<<xc1<<" "<<yc1<<endl;
1328 // cout<<"Circle info 2: "<<Rcurv2<<" "<<xc2<<" "<<yc2<<endl;
1329 // cout<<"New momenta 1: "<<px1_new<<" "<<py1_new<<" "<<pz1_new<<endl;
1330 // cout<<"New momenta 2: "<<px2_new<<" "<<py2_new<<" "<<pz2_new<<endl;
1331 // AliExternalTrackParam etp1;
1332 // etp1.CopyFromVTrack(trk1);
1333 // if(!etp1.PropagateTo(80.,(Float_t)fBzkG)) return 9999.;
1334 // etp1.GetXYZ(xyz);
1335 // cout<<"At 80 cm 1: "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<" -> "<<pow(xyz[0]-xc1,2)+pow(xyz[1]-yc1,2)-Rcurv1*Rcurv1<<endl;
1336 // if(!etp1.PropagateTo(120.,(Float_t)fBzkG)) return 9999.;
1337 // etp1.GetXYZ(xyz);
1338 // cout<<"At 120 cm 1: "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<" -> "<<pow(xyz[0]-xc1,2)+pow(xyz[1]-yc1,2)-Rcurv1*Rcurv1<<endl;
1339 // AliExternalTrackParam etp2;
1340 // etp2.CopyFromVTrack(trk2);
1341 // if(!etp2.PropagateTo(80.,(Float_t)fBzkG)) return 9999.;
1342 // etp2.GetXYZ(xyz);
1343 // cout<<"At 80 cm 2: "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<" -> "<<pow(xyz[0]-xc2,2)+pow(xyz[1]-yc2,2)-Rcurv2*Rcurv2<<endl;
1344 // if(!etp2.PropagateTo(120.,(Float_t)fBzkG)) return 9999.;
1345 // etp2.GetXYZ(xyz);
1346 // cout<<"At 120 cm 2: "<<xyz[0]<<" "<<xyz[1]<<" "<<xyz[2]<<" -> "<<pow(xyz[0]-xc2,2)+pow(xyz[1]-yc2,2)-Rcurv2*Rcurv2<<endl;
1347 // cout<<endl;
1348 
1349  return mass;
1350 }
Bool_t SingleV0Cuts(AliAODv0 *v0, AliAODVertex *vert)
Double_t fProdV0DaughterTPCCrossRatioMin
V0 daughter Minimum TPC cluster pT used before object creation.
ClassImp(AliAnalysisTaskTriggerRates) AliAnalysisTaskTriggerRates
Double_t fProdV0ProperDecayLengthMax
Min Dca between v0-pion and PV.
Double_t fSigmaElectronTPCMin
nSigma to exclude for Kaon band
AliAODPidHF * fPidObjProton
Use PID for proton from Lc.
Double_t fProdRoughMassTol
Maximum rapidity of cascade.
AliRDHFCutsLctoeleLambdafromAODtracks & operator=(const AliRDHFCutsLctoeleLambdafromAODtracks &source)
Bool_t TagConversions(AliAODTrack *etrk, Int_t *id2index, AliAODEvent *evt, Int_t ntrk, Double_t &minmass)
Double_t GetSigma(Int_t idet) const
Definition: AliAODPidHF.h:134
Double_t fProdV0CosPointingAngleToPrimVtxMin
Max Lambda pT used before object creation.
Double_t fProdV0PtMin
Lambda mass selection used before object creation.
Double_t mass
Double_t fProdV0PtMax
Minimum Lambda pT used before object creation.
void SetSftPosR125(AliAODTrack *track, Double_t bfield, Double_t priVtx[3], Double_t *XSftR125)
Double_t fExcludenSigmaKaonTPC
nSigma to exclude for proton band
void SetNVars(Int_t nVars)
Definition: AliRDHFCuts.h:362
Bool_t fProdRejectTrackWithShared
AOD filter Bit used before object creation.
Bool_t SingleTrkCuts(AliAODTrack *trk, AliAODTrack *trkpid, AliAODVertex *vert)
AliRDHFCuts & operator=(const AliRDHFCuts &source)
Bool_t fExcludePionTPC
pT cut for Lc used before object creation
Double_t fProdTrackTPCNclsRatioMin
Min. Number of TPC PID cluster.
Bool_t fUsePID
Definition: AliRDHFCuts.h:389
Double_t fSigmaElectronTPCPtDepPar1
nSigma electron lower limit (par0)
Double_t fSigmaElectronTPCPtDepPar0
nSigma to exclude for Kaon band
Double_t fExcludenSigmaProtonTPC
nSigma to exclude for pion band
Double_t fProdDcaV0PrToPrimVertexMin
Min Dca between v0 and PV.
Int_t fProdAODFilterBit
Flag for AOD filter Bit used before object creation.
virtual void GetCutVarsForOpt(AliAODRecoDecayHF *d, Float_t *vars, Int_t nvars, Int_t *pdgdaughters)
const Double_t etamin
Bool_t fProdV0KinkRejection
Flag to Reject tracks with shared clusters.
Double_t fProdV0DaughterEtaRange
Max DCA between V0 daughters used before object creation.
Int_t fnVarsForOpt
Definition: AliRDHFCuts.h:384
Bool_t fUseLambdaPID
Threshold used in IsSelectedCombinedPID.
const Double_t ptmax
Double_t fMaxPtCand
minimum pt of the candidate
Definition: AliRDHFCuts.h:411
Double_t fSigmaElectronTOFMin
nSigma to exclude for Kaon band
AliESDtrackCuts * fTrackCuts
quality cuts on the daughter tracks
Definition: AliRDHFCuts.h:377
Bool_t fExcludeKaonTPC
Flag wheter to exlude proton band.
Double_t fProdRoughPtMin
Mass cut for Lc used before object creation.
Double_t fProdDcaV0PiToPrimVertexMin
Min Dca between v0-proton and PV.
Bool_t IsDaughterSelected(AliAODTrack *track, const AliESDVertex *primary, AliESDtrackCuts *cuts) const
Double_t fSigmaElectronTOFMax
nSigma to exclude for Kaon band
AliAODTrack * GetBachelor() const
Double_t fBzkG
Flag to check if we use on-the-fly v0.
Bool_t TagConversionsSameSign(AliAODTrack *etrk, Int_t *id2index, AliAODEvent *evt, Int_t ntrk, Double_t &minmass)
Bool_t fUseOnTheFlyV0
PID object for proton from Lc.
Double_t fSigmaElectronTPCPtDepPar2
nSigma electron lower limit (par1)
const Double_t ptmin
Bool_t SelectWithRoughCuts(AliAODv0 *v0, AliAODTrack *trk1)
Int_t MakeRawPid(AliAODTrack *track, Int_t specie)
AliPIDResponse * GetPidResponse() const
Definition: AliAODPidHF.h:160
Float_t * fCutsRD
fnVars*fnPtBins
Definition: AliRDHFCuts.h:387
Double_t fProdV0EtaMin
Rejection range of Omega mass from PDG value.
void SetVarsForOpt(Int_t nVars, Bool_t *forOpt)
Double_t fProdV0DaughterTPCClusterMin
V0 Daughter pT min used before object creation.
Double_t fExcludenSigmaPionTPC
Flag wheter to exlude proton band.
void SetVarNames(Int_t nVars, TString *varNames, Bool_t *isUpperCut)
Bool_t fExcludeProtonTPC
Flag wheter to exlude pion band.
Bool_t * fVarsForOpt
number of cut vars to be optimized for candidates
Definition: AliRDHFCuts.h:385
Bool_t SingleTrkCutsNoPID(AliAODTrack *trk, AliAODTrack *trkpid, AliAODVertex *vert)
Double_t fConversionMassMax
nSigma to exclude for Kaon band
Double_t fProdV0MassTolLambdaRough
Lambda mass selection used before object creation.
Bool_t IsSelectedCustomizedPtDepeID(AliAODTrack *trk, AliAODTrack *trkpid)
Bool_t fProdUseAODFilterBit
Min. Number of TPC PID cluster.
void SetPtBins(Int_t nPtBinLimits, Float_t *ptBinLimits)
const Double_t etamax
Double_t fSigmaElectronTPCMax
nSigma electron lower limit (par2)
virtual Int_t IsSelected(TObject *obj, Int_t selectionLevel)
Double_t fProdRfidMinV0
V0 daughter Minimum TPC cluster pT used before object creation.
Double_t fProdV0DcaDaughtersMax
V0 pointing angle used before object creation.
Double_t dPhiSR125(Double_t *postrack1, Double_t *postrack2)
AliRDHFCutsLctoeleLambdafromAODtracks(const char *name="CutsLctoeleLambda")
AliAODPidHF * fPidHF
enable AOD049 centrality cleanup
Definition: AliRDHFCuts.h:391
Int_t PtBin(Double_t pt) const
Int_t GetGlobalIndex(Int_t iVar, Int_t iPtBin) const
Double_t dEtaSR125(Double_t *postrack1, Double_t *postrack2)
Double_t fMinPtCand
outcome of PID selection
Definition: AliRDHFCuts.h:410
AliAODPidHF * fPidObjPion
PID object for proton from Lc.
Double_t fProdV0DaughterPtMin
V0Daughter eta range used before object creation.
Double_t GetdPhiSdEtaSR125(AliAODTrack *tracke, AliAODTrack *trackp, AliAODTrack *trackn, Double_t bfield, Double_t priVtx[3], Double_t &dPhiS_ep, Double_t &dEtaS_ep, Double_t &dPhiS_en, Double_t &dEtaS_en)
Double_t CalculatePhotonMass(AliAODTrack *track1, AliAODTrack *track2)
void SetPidResponse(AliPIDResponse *pidResp)
Definition: AliAODPidHF.h:111