AliPhysics  5364b50 (5364b50)
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==kCentV0M) estimator = "V0";
1153  if(fUseCentrality==kCentTRK) estimator = "Tracks";
1154  if(fUseCentrality==kCentTKL) estimator = "Tracklets";
1155  if(fUseCentrality==kCentCL1) estimator = "SPD clusters outer";
1156  if(fUseCentrality==kCentZNA) estimator = "ZNA";
1157  if(fUseCentrality==kCentZPA) estimator = "ZPA";
1158  if(fUseCentrality==kCentV0A) estimator = "V0A";
1159  if(fUseCentrality==kCentCL0) estimator = "SPD clusters inner";
1160  printf("Centrality class considered: %.1f-%.1f, estimated with %s\n",fMinCentrality,fMaxCentrality,estimator.Data());
1161  }
1162  if(fIsCandTrackSPDFirst) printf("Check for candidates with pt < %2.2f, that daughters fullfill kFirst criteria\n",fMaxPtCandTrackSPDFirst);
1163 
1164  if(fCutRatioClsOverCrossRowsTPC) printf("N TPC Clusters > %f N TPC Crossed Rows\n", fCutRatioClsOverCrossRowsTPC);
1165  if(fCutRatioSignalNOverCrossRowsTPC) printf("N TPC Points for dE/dx > %f N TPC Crossed Rows\n", fCutRatioSignalNOverCrossRowsTPC);
1166  if(f1CutMinNCrossedRowsTPCPtDep) printf("N TPC Crossed Rows pT-dependent cut: %s\n", fCutMinCrossedRowsTPCPtDep.Data());
1167 
1168  if(fVarNames){
1169  cout<<"Array of variables"<<endl;
1170  for(Int_t iv=0;iv<fnVars;iv++){
1171  cout<<fVarNames[iv]<<"\t";
1172  }
1173  cout<<endl;
1174  }
1175  if(fVarsForOpt){
1176  cout<<"Array of optimization"<<endl;
1177  for(Int_t iv=0;iv<fnVars;iv++){
1178  cout<<fVarsForOpt[iv]<<"\t";
1179  }
1180  cout<<endl;
1181  }
1182  if(fIsUpperCut){
1183  cout<<"Array of upper/lower cut"<<endl;
1184  for(Int_t iv=0;iv<fnVars;iv++){
1185  cout<<fIsUpperCut[iv]<<"\t";
1186  }
1187  cout<<endl;
1188  }
1189  if(fPtBinLimits){
1190  cout<<"Array of ptbin limits"<<endl;
1191  for(Int_t ib=0;ib<fnPtBinLimits;ib++){
1192  cout<<fPtBinLimits[ib]<<"\t";
1193  }
1194  cout<<endl;
1195  }
1196  if(fCutsRD){
1197  cout<<"Matrix of cuts"<<endl;
1198  for(Int_t iv=0;iv<fnVars;iv++){
1199  for(Int_t ib=0;ib<fnPtBins;ib++){
1200  cout<<"fCutsRD["<<iv<<"]["<<ib<<"] = "<<fCutsRD[GetGlobalIndex(iv,ib)]<<"\t";
1201  }
1202  cout<<endl;
1203  }
1204  cout<<endl;
1205  }
1206  if(fPidHF) fPidHF->PrintAll();
1207  return;
1208 }
1209 
1210 //--------------------------------------------------------------------------
1212  // print the trigger selection
1213 
1214  printf("Selected trigger classes: %s %s\n",fTriggerClass[0].Data(),fTriggerClass[1].Data());
1215 
1216  cout<<" Trigger selection pattern: ";
1217  if( fTriggerMask & AliVEvent::kAny ) cout<<" kAny ";
1218  if( fTriggerMask & AliVEvent::kAnyINT ) cout<<" kAnyINT ";
1219  if( fTriggerMask & AliVEvent::kINT7 ) cout<<" kINT7 ";
1220  if( fTriggerMask & AliVEvent::kMB ) cout<<" kMB ";
1221  if( fTriggerMask & AliVEvent::kCINT5 ) cout<<" kCINT5 ";
1222  if( fTriggerMask & AliVEvent::kCentral ) cout<<" kCentral ";
1223  if( fTriggerMask & AliVEvent::kSemiCentral ) cout<<" kSemiCentral ";
1224  if( fTriggerMask & AliVEvent::kEMCEGA ) cout<<" kEMCEGA ";
1225  if( fTriggerMask & AliVEvent::kHighMult ) cout<<" kHighMult ";
1226  if( fTriggerMask & AliVEvent::kFastOnly ) cout<<" kFastOnly ";
1227  cout << endl<< endl;
1228 
1229 }
1230 
1231 //---------------------------------------------------------------------------
1232 void AliRDHFCuts::GetCuts(Float_t**& cutsRD) const{
1233  //
1234  // get the cuts
1235  //
1236 
1237  //cout<<"Give back a "<<fnVars<<"x"<<fnPtBins<<" matrix."<<endl;
1238 
1239 
1240  Int_t iv,ib;
1241  if(!cutsRD) {
1242  //cout<<"Initialization..."<<endl;
1243  cutsRD=new Float_t*[fnVars];
1244  for(iv=0; iv<fnVars; iv++) {
1245  cutsRD[iv] = new Float_t[fnPtBins];
1246  }
1247  }
1248 
1249  for(Int_t iGlobal=0; iGlobal<fGlobalIndex; iGlobal++) {
1250  GetVarPtIndex(iGlobal,iv,ib);
1251  cutsRD[iv][ib] = fCutsRD[iGlobal];
1252  }
1253 
1254  return;
1255 }
1256 
1257 //---------------------------------------------------------------------------
1259  //
1260  // give the global index from variable and pt bin
1261  //
1262  return iPtBin*fnVars+iVar;
1263 }
1264 
1265 //---------------------------------------------------------------------------
1266 void AliRDHFCuts::GetVarPtIndex(Int_t iGlob, Int_t& iVar, Int_t& iPtBin) const {
1267  //
1268  //give the index of the variable and of the pt bin from the global index
1269  //
1270  iPtBin=(Int_t)iGlob/fnVars;
1271  iVar=iGlob%fnVars;
1272 
1273  return;
1274 }
1275 
1276 //---------------------------------------------------------------------------
1278  //
1279  //give the pt bin where the pt lies.
1280  //
1281  Int_t ptbin=-1;
1282  if(pt<fPtBinLimits[0])return ptbin;
1283  for (Int_t i=0;i<fnPtBins;i++){
1284  if(pt<fPtBinLimits[i+1]) {
1285  ptbin=i;
1286  break;
1287  }
1288  }
1289  return ptbin;
1290 }
1291 //-------------------------------------------------------------------
1293  //
1294  // Give the value of cut set for the variable iVar and the pt bin iPtBin
1295  //
1296  if(!fCutsRD){
1297  cout<<"Cuts not iniziaisez yet"<<endl;
1298  return 0;
1299  }
1300  return fCutsRD[GetGlobalIndex(iVar,iPtBin)];
1301 }
1302 
1303 //-------------------------------------------------------------------
1305 
1306  if(aodEvent->GetRunNumber()<244824)return GetCentralityOldFramework(aodEvent,estimator);
1307  Double_t cent=-999;
1308 
1309  if(estimator==kCentOff) return -999;
1310 
1311  AliMultSelection *multSelection = (AliMultSelection*)aodEvent->FindListObject(fMultSelectionObjectName);
1312  if(!multSelection){
1313  AliWarning("AliMultSelection could not be found in the aod event list of objects");
1314  return cent;
1315  }
1316 
1317  // Compare centrality with the centrality at AOD filtering and on-the-fly
1318  if( fMultSelectionObjectName.CompareTo("MultSelection")!=0 ){
1319  AliMultSelection *defaultmultSelection = (AliMultSelection*)aodEvent->FindListObject("MultSelection");
1320  if(!defaultmultSelection){
1321  AliWarning("AliMultSelection default method could not be found in the aod event list of objects");
1322  return cent;
1323  }
1324  Float_t defaultCent = defaultmultSelection->GetMultiplicityPercentile("V0M");
1325  Float_t newCent = multSelection->GetMultiplicityPercentile("V0M");
1326  if( defaultCent<20. && newCent>20.) fEvRejectionBits+=1<<kMismatchOldNewCentrality;
1327  else if (defaultCent>20. && newCent<20.) fEvRejectionBits+=1<<kMismatchOldNewCentrality;
1328  }
1329 
1330  if(estimator==kCentV0M){
1331  cent=multSelection->GetMultiplicityPercentile("V0M");
1332  }else if(estimator==kCentV0A){
1333  cent=multSelection->GetMultiplicityPercentile("V0A");
1334  }else if(estimator==kCentZNA){
1335  cent=multSelection->GetMultiplicityPercentile("ZNA");
1336  }else if(estimator==kCentCL1){
1337  cent=multSelection->GetMultiplicityPercentile("CL1");
1338  }else if(estimator==kCentCL0){
1339  cent=multSelection->GetMultiplicityPercentile("CL0");
1340  }else {
1341  AliWarning(Form("CENTRALITY ESTIMATE WITH ESTIMATOR %d NOT YET IMPLEMENTED FOR NEW FRAMEWORK",(Int_t)estimator));
1342  return cent;
1343  }
1344  Int_t qual = multSelection->GetEvSelCode();
1345  if(qual == 199 ) cent=-999;
1346  return cent;
1347 }
1348 //-------------------------------------------------------------------
1350  //
1351  // Get centrality percentile
1352  //
1353 
1354  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)aodEvent)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
1355  if(mcArray) {fUseAOD049=kFALSE;}
1356 
1357  AliAODHeader *header=dynamic_cast<AliAODHeader*>(aodEvent->GetHeader());
1358  if(!header) AliFatal("Not a standard AOD");
1359  AliCentrality *centrality=header->GetCentralityP();
1360  Float_t cent=-999.;
1361  Bool_t isSelRun=kFALSE;
1362  Int_t selRun[5]={138364, 138826, 138828, 138836, 138871};
1363  if(!centrality) return cent;
1364  else{
1365  if (estimator==kCentV0M){
1366  cent=(Float_t)(centrality->GetCentralityPercentile("V0M"));
1367  if(cent<0){
1368  Int_t quality = centrality->GetQuality();
1369  if(quality<=1){ // fQuality==1 means rejected by zVertex cut that we apply a part and we want to keep separate (Giacomo)
1370  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0M");
1371  }else{
1372  Int_t runnum=aodEvent->GetRunNumber();
1373  for(Int_t ir=0;ir<5;ir++){
1374  if(runnum==selRun[ir]){
1375  isSelRun=kTRUE;
1376  break;
1377  }
1378  }
1379  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0M");
1380  }
1381  }
1382 
1383  //temporary fix for AOD049 outliers
1384  if(fUseAOD049&&cent>=0){
1385  Float_t v0=0;
1386  AliAODVZERO* aodV0 = aodEvent->GetVZEROData();
1387  v0+=aodV0->GetMTotV0A();
1388  v0+=aodV0->GetMTotV0C();
1389  if(cent==0&&v0<19500)return -1;//filtering issue
1390  Float_t tkl = (Float_t)(aodEvent->GetTracklets()->GetNumberOfTracklets());
1391  Float_t val= 1.30552 + 0.147931 * v0;
1392  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};
1393  if ( TMath::Abs(tkl-val) > 6.*tklSigma[(Int_t)cent] )return -1;//outlier
1394  }
1395  }
1396  else {
1397  if (estimator==kCentTRK) {
1398  cent=(Float_t)(centrality->GetCentralityPercentile("TRK"));
1399  if(cent<0){
1400  Int_t quality = centrality->GetQuality();
1401  if(quality<=1){
1402  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TRK");
1403  }else{
1404  Int_t runnum=aodEvent->GetRunNumber();
1405  for(Int_t ir=0;ir<5;ir++){
1406  if(runnum==selRun[ir]){
1407  isSelRun=kTRUE;
1408  break;
1409  }
1410  }
1411  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TRK");
1412  }
1413  }
1414  }
1415  else{
1416  if (estimator==kCentTKL){
1417  cent=(Float_t)(centrality->GetCentralityPercentile("TKL"));
1418  if(cent<0){
1419  Int_t quality = centrality->GetQuality();
1420  if(quality<=1){
1421  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TKL");
1422  }else{
1423  Int_t runnum=aodEvent->GetRunNumber();
1424  for(Int_t ir=0;ir<5;ir++){
1425  if(runnum==selRun[ir]){
1426  isSelRun=kTRUE;
1427  break;
1428  }
1429  }
1430  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TKL");
1431  }
1432  }
1433  }
1434  else{
1435  if (estimator==kCentCL1){
1436  cent=(Float_t)(centrality->GetCentralityPercentile("CL1"));
1437  if(cent<0){
1438  Int_t quality = centrality->GetQuality();
1439  if(quality<=1){
1440  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("CL1");
1441  }else{
1442  Int_t runnum=aodEvent->GetRunNumber();
1443  for(Int_t ir=0;ir<5;ir++){
1444  if(runnum==selRun[ir]){
1445  isSelRun=kTRUE;
1446  break;
1447  }
1448  }
1449  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("CL1");
1450  }
1451  }
1452  }
1453  else{
1454  if (estimator==kCentZNA){
1455  cent=(Float_t)(centrality->GetCentralityPercentile("ZNA"));
1456  if(cent<0){
1457  Int_t quality = centrality->GetQuality();
1458  if(quality<=1){
1459  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZNA");
1460  }else{
1461  Int_t runnum=aodEvent->GetRunNumber();
1462  for(Int_t ir=0;ir<5;ir++){
1463  if(runnum==selRun[ir]){
1464  isSelRun=kTRUE;
1465  break;
1466  }
1467  }
1468  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZNA");
1469  }
1470  }
1471  }
1472  else{
1473  if (estimator==kCentZPA){
1474  cent=(Float_t)(centrality->GetCentralityPercentile("ZPA"));
1475  if(cent<0){
1476  Int_t quality = centrality->GetQuality();
1477  if(quality<=1){
1478  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZPA");
1479  }else{
1480  Int_t runnum=aodEvent->GetRunNumber();
1481  for(Int_t ir=0;ir<5;ir++){
1482  if(runnum==selRun[ir]){
1483  isSelRun=kTRUE;
1484  break;
1485  }
1486  }
1487  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZPA");
1488  }
1489  }
1490  }
1491  else{
1492  if (estimator==kCentV0A){
1493  cent=(Float_t)(centrality->GetCentralityPercentile("V0A"));
1494  if(cent<0){
1495  Int_t quality = centrality->GetQuality();
1496  if(quality<=1){
1497  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0A");
1498  }else{
1499  Int_t runnum=aodEvent->GetRunNumber();
1500  for(Int_t ir=0;ir<5;ir++){
1501  if(runnum==selRun[ir]){
1502  isSelRun=kTRUE;
1503  break;
1504  }
1505  }
1506  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0A");
1507  }
1508  }
1509  }
1510  else {
1511  AliWarning("Centrality estimator not valid");
1512 
1513  }
1514  }
1515  }
1516  }
1517  }
1518  }
1519  }
1520  }
1521  return cent;
1522 }
1523 //-------------------------------------------------------------------
1525  //
1526  // Compare two cuts objects
1527  //
1528 
1529  Bool_t areEqual=kTRUE;
1530 
1531  if(fMinVtxType!=obj->fMinVtxType) { printf("Minimum vtx type %d %d\n",fMinVtxType,obj->fMinVtxType); areEqual=kFALSE;}
1532 
1533  if(fMinVtxContr!=obj->fMinVtxContr) { printf("Minimum vtx contr %d %d\n",fMinVtxContr,obj->fMinVtxContr); areEqual=kFALSE;}
1534 
1535  if(TMath::Abs(fMaxVtxRedChi2-obj->fMaxVtxRedChi2)>1.e-10) { printf("Max vtx red chi2 %f %f\n",fMaxVtxRedChi2,obj->fMaxVtxRedChi2);areEqual=kFALSE;}
1536 
1537  if(fMinSPDMultiplicity!=obj->fMinSPDMultiplicity) { printf("Min SPD mult %d\n %d",fMinSPDMultiplicity,obj->fMinSPDMultiplicity);areEqual=kFALSE;}
1538 
1539  if(fUsePID!=obj->fUsePID) { printf("Use PID %d %d\n",(Int_t)fUsePID,(Int_t)obj->fUsePID); areEqual=kFALSE;}
1540 
1541  if(fRemoveDaughtersFromPrimary!=obj->fRemoveDaughtersFromPrimary) {printf("Remove daughters from vtx %d %d\n",(Int_t)fRemoveDaughtersFromPrimary,(Int_t)obj->fRemoveDaughtersFromPrimary); areEqual=kFALSE;}
1542  if(fTrackCuts){
1543  if(fTrackCuts->GetMinNClusterTPC()!=obj->fTrackCuts->GetMinNClusterTPC()) {printf("MinNClsTPC %d %d\n",fTrackCuts->GetMinNClusterTPC(),obj->fTrackCuts->GetMinNClusterTPC()); areEqual=kFALSE;}
1544 
1545  if(fTrackCuts->GetMinNClustersITS()!=obj->fTrackCuts->GetMinNClustersITS()) {printf("MinNClsITS %d %d\n",fTrackCuts->GetMinNClustersITS(),obj->fTrackCuts->GetMinNClustersITS()); areEqual=kFALSE;}
1546 
1547  if(TMath::Abs(fTrackCuts->GetMaxChi2PerClusterTPC()-obj->fTrackCuts->GetMaxChi2PerClusterTPC())>1.e-10) {printf("MaxChi2ClsTPC %f %f\n",fTrackCuts->GetMaxChi2PerClusterTPC(),obj->fTrackCuts->GetMaxChi2PerClusterTPC()); areEqual=kFALSE;}
1548 
1549  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;}
1550  }
1551 
1552  if(fCutsRD) {
1553  for(Int_t iv=0;iv<fnVars;iv++) {
1554  for(Int_t ib=0;ib<fnPtBins;ib++) {
1555  if(TMath::Abs(fCutsRD[GetGlobalIndex(iv,ib)]-obj->fCutsRD[GetGlobalIndex(iv,ib)])>1.e-10) {
1556  cout<<"fCutsRD["<<iv<<"]["<<ib<<"] = "<<fCutsRD[GetGlobalIndex(iv,ib)]<<" "<<obj->fCutsRD[GetGlobalIndex(iv,ib)]<<"\n";
1557  areEqual=kFALSE;
1558  }
1559  }
1560  }
1561  }
1562 
1563  return areEqual;
1564 }
1565 //---------------------------------------------------------------------------
1567  //
1568  // print cuts values in table format
1569  //
1570 
1571  TString ptString = "pT range";
1572  if(fVarNames && fPtBinLimits && fCutsRD){
1573  TString firstLine(Form("* %-15s",ptString.Data()));
1574  for (Int_t ivar=0; ivar<fnVars; ivar++){
1575  firstLine+=Form("* %-15s ",fVarNames[ivar].Data());
1576  if (ivar == fnVars){
1577  firstLine+="*\n";
1578  }
1579  }
1580  Printf("%s",firstLine.Data());
1581 
1582  for (Int_t ipt=0; ipt<fnPtBins; ipt++){
1583  TString line;
1584  if (ipt==fnPtBins-1){
1585  line=Form("* %5.1f < pt < inf ",fPtBinLimits[ipt]);
1586  }
1587  else{
1588  line=Form("* %5.1f < pt < %4.1f ",fPtBinLimits[ipt],fPtBinLimits[ipt+1]);
1589  }
1590  for (Int_t ivar=0; ivar<fnVars; ivar++){
1591  line+=Form("* %-15f ",fCutsRD[GetGlobalIndex(ivar,ipt)]);
1592  }
1593  Printf("%s",line.Data());
1594  }
1595 
1596  }
1597 
1598 
1599  return;
1600 }
1601 //--------------------------------------------------------------------------
1603  AliAODEvent *aod) const
1604 {
1605  //
1606  // Recalculate primary vertex without daughters
1607  //
1608 
1609  if(!aod) {
1610  AliError("Can not remove daughters from vertex without AOD event");
1611  return 0;
1612  }
1613 
1614  AliAODVertex *recvtx=d->RemoveDaughtersFromPrimaryVtx(aod);
1615  if(!recvtx){
1616  AliDebug(2,"Removal of daughter tracks failed");
1617  return kFALSE;
1618  }
1619 
1620 
1621  //set recalculed primary vertex
1622  d->SetOwnPrimaryVtx(recvtx);
1623  delete recvtx;
1624 
1625  return kTRUE;
1626 }
1627 //--------------------------------------------------------------------------
1629 {
1630  //
1631  // Recalculate primary vertex without daughters
1632  //
1633 
1634  if(!aod) {
1635  AliError("Can not get MC vertex without AOD event");
1636  return kFALSE;
1637  }
1638 
1639  // load MC header
1640  AliAODMCHeader *mcHeader =
1641  (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
1642  if(!mcHeader) {
1643  AliError("Can not get MC vertex without AODMCHeader event");
1644  return kFALSE;
1645  }
1646  Double_t pos[3];
1647  Double_t covmatrix[6]={0.,0.,0.,0.,0.,0.};
1648  mcHeader->GetVertex(pos);
1649  AliAODVertex *recvtx=new AliAODVertex(pos,covmatrix);
1650 
1651  if(!recvtx){
1652  AliDebug(2,"Removal of daughter tracks failed");
1653  return kFALSE;
1654  }
1655 
1656  //set recalculed primary vertex
1657  d->SetOwnPrimaryVtx(recvtx);
1658 
1659  d->RecalculateImpPars(recvtx,aod);
1660 
1661  delete recvtx;
1662 
1663  return kTRUE;
1664 }
1665 //--------------------------------------------------------------------------
1667  AliAODEvent *aod,
1668  AliAODVertex *origownvtx) const
1669 {
1670  //
1671  // Clean-up own primary vertex if needed
1672  //
1673 
1675  d->UnsetOwnPrimaryVtx();
1676  if(origownvtx) {
1677  d->SetOwnPrimaryVtx(origownvtx);
1678  delete origownvtx; origownvtx=NULL;
1679  }
1680  d->RecalculateImpPars(d->GetPrimaryVtx(),aod);
1681  } else {
1682  if(origownvtx) {
1683  delete origownvtx; origownvtx=NULL;
1684  }
1685  }
1686  return;
1687 }
1688 //--------------------------------------------------------------------------
1689 Bool_t AliRDHFCuts::IsSignalMC(AliAODRecoDecay *d,AliAODEvent *aod,Int_t pdg) const
1690 {
1691  //
1692  // Checks if this candidate is matched to MC signal
1693  //
1694 
1695  if(!aod) return kFALSE;
1696 
1697  // get the MC array
1698  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)aod)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
1699 
1700  if(!mcArray) return kFALSE;
1701 
1702  // try to match
1703  Int_t label = d->MatchToMC(pdg,mcArray);
1704 
1705  if(label>=0) {
1706  //printf("MATCH!\n");
1707  return kTRUE;
1708  }
1709 
1710  return kFALSE;
1711 }
1712 
1713 
1714 //--------------------------------------------------------------------------
1716  // recompute event primary vertex from AOD tracks
1717 
1718  AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
1719  vertexer->SetITSMode();
1720  vertexer->SetMinClusters(3);
1721 
1722  AliAODVertex* pvtx=event->GetPrimaryVertex();
1723  if(strstr(pvtx->GetTitle(),"VertexerTracksWithConstraint")) {
1724  Float_t diamondcovxy[3];
1725  event->GetDiamondCovXY(diamondcovxy);
1726  Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
1727  Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.*10.};
1728  AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
1729  vertexer->SetVtxStart(diamond);
1730  delete diamond; diamond=NULL;
1731  }
1732 
1733  AliESDVertex* vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event);
1734  if(!vertexESD) return kFALSE;
1735  if(vertexESD->GetNContributors()<=0) {
1736  //AliDebug(2,"vertexing failed");
1737  delete vertexESD; vertexESD=NULL;
1738  return kFALSE;
1739  }
1740  delete vertexer; vertexer=NULL;
1741 
1742  // convert to AliAODVertex
1743  Double_t pos[3],cov[6],chi2perNDF;
1744  vertexESD->GetXYZ(pos); // position
1745  vertexESD->GetCovMatrix(cov); //covariance matrix
1746  chi2perNDF = vertexESD->GetChi2toNDF();
1747  delete vertexESD; vertexESD=NULL;
1748 
1749  pvtx->SetPosition(pos[0],pos[1],pos[2]);
1750  pvtx->SetChi2perNDF(chi2perNDF);
1751  pvtx->SetCovMatrix(cov);
1752 
1753  return kTRUE;
1754 }
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