AliPhysics  ec7afe5 (ec7afe5)
 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 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.) {
638  if(accept) fWhyRejection=6;
639  accept=kFALSE;
640  }
641  if(fCutOnzVertexSPD==2 && vertex){
642  if(TMath::Abs(vSPD->GetZ()-vertex->GetZ())>0.5) {
644  if(accept) fWhyRejection=6;
645  accept=kFALSE;
646  }
647  }
648  }
649  }
650 
651  // pile-up rejection
653  Bool_t isPileup=kFALSE;
655  isPileup=event->IsPileupFromSPDInMultBins();
656  }else{
659  isPileup=event->IsPileupFromSPD(cutc,cutz,3.,2.,10.);
660  }
661  if(isPileup){
662  if(accept) fWhyRejection=1;
664  accept=kFALSE;
665  }
666  }
668  AliAnalysisUtils utils;
669  Bool_t isPUMV = utils.IsPileUpMV(event);
670  if(isPUMV) {
671  if(accept) fWhyRejection=1;
673  accept=kFALSE;
674  }
675  }
676 
677 
678  // Correcting PP2012 flag to remoce tracks crossing SPD misaligned staves for periods 12def
679  if(fApplySPDMisalignedPP2012 && !(event->GetRunNumber()>=195681 && event->GetRunNumber()<=197388)) fApplySPDMisalignedPP2012=false;
680 
681  return accept;
682 }
683 //---------------------------------------------------------------------------
685  //
686  // Daughter tracks selection
687  //
688  if(!fTrackCuts) return kTRUE;
689 
690  Int_t ndaughters = d->GetNDaughters();
691  AliAODVertex *vAOD = d->GetPrimaryVtx();
692  Double_t pos[3],cov[6];
693  vAOD->GetXYZ(pos);
694  vAOD->GetCovarianceMatrix(cov);
695  const AliESDVertex vESD(pos,cov,100.,100);
696 
697  Bool_t retval=kTRUE;
698 
699  for(Int_t idg=0; idg<ndaughters; idg++) {
700  AliAODTrack *dgTrack = (AliAODTrack*)d->GetDaughter(idg);
701  if(!dgTrack) {retval = kFALSE; continue;}
702  //printf("charge %d\n",dgTrack->Charge());
703  if(dgTrack->Charge()==0) continue; // it's not a track, but a V0
704 
706  { if(!dgTrack->HasPointOnITSLayer(0)) { retval = kFALSE; continue; } }
707 
708  if(!IsDaughterSelected(dgTrack,&vESD,fTrackCuts,aod)) retval = kFALSE;
709  }
710 
711  return retval;
712 }
713 //---------------------------------------------------------------------------
715  //
716  // Check if AOD and deltaAOD files are composed of the same events:
717  // mismatches were observed in the merged AODs of LHC15o
718  //
719  // When AOD+deltaAOD are produced from ESD, mismatches can be found looking at:
720  // - the AOD trees in AliAOD.root and AliAOD.VertexingHF.root have different number of entries
721  // - the titles of the TProcessID objects do not match
722  // When deltaAOD are produced from AOD, mismatches can be found looking at:
723  // - the AOD trees in AliAOD.root and AliAOD.VertexingHF.root have different number of entries
724  //
725  // Return values:
726  // -1: AOD and deltaAOD trees have different number of entries
727  // 0: AOD and deltaAOD trees have same number of entries + the titles of the TProcessID objects do not match
728  // 1: AOD and deltaAOD trees have same number of entries + the titles of the TProcessID objects match
729  Bool_t okTProcessNames = kTRUE;
730  AliAODHandler* aodHandler = (AliAODHandler*)((AliAnalysisManager::GetAnalysisManager())->GetInputEventHandler());
731  TTree *treeAOD = aodHandler->GetTree();
732  TTree *treeDeltaAOD = treeAOD->GetFriend("aodTree");
733  if(!treeDeltaAOD || !treeAOD) return -1;
734  if(treeDeltaAOD && treeAOD){
735  if(treeAOD->GetEntries()!=treeDeltaAOD->GetEntries()){
736  printf("AliRDHFCuts::CheckMatchingAODdeltaAODevents: Difference in number of entries in main and friend tree, skipping event\n");
737  return -1;
738  }
739  TFile *mfile = treeAOD->GetCurrentFile();
740  TFile *dfile = treeDeltaAOD->GetCurrentFile();
741  TList* lm=mfile->GetListOfKeys();
742  TList* ld=dfile->GetListOfKeys();
743  Int_t nentm=lm->GetEntries();
744  Int_t nentd=ld->GetEntries();
745  for(Int_t jm=0; jm<nentm; jm++){
746  TKey* o=(TKey*)lm->At(jm);
747  TString clnam=o->GetClassName();
748  if(clnam=="TProcessID"){
749  TString pname=o->GetName();
750  TString ptit=o->GetTitle();
751  if(pname.Contains("ProcessID")){
752  TObject* od=(TObject*)ld->FindObject(pname.Data());
753  if(od){
754  TString ptit2=od->GetTitle();
755  if(ptit2!=ptit){
756  printf("AliRDHFCuts::CheckMatchingAODdeltaAODevents: mismatch in %s: AOD: %s -- deltaAOD: %s\n",pname.Data(),ptit.Data(),ptit2.Data());
757  okTProcessNames = kFALSE;
758  }
759  }
760  }
761  }
762  }
763  }
764 
765  if (okTProcessNames) return 1;
766  else return 0;
767 }
768 //---------------------------------------------------------------------------
770  //
771  // Check the correctness of the string syntax
772  //
773  Bool_t retval=kTRUE;
774 
775  if(!rows.Contains("pt")) {
776  if(print) AliError("string must contain \"pt\"");
777  retval= kFALSE;
778  }
779  return retval;
780 }
781 //---------------------------------------------------------------------------
783  //
784  //Create the TFormula from TString for TPC crossed rows pT dependent cut
785  //
786 
787 
788  // setting data member that describes the TPC crossed rows pT dependent cut
790 
791  // creating TFormula from TString
794  // resetting TFormula
796  }
797  if(!CheckPtDepCrossedRows(rows,kTRUE))return;
798 
799  TString tmp(rows);
800  tmp.ReplaceAll("pt","x");
801  f1CutMinNCrossedRowsTPCPtDep = new TFormula("f1CutMinNCrossedRowsTPCPtDep",tmp.Data());
802 
803 
804 }
805 //---------------------------------------------------------------------------
806 Bool_t AliRDHFCuts::IsDaughterSelected(AliAODTrack *track,const AliESDVertex *primary,AliESDtrackCuts *cuts, const AliAODEvent* aod) const{
807  //
808  // Convert to ESDtrack, relate to vertex and check cuts
809  //
810  if(!cuts) return kTRUE;
811 
812  if(cuts->GetFlagCutTOFdistance()) cuts->SetFlagCutTOFdistance(kFALSE);
813 
814 
815  // convert to ESD track here
816  AliESDtrack esdTrack(track);
817  // set the TPC cluster info
818  esdTrack.SetTPCClusterMap(track->GetTPCClusterMap());
819  esdTrack.SetTPCSharedMap(track->GetTPCSharedMap());
820  esdTrack.SetTPCPointsF(track->GetTPCNclsF());
821  // needed to calculate the impact parameters
822  esdTrack.RelateToVertex(primary,0.,3.);
823 
824  //applying ESDtrackCut
825  if(!cuts->IsSelected(&esdTrack)) return kFALSE;
826 
827  //appliyng kink rejection
828  if(fKinkReject){
829  AliAODVertex *maybeKink=track->GetProdVertex();
830  if(maybeKink->GetType()==AliAODVertex::kKink) return kFALSE;
831  }
832 
833  //appliyng TPC crossed rows pT dependent cut
835  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
836  if(nCrossedRowsTPC<f1CutMinNCrossedRowsTPCPtDep->Eval(esdTrack.Pt())) return kFALSE;
837  }
838 
839  //appliyng NTPCcls/NTPCcrossedRows cut
841  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
842  Float_t nClustersTPC = esdTrack.GetTPCNcls();
843  if(nCrossedRowsTPC!=0){
844  Float_t ratio = nClustersTPC/nCrossedRowsTPC;
845  if(ratio<fCutRatioClsOverCrossRowsTPC) return kFALSE;
846  }
847  else return kFALSE;
848  }
849 
850  //appliyng TPCsignalN/NTPCcrossedRows cut
852  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
853  Float_t nTPCsignal = esdTrack.GetTPCsignalN();
854  if(nCrossedRowsTPC!=0){
855  Float_t ratio = nTPCsignal/nCrossedRowsTPC;
856  if(ratio<fCutRatioSignalNOverCrossRowsTPC) return kFALSE;
857  }
858  else return kFALSE;
859  }
860 
861  // geometrical cut (note uses track at vertex instead of at TPC inner wall)
862  if(fUseCutGeoNcrNcl && aod){
863  Float_t nCrossedRowsTPC = esdTrack.GetTPCCrossedRows();
864  Float_t lengthInActiveZoneTPC=esdTrack.GetLengthInActiveZone(0,fDeadZoneWidth,220.,aod->GetMagneticField());
865  Double_t cutGeoNcrNclLength=fCutGeoNcrNclLength-TMath::Power(TMath::Abs(esdTrack.GetSigned1Pt()),fCutGeoNcrNclGeom1Pt);
866  Bool_t isOK=kTRUE;
867  if (lengthInActiveZoneTPC<cutGeoNcrNclLength) isOK=kFALSE;
868  if (nCrossedRowsTPC<fCutGeoNcrNclFractionNcr*cutGeoNcrNclLength) isOK=kFALSE;
869  if (esdTrack.GetTPCncls()<fCutGeoNcrNclFractionNcl*cutGeoNcrNclLength) isOK=kFALSE;
870  if(!isOK) return kFALSE;
871  }
872 
873 
875  // to be implemented
876  // we need either to have here the AOD Event,
877  // or to have the pileup vertex object
878  }
879 
881  Bool_t deadSPDLay1PbPb2011[20][4]={
882  {kTRUE,kTRUE,kTRUE,kTRUE},
883  {kTRUE,kTRUE,kTRUE,kTRUE},
884  {kTRUE,kTRUE,kTRUE,kTRUE},
885  {kTRUE,kTRUE,kTRUE,kTRUE},
886  {kTRUE,kTRUE,kTRUE,kTRUE},
887  {kFALSE,kFALSE,kTRUE,kTRUE},
888  {kTRUE,kTRUE,kFALSE,kFALSE},
889  {kTRUE,kTRUE,kTRUE,kTRUE},
890  {kFALSE,kFALSE,kTRUE,kTRUE},
891  {kTRUE,kTRUE,kTRUE,kTRUE},
892  {kTRUE,kTRUE,kFALSE,kFALSE},
893  {kTRUE,kTRUE,kTRUE,kTRUE},
894  {kFALSE,kFALSE,kFALSE,kFALSE},
895  {kFALSE,kFALSE,kTRUE,kTRUE},
896  {kFALSE,kFALSE,kFALSE,kFALSE},
897  {kFALSE,kFALSE,kFALSE,kFALSE},
898  {kTRUE,kTRUE,kTRUE,kTRUE},
899  {kTRUE,kTRUE,kFALSE,kFALSE},
900  {kFALSE,kFALSE,kFALSE,kFALSE},
901  {kFALSE,kFALSE,kFALSE,kFALSE}
902  };
903  Bool_t deadSPDLay2PbPb2011[40][4]={
904  {kTRUE,kTRUE,kTRUE,kTRUE},
905  {kTRUE,kTRUE,kTRUE,kTRUE},
906  {kTRUE,kTRUE,kTRUE,kTRUE},
907  {kTRUE,kTRUE,kTRUE,kTRUE},
908  {kTRUE,kTRUE,kTRUE,kTRUE},
909  {kTRUE,kTRUE,kTRUE,kTRUE},
910  {kTRUE,kTRUE,kTRUE,kTRUE},
911  {kTRUE,kTRUE,kTRUE,kTRUE},
912  {kTRUE,kTRUE,kTRUE,kTRUE},
913  {kTRUE,kTRUE,kTRUE,kTRUE},
914  {kTRUE,kTRUE,kTRUE,kTRUE},
915  {kTRUE,kTRUE,kTRUE,kTRUE},
916  {kFALSE,kFALSE,kFALSE,kFALSE},
917  {kFALSE,kFALSE,kTRUE,kTRUE},
918  {kTRUE,kTRUE,kTRUE,kTRUE},
919  {kTRUE,kTRUE,kTRUE,kTRUE},
920  {kTRUE,kTRUE,kFALSE,kFALSE},
921  {kTRUE,kTRUE,kTRUE,kTRUE},
922  {kTRUE,kTRUE,kTRUE,kTRUE},
923  {kTRUE,kTRUE,kTRUE,kTRUE},
924  {kFALSE,kFALSE,kFALSE,kFALSE},
925  {kFALSE,kFALSE,kFALSE,kFALSE},
926  {kTRUE,kTRUE,kTRUE,kTRUE},
927  {kTRUE,kTRUE,kTRUE,kTRUE},
928  {kFALSE,kFALSE,kFALSE,kFALSE},
929  {kFALSE,kFALSE,kFALSE,kFALSE},
930  {kTRUE,kTRUE,kTRUE,kTRUE},
931  {kTRUE,kTRUE,kTRUE,kTRUE},
932  {kFALSE,kFALSE,kFALSE,kFALSE},
933  {kFALSE,kFALSE,kFALSE,kFALSE},
934  {kFALSE,kFALSE,kFALSE,kFALSE},
935  {kFALSE,kFALSE,kFALSE,kFALSE},
936  {kTRUE,kTRUE,kTRUE,kTRUE},
937  {kTRUE,kTRUE,kTRUE,kTRUE},
938  {kTRUE,kTRUE,kFALSE,kFALSE},
939  {kTRUE,kTRUE,kTRUE,kTRUE},
940  {kFALSE,kFALSE,kFALSE,kFALSE},
941  {kFALSE,kFALSE,kFALSE,kFALSE},
942  {kFALSE,kFALSE,kFALSE,kFALSE},
943  {kFALSE,kFALSE,kFALSE,kFALSE}
944  };
945  Double_t xyz1[3],xyz2[3];
946  esdTrack.GetXYZAt(3.9,0.,xyz1);
947  esdTrack.GetXYZAt(7.6,0.,xyz2);
948  Double_t phi1=TMath::ATan2(xyz1[1],xyz1[0]);
949  if(phi1<0) phi1+=2*TMath::Pi();
950  Int_t lad1=(Int_t)(phi1/(2.*TMath::Pi()/20.));
951  Double_t phi2=TMath::ATan2(xyz2[1],xyz2[0]);
952  if(phi2<0) phi2+=2*TMath::Pi();
953  Int_t lad2=(Int_t)(phi2/(2.*TMath::Pi()/40.));
954  Int_t mod1=(Int_t)((xyz1[2]+14)/7.);
955  Int_t mod2=(Int_t)((xyz2[2]+14)/7.);
956  Bool_t lay1ok=kFALSE;
957  if(mod1>=0 && mod1<4 && lad1<20){
958  lay1ok=deadSPDLay1PbPb2011[lad1][mod1];
959  }
960  Bool_t lay2ok=kFALSE;
961  if(mod2>=0 && mod2<4 && lad2<40){
962  lay2ok=deadSPDLay2PbPb2011[lad2][mod2];
963  }
964  if(!lay1ok && !lay2ok) return kFALSE;
965  }
966 
968  // Cut tracks crossing the SPD at 5.6<phi<2pi
969  Double_t xyz1[3],xyz2[3];
970  esdTrack.GetXYZAt(3.9,0.,xyz1);
971  esdTrack.GetXYZAt(7.6,0.,xyz2);
972  Double_t phi1=TMath::ATan2(xyz1[1],xyz1[0]);
973  if(phi1<0) phi1+=2*TMath::Pi();
974  Double_t phi2=TMath::ATan2(xyz2[1],xyz2[0]);
975  if(phi2<0) phi2+=2*TMath::Pi();
976  Bool_t lay1ok=kTRUE;
977  if(phi1>5.6 && phi1<2.*TMath::Pi()) lay1ok=kFALSE;
978  Bool_t lay2ok=kTRUE;
979  if(phi2>5.6 && phi2<2.*TMath::Pi()) lay2ok=kFALSE;
980  if(!lay1ok || !lay2ok) return kFALSE;
981  }
982 
983  return kTRUE;
984 }
985 //---------------------------------------------------------------------------
986 void AliRDHFCuts::SetPtBins(Int_t nPtBinLimits,Float_t *ptBinLimits) {
987  // Set the pt bins
988 
989  if(fPtBinLimits) {
990  delete [] fPtBinLimits;
991  fPtBinLimits = NULL;
992  printf("Changing the pt bins\n");
993  }
994 
995  if(nPtBinLimits != fnPtBins+1){
996  cout<<"Warning: ptBinLimits dimention "<<nPtBinLimits<<" != nPtBins+1 ("<<fnPtBins+1<<")\nSetting nPtBins to "<<nPtBinLimits-1<<endl;
997  SetNPtBins(nPtBinLimits-1);
998  }
999 
1000  fnPtBinLimits = nPtBinLimits;
1001  SetGlobalIndex();
1002  //cout<<"Changing also Global Index -> "<<fGlobalIndex<<endl;
1004  for(Int_t ib=0; ib<nPtBinLimits; ib++) fPtBinLimits[ib]=ptBinLimits[ib];
1005 
1006  return;
1007 }
1008 //---------------------------------------------------------------------------
1009 void AliRDHFCuts::SetVarNames(Int_t nVars,TString *varNames,Bool_t *isUpperCut){
1010  // Set the variable names
1011 
1012  if(fVarNames) {
1013  delete [] fVarNames;
1014  fVarNames = NULL;
1015  //printf("Changing the variable names\n");
1016  }
1017  if(nVars!=fnVars){
1018  printf("Wrong number of variables: it has to be %d\n",fnVars);
1019  return;
1020  }
1021  //fnVars=nVars;
1022  fVarNames = new TString[nVars];
1023  fIsUpperCut = new Bool_t[nVars];
1024  for(Int_t iv=0; iv<nVars; iv++) {
1025  fVarNames[iv] = varNames[iv];
1026  fIsUpperCut[iv] = isUpperCut[iv];
1027  }
1028 
1029  return;
1030 }
1031 //---------------------------------------------------------------------------
1033  // Set the variables to be used for cuts optimization
1034 
1035  if(fVarsForOpt) {
1036  delete [] fVarsForOpt;
1037  fVarsForOpt = NULL;
1038  //printf("Changing the variables for cut optimization\n");
1039  }
1040 
1041  if(nVars==0){
1042  printf("%d not accepted as number of variables: it has to be %d\n",nVars,fnVars);
1043  return;
1044  }
1045 
1046  fnVarsForOpt = 0;
1047  fVarsForOpt = new Bool_t[fnVars];
1048  for(Int_t iv=0; iv<fnVars; iv++) {
1049  fVarsForOpt[iv]=forOpt[iv];
1050  if(fVarsForOpt[iv]) fnVarsForOpt++;
1051  }
1052 
1053  return;
1054 }
1055 
1056 //---------------------------------------------------------------------------
1058  //
1059  // set centrality estimator
1060  //
1061  fUseCentrality=flag;
1062  if(fUseCentrality<kCentOff||fUseCentrality>=kCentInvalid) AliWarning("Centrality estimator not valid");
1063 
1064  return;
1065 }
1066 
1067 
1068 //---------------------------------------------------------------------------
1070  //
1071  // store the cuts
1072  //
1073  if(nVars!=fnVars) {
1074  printf("Wrong number of variables: it has to be %d\n",fnVars);
1075  AliFatal("exiting");
1076  }
1077  if(nPtBins!=fnPtBins) {
1078  printf("Wrong number of pt bins: it has to be %d\n",fnPtBins);
1079  AliFatal("exiting");
1080  }
1081 
1082  if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex];
1083 
1084 
1085  for(Int_t iv=0; iv<fnVars; iv++) {
1086 
1087  for(Int_t ib=0; ib<fnPtBins; ib++) {
1088 
1089  //check
1090  if(GetGlobalIndex(iv,ib)>=fGlobalIndex) {
1091  cout<<"Overflow, exit..."<<endl;
1092  return;
1093  }
1094 
1095  fCutsRD[GetGlobalIndex(iv,ib)] = cutsRD[iv][ib];
1096 
1097  }
1098  }
1099  return;
1100 }
1101 //---------------------------------------------------------------------------
1102 void AliRDHFCuts::SetCuts(Int_t glIndex,Float_t* cutsRDGlob){
1103  //
1104  // store the cuts
1105  //
1106  if(glIndex != fGlobalIndex){
1107  cout<<"Wrong array size: it has to be "<<fGlobalIndex<<endl;
1108  AliFatal("exiting");
1109  }
1110  if(!fCutsRD) fCutsRD = new Float_t[fGlobalIndex];
1111 
1112  for(Int_t iGl=0;iGl<fGlobalIndex;iGl++){
1113  fCutsRD[iGl] = cutsRDGlob[iGl];
1114  }
1115  return;
1116 }
1117 //---------------------------------------------------------------------------
1119  //
1120  // print all cuts values
1121  //
1122 
1123  printf("Minimum vtx type %d\n",fMinVtxType);
1124  printf("Minimum vtx contr %d\n",fMinVtxContr);
1125  printf("Max vtx red chi2 %f\n",fMaxVtxRedChi2);
1126  printf("Min SPD mult %d\n",fMinSPDMultiplicity);
1127  printf("Use PID %d OldPid=%d\n",(Int_t)fUsePID,fPidHF ? fPidHF->GetOldPid() : -1);
1128  printf("Remove daughters from vtx %d\n",(Int_t)fRemoveDaughtersFromPrimary);
1129  printf("Physics selection: %s\n",fUsePhysicsSelection ? "Yes" : "No");
1130  printf("Pileup rejection: %s\n",(fOptPileup > 0) ? "Yes" : "No");
1131  if(fOptPileup==1) printf(" -- Reject pileup event");
1132  if(fOptPileup==2) printf(" -- Reject tracks from pileup vtx");
1133  if(fUseCentrality>0) {
1134  TString estimator="";
1135  if(fUseCentrality==1) estimator = "V0";
1136  if(fUseCentrality==2) estimator = "Tracks";
1137  if(fUseCentrality==3) estimator = "Tracklets";
1138  if(fUseCentrality==4) estimator = "SPD clusters outer";
1139  if(fUseCentrality==5) estimator = "ZNA";
1140  if(fUseCentrality==6) estimator = "ZPA";
1141  if(fUseCentrality==7) estimator = "V0A";
1142  printf("Centrality class considered: %.1f-%.1f, estimated with %s\n",fMinCentrality,fMaxCentrality,estimator.Data());
1143  }
1144  if(fIsCandTrackSPDFirst) printf("Check for candidates with pt < %2.2f, that daughters fullfill kFirst criteria\n",fMaxPtCandTrackSPDFirst);
1145 
1146  if(fCutRatioClsOverCrossRowsTPC) printf("N TPC Clusters > %f N TPC Crossed Rows\n", fCutRatioClsOverCrossRowsTPC);
1147  if(fCutRatioSignalNOverCrossRowsTPC) printf("N TPC Points for dE/dx > %f N TPC Crossed Rows\n", fCutRatioSignalNOverCrossRowsTPC);
1148  if(f1CutMinNCrossedRowsTPCPtDep) printf("N TPC Crossed Rows pT-dependent cut: %s\n", fCutMinCrossedRowsTPCPtDep.Data());
1149 
1150  if(fVarNames){
1151  cout<<"Array of variables"<<endl;
1152  for(Int_t iv=0;iv<fnVars;iv++){
1153  cout<<fVarNames[iv]<<"\t";
1154  }
1155  cout<<endl;
1156  }
1157  if(fVarsForOpt){
1158  cout<<"Array of optimization"<<endl;
1159  for(Int_t iv=0;iv<fnVars;iv++){
1160  cout<<fVarsForOpt[iv]<<"\t";
1161  }
1162  cout<<endl;
1163  }
1164  if(fIsUpperCut){
1165  cout<<"Array of upper/lower cut"<<endl;
1166  for(Int_t iv=0;iv<fnVars;iv++){
1167  cout<<fIsUpperCut[iv]<<"\t";
1168  }
1169  cout<<endl;
1170  }
1171  if(fPtBinLimits){
1172  cout<<"Array of ptbin limits"<<endl;
1173  for(Int_t ib=0;ib<fnPtBinLimits;ib++){
1174  cout<<fPtBinLimits[ib]<<"\t";
1175  }
1176  cout<<endl;
1177  }
1178  if(fCutsRD){
1179  cout<<"Matrix of cuts"<<endl;
1180  for(Int_t iv=0;iv<fnVars;iv++){
1181  for(Int_t ib=0;ib<fnPtBins;ib++){
1182  cout<<"fCutsRD["<<iv<<"]["<<ib<<"] = "<<fCutsRD[GetGlobalIndex(iv,ib)]<<"\t";
1183  }
1184  cout<<endl;
1185  }
1186  cout<<endl;
1187  }
1188  if(fPidHF) fPidHF->PrintAll();
1189  return;
1190 }
1191 
1192 //--------------------------------------------------------------------------
1194  // print the trigger selection
1195 
1196  printf("Selected trigger classes: %s %s\n",fTriggerClass[0].Data(),fTriggerClass[1].Data());
1197 
1198  cout<<" Trigger selection pattern: ";
1199  if( fTriggerMask & AliVEvent::kAny ) cout<<" kAny ";
1200  if( fTriggerMask & AliVEvent::kAnyINT ) cout<<" kAnyINT ";
1201  if( fTriggerMask & AliVEvent::kINT7 ) cout<<" kINT7 ";
1202  if( fTriggerMask & AliVEvent::kMB ) cout<<" kMB ";
1203  if( fTriggerMask & AliVEvent::kCINT5 ) cout<<" kCINT5 ";
1204  if( fTriggerMask & AliVEvent::kCentral ) cout<<" kCentral ";
1205  if( fTriggerMask & AliVEvent::kSemiCentral ) cout<<" kSemiCentral ";
1206  if( fTriggerMask & AliVEvent::kEMCEGA ) cout<<" kEMCEGA ";
1207  if( fTriggerMask & AliVEvent::kHighMult ) cout<<" kHighMult ";
1208  if( fTriggerMask & AliVEvent::kFastOnly ) cout<<" kFastOnly ";
1209  cout << endl<< endl;
1210 
1211 }
1212 
1213 //---------------------------------------------------------------------------
1214 void AliRDHFCuts::GetCuts(Float_t**& cutsRD) const{
1215  //
1216  // get the cuts
1217  //
1218 
1219  //cout<<"Give back a "<<fnVars<<"x"<<fnPtBins<<" matrix."<<endl;
1220 
1221 
1222  Int_t iv,ib;
1223  if(!cutsRD) {
1224  //cout<<"Initialization..."<<endl;
1225  cutsRD=new Float_t*[fnVars];
1226  for(iv=0; iv<fnVars; iv++) {
1227  cutsRD[iv] = new Float_t[fnPtBins];
1228  }
1229  }
1230 
1231  for(Int_t iGlobal=0; iGlobal<fGlobalIndex; iGlobal++) {
1232  GetVarPtIndex(iGlobal,iv,ib);
1233  cutsRD[iv][ib] = fCutsRD[iGlobal];
1234  }
1235 
1236  return;
1237 }
1238 
1239 //---------------------------------------------------------------------------
1241  //
1242  // give the global index from variable and pt bin
1243  //
1244  return iPtBin*fnVars+iVar;
1245 }
1246 
1247 //---------------------------------------------------------------------------
1248 void AliRDHFCuts::GetVarPtIndex(Int_t iGlob, Int_t& iVar, Int_t& iPtBin) const {
1249  //
1250  //give the index of the variable and of the pt bin from the global index
1251  //
1252  iPtBin=(Int_t)iGlob/fnVars;
1253  iVar=iGlob%fnVars;
1254 
1255  return;
1256 }
1257 
1258 //---------------------------------------------------------------------------
1260  //
1261  //give the pt bin where the pt lies.
1262  //
1263  Int_t ptbin=-1;
1264  if(pt<fPtBinLimits[0])return ptbin;
1265  for (Int_t i=0;i<fnPtBins;i++){
1266  if(pt<fPtBinLimits[i+1]) {
1267  ptbin=i;
1268  break;
1269  }
1270  }
1271  return ptbin;
1272 }
1273 //-------------------------------------------------------------------
1275  //
1276  // Give the value of cut set for the variable iVar and the pt bin iPtBin
1277  //
1278  if(!fCutsRD){
1279  cout<<"Cuts not iniziaisez yet"<<endl;
1280  return 0;
1281  }
1282  return fCutsRD[GetGlobalIndex(iVar,iPtBin)];
1283 }
1284 
1285 //-------------------------------------------------------------------
1287 
1288  if(aodEvent->GetRunNumber()<244824)return GetCentralityOldFramework(aodEvent,estimator);
1289  Double_t cent=-999;
1290 
1291  AliMultSelection *multSelection = (AliMultSelection*)aodEvent->FindListObject(fMultSelectionObjectName);
1292  if(!multSelection){
1293  AliWarning("AliMultSelection could not be found in the aod event list of objects");
1294  return cent;
1295  }
1296 
1297  // Compare centrality with the centrality at AOD filtering and on-the-fly
1298  if( fMultSelectionObjectName.CompareTo("MultSelection")!=0 ){
1299  AliMultSelection *defaultmultSelection = (AliMultSelection*)aodEvent->FindListObject("MultSelection");
1300  if(!defaultmultSelection){
1301  AliWarning("AliMultSelection default method could not be found in the aod event list of objects");
1302  return cent;
1303  }
1304  Float_t defaultCent = defaultmultSelection->GetMultiplicityPercentile("V0M");
1305  Float_t newCent = multSelection->GetMultiplicityPercentile("V0M");
1306  if( defaultCent<20. && newCent>20.) fEvRejectionBits+=1<<kMismatchOldNewCentrality;
1307  else if (defaultCent>20. && newCent<20.) fEvRejectionBits+=1<<kMismatchOldNewCentrality;
1308  }
1309 
1310  if(estimator==kCentV0M){
1311  cent=multSelection->GetMultiplicityPercentile("V0M");
1312  }else if(estimator==kCentV0A){
1313  cent=multSelection->GetMultiplicityPercentile("V0A");
1314  }else if(estimator==kCentZNA){
1315  cent=multSelection->GetMultiplicityPercentile("ZNA");
1316  }else if(estimator==kCentCL1){
1317  cent=multSelection->GetMultiplicityPercentile("CL1");
1318  }else {
1319  AliWarning(Form("CENTRALITY ESTIMATE WITH ESTIMATEOR %d NOT YET IMPLEMENTED FOR NEW FRAMEWORK",(Int_t)estimator));
1320  return cent;
1321  }
1322  Int_t qual = multSelection->GetEvSelCode();
1323  if(qual == 199 ) cent=-999;
1324  return cent;
1325 }
1326 //-------------------------------------------------------------------
1328  //
1329  // Get centrality percentile
1330  //
1331 
1332  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)aodEvent)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
1333  if(mcArray) {fUseAOD049=kFALSE;}
1334 
1335  AliAODHeader *header=dynamic_cast<AliAODHeader*>(aodEvent->GetHeader());
1336  if(!header) AliFatal("Not a standard AOD");
1337  AliCentrality *centrality=header->GetCentralityP();
1338  Float_t cent=-999.;
1339  Bool_t isSelRun=kFALSE;
1340  Int_t selRun[5]={138364, 138826, 138828, 138836, 138871};
1341  if(!centrality) return cent;
1342  else{
1343  if (estimator==kCentV0M){
1344  cent=(Float_t)(centrality->GetCentralityPercentile("V0M"));
1345  if(cent<0){
1346  Int_t quality = centrality->GetQuality();
1347  if(quality<=1){ // fQuality==1 means rejected by zVertex cut that we apply a part and we want to keep separate (Giacomo)
1348  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0M");
1349  }else{
1350  Int_t runnum=aodEvent->GetRunNumber();
1351  for(Int_t ir=0;ir<5;ir++){
1352  if(runnum==selRun[ir]){
1353  isSelRun=kTRUE;
1354  break;
1355  }
1356  }
1357  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0M");
1358  }
1359  }
1360 
1361  //temporary fix for AOD049 outliers
1362  if(fUseAOD049&&cent>=0){
1363  Float_t v0=0;
1364  AliAODVZERO* aodV0 = aodEvent->GetVZEROData();
1365  v0+=aodV0->GetMTotV0A();
1366  v0+=aodV0->GetMTotV0C();
1367  if(cent==0&&v0<19500)return -1;//filtering issue
1368  Float_t tkl = (Float_t)(aodEvent->GetTracklets()->GetNumberOfTracklets());
1369  Float_t val= 1.30552 + 0.147931 * v0;
1370  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};
1371  if ( TMath::Abs(tkl-val) > 6.*tklSigma[(Int_t)cent] )return -1;//outlier
1372  }
1373  }
1374  else {
1375  if (estimator==kCentTRK) {
1376  cent=(Float_t)(centrality->GetCentralityPercentile("TRK"));
1377  if(cent<0){
1378  Int_t quality = centrality->GetQuality();
1379  if(quality<=1){
1380  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TRK");
1381  }else{
1382  Int_t runnum=aodEvent->GetRunNumber();
1383  for(Int_t ir=0;ir<5;ir++){
1384  if(runnum==selRun[ir]){
1385  isSelRun=kTRUE;
1386  break;
1387  }
1388  }
1389  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TRK");
1390  }
1391  }
1392  }
1393  else{
1394  if (estimator==kCentTKL){
1395  cent=(Float_t)(centrality->GetCentralityPercentile("TKL"));
1396  if(cent<0){
1397  Int_t quality = centrality->GetQuality();
1398  if(quality<=1){
1399  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TKL");
1400  }else{
1401  Int_t runnum=aodEvent->GetRunNumber();
1402  for(Int_t ir=0;ir<5;ir++){
1403  if(runnum==selRun[ir]){
1404  isSelRun=kTRUE;
1405  break;
1406  }
1407  }
1408  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("TKL");
1409  }
1410  }
1411  }
1412  else{
1413  if (estimator==kCentCL1){
1414  cent=(Float_t)(centrality->GetCentralityPercentile("CL1"));
1415  if(cent<0){
1416  Int_t quality = centrality->GetQuality();
1417  if(quality<=1){
1418  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("CL1");
1419  }else{
1420  Int_t runnum=aodEvent->GetRunNumber();
1421  for(Int_t ir=0;ir<5;ir++){
1422  if(runnum==selRun[ir]){
1423  isSelRun=kTRUE;
1424  break;
1425  }
1426  }
1427  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("CL1");
1428  }
1429  }
1430  }
1431  else{
1432  if (estimator==kCentZNA){
1433  cent=(Float_t)(centrality->GetCentralityPercentile("ZNA"));
1434  if(cent<0){
1435  Int_t quality = centrality->GetQuality();
1436  if(quality<=1){
1437  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZNA");
1438  }else{
1439  Int_t runnum=aodEvent->GetRunNumber();
1440  for(Int_t ir=0;ir<5;ir++){
1441  if(runnum==selRun[ir]){
1442  isSelRun=kTRUE;
1443  break;
1444  }
1445  }
1446  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZNA");
1447  }
1448  }
1449  }
1450  else{
1451  if (estimator==kCentZPA){
1452  cent=(Float_t)(centrality->GetCentralityPercentile("ZPA"));
1453  if(cent<0){
1454  Int_t quality = centrality->GetQuality();
1455  if(quality<=1){
1456  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZPA");
1457  }else{
1458  Int_t runnum=aodEvent->GetRunNumber();
1459  for(Int_t ir=0;ir<5;ir++){
1460  if(runnum==selRun[ir]){
1461  isSelRun=kTRUE;
1462  break;
1463  }
1464  }
1465  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("ZPA");
1466  }
1467  }
1468  }
1469  else{
1470  if (estimator==kCentV0A){
1471  cent=(Float_t)(centrality->GetCentralityPercentile("V0A"));
1472  if(cent<0){
1473  Int_t quality = centrality->GetQuality();
1474  if(quality<=1){
1475  cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0A");
1476  }else{
1477  Int_t runnum=aodEvent->GetRunNumber();
1478  for(Int_t ir=0;ir<5;ir++){
1479  if(runnum==selRun[ir]){
1480  isSelRun=kTRUE;
1481  break;
1482  }
1483  }
1484  if((quality==8||quality==9)&&isSelRun)cent=(Float_t)centrality->GetCentralityPercentileUnchecked("V0A");
1485  }
1486  }
1487  }
1488  else {
1489  AliWarning("Centrality estimator not valid");
1490 
1491  }
1492  }
1493  }
1494  }
1495  }
1496  }
1497  }
1498  }
1499  return cent;
1500 }
1501 //-------------------------------------------------------------------
1503  //
1504  // Compare two cuts objects
1505  //
1506 
1507  Bool_t areEqual=kTRUE;
1508 
1509  if(fMinVtxType!=obj->fMinVtxType) { printf("Minimum vtx type %d %d\n",fMinVtxType,obj->fMinVtxType); areEqual=kFALSE;}
1510 
1511  if(fMinVtxContr!=obj->fMinVtxContr) { printf("Minimum vtx contr %d %d\n",fMinVtxContr,obj->fMinVtxContr); areEqual=kFALSE;}
1512 
1513  if(TMath::Abs(fMaxVtxRedChi2-obj->fMaxVtxRedChi2)>1.e-10) { printf("Max vtx red chi2 %f %f\n",fMaxVtxRedChi2,obj->fMaxVtxRedChi2);areEqual=kFALSE;}
1514 
1515  if(fMinSPDMultiplicity!=obj->fMinSPDMultiplicity) { printf("Min SPD mult %d\n %d",fMinSPDMultiplicity,obj->fMinSPDMultiplicity);areEqual=kFALSE;}
1516 
1517  if(fUsePID!=obj->fUsePID) { printf("Use PID %d %d\n",(Int_t)fUsePID,(Int_t)obj->fUsePID); areEqual=kFALSE;}
1518 
1519  if(fRemoveDaughtersFromPrimary!=obj->fRemoveDaughtersFromPrimary) {printf("Remove daughters from vtx %d %d\n",(Int_t)fRemoveDaughtersFromPrimary,(Int_t)obj->fRemoveDaughtersFromPrimary); areEqual=kFALSE;}
1520  if(fTrackCuts){
1521  if(fTrackCuts->GetMinNClusterTPC()!=obj->fTrackCuts->GetMinNClusterTPC()) {printf("MinNClsTPC %d %d\n",fTrackCuts->GetMinNClusterTPC(),obj->fTrackCuts->GetMinNClusterTPC()); areEqual=kFALSE;}
1522 
1523  if(fTrackCuts->GetMinNClustersITS()!=obj->fTrackCuts->GetMinNClustersITS()) {printf("MinNClsITS %d %d\n",fTrackCuts->GetMinNClustersITS(),obj->fTrackCuts->GetMinNClustersITS()); areEqual=kFALSE;}
1524 
1525  if(TMath::Abs(fTrackCuts->GetMaxChi2PerClusterTPC()-obj->fTrackCuts->GetMaxChi2PerClusterTPC())>1.e-10) {printf("MaxChi2ClsTPC %f %f\n",fTrackCuts->GetMaxChi2PerClusterTPC(),obj->fTrackCuts->GetMaxChi2PerClusterTPC()); areEqual=kFALSE;}
1526 
1527  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;}
1528  }
1529 
1530  if(fCutsRD) {
1531  for(Int_t iv=0;iv<fnVars;iv++) {
1532  for(Int_t ib=0;ib<fnPtBins;ib++) {
1533  if(TMath::Abs(fCutsRD[GetGlobalIndex(iv,ib)]-obj->fCutsRD[GetGlobalIndex(iv,ib)])>1.e-10) {
1534  cout<<"fCutsRD["<<iv<<"]["<<ib<<"] = "<<fCutsRD[GetGlobalIndex(iv,ib)]<<" "<<obj->fCutsRD[GetGlobalIndex(iv,ib)]<<"\n";
1535  areEqual=kFALSE;
1536  }
1537  }
1538  }
1539  }
1540 
1541  return areEqual;
1542 }
1543 //---------------------------------------------------------------------------
1545  //
1546  // print cuts values in table format
1547  //
1548 
1549  TString ptString = "pT range";
1550  if(fVarNames && fPtBinLimits && fCutsRD){
1551  TString firstLine(Form("* %-15s",ptString.Data()));
1552  for (Int_t ivar=0; ivar<fnVars; ivar++){
1553  firstLine+=Form("* %-15s ",fVarNames[ivar].Data());
1554  if (ivar == fnVars){
1555  firstLine+="*\n";
1556  }
1557  }
1558  Printf("%s",firstLine.Data());
1559 
1560  for (Int_t ipt=0; ipt<fnPtBins; ipt++){
1561  TString line;
1562  if (ipt==fnPtBins-1){
1563  line=Form("* %5.1f < pt < inf ",fPtBinLimits[ipt]);
1564  }
1565  else{
1566  line=Form("* %5.1f < pt < %4.1f ",fPtBinLimits[ipt],fPtBinLimits[ipt+1]);
1567  }
1568  for (Int_t ivar=0; ivar<fnVars; ivar++){
1569  line+=Form("* %-15f ",fCutsRD[GetGlobalIndex(ivar,ipt)]);
1570  }
1571  Printf("%s",line.Data());
1572  }
1573 
1574  }
1575 
1576 
1577  return;
1578 }
1579 //--------------------------------------------------------------------------
1581  AliAODEvent *aod) const
1582 {
1583  //
1584  // Recalculate primary vertex without daughters
1585  //
1586 
1587  if(!aod) {
1588  AliError("Can not remove daughters from vertex without AOD event");
1589  return 0;
1590  }
1591 
1592  AliAODVertex *recvtx=d->RemoveDaughtersFromPrimaryVtx(aod);
1593  if(!recvtx){
1594  AliDebug(2,"Removal of daughter tracks failed");
1595  return kFALSE;
1596  }
1597 
1598 
1599  //set recalculed primary vertex
1600  d->SetOwnPrimaryVtx(recvtx);
1601  delete recvtx;
1602 
1603  return kTRUE;
1604 }
1605 //--------------------------------------------------------------------------
1607 {
1608  //
1609  // Recalculate primary vertex without daughters
1610  //
1611 
1612  if(!aod) {
1613  AliError("Can not get MC vertex without AOD event");
1614  return kFALSE;
1615  }
1616 
1617  // load MC header
1618  AliAODMCHeader *mcHeader =
1619  (AliAODMCHeader*)aod->GetList()->FindObject(AliAODMCHeader::StdBranchName());
1620  if(!mcHeader) {
1621  AliError("Can not get MC vertex without AODMCHeader event");
1622  return kFALSE;
1623  }
1624  Double_t pos[3];
1625  Double_t covmatrix[6]={0.,0.,0.,0.,0.,0.};
1626  mcHeader->GetVertex(pos);
1627  AliAODVertex *recvtx=new AliAODVertex(pos,covmatrix);
1628 
1629  if(!recvtx){
1630  AliDebug(2,"Removal of daughter tracks failed");
1631  return kFALSE;
1632  }
1633 
1634  //set recalculed primary vertex
1635  d->SetOwnPrimaryVtx(recvtx);
1636 
1637  d->RecalculateImpPars(recvtx,aod);
1638 
1639  delete recvtx;
1640 
1641  return kTRUE;
1642 }
1643 //--------------------------------------------------------------------------
1645  AliAODEvent *aod,
1646  AliAODVertex *origownvtx) const
1647 {
1648  //
1649  // Clean-up own primary vertex if needed
1650  //
1651 
1653  d->UnsetOwnPrimaryVtx();
1654  if(origownvtx) {
1655  d->SetOwnPrimaryVtx(origownvtx);
1656  delete origownvtx; origownvtx=NULL;
1657  }
1658  d->RecalculateImpPars(d->GetPrimaryVtx(),aod);
1659  } else {
1660  if(origownvtx) {
1661  delete origownvtx; origownvtx=NULL;
1662  }
1663  }
1664  return;
1665 }
1666 //--------------------------------------------------------------------------
1667 Bool_t AliRDHFCuts::IsSignalMC(AliAODRecoDecay *d,AliAODEvent *aod,Int_t pdg) const
1668 {
1669  //
1670  // Checks if this candidate is matched to MC signal
1671  //
1672 
1673  if(!aod) return kFALSE;
1674 
1675  // get the MC array
1676  TClonesArray *mcArray = (TClonesArray*)((AliAODEvent*)aod)->GetList()->FindObject(AliAODMCParticle::StdBranchName());
1677 
1678  if(!mcArray) return kFALSE;
1679 
1680  // try to match
1681  Int_t label = d->MatchToMC(pdg,mcArray);
1682 
1683  if(label>=0) {
1684  //printf("MATCH!\n");
1685  return kTRUE;
1686  }
1687 
1688  return kFALSE;
1689 }
1690 
1691 
1692 //--------------------------------------------------------------------------
1694  // recompute event primary vertex from AOD tracks
1695 
1696  AliVertexerTracks *vertexer = new AliVertexerTracks(event->GetMagneticField());
1697  vertexer->SetITSMode();
1698  vertexer->SetMinClusters(3);
1699 
1700  AliAODVertex* pvtx=event->GetPrimaryVertex();
1701  if(strstr(pvtx->GetTitle(),"VertexerTracksWithConstraint")) {
1702  Float_t diamondcovxy[3];
1703  event->GetDiamondCovXY(diamondcovxy);
1704  Double_t pos[3]={event->GetDiamondX(),event->GetDiamondY(),0.};
1705  Double_t cov[6]={diamondcovxy[0],diamondcovxy[1],diamondcovxy[2],0.,0.,10.*10.};
1706  AliESDVertex *diamond = new AliESDVertex(pos,cov,1.,1);
1707  vertexer->SetVtxStart(diamond);
1708  delete diamond; diamond=NULL;
1709  }
1710 
1711  AliESDVertex* vertexESD = (AliESDVertex*)vertexer->FindPrimaryVertex(event);
1712  if(!vertexESD) return kFALSE;
1713  if(vertexESD->GetNContributors()<=0) {
1714  //AliDebug(2,"vertexing failed");
1715  delete vertexESD; vertexESD=NULL;
1716  return kFALSE;
1717  }
1718  delete vertexer; vertexer=NULL;
1719 
1720  // convert to AliAODVertex
1721  Double_t pos[3],cov[6],chi2perNDF;
1722  vertexESD->GetXYZ(pos); // position
1723  vertexESD->GetCovMatrix(cov); //covariance matrix
1724  chi2perNDF = vertexESD->GetChi2toNDF();
1725  delete vertexESD; vertexESD=NULL;
1726 
1727  pvtx->SetPosition(pos[0],pos[1],pos[2]);
1728  pvtx->SetChi2perNDF(chi2perNDF);
1729  pvtx->SetCovMatrix(cov);
1730 
1731  return kTRUE;
1732 }
void SetNPtBins(Int_t nptBins)
Definition: AliRDHFCuts.h:379
Int_t fIsSelectedCuts
fix the daughter track references
Definition: AliRDHFCuts.h:428
Int_t pdg
Bool_t IsEventSelectedForCentrFlattening(Float_t centvalue)
Float_t fMinDzPileup
min. n. of tracklets in pileup vertex
Definition: AliRDHFCuts.h:417
Double_t fMaxPtCandTrackSPDFirst
flag to select the track kFirst criteria for pt < ptlimit
Definition: AliRDHFCuts.h:435
Int_t fWhyRejection
PID for heavy flavours manager.
Definition: AliRDHFCuts.h:410
double Double_t
Definition: External.C:58
Int_t fCutOnzVertexSPD
flag to apply cut on tracklets vs. centrality for 2011 data
Definition: AliRDHFCuts.h:440
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:453
Bool_t fUseMCVertex
flag to switch on the removal of duaghters from the primary vertex computation
Definition: AliRDHFCuts.h:413
Bool_t fUseOnlyOneTrigger
trigger mask
Definition: AliRDHFCuts.h:392
Int_t IsEventSelectedInCentrality(AliVEvent *event)
Bool_t * fIsUpperCut
Definition: AliRDHFCuts.h:406
Bool_t SetMCPrimaryVtx(AliAODRecoDecayHF *d, AliAODEvent *aod) const
Bool_t fRemoveDaughtersFromPrimary
Definition: AliRDHFCuts.h:412
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:418
void SetUseCentrality(Int_t flag=1)
Float_t * fPtBinLimits
"number of limits", that is fnPtBins+1
Definition: AliRDHFCuts.h:399
Int_t fMinVtxContr
0: not cut; 1: SPDZ; 2: SPD3D; 3: Tracks
Definition: AliRDHFCuts.h:387
centrality
char Char_t
Definition: External.C:18
static Int_t CheckMatchingAODdeltaAODevents()
Float_t fMaxVtxRedChi2
minimum vertex contributors
Definition: AliRDHFCuts.h:388
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:445
Double_t fDeadZoneWidth
flag for enabling/disabling geometrical cut on TPC track
Definition: AliRDHFCuts.h:450
Int_t fMinVtxType
cuts on the event
Definition: AliRDHFCuts.h:386
void SetppLowEn2011(Bool_t opt)
Definition: AliAODPidHF.h:104
Double_t fMaxRapidityCand
minimum pt of the candidate
Definition: AliRDHFCuts.h:432
Double_t fCutGeoNcrNclFractionNcl
4th parameter of GeoNcrNcl cut
Definition: AliRDHFCuts.h:454
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:419
Bool_t fUsePID
Definition: AliRDHFCuts.h:407
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:439
Bool_t fUseV0ANDSelectionOffline
5th parameter of GeoNcrNcl cut
Definition: AliRDHFCuts.h:455
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:391
Bool_t fUseCutGeoNcrNcl
pT-dep cut in TPC minimum n crossed rows
Definition: AliRDHFCuts.h:449
int Int_t
Definition: External.C:63
Bool_t fUseTrackSelectionWithFilterBits
flag to reject kink daughters
Definition: AliRDHFCuts.h:442
void SetCuts(Int_t nVars, Int_t nPtBins, Float_t **cutsRD)
Int_t fnVarsForOpt
Definition: AliRDHFCuts.h:402
Double_t fCutGeoNcrNclLength
1st parameter of GeoNcrNcl cut
Definition: AliRDHFCuts.h:451
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:401
Double_t fMaxPtCand
minimum pt of the candidate
Definition: AliRDHFCuts.h:431
AliESDtrackCuts * fTrackCuts
quality cuts on the daughter tracks
Definition: AliRDHFCuts.h:395
void MakeTable() const
Bool_t fFixRefs
name of the AliMultSelection object to be considered
Definition: AliRDHFCuts.h:427
Bool_t fKeepSignalMC
max rapidity of candidate (if !=-999 overrides IsInFiducialAcceptance)
Definition: AliRDHFCuts.h:433
Int_t fOptPileup
use Physics selection criteria
Definition: AliRDHFCuts.h:415
AliESDtrackCuts * GetTrackCuts() const
Definition: AliRDHFCuts.h:252
void PrintTrigger() const
Float_t fMaxVtxZ
maximum chi2/ndf
Definition: AliRDHFCuts.h:389
Float_t GetCentrality(AliAODEvent *aodEvent)
Definition: AliRDHFCuts.h:248
Int_t fIsSelectedPID
outcome of cuts selection
Definition: AliRDHFCuts.h:429
Float_t fMinCentrality
Definition: AliRDHFCuts.h:424
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:411
Double_t fMaxDiffTRKV0Centr
flag to apply cut on tracks crossing SPD misaligned modules for PP2012 data
Definition: AliRDHFCuts.h:438
Float_t GetCentralityOldFramework(AliAODEvent *aodEvent, AliRDHFCuts::ECentrality estimator)
Int_t fnPtBinLimits
number of pt bins for cuts
Definition: AliRDHFCuts.h:398
Float_t * fCutsRD
fnVars*fnPtBins
Definition: AliRDHFCuts.h:405
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:443
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:403
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:437
Bool_t IsEventSelected(AliVEvent *event)
Int_t fMinSPDMultiplicity
maximum |z| of primary vertex
Definition: AliRDHFCuts.h:390
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:408
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
Bool_t fApplySPDDeadPbPb2011
maximum pt of the candidate for which to check if the daughters fulfill kFirst criteria ...
Definition: AliRDHFCuts.h:436
void CleanOwnPrimaryVtx(AliAODRecoDecayHF *d, AliAODEvent *aod, AliAODVertex *origownvtx) const
Bool_t fIsCandTrackSPDFirst
IsSelected returns always kTRUE for MC signal.
Definition: AliRDHFCuts.h:434
TH1F * fHistCentrDistr
flag for enabling/diabling centrality flattening in MC
Definition: AliRDHFCuts.h:444
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:441
TString fMultSelectionObjectName
maximum centrality for selected events
Definition: AliRDHFCuts.h:426
Int_t fMinContrPileup
option for pielup selection
Definition: AliRDHFCuts.h:416
Bool_t fUsePhysicsSelection
use MC primary vertex
Definition: AliRDHFCuts.h:414
TFormula * f1CutMinNCrossedRowsTPCPtDep
pT-dep cut in TPC minimum n crossed rows
Definition: AliRDHFCuts.h:448
AliAODVertex * GetPrimaryVtx() const
void AddTrackCuts(const AliESDtrackCuts *cuts)
Definition: AliRDHFCuts.h:204
TString fTriggerClass[2]
flag to select one trigger only
Definition: AliRDHFCuts.h:393
bool Bool_t
Definition: External.C:53
Int_t fnPtBins
cuts on the candidate
Definition: AliRDHFCuts.h:397
Double_t fCutGeoNcrNclGeom1Pt
2nd parameter of GeoNcrNcl cut
Definition: AliRDHFCuts.h:452
AliAODPidHF * fPidHF
enable AOD049 centrality cleanup
Definition: AliRDHFCuts.h:409
Float_t fCutRatioSignalNOverCrossRowsTPC
min. value ratio NTPCClusters/NTPCCrossedRows, cut if !=0
Definition: AliRDHFCuts.h:446
Int_t fGlobalIndex
Definition: AliRDHFCuts.h:404
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:447
Double_t fMinPtCand
outcome of PID selection
Definition: AliRDHFCuts.h:430
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:425
void SetPidResponse(AliPIDResponse *pidResp)
Definition: AliAODPidHF.h:111
Bool_t RecomputePrimaryVertex(AliAODEvent *event) const
Int_t fnVars
Definition: AliRDHFCuts.h:400