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