AliPhysics  b555aef (b555aef)
AliRDHFCuts.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 // Base class for cuts on AOD reconstructed heavy-flavour decay
21 //
22 // Author: A.Dainese, andrea.dainese@pd.infn.it
24 #include <Riostream.h>
25 
26 #include "AliVEvent.h"
27 #include "AliESDEvent.h"
28 #include "AliAODEvent.h"
29 #include "AliVVertex.h"
30 #include "AliESDVertex.h"
31 #include "AliLog.h"
32 #include "AliAODVertex.h"
33 #include "AliESDtrack.h"
34 #include "AliAODTrack.h"
35 #include "AliESDtrackCuts.h"
36 #include "AliCentrality.h"
37 #include "AliAODRecoDecayHF.h"
38 #include "AliAnalysisVertexingHF.h"
39 #include "AliAODMCHeader.h"
40 #include "AliAODMCParticle.h"
41 #include "AliVertexerTracks.h"
42 #include "AliRDHFCuts.h"
43 #include "AliAnalysisManager.h"
44 #include "AliAODHandler.h"
45 #include "AliInputEventHandler.h"
46 #include "AliPIDResponse.h"
47 #include "AliAnalysisUtils.h"
48 #include "AliMultSelection.h"
49 #include "AliAODVZERO.h"
50 #include "TRandom.h"
51 #include <TF1.h>
52 #include <TFile.h>
53 #include <TKey.h>
54 
55 using std::cout;
56 using std::endl;
57 
59 ClassImp(AliRDHFCuts);
61 
62 
63 //--------------------------------------------------------------------------
65 AliAnalysisCuts(name,title),
66 fMinVtxType(3),
67 fMinVtxContr(1),
68 fMaxVtxRedChi2(1e6),
69 fMaxVtxZ(10.),
70 fMinSPDMultiplicity(0),
71 fTriggerMask(AliVEvent::kAnyINT),
72 fUseOnlyOneTrigger(kFALSE),
73 fTrackCuts(0),
74 fnPtBins(1),
75 fnPtBinLimits(1),
76 fPtBinLimits(0),
77 fnVars(1),
78 fVarNames(0),
79 fnVarsForOpt(0),
80 fVarsForOpt(0),
81 fGlobalIndex(1),
82 fCutsRD(0),
83 fIsUpperCut(0),
84 fUsePID(kFALSE),
85 fUseAOD049(kFALSE),
86 fPidHF(0),
87 fWhyRejection(0),
88 fEvRejectionBits(0),
89 fRemoveDaughtersFromPrimary(kFALSE),
90 fUseMCVertex(kFALSE),
91 fUsePhysicsSelection(kTRUE),
92 fOptPileup(0),
93 fMinContrPileup(3),
94 fMinDzPileup(0.6),
95 fUseMultDepPileupCut(kFALSE),
96 fUseCentrality(0),
97 fMinCentrality(0.),
98 fMaxCentrality(100.),
99 fMultSelectionObjectName("MultSelection"),
100 fFixRefs(kFALSE),
101 fIsSelectedCuts(0),
102 fIsSelectedPID(0),
103 fMinPtCand(-1.),
104 fMaxPtCand(100000.),
105 fMaxRapidityCand(-999.),
106 fKeepSignalMC(kFALSE),
107 fIsCandTrackSPDFirst(kFALSE),
108 fMaxPtCandTrackSPDFirst(0.),
109 fApplySPDDeadPbPb2011(kFALSE),
110 fApplySPDMisalignedPP2012(kFALSE),
111 fMaxDiffTRKV0Centr(-1.),
112 fRemoveTrackletOutliers(kFALSE),
113 fCutOnzVertexSPD(0),
114 fKinkReject(kFALSE),
115 fUseTrackSelectionWithFilterBits(kTRUE),
116 fUseCentrFlatteningInMC(kFALSE),
117 fHistCentrDistr(0x0),
118 fCutRatioClsOverCrossRowsTPC(0),
119 fCutRatioSignalNOverCrossRowsTPC(0),
120 fCutMinCrossedRowsTPCPtDep(""),
121 f1CutMinNCrossedRowsTPCPtDep(0x0),
122 fUseCutGeoNcrNcl(kFALSE),
123 fDeadZoneWidth(3.),
124 fCutGeoNcrNclLength(130.),
125 fCutGeoNcrNclGeom1Pt(1.5),
126 fCutGeoNcrNclFractionNcr(0.85),
127 fCutGeoNcrNclFractionNcl(0.7),
128 fUseV0ANDSelectionOffline(kFALSE)
129 {
130  //
131  // Default Constructor
132  //
133  fTriggerClass[0]="CINT1"; fTriggerClass[1]="";
134 }
135 //--------------------------------------------------------------------------
137  AliAnalysisCuts(source),
138  fMinVtxType(source.fMinVtxType),
139  fMinVtxContr(source.fMinVtxContr),
141  fMaxVtxZ(source.fMaxVtxZ),
143  fTriggerMask(source.fTriggerMask),
145  fTriggerClass(),
146  fTrackCuts(0),
147  fnPtBins(source.fnPtBins),
149  fPtBinLimits(0),
150  fnVars(source.fnVars),
151  fVarNames(0),
152  fnVarsForOpt(source.fnVarsForOpt),
153  fVarsForOpt(0),
154  fGlobalIndex(source.fGlobalIndex),
155  fCutsRD(0),
156  fIsUpperCut(0),
157  fUsePID(source.fUsePID),
158  fUseAOD049(source.fUseAOD049),
159  fPidHF(0),
163  fUseMCVertex(source.fUseMCVertex),
165  fOptPileup(source.fOptPileup),
167  fMinDzPileup(source.fMinDzPileup),
173  fFixRefs(source.fFixRefs),
176  fMinPtCand(source.fMinPtCand),
177  fMaxPtCand(source.fMaxPtCand),
187  fKinkReject(source.fKinkReject),
190  fHistCentrDistr(0x0),
202 {
203  //
204  // Copy constructor
205  //
206  cout<<"Copy constructor"<<endl;
207  fTriggerClass[0] = source.fTriggerClass[0];
208  fTriggerClass[1] = source.fTriggerClass[1];
209  if(source.GetTrackCuts()) AddTrackCuts(source.GetTrackCuts());
210  if(source.fPtBinLimits) SetPtBins(source.fnPtBinLimits,source.fPtBinLimits);
211  if(source.fVarNames) SetVarNames(source.fnVars,source.fVarNames,source.fIsUpperCut);
212  if(source.fCutsRD) SetCuts(source.fGlobalIndex,source.fCutsRD);
213  if(source.fVarsForOpt) SetVarsForOpt(source.fnVarsForOpt,source.fVarsForOpt);
214  if(source.fPidHF) SetPidHF(source.fPidHF);
215  if(source.fHistCentrDistr) fHistCentrDistr=(TH1F*)(source.fHistCentrDistr->Clone());
218  PrintAll();
219 
220 }
221 //--------------------------------------------------------------------------
223 {
224  //
225  // assignment operator
226  //
227  if(&source == this) return *this;
228 
229  AliAnalysisCuts::operator=(source);
230 
231  fMinVtxType=source.fMinVtxType;
232  fMinVtxContr=source.fMinVtxContr;
234  fMaxVtxZ=source.fMaxVtxZ;
236  fTriggerMask=source.fTriggerMask;
238  fTriggerClass[0]=source.fTriggerClass[0];
239  fTriggerClass[1]=source.fTriggerClass[1];
240  fnPtBins=source.fnPtBins;
242  fnVars=source.fnVars;
243  fGlobalIndex=source.fGlobalIndex;
244  fnVarsForOpt=source.fnVarsForOpt;
245  fUsePID=source.fUsePID;
246  fUseAOD049=source.fUseAOD049;
247  if(fPidHF) delete fPidHF;
248  fPidHF=new AliAODPidHF(*(source.GetPidHF()));
252  fUseMCVertex=source.fUseMCVertex;
254  fOptPileup=source.fOptPileup;
256  fMinDzPileup=source.fMinDzPileup;
262  fFixRefs=source.fFixRefs;
265  fMinPtCand=source.fMinPtCand;
266  fMaxPtCand=source.fMaxPtCand;
276  fKinkReject=source.fKinkReject;
278  if(fHistCentrDistr) delete fHistCentrDistr;
280  if(source.fHistCentrDistr)fHistCentrDistr=(TH1F*)(source.fHistCentrDistr->Clone());
281 
282  if(source.GetTrackCuts()) {delete fTrackCuts; fTrackCuts=new AliESDtrackCuts(*(source.GetTrackCuts()));}
283  if(source.fPtBinLimits) SetPtBins(source.fnPtBinLimits,source.fPtBinLimits);
284  if(source.fVarNames) SetVarNames(source.fnVars,source.fVarNames,source.fIsUpperCut);
285  if(source.fCutsRD) SetCuts(source.fGlobalIndex,source.fCutsRD);
286  if(source.fVarsForOpt) SetVarsForOpt(source.fnVarsForOpt,source.fVarsForOpt);
287 
293 
301 
302  PrintAll();
303 
304  return *this;
305 }
306 //--------------------------------------------------------------------------
308  //
309  // Default Destructor
310  //
311  if(fTrackCuts) { delete fTrackCuts; fTrackCuts=0; }
312  if(fPtBinLimits) {delete [] fPtBinLimits; fPtBinLimits=0;}
313  if(fVarNames) {delete [] fVarNames; fVarNames=0;}
314  if(fVarsForOpt) {delete [] fVarsForOpt; fVarsForOpt=0;}
315  if(fCutsRD) {
316  delete [] fCutsRD;
317  fCutsRD=0;
318  }
319  if(fIsUpperCut) {delete [] fIsUpperCut; fIsUpperCut=0;}
320  if(fPidHF){
321  delete fPidHF;
322  fPidHF=0;
323  }
325 
329  }
330 
331 }
332 //---------------------------------------------------------------------------
334  //
335  // Centrality selection
336  //
337  if(fUseCentrality<kCentOff||fUseCentrality>=kCentInvalid){
338  AliWarning("Centrality estimator not valid");
339  return 3;
340  }else{
341  Float_t centvalue=GetCentrality((AliAODEvent*)event);
342  if (centvalue<-998.){//-999 if no centralityP
343  return 3;
345  return 3;
346  }else{
347  if (centvalue<fMinCentrality || centvalue>fMaxCentrality){
348  return 2;
349  }
350  // selection to flatten the centrality distribution
351  if(fHistCentrDistr){
352  if(!IsEventSelectedForCentrFlattening(centvalue))return 4;
353  }
354  }
355  }
356  return 0;
357 }
358 
359 
360 //-------------------------------------------------
361 void AliRDHFCuts::SetHistoForCentralityFlattening(TH1F *h,Double_t minCentr,Double_t maxCentr,Double_t centrRef,Int_t switchTRand){
362  // set the histo for centrality flattening
363  // the centrality is flatten in the range minCentr,maxCentr
364  // if centrRef is zero, the minimum in h within (minCentr,maxCentr) defines the reference
365  // positive, the value of h(centrRef) defines the reference (-> the centrality distribution might be not flat in the whole desired range)
366  // negative, h(bin with max in range)*centrRef is used to define the reference (-> defines the maximum loss of events, also in this case the distribution might be not flat)
367  // switchTRand is used to set the unerflow bin of the histo: if it is < -1 in the analysis the random event selection will be done on using TRandom
368 
369  if(maxCentr<minCentr){
370  AliWarning("AliRDHFCuts::Wrong centralities values while setting the histogram for centrality flattening");
371  }
372 
374  fHistCentrDistr=(TH1F*)h->Clone("hCentralityFlat");
375  fHistCentrDistr->SetTitle("Reference histo for centrality flattening");
376  Int_t minbin=fHistCentrDistr->FindBin(minCentr*1.00001); // fast if fix bin width
377  Int_t maxbin=fHistCentrDistr->FindBin(maxCentr*0.9999);
378  fHistCentrDistr->GetXaxis()->SetRange(minbin,maxbin);
379  Double_t ref=0.,bincont=0.,binrefwidth=1.;
380  Int_t binref=0;
381  if(TMath::Abs(centrRef)<0.0001){
382  binref=fHistCentrDistr->GetMinimumBin();
383  binrefwidth=fHistCentrDistr->GetBinWidth(binref);
384  ref=fHistCentrDistr->GetBinContent(binref)/binrefwidth;
385  }
386  else if(centrRef>0.){
387  binref=h->FindBin(centrRef);
388  if(binref<1||binref>h->GetNbinsX()){
389  AliWarning("AliRDHFCuts::Wrong centrality reference value while setting the histogram for centrality flattening");
390  }
391  binrefwidth=fHistCentrDistr->GetBinWidth(binref);
392  ref=fHistCentrDistr->GetBinContent(binref)/binrefwidth;
393  }
394  else{
395  if(centrRef<-1) AliWarning("AliRDHFCuts: with this centrality reference no flattening will be applied");
396  binref=fHistCentrDistr->GetMaximumBin();
397  binrefwidth=fHistCentrDistr->GetBinWidth(binref);
398  ref=fHistCentrDistr->GetMaximum()*TMath::Abs(centrRef)/binrefwidth;
399  }
400 
401  for(Int_t j=1;j<=h->GetNbinsX();j++){// Now set the "probabilities"
402  if(h->GetBinLowEdge(j)*1.0001>=minCentr&&h->GetBinLowEdge(j+1)*0.9999<=maxCentr){
403  bincont=h->GetBinContent(j);
404  fHistCentrDistr->SetBinContent(j,ref/bincont*h->GetBinWidth(j));
405  fHistCentrDistr->SetBinError(j,h->GetBinError(j)*ref/bincont);
406  }
407  else{
408  h->SetBinContent(j,1.1);// prob > 1 to assure that events will not be rejected
409  }
410  }
411 
412  fHistCentrDistr->SetBinContent(0,switchTRand);
413  return;
414 
415 }
416 
417 //-------------------------------------------------
419  //
420  // Random event selection, based on fHistCentrDistr, to flatten the centrality distribution
421  // Can be faster if it was required that fHistCentrDistr covers
422  // exactly the desired centrality range (e.g. part of the lines below should be done during the
423  // setting of the histo) and TH1::SetMinimum called
424  //
425 
426  if(!fHistCentrDistr) return kTRUE;
427  // Int_t maxbin=fHistCentrDistr->FindBin(fMaxCentrality*0.9999);
428  // if(maxbin>fHistCentrDistr->GetNbinsX()){
429  // AliWarning("AliRDHFCuts: The maximum centrality exceeds the x-axis limit of the histogram for centrality flattening");
430  // }
431 
432  Int_t bin=fHistCentrDistr->FindBin(centvalue); // Fast if the histo has a fix bin
433  Double_t bincont=fHistCentrDistr->GetBinContent(bin);
434  Double_t centDigits=centvalue-(Int_t)(centvalue*100.)/100.;// this is to extract a random number between 0 and 0.01
435 
436  if(fHistCentrDistr->GetBinContent(0)<-0.9999){
437  if(gRandom->Uniform(1.)<bincont)return kTRUE;
438  return kFALSE;
439  }
440 
441  if(centDigits*100.<bincont)return kTRUE;
442  return kFALSE;
443 
444 }
445 //---------------------------------------------------------------------------
446 void AliRDHFCuts::SetupPID(AliVEvent *event) {
447  // Set the PID response object in the AliAODPidHF
448  // in case of old PID sets the TPC dE/dx BB parameterization
449 
450  if(fPidHF){
451  if(fPidHF->GetPidResponse()==0x0){
452  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
453  AliInputEventHandler *inputHandler=(AliInputEventHandler*)mgr->GetInputEventHandler();
454  AliPIDResponse *pidResp=inputHandler->GetPIDResponse();
455  fPidHF->SetPidResponse(pidResp);
456  }
458  if(fPidHF->GetOldPid()) {
459 
460  Bool_t isMC=kFALSE;
461  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)event)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
462  if(mcArray) {isMC=kTRUE;fUseAOD049=kFALSE;}
463 
464  // pp, from LHC10d onwards
465  if((event->GetRunNumber()>121693 && event->GetRunNumber()<136851) ||
466  event->GetRunNumber()>139517) fPidHF->SetOnePad(kTRUE);
467  // pp, 2011 low energy run
468  if((event->GetRunNumber()>=146686 && event->GetRunNumber()<=146860)){
469  fPidHF->SetppLowEn2011(kTRUE);
470  fPidHF->SetOnePad(kFALSE);
471  }
472  // PbPb LHC10h
473  if(event->GetRunNumber()>=136851 && event->GetRunNumber()<=139517) fPidHF->SetPbPb(kTRUE);
474  // MC
475  if(isMC) fPidHF->SetMC(kTRUE);
476  if(isMC && (event->GetRunNumber()>=146686 && event->GetRunNumber()<=146860))
477  fPidHF->SetMClowenpp2011(kTRUE);
479  }else{
480  // check that AliPIDResponse object was properly set in case of using OADB
481  if(fPidHF->GetPidResponse()==0x0) AliFatal("AliPIDResponse object not set");
482  }
483  }
484 }
485 //---------------------------------------------------------------------------
487  //
488  // Event selection
489  //
490  //if(fTriggerMask && event->GetTriggerMask()!=fTriggerMask) return kFALSE;
491 
492 
493 
494  fWhyRejection=0;
496  Bool_t accept=kTRUE;
497 
498 
499  // check if it's MC
500  Bool_t isMC=kFALSE;
501  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)event)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
502  if(mcArray) {isMC=kTRUE;fUseAOD049=kFALSE;}
503 
504 
505  SetupPID(event);
506 
507  // trigger class
508  TString firedTriggerClasses=((AliAODEvent*)event)->GetFiredTriggerClasses();
509  // don't do for MC and for PbPb 2010 data
510  if(!isMC && (event->GetRunNumber()<136851 || event->GetRunNumber()>139517)) {
511  if(!firedTriggerClasses.Contains(fTriggerClass[0].Data()) &&
512  (fTriggerClass[1].CompareTo("")==0 || !firedTriggerClasses.Contains(fTriggerClass[1].Data())) ) {
513  fWhyRejection=5;
515  accept=kFALSE;
516  }
517  }
518 
519  // TEMPORARY FIX FOR GetEvent
520  Int_t nTracks=((AliAODEvent*)event)->GetNumberOfTracks();
521  for(Int_t itr=0; itr<nTracks; itr++){
522  AliAODTrack* tr=(AliAODTrack*)((AliAODEvent*)event)->GetTrack(itr);
523  tr->SetAODEvent((AliAODEvent*)event);
524  }
525 
526  // TEMPORARY FIX FOR REFERENCES
527  // Fix references to daughter tracks
528  // if(fFixRefs) {
529  // AliAnalysisVertexingHF *fixer = new AliAnalysisVertexingHF();
530  // fixer->FixReferences((AliAODEvent*)event);
531  // delete fixer;
532  // }
533  //
534 
535 
536  // physics selection requirements
538  Bool_t isSelected = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & fTriggerMask);
539  if(!isSelected) {
540  if(accept) fWhyRejection=7;
542  accept=kFALSE;
543  }else{
544  if(fUseOnlyOneTrigger){
545  if(((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected()!=fTriggerMask){
546  if(accept) fWhyRejection=7;
548  accept=kFALSE;
549  }
550  }
552  AliAODVZERO* v0data=(AliAODVZERO*)((AliAODEvent*)event)->GetVZEROData();
553  Int_t tv0a=v0data->GetV0ADecision();
554  Int_t tv0c=v0data->GetV0CDecision();
555  if(!(tv0a==1 && tv0c==1)){
556  if(accept) fWhyRejection=7;
558  accept=kFALSE;
559  }
560  }
561  }
562  }
563 
564  // centrality selection
565  if (fUseCentrality!=kCentOff) {
566  Int_t rejection=IsEventSelectedInCentrality(event);
567  Bool_t okCent=kFALSE;
568  if(rejection==0) okCent=kTRUE;
569  if(isMC && rejection==4 && !fUseCentrFlatteningInMC) okCent=kTRUE;
570  if(!okCent){
571  if(accept) fWhyRejection=rejection;
574  accept=kFALSE;
575  }
576 
577  }
578 
579  // PbPb2011 outliers in tracklets vs. VZERO and centTRK vs. centV0
580  if(event->GetRunNumber()>=167693 && event->GetRunNumber()<=170593){
582  Double_t v0cent=GetCentrality((AliAODEvent*)event,kCentV0M);
583  Double_t ntracklets=((AliAODEvent*)event)->GetTracklets()->GetNumberOfTracklets();
584  Double_t cutval=60.-0.08*ntracklets+1./50000.*ntracklets*ntracklets;
585  if(ntracklets<1000. && v0cent<cutval){
586  if(accept) fWhyRejection=2;
588  accept=kFALSE;
589  }
590  }
591  if(fMaxDiffTRKV0Centr>0.){
592  Double_t v0cent=GetCentrality((AliAODEvent*)event,kCentV0M);
593  Double_t trkcent=GetCentrality((AliAODEvent*)event,kCentTRK);
594  if(TMath::Abs(trkcent-v0cent)>fMaxDiffTRKV0Centr){
595  if(accept) fWhyRejection=1;
597  accept=kFALSE;
598  }
599  }
600  }
601 
602  // vertex requirements
603 
604  const AliVVertex *vertex = event->GetPrimaryVertex();
605 
606  if(!vertex){
607  accept=kFALSE;
609  }else{
610  TString title=vertex->GetTitle();
611  if(title.Contains("Z") && fMinVtxType>1){
612  accept=kFALSE;
614  }
615  else if(title.Contains("3D") && fMinVtxType>2){
616  accept=kFALSE;
618  }
619  if(vertex->GetNContributors()<fMinVtxContr){
620  accept=kFALSE;
622  }
623  if(TMath::Abs(vertex->GetZ())>fMaxVtxZ) {
625  if(accept) fWhyRejection=6;
626  accept=kFALSE;
627  }
628  }
629 
630  if(fCutOnzVertexSPD>0){
631  const AliVVertex *vSPD = ((AliAODEvent*)event)->GetPrimaryVertexSPD();
632  if(!vSPD || (vSPD && vSPD->GetNContributors()<fMinVtxContr)){
633  accept=kFALSE;
635  }else{
636  if(fCutOnzVertexSPD==1 && TMath::Abs(vSPD->GetZ())>12.) {
637  // protection for events with bad reconstructed track vertex (introduced for 2011 Pb-Pb)
639  if(accept) fWhyRejection=6;
640  accept=kFALSE;
641  }
642  if(fCutOnzVertexSPD>=2 && vertex){
643  Double_t dz = vSPD->GetZ()-vertex->GetZ();
644  // cut on absolute distance between track and SPD vertex (introduced for 2011 Pb-Pb)
645  if(TMath::Abs(dz)>0.5) {
647  if(accept) fWhyRejection=0;
648  accept=kFALSE;
649  }
650  if(accept && fCutOnzVertexSPD==3){
651  // cut on nsigma distance between track and SPD vertex (for 2015 Pb-Pb)
652  double covTrc[6],covSPD[6];
653  vertex->GetCovarianceMatrix(covTrc);
654  vSPD->GetCovarianceMatrix(covSPD);
655  double errTot = TMath::Sqrt(covTrc[5]+covSPD[5]);
656  double errTrc = TMath::Sqrt(covTrc[5]);
657  double nsigTot = TMath::Abs(dz)/errTot, nsigTrc = TMath::Abs(dz)/errTrc;
658  if (TMath::Abs(dz)>0.2 || nsigTot>10 || nsigTrc>20){
659  // reject, bad reconstructed track vertex
661  if(accept) fWhyRejection=0;
662  accept=kFALSE;
663  }
664  }
665  }
666  }
667  }
668 
669  // pile-up rejection
671  Bool_t isPileup=kFALSE;
673  isPileup=event->IsPileupFromSPDInMultBins();
674  }else{
677  isPileup=event->IsPileupFromSPD(cutc,cutz,3.,2.,10.);
678  }
679  if(isPileup){
680  if(accept) fWhyRejection=1;
682  accept=kFALSE;
683  }
684  }
686  AliAnalysisUtils utils;
687  Bool_t isPUMV = utils.IsPileUpMV(event);
688  if(isPUMV) {
689  if(accept) fWhyRejection=1;
691  accept=kFALSE;
692  }
693  }
694 
695 
696  // Correcting PP2012 flag to remoce tracks crossing SPD misaligned staves for periods 12def
697  if(fApplySPDMisalignedPP2012 && !(event->GetRunNumber()>=195681 && event->GetRunNumber()<=197388)) fApplySPDMisalignedPP2012=false;
698 
699  return accept;
700 }
701 //---------------------------------------------------------------------------
703  //
704  // Daughter tracks selection
705  //
706  if(!fTrackCuts) return kTRUE;
707 
708  Int_t ndaughters = d->GetNDaughters();
709  AliAODVertex *vAOD = d->GetPrimaryVtx();
710  Double_t pos[3],cov[6];
711  vAOD->GetXYZ(pos);
712  vAOD->GetCovarianceMatrix(cov);
713  const AliESDVertex vESD(pos,cov,100.,100);
714 
715  Bool_t retval=kTRUE;
716 
717  for(Int_t idg=0; idg<ndaughters; idg++) {
718  AliAODTrack *dgTrack = (AliAODTrack*)d->GetDaughter(idg);
719  if(!dgTrack) {retval = kFALSE; continue;}
720  //printf("charge %d\n",dgTrack->Charge());
721  if(dgTrack->Charge()==0) continue; // it's not a track, but a V0
722 
724  { if(!dgTrack->HasPointOnITSLayer(0)) { retval = kFALSE; continue; } }
725 
726  if(!IsDaughterSelected(dgTrack,&vESD,fTrackCuts,aod)) retval = kFALSE;
727  }
728 
729  return retval;
730 }
731 //---------------------------------------------------------------------------
733  //
734  // Check if AOD and deltaAOD files are composed of the same events:
735  // mismatches were observed in the merged AODs of LHC15o
736  //
737  // When AOD+deltaAOD are produced from ESD, mismatches can be found looking at:
738  // - the AOD trees in AliAOD.root and AliAOD.VertexingHF.root have different number of entries
739  // - the titles of the TProcessID objects do not match
740  // When deltaAOD are produced from AOD, mismatches can be found looking at:
741  // - the AOD trees in AliAOD.root and AliAOD.VertexingHF.root have different number of entries
742  //
743  // Return values:
744  // -1: AOD and deltaAOD trees have different number of entries
745  // 0: AOD and deltaAOD trees have same number of entries + the titles of the TProcessID objects do not match
746  // 1: AOD and deltaAOD trees have same number of entries + the titles of the TProcessID objects match
747  Bool_t okTProcessNames = kTRUE;
748  AliAODHandler* aodHandler = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
749  TTree *treeAOD = aodHandler->GetTree();
750  TTree *treeDeltaAOD = treeAOD->GetFriend("aodTree");
751  if(!treeDeltaAOD || !treeAOD) return -1;
752  if(treeDeltaAOD && treeAOD){
753  if(treeAOD->GetEntries()!=treeDeltaAOD->GetEntries()){
754  printf("AliRDHFCuts::CheckMatchingAODdeltaAODevents: Difference in number of entries in main and friend tree, skipping event\n");
755  return -1;
756  }
757  TFile *mfile = treeAOD->GetCurrentFile();
758  TFile *dfile = treeDeltaAOD->GetCurrentFile();
759  TList* lm=mfile->GetListOfKeys();
760  TList* ld=dfile->GetListOfKeys();
761  Int_t nentm=lm->GetEntries();
762  for(Int_t jm=0; jm<nentm; jm++){
763  TKey* o=(TKey*)lm->At(jm);
764  TString clnam=o->GetClassName();
765  if(clnam=="TProcessID"){
766  TString pname=o->GetName();
767  TString ptit=o->GetTitle();
768  if(pname.Contains("ProcessID")){
769  TObject* od=(TObject*)ld->FindObject(pname.Data());
770  if(od){
771  TString ptit2=od->GetTitle();
772  if(ptit2!=ptit){
773  printf("AliRDHFCuts::CheckMatchingAODdeltaAODevents: mismatch in %s: AOD: %s -- deltaAOD: %s\n",pname.Data(),ptit.Data(),ptit2.Data());
774  okTProcessNames = kFALSE;
775  }
776  }
777  }
778  }
779  }
780  }
781 
782  if (okTProcessNames) return 1;
783  else return 0;
784 }
785 //---------------------------------------------------------------------------
787  //
788  // Check the correctness of the string syntax
789  //
790  Bool_t retval=kTRUE;
791 
792  if(!rows.Contains("pt")) {
793  if(print) AliError("string must contain \"pt\"");
794  retval= kFALSE;
795  }
796  return retval;
797 }
798 //---------------------------------------------------------------------------
800  //
801  //Create the TFormula from TString for TPC crossed rows pT dependent cut
802  //
803 
804 
805  // setting data member that describes the TPC crossed rows pT dependent cut
807 
808  // creating TFormula from TString
811  // resetting TFormula
813  }
814  if(!CheckPtDepCrossedRows(rows,kTRUE))return;
815 
816  TString tmp(rows);
817  tmp.ReplaceAll("pt","x");
818  f1CutMinNCrossedRowsTPCPtDep = new TFormula("f1CutMinNCrossedRowsTPCPtDep",tmp.Data());
819 
820 
821 }
822 //---------------------------------------------------------------------------
823 Bool_t AliRDHFCuts::IsDaughterSelected(AliAODTrack *track,const AliESDVertex *primary,AliESDtrackCuts *cuts, const AliAODEvent* aod) const{
824  //
825  // Convert to ESDtrack, relate to vertex and check cuts
826  //
827  if(!cuts) return kTRUE;
828 
829  if(cuts->GetFlagCutTOFdistance()) cuts->SetFlagCutTOFdistance(kFALSE);
830 
831 
832  // convert to ESD track here
833  AliESDtrack esdTrack(track);
834  // set the TPC cluster info
835  esdTrack.SetTPCClusterMap(track->GetTPCClusterMap());
836  esdTrack.SetTPCSharedMap(track->GetTPCSharedMap());
837  esdTrack.SetTPCPointsF(track->GetTPCNclsF());
838  // needed to calculate the impact parameters
839  esdTrack.RelateToVertex(primary,0.,3.);
840 
841  //applying ESDtrackCut
842  if(!cuts->IsSelected(&esdTrack)) return kFALSE;
843 
844  //appliyng kink rejection
845  if(fKinkReject){
846  AliAODVertex *maybeKink=track->GetProdVertex();
847  if(maybeKink->GetType()==AliAODVertex::kKink) return kFALSE;
848  }
849 
850  //appliyng TPC crossed rows pT dependent cut
852  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
853  if(nCrossedRowsTPC<f1CutMinNCrossedRowsTPCPtDep->Eval(esdTrack.Pt())) return kFALSE;
854  }
855 
856  //appliyng NTPCcls/NTPCcrossedRows cut
858  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
859  Float_t nClustersTPC = esdTrack.GetTPCNcls();
860  if(nCrossedRowsTPC!=0){
861  Float_t ratio = nClustersTPC/nCrossedRowsTPC;
862  if(ratio<fCutRatioClsOverCrossRowsTPC) return kFALSE;
863  }
864  else return kFALSE;
865  }
866 
867  //appliyng TPCsignalN/NTPCcrossedRows cut
869  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
870  Float_t nTPCsignal = esdTrack.GetTPCsignalN();
871  if(nCrossedRowsTPC!=0){
872  Float_t ratio = nTPCsignal/nCrossedRowsTPC;
873  if(ratio<fCutRatioSignalNOverCrossRowsTPC) return kFALSE;
874  }
875  else return kFALSE;
876  }
877 
878  // geometrical cut (note uses track at vertex instead of at TPC inner wall)
879  if(fUseCutGeoNcrNcl && aod){
880  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
881  Float_t lengthInActiveZoneTPC=esdTrack.GetLengthInActiveZone(0,fDeadZoneWidth,220.,aod->GetMagneticField());
882  Double_t cutGeoNcrNclLength=fCutGeoNcrNclLength-TMath::Power(TMath::Abs(esdTrack.GetSigned1Pt()),fCutGeoNcrNclGeom1Pt);
883  Bool_t isOK=kTRUE;
884  if (lengthInActiveZoneTPC<cutGeoNcrNclLength) isOK=kFALSE;
885  if (nCrossedRowsTPC<fCutGeoNcrNclFractionNcr*cutGeoNcrNclLength) isOK=kFALSE;
886  if (esdTrack.GetTPCncls()<fCutGeoNcrNclFractionNcl*cutGeoNcrNclLength) isOK=kFALSE;
887  if(!isOK) return kFALSE;
888  }
889 
890 
892  // to be implemented
893  // we need either to have here the AOD Event,
894  // or to have the pileup vertex object
895  }
896 
898  Bool_t deadSPDLay1PbPb2011[20][4]={
899  {kTRUE,kTRUE,kTRUE,kTRUE},
900  {kTRUE,kTRUE,kTRUE,kTRUE},
901  {kTRUE,kTRUE,kTRUE,kTRUE},
902  {kTRUE,kTRUE,kTRUE,kTRUE},
903  {kTRUE,kTRUE,kTRUE,kTRUE},
904  {kFALSE,kFALSE,kTRUE,kTRUE},
905  {kTRUE,kTRUE,kFALSE,kFALSE},
906  {kTRUE,kTRUE,kTRUE,kTRUE},
907  {kFALSE,kFALSE,kTRUE,kTRUE},
908  {kTRUE,kTRUE,kTRUE,kTRUE},
909  {kTRUE,kTRUE,kFALSE,kFALSE},
910  {kTRUE,kTRUE,kTRUE,kTRUE},
911  {kFALSE,kFALSE,kFALSE,kFALSE},
912  {kFALSE,kFALSE,kTRUE,kTRUE},
913  {kFALSE,kFALSE,kFALSE,kFALSE},
914  {kFALSE,kFALSE,kFALSE,kFALSE},
915  {kTRUE,kTRUE,kTRUE,kTRUE},
916  {kTRUE,kTRUE,kFALSE,kFALSE},
917  {kFALSE,kFALSE,kFALSE,kFALSE},
918  {kFALSE,kFALSE,kFALSE,kFALSE}
919  };
920  Bool_t deadSPDLay2PbPb2011[40][4]={
921  {kTRUE,kTRUE,kTRUE,kTRUE},
922  {kTRUE,kTRUE,kTRUE,kTRUE},
923  {kTRUE,kTRUE,kTRUE,kTRUE},
924  {kTRUE,kTRUE,kTRUE,kTRUE},
925  {kTRUE,kTRUE,kTRUE,kTRUE},
926  {kTRUE,kTRUE,kTRUE,kTRUE},
927  {kTRUE,kTRUE,kTRUE,kTRUE},
928  {kTRUE,kTRUE,kTRUE,kTRUE},
929  {kTRUE,kTRUE,kTRUE,kTRUE},
930  {kTRUE,kTRUE,kTRUE,kTRUE},
931  {kTRUE,kTRUE,kTRUE,kTRUE},
932  {kTRUE,kTRUE,kTRUE,kTRUE},
933  {kFALSE,kFALSE,kFALSE,kFALSE},
934  {kFALSE,kFALSE,kTRUE,kTRUE},
935  {kTRUE,kTRUE,kTRUE,kTRUE},
936  {kTRUE,kTRUE,kTRUE,kTRUE},
937  {kTRUE,kTRUE,kFALSE,kFALSE},
938  {kTRUE,kTRUE,kTRUE,kTRUE},
939  {kTRUE,kTRUE,kTRUE,kTRUE},
940  {kTRUE,kTRUE,kTRUE,kTRUE},
941  {kFALSE,kFALSE,kFALSE,kFALSE},
942  {kFALSE,kFALSE,kFALSE,kFALSE},
943  {kTRUE,kTRUE,kTRUE,kTRUE},
944  {kTRUE,kTRUE,kTRUE,kTRUE},
945  {kFALSE,kFALSE,kFALSE,kFALSE},
946  {kFALSE,kFALSE,kFALSE,kFALSE},
947  {kTRUE,kTRUE,kTRUE,kTRUE},
948  {kTRUE,kTRUE,kTRUE,kTRUE},
949  {kFALSE,kFALSE,kFALSE,kFALSE},
950  {kFALSE,kFALSE,kFALSE,kFALSE},
951  {kFALSE,kFALSE,kFALSE,kFALSE},
952  {kFALSE,kFALSE,kFALSE,kFALSE},
953  {kTRUE,kTRUE,kTRUE,kTRUE},
954  {kTRUE,kTRUE,kTRUE,kTRUE},
955  {kTRUE,kTRUE,kFALSE,kFALSE},
956  {kTRUE,kTRUE,kTRUE,kTRUE},
957  {kFALSE,kFALSE,kFALSE,kFALSE},
958  {kFALSE,kFALSE,kFALSE,kFALSE},
959  {kFALSE,kFALSE,kFALSE,kFALSE},
960  {kFALSE,kFALSE,kFALSE,kFALSE}
961  };
962  Double_t xyz1[3],xyz2[3];
963  esdTrack.GetXYZAt(3.9,0.,xyz1);
964  esdTrack.GetXYZAt(7.6,0.,xyz2);
965  Double_t phi1=TMath::ATan2(xyz1[1],xyz1[0]);
966  if(phi1<0) phi1+=2*TMath::Pi();
967  Int_t lad1=(Int_t)(phi1/(2.*TMath::Pi()/20.));
968  Double_t phi2=TMath::ATan2(xyz2[1],xyz2[0]);
969  if(phi2<0) phi2+=2*TMath::Pi();
970  Int_t lad2=(Int_t)(phi2/(2.*TMath::Pi()/40.));
971  Int_t mod1=(Int_t)((xyz1[2]+14)/7.);
972  Int_t mod2=(Int_t)((xyz2[2]+14)/7.);
973  Bool_t lay1ok=kFALSE;
974  if(mod1>=0 && mod1<4 && lad1<20){
975  lay1ok=deadSPDLay1PbPb2011[lad1][mod1];
976  }
977  Bool_t lay2ok=kFALSE;
978  if(mod2>=0 && mod2<4 && lad2<40){
979  lay2ok=deadSPDLay2PbPb2011[lad2][mod2];
980  }
981  if(!lay1ok && !lay2ok) return kFALSE;
982  }
983 
985  // Cut tracks crossing the SPD at 5.6<phi<2pi
986  Double_t xyz1[3],xyz2[3];
987  esdTrack.GetXYZAt(3.9,0.,xyz1);
988  esdTrack.GetXYZAt(7.6,0.,xyz2);
989  Double_t phi1=TMath::ATan2(xyz1[1],xyz1[0]);
990  if(phi1<0) phi1+=2*TMath::Pi();
991  Double_t phi2=TMath::ATan2(xyz2[1],xyz2[0]);
992  if(phi2<0) phi2+=2*TMath::Pi();
993  Bool_t lay1ok=kTRUE;
994  if(phi1>5.6 && phi1<2.*TMath::Pi()) lay1ok=kFALSE;
995  Bool_t lay2ok=kTRUE;
996  if(phi2>5.6 && phi2<2.*TMath::Pi()) lay2ok=kFALSE;
997  if(!lay1ok || !lay2ok) return kFALSE;
998  }
999 
1000  return kTRUE;
1001 }
1002 //---------------------------------------------------------------------------
1003 void AliRDHFCuts::SetPtBins(Int_t nPtBinLimits,Float_t *ptBinLimits) {
1004  // Set the pt bins
1005 
1006  if(fPtBinLimits) {
1007  delete [] fPtBinLimits;
1008  fPtBinLimits = NULL;
1009  printf("Changing the pt bins\n");
1010  }
1011 
1012  if(nPtBinLimits != fnPtBins+1){
1013  cout<<"Warning: ptBinLimits dimention "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBins+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
1014  SetNPtBins(nPtBinLimits-1);
1015  }
1016 
1017  fnPtBinLimits = nPtBinLimits;
1018  SetGlobalIndex();
1019  //cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl;
1021  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimits[ib]=ptBinLimits[ib];
1022 
1023  return;
1024 }
1025 //---------------------------------------------------------------------------
1026 void AliRDHFCuts::SetVarNames(Int_t nVars,TString *varNames,Bool_t *isUpperCut){
1027  // Set the variable names
1028 
1029  if(fVarNames) {
1030  delete [] fVarNames;
1031  fVarNames = NULL;
1032  //printf("Changing the variable names\n");
1033  }
1034  if(nVars!=fnVars){
1035  printf("Wrong number of variables: it has to be %d\n",fnVars);
1036  return;
1037  }
1038  //fnVars=nVars;
1039  fVarNames = new TString[nVars];
1040  fIsUpperCut = new Bool_t[nVars];
1041  for(Int_t iv=0; iv<nVars; iv++) {
1042  fVarNames[iv] = varNames[iv];
1043  fIsUpperCut[iv] = isUpperCut[iv];
1044  }
1045 
1046  return;
1047 }
1048 //---------------------------------------------------------------------------
1050  // Set the variables to be used for cuts optimization
1051 
1052  if(fVarsForOpt) {
1053  delete [] fVarsForOpt;
1054  fVarsForOpt = NULL;
1055  //printf("Changing the variables for cut optimization\n");
1056  }
1057 
1058  if(nVars==0){
1059  printf("%d not accepted as number of variables: it has to be %d\n",nVars,fnVars);
1060  return;
1061  }
1062 
1063  fnVarsForOpt = 0;
1064  fVarsForOpt = new Bool_t[fnVars];
1065  for(Int_t iv=0; iv<fnVars; iv++) {
1066  fVarsForOpt[iv]=forOpt[iv];
1067  if(fVarsForOpt[iv]) fnVarsForOpt++;
1068  }
1069 
1070  return;
1071 }
1072 
1073 //---------------------------------------------------------------------------
1075  //
1076  // set centrality estimator
1077  //
1078  fUseCentrality=flag;
1079  if(fUseCentrality<kCentOff||fUseCentrality>=kCentInvalid) AliWarning("Centrality estimator not valid");
1080 
1081  return;
1082 }
1083 
1084 
1085 //---------------------------------------------------------------------------
1087  //
1088  // store the cuts
1089  //
1090  if(nVars!=fnVars) {
1091  printf("Wrong number of variables: it has to be %d\n",fnVars);
1092  AliFatal("exiting");
1093  }
1094  if(nPtBins!=fnPtBins) {
1095  printf("Wrong number of pt bins: it has to be %d\n",fnPtBins);
1096  AliFatal("exiting");
1097  }
1098 
1099  if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex];
1100 
1101 
1102  for(Int_t iv=0; iv<fnVars; iv++) {
1103 
1104  for(Int_t ib=0; ib<fnPtBins; ib++) {
1105 
1106  //check
1107  if(GetGlobalIndex(iv,ib)>=fGlobalIndex) {
1108  cout<<"Overflow, exit..."<<endl;
1109  return;
1110  }
1111 
1112  fCutsRD[GetGlobalIndex(iv,ib)] = cutsRD[iv][ib];
1113 
1114  }
1115  }
1116  return;
1117 }
1118 //---------------------------------------------------------------------------
1119 void AliRDHFCuts::SetCuts(Int_t glIndex,Float_t* cutsRDGlob){
1120  //
1121  // store the cuts
1122  //
1123  if(glIndex != fGlobalIndex){
1124  cout<<"Wrong array size: it has to be "<<fGlobalIndex<<endl;
1125  AliFatal("exiting");
1126  }
1127  if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex];
1128 
1129  for(Int_t iGl=0;iGl<fGlobalIndex;iGl++){
1130  fCutsRD[iGl] = cutsRDGlob[iGl];
1131  }
1132  return;
1133 }
1134 //---------------------------------------------------------------------------
1136  //
1137  // print all cuts values
1138  //
1139 
1140  printf("Minimum vtx type %d\n",fMinVtxType);
1141  printf("Minimum vtx contr %d\n",fMinVtxContr);
1142  printf("Max vtx red chi2 %f\n",fMaxVtxRedChi2);
1143  printf("Min SPD mult %d\n",fMinSPDMultiplicity);
1144  printf("Use PID %d OldPid=%d\n",(Int_t)fUsePID,fPidHF ? fPidHF->GetOldPid() : -1);
1145  printf("Remove daughters from vtx %d\n",(Int_t)fRemoveDaughtersFromPrimary);
1146  printf("Physics selection: %s\n",fUsePhysicsSelection ? "Yes" : "No");
1147  printf("Pileup rejection: %s\n",(fOptPileup > 0) ? "Yes" : "No");
1148  if(fOptPileup==1) printf(" -- Reject pileup event");
1149  if(fOptPileup==2) printf(" -- Reject tracks from pileup vtx");
1150  if(fUseCentrality>0) {
1151  TString estimator="";
1152  if(fUseCentrality==1) estimator = "V0";
1153  if(fUseCentrality==2) estimator = "Tracks";
1154  if(fUseCentrality==3) estimator = "Tracklets";
1155  if(fUseCentrality==4) estimator = "SPD clusters outer";
1156  if(fUseCentrality==5) estimator = "ZNA";
1157  if(fUseCentrality==6) estimator = "ZPA";
1158  if(fUseCentrality==7) estimator = "V0A";
1159  printf("Centrality class considered: %.1f-%.1f, estimated with %s\n",fMinCentrality,fMaxCentrality,estimator.Data());
1160  }
1161  if(fIsCandTrackSPDFirst) printf("Check for candidates with pt < %2.2f, that daughters fullfill kFirst criteria\n",fMaxPtCandTrackSPDFirst);
1162 
1163  if(fCutRatioClsOverCrossRowsTPC) printf("N TPC Clusters > %f N TPC Crossed Rows\n", fCutRatioClsOverCrossRowsTPC);
1164  if(fCutRatioSignalNOverCrossRowsTPC) printf("N TPC Points for dE/dx > %f N TPC Crossed Rows\n", fCutRatioSignalNOverCrossRowsTPC);
1165  if(f1CutMinNCrossedRowsTPCPtDep) printf("N TPC Crossed Rows pT-dependent cut: %s\n", fCutMinCrossedRowsTPCPtDep.Data());
1166 
1167  if(fVarNames){
1168  cout<<"Array of variables"<<endl;
1169  for(Int_t iv=0;iv<fnVars;iv++){
1170  cout<<fVarNames[iv]<<"\t";
1171  }
1172  cout<<endl;
1173  }
1174  if(fVarsForOpt){
1175  cout<<"Array of optimization"<<endl;
1176  for(Int_t iv=0;iv<fnVars;iv++){
1177  cout<<fVarsForOpt[iv]<<"\t";
1178  }
1179  cout<<endl;
1180  }
1181  if(fIsUpperCut){
1182  cout<<"Array of upper/lower cut"<<endl;
1183  for(Int_t iv=0;iv<fnVars;iv++){
1184  cout<<fIsUpperCut[iv]<<"\t";
1185  }
1186  cout<<endl;
1187  }
1188  if(fPtBinLimits){
1189  cout<<"Array of ptbin limits"<<endl;
1190  for(Int_t ib=0;ib<fnPtBinLimits;ib++){
1191  cout<<fPtBinLimits[ib]<<"\t";
1192  }
1193  cout<<endl;
1194  }
1195  if(fCutsRD){
1196  cout<<"Matrix of cuts"<<endl;
1197  for(Int_t iv=0;iv<fnVars;iv++){
1198  for(Int_t ib=0;ib<fnPtBins;ib++){
1199  cout<<"fCutsRD["<<iv<<"]["<<ib<<"] = "<<fCutsRD[GetGlobalIndex(iv,ib)]<<"\t";
1200  }
1201  cout<<endl;
1202  }
1203  cout<<endl;
1204  }
1205  if(fPidHF) fPidHF->PrintAll();
1206  return;
1207 }
1208 
1209 //--------------------------------------------------------------------------
1211  // print the trigger selection
1212 
1213  printf("Selected trigger classes: %s %s\n",fTriggerClass[0].Data(),fTriggerClass[1].Data());
1214 
1215  cout<<" Trigger selection pattern: ";
1216  if( fTriggerMask & AliVEvent::kAny ) cout<<" kAny ";
1217  if( fTriggerMask & AliVEvent::kAnyINT ) cout<<" kAnyINT ";
1218  if( fTriggerMask & AliVEvent::kINT7 ) cout<<" kINT7 ";
1219  if( fTriggerMask & AliVEvent::kMB ) cout<<" kMB ";
1220  if( fTriggerMask & AliVEvent::kCINT5 ) cout<<" kCINT5 ";
1221  if( fTriggerMask & AliVEvent::kCentral ) cout<<" kCentral ";
1222  if( fTriggerMask & AliVEvent::kSemiCentral ) cout<<" kSemiCentral ";
1223  if( fTriggerMask & AliVEvent::kEMCEGA ) cout<<" kEMCEGA ";
1224  if( fTriggerMask & AliVEvent::kHighMult ) cout<<" kHighMult ";
1225  if( fTriggerMask & AliVEvent::kFastOnly ) cout<<" kFastOnly ";
1226  cout << endl<< endl;
1227 
1228 }
1229 
1230 //---------------------------------------------------------------------------
1231 void AliRDHFCuts::GetCuts(Float_t**& cutsRD) const{
1232  //
1233  // get the cuts
1234  //
1235 
1236  //cout<<"Give back a "<<fnVars<<"x"<<fnPtBins<<" matrix."<<endl;
1237 
1238 
1239  Int_t iv,ib;
1240  if(!cutsRD) {
1241  //cout<<"Initialization..."<<endl;
1242  cutsRD=new Float_t*[fnVars];
1243  for(iv=0; iv<fnVars; iv++) {
1244  cutsRD[iv] = new Float_t[fnPtBins];
1245  }
1246  }
1247 
1248  for(Int_t iGlobal=0; iGlobal<fGlobalIndex; iGlobal++) {
1249  GetVarPtIndex(iGlobal,iv,ib);
1250  cutsRD[iv][ib] = fCutsRD[iGlobal];
1251  }
1252 
1253  return;
1254 }
1255 
1256 //---------------------------------------------------------------------------
1258  //
1259  // give the global index from variable and pt bin
1260  //
1261  return iPtBin*fnVars+iVar;
1262 }
1263 
1264 //---------------------------------------------------------------------------
1265 void AliRDHFCuts::GetVarPtIndex(Int_t iGlob, Int_t& iVar, Int_t& iPtBin) const {
1266  //
1267  //give the index of the variable and of the pt bin from the global index
1268  //
1269  iPtBin=(Int_t)iGlob/fnVars;
1270  iVar=iGlob%fnVars;
1271 
1272  return;
1273 }
1274 
1275 //---------------------------------------------------------------------------
1277  //
1278  //give the pt bin where the pt lies.
1279  //
1280  Int_t ptbin=-1;
1281  if(pt<fPtBinLimits[0])return ptbin;
1282  for (Int_t i=0;i<fnPtBins;i++){
1283  if(pt<fPtBinLimits[i+1]) {
1284  ptbin=i;
1285  break;
1286  }
1287  }
1288  return ptbin;
1289 }
1290 //-------------------------------------------------------------------
1292  //
1293  // Give the value of cut set for the variable iVar and the pt bin iPtBin
1294  //
1295  if(!fCutsRD){
1296  cout<<"Cuts not iniziaisez yet"<<endl;
1297  return 0;
1298  }
1299  return fCutsRD[GetGlobalIndex(iVar,iPtBin)];
1300 }
1301 
1302 //-------------------------------------------------------------------
1304 
1305  if(aodEvent->GetRunNumber()<244824)return GetCentralityOldFramework(aodEvent,estimator);
1306  Double_t cent=-999;
1307 
1308  if(estimator==kCentOff) return -999;
1309 
1310  AliMultSelection *multSelection = (AliMultSelection*)aodEvent->FindListObject(fMultSelectionObjectName);
1311  if(!multSelection){
1312  AliWarning("AliMultSelection could not be found in the aod event list of objects");
1313  return cent;
1314  }
1315 
1316  // Compare centrality with the centrality at AOD filtering and on-the-fly
1317  if( fMultSelectionObjectName.CompareTo("MultSelection")!=0 ){
1318  AliMultSelection *defaultmultSelection = (AliMultSelection*)aodEvent->FindListObject("MultSelection");
1319  if(!defaultmultSelection){
1320  AliWarning("AliMultSelection default method could not be found in the aod event list of objects");
1321  return cent;
1322  }
1323  Float_t defaultCent = defaultmultSelection->GetMultiplicityPercentile("V0M");
1324  Float_t newCent = multSelection->GetMultiplicityPercentile("V0M");
1325  if( defaultCent<20. && newCent>20.) fEvRejectionBits+=1<<kMismatchOldNewCentrality;
1326  else if (defaultCent>20. && newCent<20.) fEvRejectionBits+=1<<kMismatchOldNewCentrality;
1327  }
1328 
1329  if(estimator==kCentV0M){
1330  cent=multSelection->GetMultiplicityPercentile("V0M");
1331  }else if(estimator==kCentV0A){
1332  cent=multSelection->GetMultiplicityPercentile("V0A");
1333  }else if(estimator==kCentZNA){
1334  cent=multSelection->GetMultiplicityPercentile("ZNA");
1335  }else if(estimator==kCentCL1){
1336  cent=multSelection->GetMultiplicityPercentile("CL1");
1337  }else {
1338  AliWarning(Form("CENTRALITY ESTIMATE WITH ESTIMATOR %d NOT YET IMPLEMENTED FOR NEW FRAMEWORK",(Int_t)estimator));
1339  return cent;
1340  }
1341  Int_t qual = multSelection->GetEvSelCode();
1342  if(qual == 199 ) cent=-999;
1343  return cent;
1344 }
1345 //-------------------------------------------------------------------
1347  //
1348  // Get centrality percentile
1349  //
1350 
1351  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)aodEvent)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
1352  if(mcArray) {fUseAOD049=kFALSE;}
1353 
1354  AliAODHeader *header=dynamic_cast<AliAODHeader*>(aodEvent->GetHeader());
1355  if(!header) AliFatal("Not a standard AOD");
1356  AliCentrality *centrality=header->GetCentralityP();
1357  Float_t cent=-999.;
1358  Bool_t isSelRun=kFALSE;
1359  Int_t selRun[5]={138364, 138826, 138828, 138836, 138871};
1360  if(!centrality) return cent;
1361  else{
1362  if (estimator==kCentV0M){
1363  cent=(Float_t)(centrality->GetCentralityPercentile("V0M"));
1364  if(cent<0){
1365  Int_t quality = centrality->GetQuality();
1366  if(quality<=1){ // fQuality==1 means rejected by zVertex cut that we apply a part and we want to keep separate (Giacomo)
1367  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0M");
1368  }else{
1369  Int_t runnum=aodEvent->GetRunNumber();
1370  for(Int_t ir=0;ir<5;ir++){
1371  if(runnum==selRun[ir]){
1372  isSelRun=kTRUE;
1373  break;
1374  }
1375  }
1376  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0M");
1377  }
1378  }
1379 
1380  //temporary fix for AOD049 outliers
1381  if(fUseAOD049&&cent>=0){
1382  Float_t v0=0;
1383  AliAODVZERO* aodV0 = aodEvent->GetVZEROData();
1384  v0+=aodV0->GetMTotV0A();
1385  v0+=aodV0->GetMTotV0C();
1386  if(cent==0&&v0<19500)return -1;//filtering issue
1387  Float_t tkl = (Float_t)(aodEvent->GetTracklets()->GetNumberOfTracklets());
1388  Float_t val= 1.30552 + 0.147931 * v0;
1389  Float_t tklSigma[101]={176.644, 156.401, 153.789, 153.015, 142.476, 137.951, 136.127, 129.852, 127.436, 124.86, 120.788, 115.611, 113.172, 110.496, 109.127, 104.421, 102.479, 99.9766, 97.5152, 94.0654, 92.4602, 89.3364, 87.1342, 83.3497, 82.6216, 81.1084, 78.0793, 76.1234, 72.9434, 72.1334, 68.0056, 68.2755, 66.0376, 62.9666, 62.4274, 59.65, 58.3776, 56.6361, 54.5184, 53.4224, 51.932, 50.8922, 48.2848, 47.912, 46.5717, 43.4114, 43.2083, 41.3065, 40.1863, 38.5255, 37.2851, 37.5396, 34.4949, 33.8366, 31.8043, 31.7412, 30.8392, 30.0274, 28.8793, 27.6398, 26.6488, 25.0183, 25.1489, 24.4185, 22.9107, 21.2002, 21.6977, 20.1242, 20.4963, 19.0235, 19.298, 17.4103, 16.868, 15.2939, 15.2939, 16.0295, 14.186, 14.186, 15.2173, 12.9504, 12.9504, 12.9504, 15.264, 12.3674, 12.3674, 12.3674, 12.3674, 12.3674, 18.3811, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544, 13.7544};
1390  if ( TMath::Abs(tkl-val) > 6.*tklSigma[(Int_t)cent] )return -1;//outlier
1391  }
1392  }
1393  else {
1394  if (estimator==kCentTRK) {
1395  cent=(Float_t)(centrality->GetCentralityPercentile("TRK"));
1396  if(cent<0){
1397  Int_t quality = centrality->GetQuality();
1398  if(quality<=1){
1399  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TRK");
1400  }else{
1401  Int_t runnum=aodEvent->GetRunNumber();
1402  for(Int_t ir=0;ir<5;ir++){
1403  if(runnum==selRun[ir]){
1404  isSelRun=kTRUE;
1405  break;
1406  }
1407  }
1408  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TRK");
1409  }
1410  }
1411  }
1412  else{
1413  if (estimator==kCentTKL){
1414  cent=(Float_t)(centrality->GetCentralityPercentile("TKL"));
1415  if(cent<0){
1416  Int_t quality = centrality->GetQuality();
1417  if(quality<=1){
1418  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TKL");
1419  }else{
1420  Int_t runnum=aodEvent->GetRunNumber();
1421  for(Int_t ir=0;ir<5;ir++){
1422  if(runnum==selRun[ir]){
1423  isSelRun=kTRUE;
1424  break;
1425  }
1426  }
1427  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TKL");
1428  }
1429  }
1430  }
1431  else{
1432  if (estimator==kCentCL1){
1433  cent=(Float_t)(centrality->GetCentralityPercentile("CL1"));
1434  if(cent<0){
1435  Int_t quality = centrality->GetQuality();
1436  if(quality<=1){
1437  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("CL1");
1438  }else{
1439  Int_t runnum=aodEvent->GetRunNumber();
1440  for(Int_t ir=0;ir<5;ir++){
1441  if(runnum==selRun[ir]){
1442  isSelRun=kTRUE;
1443  break;
1444  }
1445  }
1446  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("CL1");
1447  }
1448  }
1449  }
1450  else{
1451  if (estimator==kCentZNA){
1452  cent=(Float_t)(centrality->GetCentralityPercentile("ZNA"));
1453  if(cent<0){
1454  Int_t quality = centrality->GetQuality();
1455  if(quality<=1){
1456  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZNA");
1457  }else{
1458  Int_t runnum=aodEvent->GetRunNumber();
1459  for(Int_t ir=0;ir<5;ir++){
1460  if(runnum==selRun[ir]){
1461  isSelRun=kTRUE;
1462  break;
1463  }
1464  }
1465  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZNA");
1466  }
1467  }
1468  }
1469  else{
1470  if (estimator==kCentZPA){
1471  cent=(Float_t)(centrality->GetCentralityPercentile("ZPA"));
1472  if(cent<0){
1473  Int_t quality = centrality->GetQuality();
1474  if(quality<=1){
1475  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZPA");
1476  }else{
1477  Int_t runnum=aodEvent->GetRunNumber();
1478  for(Int_t ir=0;ir<5;ir++){
1479  if(runnum==selRun[ir]){
1480  isSelRun=kTRUE;
1481  break;
1482  }
1483  }
1484  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZPA");
1485  }
1486  }
1487  }
1488  else{
1489  if (estimator==kCentV0A){
1490  cent=(Float_t)(centrality->GetCentralityPercentile("V0A"));
1491  if(cent<0){
1492  Int_t quality = centrality->GetQuality();
1493  if(quality<=1){
1494  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0A");
1495  }else{
1496  Int_t runnum=aodEvent->GetRunNumber();
1497  for(Int_t ir=0;ir<5;ir++){
1498  if(runnum==selRun[ir]){
1499  isSelRun=kTRUE;
1500  break;
1501  }
1502  }
1503  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0A");
1504  }
1505  }
1506  }
1507  else {
1508  AliWarning("Centrality estimator not valid");
1509 
1510  }
1511  }
1512  }
1513  }
1514  }
1515  }
1516  }
1517  }
1518  return cent;
1519 }
1520 //-------------------------------------------------------------------
1522  //
1523  // Compare two cuts objects
1524  //
1525 
1526  Bool_t areEqual=kTRUE;
1527 
1528  if(fMinVtxType!=obj->fMinVtxType) { printf("Minimum vtx type %d %d\n",fMinVtxType,obj->fMinVtxType); areEqual=kFALSE;}
1529 
1530  if(fMinVtxContr!=obj->fMinVtxContr) { printf("Minimum vtx contr %d %d\n",fMinVtxContr,obj->fMinVtxContr); areEqual=kFALSE;}
1531 
1532  if(TMath::Abs(fMaxVtxRedChi2-obj->fMaxVtxRedChi2)>1.e-10) { printf("Max vtx red chi2 %f %f\n",fMaxVtxRedChi2,obj->fMaxVtxRedChi2);areEqual=kFALSE;}
1533 
1534  if(fMinSPDMultiplicity!=obj->fMinSPDMultiplicity) { printf("Min SPD mult %d\n %d",fMinSPDMultiplicity,obj->fMinSPDMultiplicity);areEqual=kFALSE;}
1535 
1536  if(fUsePID!=obj->fUsePID) { printf("Use PID %d %d\n",(Int_t)fUsePID,(Int_t)obj->fUsePID); areEqual=kFALSE;}
1537 
1538  if(fRemoveDaughtersFromPrimary!=obj->fRemoveDaughtersFromPrimary) {printf("Remove daughters from vtx %d %d\n",(Int_t)fRemoveDaughtersFromPrimary,(Int_t)obj->fRemoveDaughtersFromPrimary); areEqual=kFALSE;}
1539  if(fTrackCuts){
1540  if(fTrackCuts->GetMinNClusterTPC()!=obj->fTrackCuts->GetMinNClusterTPC()) {printf("MinNClsTPC %d %d\n",fTrackCuts->GetMinNClusterTPC(),obj->fTrackCuts->GetMinNClusterTPC()); areEqual=kFALSE;}
1541 
1542  if(fTrackCuts->GetMinNClustersITS()!=obj->fTrackCuts->GetMinNClustersITS()) {printf("MinNClsITS %d %d\n",fTrackCuts->GetMinNClustersITS(),obj->fTrackCuts->GetMinNClustersITS()); areEqual=kFALSE;}
1543 
1544  if(TMath::Abs(fTrackCuts->GetMaxChi2PerClusterTPC()-obj->fTrackCuts->GetMaxChi2PerClusterTPC())>1.e-10) {printf("MaxChi2ClsTPC %f %f\n",fTrackCuts->GetMaxChi2PerClusterTPC(),obj->fTrackCuts->GetMaxChi2PerClusterTPC()); areEqual=kFALSE;}
1545 
1546  if(fTrackCuts->GetClusterRequirementITS(AliESDtrackCuts::kSPD)!=obj->fTrackCuts->GetClusterRequirementITS(AliESDtrackCuts::kSPD)) {printf("ClusterReq SPD %d %d\n",fTrackCuts->GetClusterRequirementITS(AliESDtrackCuts::kSPD),obj->fTrackCuts->GetClusterRequirementITS(AliESDtrackCuts::kSPD)); areEqual=kFALSE;}
1547  }
1548 
1549  if(fCutsRD) {
1550  for(Int_t iv=0;iv<fnVars;iv++) {
1551  for(Int_t ib=0;ib<fnPtBins;ib++) {
1552  if(TMath::Abs(fCutsRD[GetGlobalIndex(iv,ib)]-obj->fCutsRD[GetGlobalIndex(iv,ib)])>1.e-10) {
1553  cout<<"fCutsRD["<<iv<<"]["<<ib<<"] = "<<fCutsRD[GetGlobalIndex(iv,ib)]<<" "<<obj->fCutsRD[GetGlobalIndex(iv,ib)]<<"\n";
1554  areEqual=kFALSE;
1555  }
1556  }
1557  }
1558  }
1559 
1560  return areEqual;
1561 }
1562 //---------------------------------------------------------------------------
1564  //
1565  // print cuts values in table format
1566  //
1567 
1568  TString ptString = "pT range";
1569  if(fVarNames && fPtBinLimits && fCutsRD){
1570  TString firstLine(Form("* %-15s",ptString.Data()));
1571  for (Int_t ivar=0; ivar<fnVars; ivar++){
1572  firstLine+=Form("* %-15s ",fVarNames[ivar].Data());
1573  if (ivar == fnVars){
1574  firstLine+="*\n";
1575  }
1576  }
1577  Printf("%s",firstLine.Data());
1578 
1579  for (Int_t ipt=0; ipt<fnPtBins; ipt++){
1580  TString line;
1581  if (ipt==fnPtBins-1){
1582  line=Form("* %5.1f < pt < inf ",fPtBinLimits[ipt]);
1583  }
1584  else{
1585  line=Form("* %5.1f < pt < %4.1f ",fPtBinLimits[ipt],fPtBinLimits[ipt+1]);
1586  }
1587  for (Int_t ivar=0; ivar<fnVars; ivar++){
1588  line+=Form("* %-15f ",fCutsRD[GetGlobalIndex(ivar,ipt)]);
1589  }
1590  Printf("%s",line.Data());
1591  }
1592 
1593  }
1594 
1595 
1596  return;
1597 }
1598 //--------------------------------------------------------------------------
1600  AliAODEvent *aod) const
1601 {
1602  //
1603  // Recalculate primary vertex without daughters
1604  //
1605 
1606  if(!aod) {
1607  AliError("Can not remove daughters from vertex without AOD event");
1608  return 0;
1609  }
1610 
1611  AliAODVertex *recvtx=d->RemoveDaughtersFromPrimaryVtx(aod);
1612  if(!recvtx){
1613  AliDebug(2,"Removal of daughter tracks failed");
1614  return kFALSE;
1615  }
1616 
1617 
1618  //set recalculed primary vertex
1619  d->SetOwnPrimaryVtx(recvtx);
1620  delete recvtx;
1621 
1622  return kTRUE;
1623 }
1624 //--------------------------------------------------------------------------
1626 {
1627  //
1628  // Recalculate primary vertex without daughters
1629  //
1630 
1631  if(!aod) {
1632  AliError("Can not get MC vertex without AOD event");
1633  return kFALSE;
1634  }
1635 
1636  // load MC header
1637  AliAODMCHeader *mcHeader =
1638  (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
1639  if(!mcHeader) {
1640  AliError("Can not get MC vertex without AODMCHeader event");
1641  return kFALSE;
1642  }
1643  Double_t pos[3];
1644  Double_t covmatrix[6]={0.,0.,0.,0.,0.,0.};
1645  mcHeader->GetVertex(pos);
1646  AliAODVertex *recvtx=new AliAODVertex(pos,covmatrix);
1647 
1648  if(!recvtx){
1649  AliDebug(2,"Removal of daughter tracks failed");
1650  return kFALSE;
1651  }
1652 
1653  //set recalculed primary vertex
1654  d->SetOwnPrimaryVtx(recvtx);
1655 
1656  d->RecalculateImpPars(recvtx,aod);
1657 
1658  delete recvtx;
1659 
1660  return kTRUE;
1661 }
1662 //--------------------------------------------------------------------------
1664  AliAODEvent *aod,
1665  AliAODVertex *origownvtx) const
1666 {
1667  //
1668  // Clean-up own primary vertex if needed
1669  //
1670 
1672  d->UnsetOwnPrimaryVtx();
1673  if(origownvtx) {
1674  d->SetOwnPrimaryVtx(origownvtx);
1675  delete origownvtx; origownvtx=NULL;
1676  }
1677  d->RecalculateImpPars(d->GetPrimaryVtx(),aod);
1678  } else {
1679  if(origownvtx) {
1680  delete origownvtx; origownvtx=NULL;
1681  }
1682  }
1683  return;
1684 }
1685 //--------------------------------------------------------------------------
1686 Bool_t AliRDHFCuts::IsSignalMC(AliAODRecoDecay *d,AliAODEvent *aod,Int_t pdg) const
1687 {
1688  //
1689  // Checks if this candidate is matched to MC signal
1690  //
1691 
1692  if(!aod) return kFALSE;
1693 
1694  // get the MC array
1695  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)aod)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
1696 
1697  if(!mcArray) return kFALSE;
1698 
1699  // try to match
1700  Int_t label = d->MatchToMC(pdg,mcArray);
1701 
1702  if(label>=0) {
1703  //printf("MATCH!\n");
1704  return kTRUE;
1705  }
1706 
1707  return kFALSE;
1708 }
1709 
1710 
1711 //--------------------------------------------------------------------------
1713  // recompute event primary vertex from AOD tracks
1714 
1715  AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
1716  vertexer->SetITSMode();
1717  vertexer->SetMinClusters(3);
1718 
1719  AliAODVertex* pvtx=event->GetPrimaryVertex();
1720  if(strstr(pvtx->GetTitle(),"VertexerTracksWithConstraint")) {
1721  Float_t diamondcovxy[3];
1722  event->GetDiamondCovXY(diamondcovxy);
1723  Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
1724  Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.*10.};
1725  AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
1726  vertexer->SetVtxStart(diamond);
1727  delete diamond; diamond=NULL;
1728  }
1729 
1730  AliESDVertex* vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event);
1731  if(!vertexESD) return kFALSE;
1732  if(vertexESD->GetNContributors()<=0) {
1733  //AliDebug(2,"vertexing failed");
1734  delete vertexESD; vertexESD=NULL;
1735  return kFALSE;
1736  }
1737  delete vertexer; vertexer=NULL;
1738 
1739  // convert to AliAODVertex
1740  Double_t pos[3],cov[6],chi2perNDF;
1741  vertexESD->GetXYZ(pos); // position
1742  vertexESD->GetCovMatrix(cov); //covariance matrix
1743  chi2perNDF = vertexESD->GetChi2toNDF();
1744  delete vertexESD; vertexESD=NULL;
1745 
1746  pvtx->SetPosition(pos[0],pos[1],pos[2]);
1747  pvtx->SetChi2perNDF(chi2perNDF);
1748  pvtx->SetCovMatrix(cov);
1749 
1750  return kTRUE;
1751 }
void SetNPtBins(Int_t nptBins)
Definition: AliRDHFCuts.h:382
Int_t fIsSelectedCuts
fix the daughter track references
Definition: AliRDHFCuts.h:431
Int_t pdg
Bool_t IsEventSelectedForCentrFlattening(Float_t centvalue)
Float_t fMinDzPileup
min. n. of tracklets in pileup vertex
Definition: AliRDHFCuts.h:420
Double_t fMaxPtCandTrackSPDFirst
flag to select the track kFirst criteria for pt < ptlimit
Definition: AliRDHFCuts.h:438
Int_t fWhyRejection
PID for heavy flavours manager.
Definition: AliRDHFCuts.h:413
double Double_t
Definition: External.C:58
Int_t fCutOnzVertexSPD
flag to apply cut on tracklets vs. centrality for 2011 data
Definition: AliRDHFCuts.h:443
void SetupPID(AliVEvent *event)
Bool_t IsSignalMC(AliAODRecoDecay *d, AliAODEvent *aod, Int_t pdg) const
const char * title
Definition: MakeQAPdf.C:27
Double_t fCutGeoNcrNclFractionNcr
3rd parameter of GeoNcrNcl cut
Definition: AliRDHFCuts.h:456
Bool_t fUseMCVertex
flag to switch on the removal of duaghters from the primary vertex computation
Definition: AliRDHFCuts.h:416
Bool_t fUseOnlyOneTrigger
trigger mask
Definition: AliRDHFCuts.h:395
Int_t IsEventSelectedInCentrality(AliVEvent *event)
Bool_t * fIsUpperCut
Definition: AliRDHFCuts.h:409
Bool_t SetMCPrimaryVtx(AliAODRecoDecayHF *d, AliAODEvent *aod) const
Bool_t fRemoveDaughtersFromPrimary
Definition: AliRDHFCuts.h:415
void SetHistoForCentralityFlattening(TH1F *h, Double_t minCentr, Double_t maxCentr, Double_t centrRef=0., Int_t switchTRand=0)
Bool_t GetUseCombined()
Definition: AliAODPidHF.h:165
Bool_t fUseMultDepPileupCut
min deltaz between main and pileup vertices
Definition: AliRDHFCuts.h:421
void SetUseCentrality(Int_t flag=1)
Float_t * fPtBinLimits
"number of limits", that is fnPtBins+1
Definition: AliRDHFCuts.h:402
Int_t fMinVtxContr
0: not cut; 1: SPDZ; 2: SPD3D; 3: Tracks
Definition: AliRDHFCuts.h:390
centrality
char Char_t
Definition: External.C:18
static Int_t CheckMatchingAODdeltaAODevents()
Float_t fMaxVtxRedChi2
minimum vertex contributors
Definition: AliRDHFCuts.h:391
void SetMClowenpp2011(Bool_t mc)
Definition: AliAODPidHF.h:102
const Float_t * GetCuts() const
Definition: AliRDHFCuts.h:244
void SetMinCrossedRowsTPCPtDep(const char *rows="")
Float_t fCutRatioClsOverCrossRowsTPC
histogram with reference centrality distribution for centrality distribution flattening ...
Definition: AliRDHFCuts.h:448
Double_t fDeadZoneWidth
flag for enabling/disabling geometrical cut on TPC track
Definition: AliRDHFCuts.h:453
Int_t fMinVtxType
cuts on the event
Definition: AliRDHFCuts.h:389
void SetppLowEn2011(Bool_t opt)
Definition: AliAODPidHF.h:104
Double_t fMaxRapidityCand
minimum pt of the candidate
Definition: AliRDHFCuts.h:435
Double_t fCutGeoNcrNclFractionNcl
4th parameter of GeoNcrNcl cut
Definition: AliRDHFCuts.h:457
void SetGlobalIndex()
Definition: AliRDHFCuts.h:198
AliRDHFCuts & operator=(const AliRDHFCuts &source)
Float_t GetCutValue(Int_t iVar, Int_t iPtBin) const
Int_t fUseCentrality
flag to use a multiplicity dependent pileup selection
Definition: AliRDHFCuts.h:422
Bool_t fUsePID
Definition: AliRDHFCuts.h:410
TRandom * gRandom
void PrintAll() const
void SetPidHF(AliAODPidHF *pidObj)
see enum below
Definition: AliRDHFCuts.h:212
Bool_t GetOldPid()
Definition: AliAODPidHF.h:157
TList * GetList(const TDirectory *d, const char *what)
Definition: ExtractData.C:172
AliAODPidHF * GetPidHF() const
Definition: AliRDHFCuts.h:237
void RecalculateImpPars(AliAODVertex *vtxAODNew, AliAODEvent *aod)
Bool_t fRemoveTrackletOutliers
Max. difference between TRK and V0 centrality (remove TPC pileup for PbPb 2011)
Definition: AliRDHFCuts.h:442
Bool_t fUseV0ANDSelectionOffline
5th parameter of GeoNcrNcl cut
Definition: AliRDHFCuts.h:458
AliRDHFCuts(const Char_t *name="RDHFCuts", const Char_t *title="")
Definition: AliRDHFCuts.cxx:64
const Int_t nPtBins
ULong64_t fTriggerMask
SPD multiplicity.
Definition: AliRDHFCuts.h:394
Bool_t fUseCutGeoNcrNcl
pT-dep cut in TPC minimum n crossed rows
Definition: AliRDHFCuts.h:452
int Int_t
Definition: External.C:63
Bool_t fUseTrackSelectionWithFilterBits
flag to reject kink daughters
Definition: AliRDHFCuts.h:445
void SetCuts(Int_t nVars, Int_t nPtBins, Float_t **cutsRD)
Int_t fnVarsForOpt
Definition: AliRDHFCuts.h:405
Double_t fCutGeoNcrNclLength
1st parameter of GeoNcrNcl cut
Definition: AliRDHFCuts.h:454
float Float_t
Definition: External.C:68
virtual ~AliRDHFCuts()
void SetPbPb(Bool_t pbpb)
Definition: AliAODPidHF.h:105
TString * fVarNames
number of cut vars for candidates
Definition: AliRDHFCuts.h:404
Double_t fMaxPtCand
minimum pt of the candidate
Definition: AliRDHFCuts.h:434
AliESDtrackCuts * fTrackCuts
quality cuts on the daughter tracks
Definition: AliRDHFCuts.h:398
void MakeTable() const
Bool_t fFixRefs
name of the AliMultSelection object to be considered
Definition: AliRDHFCuts.h:430
Bool_t fKeepSignalMC
max rapidity of candidate (if !=-999 overrides IsInFiducialAcceptance)
Definition: AliRDHFCuts.h:436
Int_t fOptPileup
use Physics selection criteria
Definition: AliRDHFCuts.h:418
AliESDtrackCuts * GetTrackCuts() const
Definition: AliRDHFCuts.h:252
void PrintTrigger() const
Float_t fMaxVtxZ
maximum chi2/ndf
Definition: AliRDHFCuts.h:392
Float_t GetCentrality(AliAODEvent *aodEvent)
Definition: AliRDHFCuts.h:248
Int_t fIsSelectedPID
outcome of cuts selection
Definition: AliRDHFCuts.h:432
Float_t fMinCentrality
Definition: AliRDHFCuts.h:427
AliAODVertex * RemoveDaughtersFromPrimaryVtx(AliAODEvent *aod)
void SetUpCombinedPID()
AliPIDResponse * GetPidResponse() const
Definition: AliAODPidHF.h:160
UInt_t fEvRejectionBits
used to code the step at which candidate was rejected
Definition: AliRDHFCuts.h:414
Double_t fMaxDiffTRKV0Centr
flag to apply cut on tracks crossing SPD misaligned modules for PP2012 data
Definition: AliRDHFCuts.h:441
Float_t GetCentralityOldFramework(AliAODEvent *aodEvent, AliRDHFCuts::ECentrality estimator)
Int_t fnPtBinLimits
number of pt bins for cuts
Definition: AliRDHFCuts.h:401
Float_t * fCutsRD
fnVars*fnPtBins
Definition: AliRDHFCuts.h:408
Bool_t CheckPtDepCrossedRows(TString rows, Bool_t print=kFALSE) const
Bool_t Data(TH1F *h, Double_t *rangefit, Bool_t writefit, Double_t &sgn, Double_t &errsgn, Double_t &bkg, Double_t &errbkg, Double_t &sgnf, Double_t &errsgnf, Double_t &sigmafit, Int_t &status)
void SetOwnPrimaryVtx(const AliAODVertex *vtx)
Bool_t fUseCentrFlatteningInMC
flag to enable/disable the check on filter bits
Definition: AliRDHFCuts.h:446
void SetVarsForOpt(Int_t nVars, Bool_t *forOpt)
void SetVarNames(Int_t nVars, TString *varNames, Bool_t *isUpperCut)
void GetVarPtIndex(Int_t iGlob, Int_t &iVar, Int_t &iPtBin) const
void SetBetheBloch()
Bool_t * fVarsForOpt
number of cut vars to be optimized for candidates
Definition: AliRDHFCuts.h:406
Bool_t isMC
Bool_t CompareCuts(const AliRDHFCuts *obj) const
Bool_t AreDaughtersSelected(AliAODRecoDecayHF *rd, const AliAODEvent *aod=0x0) const
Bool_t fApplySPDMisalignedPP2012
flag to apply SPD dead module map of PbPb2011
Definition: AliRDHFCuts.h:440
Bool_t IsEventSelected(AliVEvent *event)
Int_t fMinSPDMultiplicity
maximum |z| of primary vertex
Definition: AliRDHFCuts.h:393
void SetMC(Bool_t mc)
Definition: AliAODPidHF.h:101
virtual void PrintAll() const
Bool_t fUseAOD049
enable PID usage (off by default)
Definition: AliRDHFCuts.h:411
Bool_t fApplySPDDeadPbPb2011
maximum pt of the candidate for which to check if the daughters fulfill kFirst criteria ...
Definition: AliRDHFCuts.h:439
void CleanOwnPrimaryVtx(AliAODRecoDecayHF *d, AliAODEvent *aod, AliAODVertex *origownvtx) const
Bool_t fIsCandTrackSPDFirst
IsSelected returns always kTRUE for MC signal.
Definition: AliRDHFCuts.h:437
TH1F * fHistCentrDistr
flag for enabling/diabling centrality flattening in MC
Definition: AliRDHFCuts.h:447
void SetPtBins(Int_t nPtBinLimits, Float_t *ptBinLimits)
Bool_t fKinkReject
cut on zSPD vertex to remove outliers in centrality vs. tracklets (0=no cut, 1= cut at 12 cm...
Definition: AliRDHFCuts.h:444
TString fMultSelectionObjectName
maximum centrality for selected events
Definition: AliRDHFCuts.h:429
Int_t fMinContrPileup
option for pielup selection
Definition: AliRDHFCuts.h:419
Bool_t fUsePhysicsSelection
use MC primary vertex
Definition: AliRDHFCuts.h:417
TFormula * f1CutMinNCrossedRowsTPCPtDep
pT-dep cut in TPC minimum n crossed rows
Definition: AliRDHFCuts.h:451
AliAODVertex * GetPrimaryVtx() const
void AddTrackCuts(const AliESDtrackCuts *cuts)
Definition: AliRDHFCuts.h:204
TString fTriggerClass[2]
flag to select one trigger only
Definition: AliRDHFCuts.h:396
bool Bool_t
Definition: External.C:53
Int_t fnPtBins
cuts on the candidate
Definition: AliRDHFCuts.h:400
Double_t fCutGeoNcrNclGeom1Pt
2nd parameter of GeoNcrNcl cut
Definition: AliRDHFCuts.h:455
AliAODPidHF * fPidHF
enable AOD049 centrality cleanup
Definition: AliRDHFCuts.h:412
Float_t fCutRatioSignalNOverCrossRowsTPC
min. value ratio NTPCClusters/NTPCCrossedRows, cut if !=0
Definition: AliRDHFCuts.h:449
Int_t fGlobalIndex
Definition: AliRDHFCuts.h:407
Bool_t RecalcOwnPrimaryVtx(AliAODRecoDecayHF *d, AliAODEvent *aod) const
Int_t PtBin(Double_t pt) const
Int_t GetGlobalIndex(Int_t iVar, Int_t iPtBin) const
TString fCutMinCrossedRowsTPCPtDep
min. value ratio TPCPointsUsedForPID/NTPCCrossedRows, cut if !=0
Definition: AliRDHFCuts.h:450
Double_t fMinPtCand
outcome of PID selection
Definition: AliRDHFCuts.h:433
Bool_t IsDaughterSelected(AliAODTrack *track, const AliESDVertex *primary, AliESDtrackCuts *cuts, const AliAODEvent *aod=0x0) const
void SetOnePad(Bool_t onepad)
Definition: AliAODPidHF.h:103
Float_t fMaxCentrality
minimum centrality for selected events
Definition: AliRDHFCuts.h:428
void SetPidResponse(AliPIDResponse *pidResp)
Definition: AliAODPidHF.h:111
Bool_t RecomputePrimaryVertex(AliAODEvent *event) const
Int_t fnVars
Definition: AliRDHFCuts.h:403