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