AliPhysics  3337bb0 (3337bb0)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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),
140  fMaxVtxRedChi2(source.fMaxVtxRedChi2),
141  fMaxVtxZ(source.fMaxVtxZ),
142  fMinSPDMultiplicity(source.fMinSPDMultiplicity),
143  fTriggerMask(source.fTriggerMask),
144  fUseOnlyOneTrigger(source.fUseOnlyOneTrigger),
145  fTriggerClass(),
146  fTrackCuts(0),
147  fnPtBins(source.fnPtBins),
148  fnPtBinLimits(source.fnPtBinLimits),
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),
160  fWhyRejection(source.fWhyRejection),
161  fEvRejectionBits(source.fEvRejectionBits),
162  fRemoveDaughtersFromPrimary(source.fRemoveDaughtersFromPrimary),
163  fUseMCVertex(source.fUseMCVertex),
164  fUsePhysicsSelection(source.fUsePhysicsSelection),
165  fOptPileup(source.fOptPileup),
166  fMinContrPileup(source.fMinContrPileup),
167  fMinDzPileup(source.fMinDzPileup),
168  fUseMultDepPileupCut(source.fUseMultDepPileupCut),
169  fUseCentrality(source.fUseCentrality),
170  fMinCentrality(source.fMinCentrality),
171  fMaxCentrality(source.fMaxCentrality),
172  fMultSelectionObjectName(source.fMultSelectionObjectName),
173  fFixRefs(source.fFixRefs),
174  fIsSelectedCuts(source.fIsSelectedCuts),
175  fIsSelectedPID(source.fIsSelectedPID),
176  fMinPtCand(source.fMinPtCand),
177  fMaxPtCand(source.fMaxPtCand),
178  fMaxRapidityCand(source.fMaxRapidityCand),
179  fKeepSignalMC(source.fKeepSignalMC),
180  fIsCandTrackSPDFirst(source.fIsCandTrackSPDFirst),
181  fMaxPtCandTrackSPDFirst(source.fMaxPtCandTrackSPDFirst),
182  fApplySPDDeadPbPb2011(source.fApplySPDDeadPbPb2011),
183  fApplySPDMisalignedPP2012(source.fApplySPDMisalignedPP2012),
184  fMaxDiffTRKV0Centr(source.fMaxDiffTRKV0Centr),
185  fRemoveTrackletOutliers(source.fRemoveTrackletOutliers),
186  fCutOnzVertexSPD(source.fCutOnzVertexSPD),
187  fKinkReject(source.fKinkReject),
188  fUseTrackSelectionWithFilterBits(source.fUseTrackSelectionWithFilterBits),
189  fUseCentrFlatteningInMC(source.fUseCentrFlatteningInMC),
190  fHistCentrDistr(0x0),
191  fCutRatioClsOverCrossRowsTPC(source.fCutRatioClsOverCrossRowsTPC),
192  fCutRatioSignalNOverCrossRowsTPC(source.fCutRatioSignalNOverCrossRowsTPC),
193  fCutMinCrossedRowsTPCPtDep(""),
194  f1CutMinNCrossedRowsTPCPtDep(0x0),
195  fUseCutGeoNcrNcl(source.fUseCutGeoNcrNcl),
196  fDeadZoneWidth(source.fDeadZoneWidth),
197  fCutGeoNcrNclLength(source.fCutGeoNcrNclLength),
198  fCutGeoNcrNclGeom1Pt(source.fCutGeoNcrNclGeom1Pt),
199  fCutGeoNcrNclFractionNcr(source.fCutGeoNcrNclFractionNcr),
200  fCutGeoNcrNclFractionNcl(source.fCutGeoNcrNclFractionNcl),
201  fUseV0ANDSelectionOffline(source.fUseV0ANDSelectionOffline)
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  Int_t nentd=ld->GetEntries();
763  for(Int_t jm=0; jm<nentm; jm++){
764  TKey* o=(TKey*)lm->At(jm);
765  TString clnam=o->GetClassName();
766  if(clnam=="TProcessID"){
767  TString pname=o->GetName();
768  TString ptit=o->GetTitle();
769  if(pname.Contains("ProcessID")){
770  TObject* od=(TObject*)ld->FindObject(pname.Data());
771  if(od){
772  TString ptit2=od->GetTitle();
773  if(ptit2!=ptit){
774  printf("AliRDHFCuts::CheckMatchingAODdeltaAODevents: mismatch in %s: AOD: %s -- deltaAOD: %s\n",pname.Data(),ptit.Data(),ptit2.Data());
775  okTProcessNames = kFALSE;
776  }
777  }
778  }
779  }
780  }
781  }
782 
783  if (okTProcessNames) return 1;
784  else return 0;
785 }
786 //---------------------------------------------------------------------------
788  //
789  // Check the correctness of the string syntax
790  //
791  Bool_t retval=kTRUE;
792 
793  if(!rows.Contains("pt")) {
794  if(print) AliError("string must contain \"pt\"");
795  retval= kFALSE;
796  }
797  return retval;
798 }
799 //---------------------------------------------------------------------------
801  //
802  //Create the TFormula from TString for TPC crossed rows pT dependent cut
803  //
804 
805 
806  // setting data member that describes the TPC crossed rows pT dependent cut
808 
809  // creating TFormula from TString
812  // resetting TFormula
814  }
815  if(!CheckPtDepCrossedRows(rows,kTRUE))return;
816 
817  TString tmp(rows);
818  tmp.ReplaceAll("pt","x");
819  f1CutMinNCrossedRowsTPCPtDep = new TFormula("f1CutMinNCrossedRowsTPCPtDep",tmp.Data());
820 
821 
822 }
823 //---------------------------------------------------------------------------
824 Bool_t AliRDHFCuts::IsDaughterSelected(AliAODTrack *track,const AliESDVertex *primary,AliESDtrackCuts *cuts, const AliAODEvent* aod) const{
825  //
826  // Convert to ESDtrack, relate to vertex and check cuts
827  //
828  if(!cuts) return kTRUE;
829 
830  if(cuts->GetFlagCutTOFdistance()) cuts->SetFlagCutTOFdistance(kFALSE);
831 
832 
833  // convert to ESD track here
834  AliESDtrack esdTrack(track);
835  // set the TPC cluster info
836  esdTrack.SetTPCClusterMap(track->GetTPCClusterMap());
837  esdTrack.SetTPCSharedMap(track->GetTPCSharedMap());
838  esdTrack.SetTPCPointsF(track->GetTPCNclsF());
839  // needed to calculate the impact parameters
840  esdTrack.RelateToVertex(primary,0.,3.);
841 
842  //applying ESDtrackCut
843  if(!cuts->IsSelected(&esdTrack)) return kFALSE;
844 
845  //appliyng kink rejection
846  if(fKinkReject){
847  AliAODVertex *maybeKink=track->GetProdVertex();
848  if(maybeKink->GetType()==AliAODVertex::kKink) return kFALSE;
849  }
850 
851  //appliyng TPC crossed rows pT dependent cut
853  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
854  if(nCrossedRowsTPC<f1CutMinNCrossedRowsTPCPtDep->Eval(esdTrack.Pt())) return kFALSE;
855  }
856 
857  //appliyng NTPCcls/NTPCcrossedRows cut
859  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
860  Float_t nClustersTPC = esdTrack.GetTPCNcls();
861  if(nCrossedRowsTPC!=0){
862  Float_t ratio = nClustersTPC/nCrossedRowsTPC;
863  if(ratio<fCutRatioClsOverCrossRowsTPC) return kFALSE;
864  }
865  else return kFALSE;
866  }
867 
868  //appliyng TPCsignalN/NTPCcrossedRows cut
870  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
871  Float_t nTPCsignal = esdTrack.GetTPCsignalN();
872  if(nCrossedRowsTPC!=0){
873  Float_t ratio = nTPCsignal/nCrossedRowsTPC;
874  if(ratio<fCutRatioSignalNOverCrossRowsTPC) return kFALSE;
875  }
876  else return kFALSE;
877  }
878 
879  // geometrical cut (note uses track at vertex instead of at TPC inner wall)
880  if(fUseCutGeoNcrNcl && aod){
881  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
882  Float_t lengthInActiveZoneTPC=esdTrack.GetLengthInActiveZone(0,fDeadZoneWidth,220.,aod->GetMagneticField());
883  Double_t cutGeoNcrNclLength=fCutGeoNcrNclLength-TMath::Power(TMath::Abs(esdTrack.GetSigned1Pt()),fCutGeoNcrNclGeom1Pt);
884  Bool_t isOK=kTRUE;
885  if (lengthInActiveZoneTPC<cutGeoNcrNclLength) isOK=kFALSE;
886  if (nCrossedRowsTPC<fCutGeoNcrNclFractionNcr*cutGeoNcrNclLength) isOK=kFALSE;
887  if (esdTrack.GetTPCncls()<fCutGeoNcrNclFractionNcl*cutGeoNcrNclLength) isOK=kFALSE;
888  if(!isOK) return kFALSE;
889  }
890 
891 
893  // to be implemented
894  // we need either to have here the AOD Event,
895  // or to have the pileup vertex object
896  }
897 
899  Bool_t deadSPDLay1PbPb2011[20][4]={
900  {kTRUE,kTRUE,kTRUE,kTRUE},
901  {kTRUE,kTRUE,kTRUE,kTRUE},
902  {kTRUE,kTRUE,kTRUE,kTRUE},
903  {kTRUE,kTRUE,kTRUE,kTRUE},
904  {kTRUE,kTRUE,kTRUE,kTRUE},
905  {kFALSE,kFALSE,kTRUE,kTRUE},
906  {kTRUE,kTRUE,kFALSE,kFALSE},
907  {kTRUE,kTRUE,kTRUE,kTRUE},
908  {kFALSE,kFALSE,kTRUE,kTRUE},
909  {kTRUE,kTRUE,kTRUE,kTRUE},
910  {kTRUE,kTRUE,kFALSE,kFALSE},
911  {kTRUE,kTRUE,kTRUE,kTRUE},
912  {kFALSE,kFALSE,kFALSE,kFALSE},
913  {kFALSE,kFALSE,kTRUE,kTRUE},
914  {kFALSE,kFALSE,kFALSE,kFALSE},
915  {kFALSE,kFALSE,kFALSE,kFALSE},
916  {kTRUE,kTRUE,kTRUE,kTRUE},
917  {kTRUE,kTRUE,kFALSE,kFALSE},
918  {kFALSE,kFALSE,kFALSE,kFALSE},
919  {kFALSE,kFALSE,kFALSE,kFALSE}
920  };
921  Bool_t deadSPDLay2PbPb2011[40][4]={
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  {kTRUE,kTRUE,kTRUE,kTRUE},
934  {kFALSE,kFALSE,kFALSE,kFALSE},
935  {kFALSE,kFALSE,kTRUE,kTRUE},
936  {kTRUE,kTRUE,kTRUE,kTRUE},
937  {kTRUE,kTRUE,kTRUE,kTRUE},
938  {kTRUE,kTRUE,kFALSE,kFALSE},
939  {kTRUE,kTRUE,kTRUE,kTRUE},
940  {kTRUE,kTRUE,kTRUE,kTRUE},
941  {kTRUE,kTRUE,kTRUE,kTRUE},
942  {kFALSE,kFALSE,kFALSE,kFALSE},
943  {kFALSE,kFALSE,kFALSE,kFALSE},
944  {kTRUE,kTRUE,kTRUE,kTRUE},
945  {kTRUE,kTRUE,kTRUE,kTRUE},
946  {kFALSE,kFALSE,kFALSE,kFALSE},
947  {kFALSE,kFALSE,kFALSE,kFALSE},
948  {kTRUE,kTRUE,kTRUE,kTRUE},
949  {kTRUE,kTRUE,kTRUE,kTRUE},
950  {kFALSE,kFALSE,kFALSE,kFALSE},
951  {kFALSE,kFALSE,kFALSE,kFALSE},
952  {kFALSE,kFALSE,kFALSE,kFALSE},
953  {kFALSE,kFALSE,kFALSE,kFALSE},
954  {kTRUE,kTRUE,kTRUE,kTRUE},
955  {kTRUE,kTRUE,kTRUE,kTRUE},
956  {kTRUE,kTRUE,kFALSE,kFALSE},
957  {kTRUE,kTRUE,kTRUE,kTRUE},
958  {kFALSE,kFALSE,kFALSE,kFALSE},
959  {kFALSE,kFALSE,kFALSE,kFALSE},
960  {kFALSE,kFALSE,kFALSE,kFALSE},
961  {kFALSE,kFALSE,kFALSE,kFALSE}
962  };
963  Double_t xyz1[3],xyz2[3];
964  esdTrack.GetXYZAt(3.9,0.,xyz1);
965  esdTrack.GetXYZAt(7.6,0.,xyz2);
966  Double_t phi1=TMath::ATan2(xyz1[1],xyz1[0]);
967  if(phi1<0) phi1+=2*TMath::Pi();
968  Int_t lad1=(Int_t)(phi1/(2.*TMath::Pi()/20.));
969  Double_t phi2=TMath::ATan2(xyz2[1],xyz2[0]);
970  if(phi2<0) phi2+=2*TMath::Pi();
971  Int_t lad2=(Int_t)(phi2/(2.*TMath::Pi()/40.));
972  Int_t mod1=(Int_t)((xyz1[2]+14)/7.);
973  Int_t mod2=(Int_t)((xyz2[2]+14)/7.);
974  Bool_t lay1ok=kFALSE;
975  if(mod1>=0 && mod1<4 && lad1<20){
976  lay1ok=deadSPDLay1PbPb2011[lad1][mod1];
977  }
978  Bool_t lay2ok=kFALSE;
979  if(mod2>=0 && mod2<4 && lad2<40){
980  lay2ok=deadSPDLay2PbPb2011[lad2][mod2];
981  }
982  if(!lay1ok && !lay2ok) return kFALSE;
983  }
984 
986  // Cut tracks crossing the SPD at 5.6<phi<2pi
987  Double_t xyz1[3],xyz2[3];
988  esdTrack.GetXYZAt(3.9,0.,xyz1);
989  esdTrack.GetXYZAt(7.6,0.,xyz2);
990  Double_t phi1=TMath::ATan2(xyz1[1],xyz1[0]);
991  if(phi1<0) phi1+=2*TMath::Pi();
992  Double_t phi2=TMath::ATan2(xyz2[1],xyz2[0]);
993  if(phi2<0) phi2+=2*TMath::Pi();
994  Bool_t lay1ok=kTRUE;
995  if(phi1>5.6 && phi1<2.*TMath::Pi()) lay1ok=kFALSE;
996  Bool_t lay2ok=kTRUE;
997  if(phi2>5.6 && phi2<2.*TMath::Pi()) lay2ok=kFALSE;
998  if(!lay1ok || !lay2ok) return kFALSE;
999  }
1000 
1001  return kTRUE;
1002 }
1003 //---------------------------------------------------------------------------
1004 void AliRDHFCuts::SetPtBins(Int_t nPtBinLimits,Float_t *ptBinLimits) {
1005  // Set the pt bins
1006 
1007  if(fPtBinLimits) {
1008  delete [] fPtBinLimits;
1009  fPtBinLimits = NULL;
1010  printf("Changing the pt bins\n");
1011  }
1012 
1013  if(nPtBinLimits != fnPtBins+1){
1014  cout<<"Warning: ptBinLimits dimention "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBins+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
1015  SetNPtBins(nPtBinLimits-1);
1016  }
1017 
1018  fnPtBinLimits = nPtBinLimits;
1019  SetGlobalIndex();
1020  //cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl;
1022  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimits[ib]=ptBinLimits[ib];
1023 
1024  return;
1025 }
1026 //---------------------------------------------------------------------------
1027 void AliRDHFCuts::SetVarNames(Int_t nVars,TString *varNames,Bool_t *isUpperCut){
1028  // Set the variable names
1029 
1030  if(fVarNames) {
1031  delete [] fVarNames;
1032  fVarNames = NULL;
1033  //printf("Changing the variable names\n");
1034  }
1035  if(nVars!=fnVars){
1036  printf("Wrong number of variables: it has to be %d\n",fnVars);
1037  return;
1038  }
1039  //fnVars=nVars;
1040  fVarNames = new TString[nVars];
1041  fIsUpperCut = new Bool_t[nVars];
1042  for(Int_t iv=0; iv<nVars; iv++) {
1043  fVarNames[iv] = varNames[iv];
1044  fIsUpperCut[iv] = isUpperCut[iv];
1045  }
1046 
1047  return;
1048 }
1049 //---------------------------------------------------------------------------
1051  // Set the variables to be used for cuts optimization
1052 
1053  if(fVarsForOpt) {
1054  delete [] fVarsForOpt;
1055  fVarsForOpt = NULL;
1056  //printf("Changing the variables for cut optimization\n");
1057  }
1058 
1059  if(nVars==0){
1060  printf("%d not accepted as number of variables: it has to be %d\n",nVars,fnVars);
1061  return;
1062  }
1063 
1064  fnVarsForOpt = 0;
1065  fVarsForOpt = new Bool_t[fnVars];
1066  for(Int_t iv=0; iv<fnVars; iv++) {
1067  fVarsForOpt[iv]=forOpt[iv];
1068  if(fVarsForOpt[iv]) fnVarsForOpt++;
1069  }
1070 
1071  return;
1072 }
1073 
1074 //---------------------------------------------------------------------------
1076  //
1077  // set centrality estimator
1078  //
1079  fUseCentrality=flag;
1080  if(fUseCentrality<kCentOff||fUseCentrality>=kCentInvalid) AliWarning("Centrality estimator not valid");
1081 
1082  return;
1083 }
1084 
1085 
1086 //---------------------------------------------------------------------------
1088  //
1089  // store the cuts
1090  //
1091  if(nVars!=fnVars) {
1092  printf("Wrong number of variables: it has to be %d\n",fnVars);
1093  AliFatal("exiting");
1094  }
1095  if(nPtBins!=fnPtBins) {
1096  printf("Wrong number of pt bins: it has to be %d\n",fnPtBins);
1097  AliFatal("exiting");
1098  }
1099 
1100  if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex];
1101 
1102 
1103  for(Int_t iv=0; iv<fnVars; iv++) {
1104 
1105  for(Int_t ib=0; ib<fnPtBins; ib++) {
1106 
1107  //check
1108  if(GetGlobalIndex(iv,ib)>=fGlobalIndex) {
1109  cout<<"Overflow, exit..."<<endl;
1110  return;
1111  }
1112 
1113  fCutsRD[GetGlobalIndex(iv,ib)] = cutsRD[iv][ib];
1114 
1115  }
1116  }
1117  return;
1118 }
1119 //---------------------------------------------------------------------------
1120 void AliRDHFCuts::SetCuts(Int_t glIndex,Float_t* cutsRDGlob){
1121  //
1122  // store the cuts
1123  //
1124  if(glIndex != fGlobalIndex){
1125  cout<<"Wrong array size: it has to be "<<fGlobalIndex<<endl;
1126  AliFatal("exiting");
1127  }
1128  if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex];
1129 
1130  for(Int_t iGl=0;iGl<fGlobalIndex;iGl++){
1131  fCutsRD[iGl] = cutsRDGlob[iGl];
1132  }
1133  return;
1134 }
1135 //---------------------------------------------------------------------------
1137  //
1138  // print all cuts values
1139  //
1140 
1141  printf("Minimum vtx type %d\n",fMinVtxType);
1142  printf("Minimum vtx contr %d\n",fMinVtxContr);
1143  printf("Max vtx red chi2 %f\n",fMaxVtxRedChi2);
1144  printf("Min SPD mult %d\n",fMinSPDMultiplicity);
1145  printf("Use PID %d OldPid=%d\n",(Int_t)fUsePID,fPidHF ? fPidHF->GetOldPid() : -1);
1146  printf("Remove daughters from vtx %d\n",(Int_t)fRemoveDaughtersFromPrimary);
1147  printf("Physics selection: %s\n",fUsePhysicsSelection ? "Yes" : "No");
1148  printf("Pileup rejection: %s\n",(fOptPileup > 0) ? "Yes" : "No");
1149  if(fOptPileup==1) printf(" -- Reject pileup event");
1150  if(fOptPileup==2) printf(" -- Reject tracks from pileup vtx");
1151  if(fUseCentrality>0) {
1152  TString estimator="";
1153  if(fUseCentrality==1) estimator = "V0";
1154  if(fUseCentrality==2) estimator = "Tracks";
1155  if(fUseCentrality==3) estimator = "Tracklets";
1156  if(fUseCentrality==4) estimator = "SPD clusters outer";
1157  if(fUseCentrality==5) estimator = "ZNA";
1158  if(fUseCentrality==6) estimator = "ZPA";
1159  if(fUseCentrality==7) estimator = "V0A";
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  AliMultSelection *multSelection = (AliMultSelection*)aodEvent->FindListObject(fMultSelectionObjectName);
1310  if(!multSelection){
1311  AliWarning("AliMultSelection could not be found in the aod event list of objects");
1312  return cent;
1313  }
1314 
1315  // Compare centrality with the centrality at AOD filtering and on-the-fly
1316  if( fMultSelectionObjectName.CompareTo("MultSelection")!=0 ){
1317  AliMultSelection *defaultmultSelection = (AliMultSelection*)aodEvent->FindListObject("MultSelection");
1318  if(!defaultmultSelection){
1319  AliWarning("AliMultSelection default method could not be found in the aod event list of objects");
1320  return cent;
1321  }
1322  Float_t defaultCent = defaultmultSelection->GetMultiplicityPercentile("V0M");
1323  Float_t newCent = multSelection->GetMultiplicityPercentile("V0M");
1324  if( defaultCent<20. && newCent>20.) fEvRejectionBits+=1<<kMismatchOldNewCentrality;
1325  else if (defaultCent>20. && newCent<20.) fEvRejectionBits+=1<<kMismatchOldNewCentrality;
1326  }
1327 
1328  if(estimator==kCentV0M){
1329  cent=multSelection->GetMultiplicityPercentile("V0M");
1330  }else if(estimator==kCentV0A){
1331  cent=multSelection->GetMultiplicityPercentile("V0A");
1332  }else if(estimator==kCentZNA){
1333  cent=multSelection->GetMultiplicityPercentile("ZNA");
1334  }else if(estimator==kCentCL1){
1335  cent=multSelection->GetMultiplicityPercentile("CL1");
1336  }else {
1337  AliWarning(Form("CENTRALITY ESTIMATE WITH ESTIMATEOR %d NOT YET IMPLEMENTED FOR NEW FRAMEWORK",(Int_t)estimator));
1338  return cent;
1339  }
1340  Int_t qual = multSelection->GetEvSelCode();
1341  if(qual == 199 ) cent=-999;
1342  return cent;
1343 }
1344 //-------------------------------------------------------------------
1346  //
1347  // Get centrality percentile
1348  //
1349 
1350  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)aodEvent)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
1351  if(mcArray) {fUseAOD049=kFALSE;}
1352 
1353  AliAODHeader *header=dynamic_cast<AliAODHeader*>(aodEvent->GetHeader());
1354  if(!header) AliFatal("Not a standard AOD");
1355  AliCentrality *centrality=header->GetCentralityP();
1356  Float_t cent=-999.;
1357  Bool_t isSelRun=kFALSE;
1358  Int_t selRun[5]={138364, 138826, 138828, 138836, 138871};
1359  if(!centrality) return cent;
1360  else{
1361  if (estimator==kCentV0M){
1362  cent=(Float_t)(centrality->GetCentralityPercentile("V0M"));
1363  if(cent<0){
1364  Int_t quality = centrality->GetQuality();
1365  if(quality<=1){ // fQuality==1 means rejected by zVertex cut that we apply a part and we want to keep separate (Giacomo)
1366  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0M");
1367  }else{
1368  Int_t runnum=aodEvent->GetRunNumber();
1369  for(Int_t ir=0;ir<5;ir++){
1370  if(runnum==selRun[ir]){
1371  isSelRun=kTRUE;
1372  break;
1373  }
1374  }
1375  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0M");
1376  }
1377  }
1378 
1379  //temporary fix for AOD049 outliers
1380  if(fUseAOD049&&cent>=0){
1381  Float_t v0=0;
1382  AliAODVZERO* aodV0 = aodEvent->GetVZEROData();
1383  v0+=aodV0->GetMTotV0A();
1384  v0+=aodV0->GetMTotV0C();
1385  if(cent==0&&v0<19500)return -1;//filtering issue
1386  Float_t tkl = (Float_t)(aodEvent->GetTracklets()->GetNumberOfTracklets());
1387  Float_t val= 1.30552 + 0.147931 * v0;
1388  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};
1389  if ( TMath::Abs(tkl-val) > 6.*tklSigma[(Int_t)cent] )return -1;//outlier
1390  }
1391  }
1392  else {
1393  if (estimator==kCentTRK) {
1394  cent=(Float_t)(centrality->GetCentralityPercentile("TRK"));
1395  if(cent<0){
1396  Int_t quality = centrality->GetQuality();
1397  if(quality<=1){
1398  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TRK");
1399  }else{
1400  Int_t runnum=aodEvent->GetRunNumber();
1401  for(Int_t ir=0;ir<5;ir++){
1402  if(runnum==selRun[ir]){
1403  isSelRun=kTRUE;
1404  break;
1405  }
1406  }
1407  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TRK");
1408  }
1409  }
1410  }
1411  else{
1412  if (estimator==kCentTKL){
1413  cent=(Float_t)(centrality->GetCentralityPercentile("TKL"));
1414  if(cent<0){
1415  Int_t quality = centrality->GetQuality();
1416  if(quality<=1){
1417  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TKL");
1418  }else{
1419  Int_t runnum=aodEvent->GetRunNumber();
1420  for(Int_t ir=0;ir<5;ir++){
1421  if(runnum==selRun[ir]){
1422  isSelRun=kTRUE;
1423  break;
1424  }
1425  }
1426  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TKL");
1427  }
1428  }
1429  }
1430  else{
1431  if (estimator==kCentCL1){
1432  cent=(Float_t)(centrality->GetCentralityPercentile("CL1"));
1433  if(cent<0){
1434  Int_t quality = centrality->GetQuality();
1435  if(quality<=1){
1436  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("CL1");
1437  }else{
1438  Int_t runnum=aodEvent->GetRunNumber();
1439  for(Int_t ir=0;ir<5;ir++){
1440  if(runnum==selRun[ir]){
1441  isSelRun=kTRUE;
1442  break;
1443  }
1444  }
1445  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("CL1");
1446  }
1447  }
1448  }
1449  else{
1450  if (estimator==kCentZNA){
1451  cent=(Float_t)(centrality->GetCentralityPercentile("ZNA"));
1452  if(cent<0){
1453  Int_t quality = centrality->GetQuality();
1454  if(quality<=1){
1455  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZNA");
1456  }else{
1457  Int_t runnum=aodEvent->GetRunNumber();
1458  for(Int_t ir=0;ir<5;ir++){
1459  if(runnum==selRun[ir]){
1460  isSelRun=kTRUE;
1461  break;
1462  }
1463  }
1464  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZNA");
1465  }
1466  }
1467  }
1468  else{
1469  if (estimator==kCentZPA){
1470  cent=(Float_t)(centrality->GetCentralityPercentile("ZPA"));
1471  if(cent<0){
1472  Int_t quality = centrality->GetQuality();
1473  if(quality<=1){
1474  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZPA");
1475  }else{
1476  Int_t runnum=aodEvent->GetRunNumber();
1477  for(Int_t ir=0;ir<5;ir++){
1478  if(runnum==selRun[ir]){
1479  isSelRun=kTRUE;
1480  break;
1481  }
1482  }
1483  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZPA");
1484  }
1485  }
1486  }
1487  else{
1488  if (estimator==kCentV0A){
1489  cent=(Float_t)(centrality->GetCentralityPercentile("V0A"));
1490  if(cent<0){
1491  Int_t quality = centrality->GetQuality();
1492  if(quality<=1){
1493  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0A");
1494  }else{
1495  Int_t runnum=aodEvent->GetRunNumber();
1496  for(Int_t ir=0;ir<5;ir++){
1497  if(runnum==selRun[ir]){
1498  isSelRun=kTRUE;
1499  break;
1500  }
1501  }
1502  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0A");
1503  }
1504  }
1505  }
1506  else {
1507  AliWarning("Centrality estimator not valid");
1508 
1509  }
1510  }
1511  }
1512  }
1513  }
1514  }
1515  }
1516  }
1517  return cent;
1518 }
1519 //-------------------------------------------------------------------
1521  //
1522  // Compare two cuts objects
1523  //
1524 
1525  Bool_t areEqual=kTRUE;
1526 
1527  if(fMinVtxType!=obj->fMinVtxType) { printf("Minimum vtx type %d %d\n",fMinVtxType,obj->fMinVtxType); areEqual=kFALSE;}
1528 
1529  if(fMinVtxContr!=obj->fMinVtxContr) { printf("Minimum vtx contr %d %d\n",fMinVtxContr,obj->fMinVtxContr); areEqual=kFALSE;}
1530 
1531  if(TMath::Abs(fMaxVtxRedChi2-obj->fMaxVtxRedChi2)>1.e-10) { printf("Max vtx red chi2 %f %f\n",fMaxVtxRedChi2,obj->fMaxVtxRedChi2);areEqual=kFALSE;}
1532 
1533  if(fMinSPDMultiplicity!=obj->fMinSPDMultiplicity) { printf("Min SPD mult %d\n %d",fMinSPDMultiplicity,obj->fMinSPDMultiplicity);areEqual=kFALSE;}
1534 
1535  if(fUsePID!=obj->fUsePID) { printf("Use PID %d %d\n",(Int_t)fUsePID,(Int_t)obj->fUsePID); areEqual=kFALSE;}
1536 
1537  if(fRemoveDaughtersFromPrimary!=obj->fRemoveDaughtersFromPrimary) {printf("Remove daughters from vtx %d %d\n",(Int_t)fRemoveDaughtersFromPrimary,(Int_t)obj->fRemoveDaughtersFromPrimary); areEqual=kFALSE;}
1538  if(fTrackCuts){
1539  if(fTrackCuts->GetMinNClusterTPC()!=obj->fTrackCuts->GetMinNClusterTPC()) {printf("MinNClsTPC %d %d\n",fTrackCuts->GetMinNClusterTPC(),obj->fTrackCuts->GetMinNClusterTPC()); areEqual=kFALSE;}
1540 
1541  if(fTrackCuts->GetMinNClustersITS()!=obj->fTrackCuts->GetMinNClustersITS()) {printf("MinNClsITS %d %d\n",fTrackCuts->GetMinNClustersITS(),obj->fTrackCuts->GetMinNClustersITS()); areEqual=kFALSE;}
1542 
1543  if(TMath::Abs(fTrackCuts->GetMaxChi2PerClusterTPC()-obj->fTrackCuts->GetMaxChi2PerClusterTPC())>1.e-10) {printf("MaxChi2ClsTPC %f %f\n",fTrackCuts->GetMaxChi2PerClusterTPC(),obj->fTrackCuts->GetMaxChi2PerClusterTPC()); areEqual=kFALSE;}
1544 
1545  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;}
1546  }
1547 
1548  if(fCutsRD) {
1549  for(Int_t iv=0;iv<fnVars;iv++) {
1550  for(Int_t ib=0;ib<fnPtBins;ib++) {
1551  if(TMath::Abs(fCutsRD[GetGlobalIndex(iv,ib)]-obj->fCutsRD[GetGlobalIndex(iv,ib)])>1.e-10) {
1552  cout<<"fCutsRD["<<iv<<"]["<<ib<<"] = "<<fCutsRD[GetGlobalIndex(iv,ib)]<<" "<<obj->fCutsRD[GetGlobalIndex(iv,ib)]<<"\n";
1553  areEqual=kFALSE;
1554  }
1555  }
1556  }
1557  }
1558 
1559  return areEqual;
1560 }
1561 //---------------------------------------------------------------------------
1563  //
1564  // print cuts values in table format
1565  //
1566 
1567  TString ptString = "pT range";
1568  if(fVarNames && fPtBinLimits && fCutsRD){
1569  TString firstLine(Form("* %-15s",ptString.Data()));
1570  for (Int_t ivar=0; ivar<fnVars; ivar++){
1571  firstLine+=Form("* %-15s ",fVarNames[ivar].Data());
1572  if (ivar == fnVars){
1573  firstLine+="*\n";
1574  }
1575  }
1576  Printf("%s",firstLine.Data());
1577 
1578  for (Int_t ipt=0; ipt<fnPtBins; ipt++){
1579  TString line;
1580  if (ipt==fnPtBins-1){
1581  line=Form("* %5.1f < pt < inf ",fPtBinLimits[ipt]);
1582  }
1583  else{
1584  line=Form("* %5.1f < pt < %4.1f ",fPtBinLimits[ipt],fPtBinLimits[ipt+1]);
1585  }
1586  for (Int_t ivar=0; ivar<fnVars; ivar++){
1587  line+=Form("* %-15f ",fCutsRD[GetGlobalIndex(ivar,ipt)]);
1588  }
1589  Printf("%s",line.Data());
1590  }
1591 
1592  }
1593 
1594 
1595  return;
1596 }
1597 //--------------------------------------------------------------------------
1599  AliAODEvent *aod) const
1600 {
1601  //
1602  // Recalculate primary vertex without daughters
1603  //
1604 
1605  if(!aod) {
1606  AliError("Can not remove daughters from vertex without AOD event");
1607  return 0;
1608  }
1609 
1610  AliAODVertex *recvtx=d->RemoveDaughtersFromPrimaryVtx(aod);
1611  if(!recvtx){
1612  AliDebug(2,"Removal of daughter tracks failed");
1613  return kFALSE;
1614  }
1615 
1616 
1617  //set recalculed primary vertex
1618  d->SetOwnPrimaryVtx(recvtx);
1619  delete recvtx;
1620 
1621  return kTRUE;
1622 }
1623 //--------------------------------------------------------------------------
1625 {
1626  //
1627  // Recalculate primary vertex without daughters
1628  //
1629 
1630  if(!aod) {
1631  AliError("Can not get MC vertex without AOD event");
1632  return kFALSE;
1633  }
1634 
1635  // load MC header
1636  AliAODMCHeader *mcHeader =
1637  (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
1638  if(!mcHeader) {
1639  AliError("Can not get MC vertex without AODMCHeader event");
1640  return kFALSE;
1641  }
1642  Double_t pos[3];
1643  Double_t covmatrix[6]={0.,0.,0.,0.,0.,0.};
1644  mcHeader->GetVertex(pos);
1645  AliAODVertex *recvtx=new AliAODVertex(pos,covmatrix);
1646 
1647  if(!recvtx){
1648  AliDebug(2,"Removal of daughter tracks failed");
1649  return kFALSE;
1650  }
1651 
1652  //set recalculed primary vertex
1653  d->SetOwnPrimaryVtx(recvtx);
1654 
1655  d->RecalculateImpPars(recvtx,aod);
1656 
1657  delete recvtx;
1658 
1659  return kTRUE;
1660 }
1661 //--------------------------------------------------------------------------
1663  AliAODEvent *aod,
1664  AliAODVertex *origownvtx) const
1665 {
1666  //
1667  // Clean-up own primary vertex if needed
1668  //
1669 
1671  d->UnsetOwnPrimaryVtx();
1672  if(origownvtx) {
1673  d->SetOwnPrimaryVtx(origownvtx);
1674  delete origownvtx; origownvtx=NULL;
1675  }
1676  d->RecalculateImpPars(d->GetPrimaryVtx(),aod);
1677  } else {
1678  if(origownvtx) {
1679  delete origownvtx; origownvtx=NULL;
1680  }
1681  }
1682  return;
1683 }
1684 //--------------------------------------------------------------------------
1685 Bool_t AliRDHFCuts::IsSignalMC(AliAODRecoDecay *d,AliAODEvent *aod,Int_t pdg) const
1686 {
1687  //
1688  // Checks if this candidate is matched to MC signal
1689  //
1690 
1691  if(!aod) return kFALSE;
1692 
1693  // get the MC array
1694  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)aod)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
1695 
1696  if(!mcArray) return kFALSE;
1697 
1698  // try to match
1699  Int_t label = d->MatchToMC(pdg,mcArray);
1700 
1701  if(label>=0) {
1702  //printf("MATCH!\n");
1703  return kTRUE;
1704  }
1705 
1706  return kFALSE;
1707 }
1708 
1709 
1710 //--------------------------------------------------------------------------
1712  // recompute event primary vertex from AOD tracks
1713 
1714  AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
1715  vertexer->SetITSMode();
1716  vertexer->SetMinClusters(3);
1717 
1718  AliAODVertex* pvtx=event->GetPrimaryVertex();
1719  if(strstr(pvtx->GetTitle(),"VertexerTracksWithConstraint")) {
1720  Float_t diamondcovxy[3];
1721  event->GetDiamondCovXY(diamondcovxy);
1722  Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
1723  Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.*10.};
1724  AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
1725  vertexer->SetVtxStart(diamond);
1726  delete diamond; diamond=NULL;
1727  }
1728 
1729  AliESDVertex* vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event);
1730  if(!vertexESD) return kFALSE;
1731  if(vertexESD->GetNContributors()<=0) {
1732  //AliDebug(2,"vertexing failed");
1733  delete vertexESD; vertexESD=NULL;
1734  return kFALSE;
1735  }
1736  delete vertexer; vertexer=NULL;
1737 
1738  // convert to AliAODVertex
1739  Double_t pos[3],cov[6],chi2perNDF;
1740  vertexESD->GetXYZ(pos); // position
1741  vertexESD->GetCovMatrix(cov); //covariance matrix
1742  chi2perNDF = vertexESD->GetChi2toNDF();
1743  delete vertexESD; vertexESD=NULL;
1744 
1745  pvtx->SetPosition(pos[0],pos[1],pos[2]);
1746  pvtx->SetChi2perNDF(chi2perNDF);
1747  pvtx->SetCovMatrix(cov);
1748 
1749  return kTRUE;
1750 }
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