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