AliPhysics  a6017e1 (a6017e1)
AliConvEventCuts.cxx
Go to the documentation of this file.
1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Authors: Friederike Bock, Daniel Muehlheim *
5 * Version 1.0 *
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 
17 //---------------------------------------------
18 // Class handling all kinds of selection cuts for
19 // Gamma Conversion analysis
20 //---------------------------------------------
22 
23 #include "AliConvEventCuts.h"
24 
25 #include "AliAODTrack.h"
26 #include "AliESDtrack.h"
27 #include "AliAnalysisManager.h"
28 #include "AliInputEventHandler.h"
29 #include "AliMCEventHandler.h"
30 #include "AliAODHandler.h"
31 #include "TH1.h"
32 #include "TH2.h"
33 #include "TF1.h"
34 #include "TObjString.h"
35 #include "AliMCEvent.h"
36 #include "AliAODEvent.h"
37 #include "AliESDEvent.h"
38 #include "AliCentrality.h"
39 #include "AliMultSelection.h"
40 #include "TList.h"
41 #include "TFile.h"
42 #include "AliLog.h"
43 #include "AliGenCocktailEventHeader.h"
44 #include "AliGenDPMjetEventHeader.h"
45 #include "AliGenPythiaEventHeader.h"
46 #include "AliGenHijingEventHeader.h"
47 #include "AliTriggerAnalysis.h"
48 #include "AliV0ReaderV1.h"
49 #include "AliVCaloCells.h"
50 #include "AliAODMCParticle.h"
51 #include "AliAODMCHeader.h"
52 #include "AliEMCALTriggerPatchInfo.h"
53 
54 class iostream;
55 
56 using namespace std;
57 
59 ClassImp(AliConvEventCuts)
61 
62 
63 const char* AliConvEventCuts::fgkCutNames[AliConvEventCuts::kNCuts] = {
64  "HeavyIon", //0
65  "CentralityMin", //1
66  "CentralityMax", //2
67  "SelectSpecialTrigger", //3
68  "SelectSpecialSubTriggerClass", //4
69  "RemovePileUp", //5
70  "RejectExtraSignals", //6
71  "VertexCut", //7
72 };
73 
74 
75 //________________________________________________________________________
76 AliConvEventCuts::AliConvEventCuts(const char *name,const char *title) :
77  AliAnalysisCuts(name,title),
78  fHistograms(NULL),
79  fHeaderList(NULL),
80  fDoLightOutput(kFALSE),
81  fEventQuality(-1),
82  fIsHeavyIon(0),
83  fDetectorCentrality(0),
84  fModCentralityClass(0),
85  fEnableVertexCut(kTRUE),
86  fMaxVertexZ(10),
87  fCentralityMin(0),
88  fCentralityMax(0),
89  fMultiplicityMethod(0),
90  fSpecialTrigger(0),
91  fSpecialSubTrigger(0),
92  fRemovePileUp(kFALSE),
93  fRemovePileUpSPD(kFALSE),
94  fUseSphericity(0),
95  fPastFutureRejectionLow(0),
96  fPastFutureRejectionHigh(0),
97  fDoPileUpRejectV0MTPCout(0),
98  fFPileUpRejectV0MTPCout(0),
99  fRejectExtraSignals(0),
100  fOfflineTriggerMask(0),
101  fHasV0AND(kTRUE),
102  fIsSDDFired(kTRUE),
103  fRandom(0),
104  fnHeaders(0),
105  fNotRejectedStart(NULL),
106  fNotRejectedEnd(NULL),
107  fGeneratorNames(NULL),
108  fPeriodEnum(kNoPeriod),
109  fEnergyEnum(kUnset),
110  fCutString(NULL),
111  fCutStringRead(""),
112  fUtils(NULL),
113  fEtaShift(0.0),
114  fDoEtaShift(kFALSE),
115  fDoCentralityFlat(0),
116  fPathWeightsFlatCent(""),
117  fNameHistoNotFlatCentrality(""),
118  fDoReweightHistoMCPi0(kFALSE),
119  fDoReweightHistoMCEta(kFALSE),
120  fDoReweightHistoMCK0s(kFALSE),
121  fPathTrFReweighting(""),
122  fNameHistoReweightingPi0(""),
123  fNameHistoReweightingEta(""),
124  fNameHistoReweightingK0s(""),
125  fNameFitDataPi0(""),
126  fNameFitDataEta(""),
127  fNameFitDataK0s(""),
128  fHistoEventCuts(NULL),
129  fHistoPastFutureBits(NULL),
130  hCentrality(NULL),
131  hCentralityNotFlat(NULL),
132  //hCentralityVsNumberOfPrimaryTracks(NULL),
133  hVertexZ(NULL),
134  hNPileupVertices(NULL),
135  hPileupVertexToPrimZ(NULL),
136  hPileupVertexToPrimZSPDPileup(NULL),
137  hPileupVertexToPrimZTrackletvsHits(NULL),
138  hEventPlaneAngle(NULL),
139  fEventPlaneAngle(0),
140  hTriggerClass(NULL),
141  hTriggerClassSelected(NULL),
142  hTriggerClassesCorrelated(NULL),
143  hReweightMCHistPi0(NULL),
144  hReweightMCHistEta(NULL),
145  hReweightMCHistK0s(NULL),
146  fFitDataPi0(NULL),
147  fFitDataEta(NULL),
148  fFitDataK0s(NULL),
149  fAddedSignalPDGCode(0),
150  fPreSelCut(kFALSE),
151  fTriggerSelectedManually(kFALSE),
152  fSpecialTriggerName(""),
153  fSpecialSubTriggerName(""),
154  fNSpecialSubTriggerOptions(0),
155  hSPDClusterTrackletBackgroundBefore(NULL),
156  hSPDClusterTrackletBackground(NULL),
157  fV0ReaderName(""),
158  fCorrTaskSetting(""),
159  fCaloTriggers(NULL),
160  fTriggerPatchInfo(NULL),
161  fMainTriggerPatchEMCAL(NULL),
162  fCaloTriggersName(""),
163  fCaloTriggerPatchInfoName(""),
164  fTriggersEMCAL(0),
165  fTriggersEMCALSelected(-1),
166  fEMCALTrigInitialized(kFALSE),
167  fSecProdBoundary(1.0),
168  fMaxPtJetMC(0),
169  fMaxFacPtHard(2.5),
170  fMaxFacPtHardSingleParticle(1.5),
171  fMimicTrigger(kFALSE),
172  fRejectTriggerOverlap(kFALSE),
173  fDoMultiplicityWeighting(kFALSE),
174  fPathReweightingMult(""),
175  fNameHistoReweightingMultData(""),
176  fNameHistoReweightingMultMC(""),
177  hReweightMultData(NULL),
178  hReweightMultMC(NULL),
179  fDebugLevel(0)
180 {
181  for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=0;}
182  fCutString=new TObjString((GetCutNumber()).Data());
183 
184  fUtils = new AliAnalysisUtils();
185  //if you do not want to apply the cut on the distance between the SPD and TRK vertex:
186  //fUtils->SetCutOnZVertexSPD(kFALSE);
187 
188 
189 }
190 
191 //________________________________________________________________________
193  AliAnalysisCuts(ref),
194  fHistograms(NULL),
217  fHasV0AND(ref.fHasV0AND),
219  fRandom(ref.fRandom),
220  fnHeaders(ref.fnHeaders),
221  fNotRejectedStart(NULL),
222  fNotRejectedEnd(NULL),
226  fCutString(NULL),
227  fCutStringRead(""),
228  fUtils(NULL),
229  fEtaShift(ref.fEtaShift),
244  fHistoEventCuts(NULL),
245  fHistoPastFutureBits(NULL),
248  //hCentralityVsNumberOfPrimaryTracks(ref.hCentralityVsNumberOfPrimaryTracks),
249  hVertexZ(ref.hVertexZ),
256  hTriggerClass(NULL),
257  hTriggerClassSelected(NULL),
266  fPreSelCut(ref.fPreSelCut),
275  fCaloTriggers(NULL),
276  fTriggerPatchInfo(NULL),
282  fEMCALTrigInitialized(kFALSE),
296 {
297  // Copy Constructor
298  for(Int_t jj=0;jj<kNCuts;jj++){fCuts[jj]=ref.fCuts[jj];}
299  fCutString=new TObjString((GetCutNumber()).Data());
300  fUtils = new AliAnalysisUtils();
301  // dont copy histograms (if you like histograms, call InitCutHistograms())
302 
303 }
304 
305 
306 //________________________________________________________________________
308  // Destructor
309  //Deleting fHistograms leads to seg fault it it's added to output collection of a task
310  // if(fHistograms)
311  // delete fHistograms;
312  // fHistograms = NULL;
313  if(fCutString != NULL){
314  delete fCutString;
315  fCutString = NULL;
316  }
317  if(fNotRejectedStart){
318  delete[] fNotRejectedStart;
319  fNotRejectedStart = NULL;
320  }
321  if(fNotRejectedEnd){
322  delete[] fNotRejectedEnd;
323  fNotRejectedEnd = NULL;
324  }
325  if(fGeneratorNames){
326  delete[] fGeneratorNames;
327  fGeneratorNames = NULL;
328  }
329  if(fUtils){
330  delete fUtils;
331  fUtils = NULL;
332  }
333 
334 }
335 
336 //________________________________________________________________________
338 
339  // Initialize Cut Histograms for QA (only initialized and filled if function is called)
340  TH1::AddDirectory(kFALSE);
341 
342  if(fHistograms != NULL){
343  delete fHistograms;
344  fHistograms=NULL;
345  }
346  if(fHistograms==NULL){
347  fHistograms=new TList();
348  fHistograms->SetOwner(kTRUE);
349  if(name=="")fHistograms->SetName(Form("ConvEventCuts_%s",GetCutNumber().Data()));
350  else fHistograms->SetName(Form("%s_%s",name.Data(),GetCutNumber().Data()));
351  }
352 
353  if (hReweightMCHistPi0){
354  hReweightMCHistPi0->SetName("MCInputForWeightingPi0");
356  }
357  if (hReweightMCHistEta){
358  hReweightMCHistEta->SetName("MCInputForWeightingEta");
360  }
361  if (hReweightMCHistK0s){
362  hReweightMCHistK0s->SetName("MCInputForWeightingK0s");
364  }
365 
366  if (hReweightMultData){
367  hReweightMultData->SetName(Form("hReweightMultData_%s",GetCutNumber().Data()));
369  }
370  if (hReweightMultMC){
371  hReweightMultMC->SetName(Form("hReweightMultMC_%s",GetCutNumber().Data()));
373  }
374 
375  if(!fDoLightOutput){
376  if (fIsHeavyIon == 1){
377  hSPDClusterTrackletBackgroundBefore = new TH2F(Form("SPD tracklets vs SPD clusters %s before Pileup Cut",GetCutNumber().Data()),"SPD tracklets vs SPD clusters", 200, 0, 6000, 200, 0, 20000);
379  hSPDClusterTrackletBackground = new TH2F(Form("SPD tracklets vs SPD clusters %s",GetCutNumber().Data()),"SPD tracklets vs SPD clusters", 200, 0, 6000, 200, 0, 20000);
381  } else{
382  hSPDClusterTrackletBackgroundBefore = new TH2F(Form("SPD tracklets vs SPD clusters %s before Pileup Cut",GetCutNumber().Data()),"SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
384  hSPDClusterTrackletBackground = new TH2F(Form("SPD tracklets vs SPD clusters %s",GetCutNumber().Data()),"SPD tracklets vs SPD clusters",100,0,200,250,0,1000);
386  }
387  }
388 
389  if(fIsHeavyIon > 0){
390  hCentrality=new TH1F(Form("Centrality %s",GetCutNumber().Data()),"Centrality",420,0,105);
391  fHistograms->Add(hCentrality);
392  }
393 
394  //hCentralityVsNumberOfPrimaryTracks=new TH2F(Form("Centrality vs Primary Tracks %s",GetCutNumber().Data()),"Centrality vs Primary Tracks ",400,0,100,4000,0,4000);
395  //fHistograms->Add(hCentralityVsNumberOfPrimaryTracks); commented on 3.3.2015 because it's in the main Task
396 
397  hVertexZ = new TH1F(Form("VertexZ %s",GetCutNumber().Data()),"VertexZ",1000,-50,50);
398  fHistograms->Add(hVertexZ);
399 
400  hNPileupVertices = new TH1F(Form("NPileupVertices %s",GetCutNumber().Data()),"NPileupVertices",30,-0.5,29.5);
402 
403  hPileupVertexToPrimZ = new TH1F(Form("PileupVertexDistance %s",GetCutNumber().Data()),"PileupVertexDistance",600,-15,15);
405  hPileupVertexToPrimZSPDPileup = new TH1F(Form("PileupVertexDistance_SPDPileup %s",GetCutNumber().Data()),"PileupVertexDistance_SPDPileup",600,-15,15);
407  hPileupVertexToPrimZTrackletvsHits = new TH1F(Form("PileupVertexDistance_TrackletvsHits %s",GetCutNumber().Data()),"PileupVertexDistance_TrackletvsHits",600,-15,15);
409 
410  if(fIsHeavyIon == 1){
411  hEventPlaneAngle = new TH1F(Form("EventPlaneAngle %s",GetCutNumber().Data()),"EventPlaneAngle",60, 0, TMath::Pi());
413  }
414  fHistoPastFutureBits=new TH1F(Form("PastFutureBits %s",GetCutNumber().Data()),"Past Future Bits",180,-90*25,90*25);
416 
417  // Event Cuts and Info
418  if(preCut){
419  fHistoEventCuts=new TH1F(Form("ESD_EventCuts %s",GetCutNumber().Data()),"Event Cuts",8,-0.5,7.5);
420  fHistoEventCuts->GetXaxis()->SetBinLabel(1,"in");
421  fHistoEventCuts->GetXaxis()->SetBinLabel(2,"OfflineTrigger");
422  fHistoEventCuts->GetXaxis()->SetBinLabel(3,"nvtxcontr");
423  fHistoEventCuts->GetXaxis()->SetBinLabel(4,"VertexZ");
424  fHistoEventCuts->GetXaxis()->SetBinLabel(5,"pileup");
425  fHistoEventCuts->GetXaxis()->SetBinLabel(6,"centrsel");
426  fHistoEventCuts->GetXaxis()->SetBinLabel(7,"OOB-pileup");
427  fHistoEventCuts->GetXaxis()->SetBinLabel(8,"out");
429 
430  hTriggerClass= new TH1F(Form("OfflineTrigger %s",GetCutNumber().Data()),"OfflineTrigger",37,-0.5,36.5);
431  hTriggerClass->GetXaxis()->SetBinLabel( 1,"kMB");
432  hTriggerClass->GetXaxis()->SetBinLabel( 2,"kINT7");
433  hTriggerClass->GetXaxis()->SetBinLabel( 3,"kMUON");
434  hTriggerClass->GetXaxis()->SetBinLabel( 4,"kHighMult");
435  hTriggerClass->GetXaxis()->SetBinLabel( 5,"kEMC1");
436  hTriggerClass->GetXaxis()->SetBinLabel( 6,"kCINT5");
437  hTriggerClass->GetXaxis()->SetBinLabel( 7,"kCMUS5/kMUSPB");
438  hTriggerClass->GetXaxis()->SetBinLabel( 8,"kMUSH7/kMUSHPB");
439  hTriggerClass->GetXaxis()->SetBinLabel( 9,"kMUL7/kMuonLikePB");
440  hTriggerClass->GetXaxis()->SetBinLabel(10,"kMUU7/kMuonUnlikePB");
441  hTriggerClass->GetXaxis()->SetBinLabel(11,"kEMC7/kEMC8");
442  hTriggerClass->GetXaxis()->SetBinLabel(12,"kMUS7");
443  hTriggerClass->GetXaxis()->SetBinLabel(13,"kPHI1");
444  hTriggerClass->GetXaxis()->SetBinLabel(14,"kPHI7/kPHI8/kPHOSPb");
445  hTriggerClass->GetXaxis()->SetBinLabel(15,"kEMCEJE");
446  hTriggerClass->GetXaxis()->SetBinLabel(16,"kEMCEGA");
447  hTriggerClass->GetXaxis()->SetBinLabel(17,"kCentral");
448  hTriggerClass->GetXaxis()->SetBinLabel(18,"kSemiCentral");
449  hTriggerClass->GetXaxis()->SetBinLabel(19,"kDG5");
450  hTriggerClass->GetXaxis()->SetBinLabel(20,"kZED");
451  hTriggerClass->GetXaxis()->SetBinLabel(21,"kSPI7/kSPI");
452  hTriggerClass->GetXaxis()->SetBinLabel(22,"kINT8");
453  hTriggerClass->GetXaxis()->SetBinLabel(23,"kMuonSingleLowPt8");
454  hTriggerClass->GetXaxis()->SetBinLabel(24,"kMuonSingleHighPt8");
455  hTriggerClass->GetXaxis()->SetBinLabel(25,"kMuonLikeLowPt8");
456  hTriggerClass->GetXaxis()->SetBinLabel(26,"kMuonUnlikeLowPt8");
457  hTriggerClass->GetXaxis()->SetBinLabel(27,"kMuonUnlikeLowPt0");
458  hTriggerClass->GetXaxis()->SetBinLabel(28,"kUserDefined");
459  hTriggerClass->GetXaxis()->SetBinLabel(29,"kTRD");
460  hTriggerClass->GetXaxis()->SetBinLabel(30,"kFastOnly");
461  hTriggerClass->GetXaxis()->SetBinLabel(31,"kAnyINT");
462  hTriggerClass->GetXaxis()->SetBinLabel(32,"kAny");
463  hTriggerClass->GetXaxis()->SetBinLabel(33,"V0AND");
464  hTriggerClass->GetXaxis()->SetBinLabel(34,"NOT kFastOnly");
465  hTriggerClass->GetXaxis()->SetBinLabel(35,"kCaloOnly");
466  hTriggerClass->GetXaxis()->SetBinLabel(36,"failed Physics Selection");
467  hTriggerClass->GetXaxis()->SetBinLabel(37,"mimickedTrigger");
469  }
470  if(!preCut){
471  hTriggerClassSelected= new TH1F(Form("OfflineTriggerSelected %s",GetCutNumber().Data()),"OfflineTriggerSelected",35,-0.5,34.5);
472  hTriggerClassSelected->GetXaxis()->SetBinLabel( 1,"kMB");
473  hTriggerClassSelected->GetXaxis()->SetBinLabel( 2,"kINT7");
474  hTriggerClassSelected->GetXaxis()->SetBinLabel( 3,"kMUON");
475  hTriggerClassSelected->GetXaxis()->SetBinLabel( 4,"kHighMult");
476  hTriggerClassSelected->GetXaxis()->SetBinLabel( 5,"kEMC1");
477  hTriggerClassSelected->GetXaxis()->SetBinLabel( 6,"kCINT5");
478  hTriggerClassSelected->GetXaxis()->SetBinLabel( 7,"kCMUS5/kMUSPB");
479  hTriggerClassSelected->GetXaxis()->SetBinLabel( 8,"kMUSH7/kMUSHPB");
480  hTriggerClassSelected->GetXaxis()->SetBinLabel( 9,"kMUL7/kMuonLikePB");
481  hTriggerClassSelected->GetXaxis()->SetBinLabel(10,"kMUU7/kMuonUnlikePB");
482  hTriggerClassSelected->GetXaxis()->SetBinLabel(11,"kEMC7/kEMC8");
483  hTriggerClassSelected->GetXaxis()->SetBinLabel(12,"kMUS7");
484  hTriggerClassSelected->GetXaxis()->SetBinLabel(13,"kPHI1");
485  hTriggerClassSelected->GetXaxis()->SetBinLabel(14,"kPHI7/kPHI8/kPHOSPb");
486  hTriggerClassSelected->GetXaxis()->SetBinLabel(15,"kEMCEJE");
487  hTriggerClassSelected->GetXaxis()->SetBinLabel(16,"kEMCEGA");
488  hTriggerClassSelected->GetXaxis()->SetBinLabel(17,"kCentral");
489  hTriggerClassSelected->GetXaxis()->SetBinLabel(18,"kSemiCentral");
490  hTriggerClassSelected->GetXaxis()->SetBinLabel(19,"kDG5");
491  hTriggerClassSelected->GetXaxis()->SetBinLabel(20,"kZED");
492  hTriggerClassSelected->GetXaxis()->SetBinLabel(21,"kSPI7/kSPI");
493  hTriggerClassSelected->GetXaxis()->SetBinLabel(22,"kINT8");
494  hTriggerClassSelected->GetXaxis()->SetBinLabel(23,"kMuonSingleLowPt8");
495  hTriggerClassSelected->GetXaxis()->SetBinLabel(24,"kMuonSingleHighPt8");
496  hTriggerClassSelected->GetXaxis()->SetBinLabel(25,"kMuonLikeLowPt8");
497  hTriggerClassSelected->GetXaxis()->SetBinLabel(26,"kMuonUnlikeLowPt8");
498  hTriggerClassSelected->GetXaxis()->SetBinLabel(27,"kMuonUnlikeLowPt0");
499  hTriggerClassSelected->GetXaxis()->SetBinLabel(28,"kUserDefined");
500  hTriggerClassSelected->GetXaxis()->SetBinLabel(29,"kTRD");
501  hTriggerClassSelected->GetXaxis()->SetBinLabel(30,"kFastOnly");
502  hTriggerClassSelected->GetXaxis()->SetBinLabel(31,"kAnyINT");
503  hTriggerClassSelected->GetXaxis()->SetBinLabel(32,"kAny");
504  hTriggerClassSelected->GetXaxis()->SetBinLabel(33,"V0AND");
505  hTriggerClassSelected->GetXaxis()->SetBinLabel(34,"NOT kFastOnly");
506  hTriggerClassSelected->GetXaxis()->SetBinLabel(35,"mimickedTrigger");
508 
509  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9 || fSpecialTrigger == 10){
510  hTriggerClassesCorrelated= new TH1F(Form("TriggerCorrelations %s",GetCutNumber().Data()),"Triggers Correlated with EMCal triggers",17,-0.5,16.5);
511  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 1,"kMB");
512  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 2,"kINT7");
513  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 3,"kEMC1");
514  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 4,"kEMC7");
515  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 5,"kEMCEJE");
516  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 6,"kEMCEJ1");
517  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 7,"kEMCEJ2");
518  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 8,"kEMCEGA");
519  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 9,"kEMCEG1");
520  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 10,"kEMCEG2");
521  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 11,"kDMC7");
522  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 12,"kDMCDJE");
523  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 13,"kDMCDJ1");
524  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 14,"kDMCDJ2");
525  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 15,"kDMCDGA");
526  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 16,"kDMCDG1");
527  hTriggerClassesCorrelated->GetXaxis()->SetBinLabel( 17,"kDMCDG2");
529  }
530 
531  }
532  TH1::AddDirectory(kTRUE);
533 }
534 
536 Bool_t AliConvEventCuts::EventIsSelected(AliVEvent *event, AliMCEvent *mcEvent){
537  // Process Event Selection
538 
539  Int_t cutindex=0;
540  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
541  cutindex++;
542 
543  // Check for MC event
544  Bool_t isMC = kFALSE;
545  if(mcEvent && event->IsA()==AliESDEvent::Class()){
546  // Check if MC event is correctly loaded
547  AliMCEventHandler* mcHandler = dynamic_cast<AliMCEventHandler*> (AliAnalysisManager::GetAnalysisManager()->GetMCtruthEventHandler());
548  if (!mcHandler){
549  fEventQuality = 2;
550  return kFALSE;
551  }
552  if (!mcHandler->InitOk() ){
553  fEventQuality = 2;
554  return kFALSE;
555  }
556  if (!mcHandler->TreeK() ){
557  fEventQuality = 2;
558  return kFALSE;
559  }
560  // TrackRefs.root is currently not used by anyone
561  // and was excluded from future MC productions
562  // if (!mcHandler->TreeTR() ) {
563  // fEventQuality = 2;
564  // return kFALSE;
565  // }
566  isMC = kTRUE;
567  }
568 
569 
570 
571  // Event Trigger
572  // cout << "before event trigger" << endl;
573  if(!IsTriggerSelected(event, isMC )){
574  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
575  fEventQuality = 3;
576  return kFALSE;
577  }
578  cutindex++;
579 
580  if(event->IsA()==AliESDEvent::Class()){
581  AliTriggerAnalysis fTriggerAnalysis;// = new AliTriggerAnalysis;
582  fHasV0AND = fTriggerAnalysis.IsOfflineTriggerFired((AliESDEvent*)event, AliTriggerAnalysis::kV0AND);
583  if(fHasV0AND&&hTriggerClass)hTriggerClass->Fill(32);
584  }
585  // cout << "event number " << ((AliESDEvent*)event)->GetEventNumberInFile() << " entered"<< endl;
586 
587 
588  // Number of Contributors Cut
589  if (fEnableVertexCut){
590  if(GetNumberOfContributorsVtx(event)<=0) {
591  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
592  fEventQuality = 5;
593  return kFALSE;
594  }
595  }
596  cutindex++;
597 
598  // Z Vertex Position Cut
599  if (fEnableVertexCut){
600  if(!VertexZCut(event)){
601  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
602  fEventQuality = 4;
603  return kFALSE;
604  }
605  }
606  cutindex++;
607 
608  // SPD clusters vs tracklets to check for pileup/background
609  Int_t nClustersLayer0 = event->GetNumberOfITSClusters(0);
610  Int_t nClustersLayer1 = event->GetNumberOfITSClusters(1);
611  Int_t nTracklets = event->GetMultiplicity()->GetNumberOfTracklets();
612  if(hSPDClusterTrackletBackgroundBefore) hSPDClusterTrackletBackgroundBefore->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
613 
614 
615  Double_t distZMax = 0;
616  if(event->IsA()==AliESDEvent::Class()){
617  Int_t nPileVert = ((AliESDEvent*)event)->GetNumberOfPileupVerticesSPD();
618  if (hNPileupVertices) hNPileupVertices->Fill(nPileVert);
619  if (nPileVert > 0){
620  for(Int_t i=0; i<nPileVert;i++){
621  const AliESDVertex* pv = ((AliESDEvent*)event)->GetPileupVertexSPD(i);
622  Int_t nc2 = pv->GetNContributors();
623  if(nc2>=3){
624  Double_t z1 = ((AliESDEvent*)event)->GetPrimaryVertexSPD()->GetZ();
625  Double_t z2 = pv->GetZ();
626  Double_t distZ = z2-z1;
627  if (TMath::Abs(distZMax) < TMath::Abs(distZ) ){
628  distZMax = distZ;
629  }
630  }
631  }
632  if (hPileupVertexToPrimZ) hPileupVertexToPrimZ->Fill(distZMax);
633  }
634  }
635 
636  // Pile Up Rejection
637  if (fIsHeavyIon == 2){
638  if(GetUseNewMultiplicityFramework()){// for Run2 pPb
639  if(fUtils->IsPileUpMV(event)){
640  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
641  fEventQuality = 6;
642  return kFALSE;
643  }
644  } else{
645  if(fUtils->IsFirstEventInChunk(event)){
646  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
647  fEventQuality = 6;
648  return kFALSE;
649  }
650  if(fRemovePileUpSPD){
651  if(fUtils->IsPileUpEvent(event)){
652  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
654  fEventQuality = 6;
655  return kFALSE;
656  }
657  if (fUtils->IsSPDClusterVsTrackletBG(event)){
658  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
660  fEventQuality = 11;
661  return kFALSE;
662  }
663  }
664  }
665  } else if(fRemovePileUpSPD){
666  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.) ){
667  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
669  fEventQuality = 6;
670  return kFALSE;
671  }
672  if (fUtils->IsSPDClusterVsTrackletBG(event)){
673  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
675  fEventQuality = 11;
676  return kFALSE;
677  }
678  }
679  cutindex++;
680 
681  // Centrality Selection
682  if(!IsCentralitySelected(event,mcEvent)){
683  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
684  fEventQuality = 1;
685  return kFALSE;
686  }
687  cutindex++;
688 
690  if(fHistoEventCuts) fHistoEventCuts->Fill(cutindex);
691  fEventQuality = 12;
692  return kFALSE;
693  }
694  cutindex++;
695  // Fill Event Histograms
696  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
697  if(hCentrality)hCentrality->Fill(GetCentrality(event));
698  if(hVertexZ)hVertexZ->Fill(event->GetPrimaryVertex()->GetZ());
699  // if(hCentralityVsNumberOfPrimaryTracks)
700  // hCentralityVsNumberOfPrimaryTracks->Fill(GetCentrality(event),
701  // ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
702  // ->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks());
703 
704  if(fIsHeavyIon == 1){
705  AliEventplane *EventPlane = event->GetEventplane();
706  fEventPlaneAngle = EventPlane->GetEventplane("V0",event,2);
707  if(hEventPlaneAngle)hEventPlaneAngle->Fill(TMath::Abs(fEventPlaneAngle));
708  }
709  if(hSPDClusterTrackletBackground) hSPDClusterTrackletBackground->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
710 
711  fEventQuality = 0;
712  return kTRUE;
713 }
714 
718 
719  if(fCutString && fCutString->GetString().Length() == kNCuts) {
720  fCutString->SetString(GetCutNumber());
721  } else {
722  return kFALSE;
723  }
724  return kTRUE;
725 }
726 
729 
730  AliInfo("Entering loading of weights for centrality flattening");
731  TFile *w = TFile::Open(fPathWeightsFlatCent.Data());
732  if(!w){
733  AliError(Form("file for centrality flattening %s not found",fPathWeightsFlatCent.Data()));
734  return;
735  }
736 
737  if (fNameHistoNotFlatCentrality.CompareTo("") != 0 && (fDoCentralityFlat > 0)){
738  cout << "I have to find: " << fNameHistoNotFlatCentrality.Data() << endl;
739  TH1D *hCentralityNotFlattemp = (TH1D*)w->Get(fNameHistoNotFlatCentrality.Data());
740  hCentralityNotFlat = new TH1D(*hCentralityNotFlattemp);
741  if (hCentralityNotFlat) AliInfo(Form("%s has been loaded from %s", fNameHistoNotFlatCentrality.Data(),fPathWeightsFlatCent.Data() ));
742  else AliWarning(Form("%s not found in %s", fNameHistoNotFlatCentrality.Data() ,fPathWeightsFlatCent.Data()));
743  hCentralityNotFlat->SetDirectory(0);
744  }
745 
746  w->Close();
747  delete w;
748 }
749 
752 
753  AliInfo("Entering loading of weights for multiplicity weighting");
754  TFile *w = TFile::Open(fPathReweightingMult.Data());
755  if(!w){
756  AliError(Form("file for multiplicity reweighting %s not found",fPathReweightingMult.Data()));
757  return;
758  }
759 
760  if (fNameHistoReweightingMultData.CompareTo("") != 0 && (fDoMultiplicityWeighting > 0)){
761  cout << "I have to find: " << fNameHistoReweightingMultData.Data() << endl;
762  TH1D *hReweightMultDatatemp = (TH1D*)w->Get(fNameHistoReweightingMultData.Data());
763  if(hReweightMultDatatemp){
764  hReweightMultData = new TH1D(*hReweightMultDatatemp);
765  hReweightMultData->SetDirectory(0);
766  AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingMultData.Data(),fPathReweightingMult.Data() ));
767  } else AliError(Form("%s was not contained in %s", fNameHistoReweightingMultData.Data(),fPathReweightingMult.Data() ));
768  }
769  if (fNameHistoReweightingMultMC.CompareTo("") != 0 && (fDoMultiplicityWeighting > 0)){
770  cout << "I have to find: " << fNameHistoReweightingMultMC.Data() << endl;
771  TH1D *hReweightMultMCtemp = (TH1D*)w->Get(fNameHistoReweightingMultMC.Data());
772  if(hReweightMultMCtemp){
773  hReweightMultMC = new TH1D(*hReweightMultMCtemp);
774  hReweightMultMC->SetDirectory(0);
775  AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingMultMC.Data(),fPathReweightingMult.Data() ));
776  } else AliError(Form("%s was not contained in %s", fNameHistoReweightingMultMC.Data(),fPathReweightingMult.Data() ));
777  }
778 
779  w->Close();
780  delete w;
781 }
782 
783 
786 
787  AliInfo("Entering loading of histograms for weighting");
788  TFile *f = TFile::Open(fPathTrFReweighting.Data());
789  if(!f){
790  AliError(Form("file for weighting %s not found",fPathTrFReweighting.Data()));
791  return;
792  }
793  if (fNameHistoReweightingPi0.CompareTo("") != 0 && fDoReweightHistoMCPi0 ){
794  cout << "I have to find: " << fNameHistoReweightingPi0.Data() << endl;
795  TH1D *hReweightMCHistPi0temp = (TH1D*)f->Get(fNameHistoReweightingPi0.Data());
796  if(hReweightMCHistPi0temp){
797  hReweightMCHistPi0 = new TH1D(*hReweightMCHistPi0temp);
798  hReweightMCHistPi0->SetDirectory(0);
799  AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingPi0.Data(),fPathTrFReweighting.Data() ));
800  } else AliWarning(Form("%s not found in %s", fNameHistoReweightingPi0.Data() ,fPathTrFReweighting.Data()));
801  }
802  if (fNameFitDataPi0.CompareTo("") != 0 && fDoReweightHistoMCPi0 ){
803  cout << "I have to find: " << fNameFitDataPi0.Data() << endl;
804  TF1 *fFitDataPi0temp = (TF1*)f->Get(fNameFitDataPi0.Data());
805  if(fFitDataPi0temp){
806  fFitDataPi0 = new TF1(*fFitDataPi0temp);
807  AliInfo(Form("%s has been loaded from %s", fNameFitDataPi0.Data(),fPathTrFReweighting.Data() ));
808  } else AliWarning(Form("%s not found in %s",fPathTrFReweighting.Data(), fNameFitDataPi0.Data() ));
809  }
810 
811  if (fNameHistoReweightingEta.CompareTo("") != 0 && fDoReweightHistoMCEta){
812  cout << "I have to find: " << fNameHistoReweightingEta.Data() << endl;
813  TH1D *hReweightMCHistEtatemp = (TH1D*)f->Get(fNameHistoReweightingEta.Data());
814  if(hReweightMCHistEtatemp){
815  hReweightMCHistEta = new TH1D(*hReweightMCHistEtatemp);
816  hReweightMCHistEta->SetDirectory(0);
817  AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingEta.Data(),fPathTrFReweighting.Data() ));
818  } else AliWarning(Form("%s not found in %s", fNameHistoReweightingEta.Data(),fPathTrFReweighting.Data() ));
819  }
820 
821  if (fNameFitDataEta.CompareTo("") != 0 && fDoReweightHistoMCEta){
822  cout << "I have to find: " << fNameFitDataEta.Data() << endl;
823  TF1 *fFitDataEtatemp = (TF1*)f->Get(fNameFitDataEta.Data());
824  if(fFitDataEtatemp){
825  fFitDataEta = new TF1(*fFitDataEtatemp);
826  AliInfo(Form("%s has been loaded from %s", fNameFitDataEta.Data(),fPathTrFReweighting.Data() ));
827  } else AliWarning(Form("%s not found in %s", fNameFitDataEta.Data(),fPathTrFReweighting.Data() ));
828 
829  }
830  if (fNameHistoReweightingK0s.CompareTo("") != 0 && fDoReweightHistoMCK0s){
831  cout << "I have to find: " << fNameHistoReweightingK0s.Data() << endl;
832  TH1D *hReweightMCHistK0stemp = (TH1D*)f->Get(fNameHistoReweightingK0s.Data());
833  if(hReweightMCHistK0stemp){
834  hReweightMCHistK0s = new TH1D(*hReweightMCHistK0stemp);
835  hReweightMCHistK0s->SetDirectory(0);
836  AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingK0s.Data(),fPathTrFReweighting.Data() ));
837  } else AliWarning(Form("%s not found in %s", fNameHistoReweightingK0s.Data(),fPathTrFReweighting.Data() ));
838  }
839 
840  if (fNameFitDataK0s.CompareTo("") != 0 && fDoReweightHistoMCK0s){
841  cout << "I have to find: " << fNameFitDataK0s.Data() << endl;
842  TF1 *fFitDataK0stemp = (TF1*)f->Get(fNameFitDataK0s.Data());
843  if(fFitDataK0stemp){
844  fFitDataK0s = new TF1(*fFitDataK0stemp);
845  AliInfo(Form("%s has been loaded from %s", fNameFitDataK0s.Data(),fPathTrFReweighting.Data() ));
846  } else AliWarning(Form("%s not found in %s", fNameFitDataK0s.Data(),fPathTrFReweighting.Data() ));
847  }
848  f->Close();
849  delete f;
850 }
851 
852 
855  fCutStringRead = Form("%s",analysisCutSelection.Data());
856 
857  // Initialize Cuts from a given Cut string
858  if(fDoCentralityFlat > 0){
859  AliInfo("Centrality flattening was enabled");
861  }
862 
864  AliInfo("Multiplicity weighting was enabled");
866  }
868  AliInfo("Particle Weighting was enabled");
870  }
871 
872 
873  AliInfo(Form("Set Event Cut Number: %s",analysisCutSelection.Data()));
874  if(analysisCutSelection.Length()!=kNCuts) {
875  AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
876  return kFALSE;
877  }
878  if(!analysisCutSelection.IsAlnum()){
879  AliError("Cut selection is not alphanumeric");
880  return kFALSE;
881  }
882 
883  if (fV0ReaderName.CompareTo("") == 0){
884  fV0ReaderName = "V0ReaderV1";
885  }
886  TString analysisCutSelectionLowerCase = Form("%s",analysisCutSelection.Data());
887  analysisCutSelectionLowerCase.ToLower();
888  const char *cutSelection = analysisCutSelectionLowerCase.Data();
889  #define ASSIGNARRAY(i) fCuts[i] = ((int)cutSelection[i]>=(int)'a') ? cutSelection[i]-'a'+10 : cutSelection[i]-'0'
890  for(Int_t ii=0;ii<kNCuts;ii++){
891  ASSIGNARRAY(ii);
892  }
893 
894  // Set Individual Cuts
895  for(Int_t ii=0;ii<kNCuts;ii++){
896  if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
897  }
898 
900 
901  return kTRUE;
902 }
903 
907 // "HeavyIon", //0
908 // "CentralityMin", //1
909 // "CentralityMax", //2
910 // "SelectSpecialTrigger", //3
911 // "SelectSpecialSubTriggerClass", //4
912 // "RemovePileUp", //5
913 // "RejectExtraSignals", //6
914 // "VertexCut", //7
915 
916  switch (cutID) {
917  case kisHeavyIon:
918  if( SetIsHeavyIon(value)) {
919  fCuts[kisHeavyIon] = value;
920  UpdateCutString();
921  return kTRUE;
922  } else return kFALSE;
923  case kCentralityMin:
924  if( SetCentralityMin(value)) {
925  fCuts[kCentralityMin] = value;
926  UpdateCutString();
927  return kTRUE;
928  } else return kFALSE;
929  case kCentralityMax:
930  if( SetCentralityMax(value)) {
931  fCuts[kCentralityMax] = value;
932  UpdateCutString();
933  return kTRUE;
934  } else return kFALSE;
936  if( SetSelectSpecialTrigger(value)) {
938  UpdateCutString();
939  return kTRUE;
940  } else return kFALSE;
942  if( SetSelectSubTriggerClass(value)) {
943  fCuts[kSelectSubTriggerClass] = value;
944  UpdateCutString();
945  return kTRUE;
946  } else return kFALSE;
947  case kremovePileUp:
948  if( SetRemovePileUp(value)) {
949  fCuts[kremovePileUp] = value;
950  UpdateCutString();
951  return kTRUE;
952  } else return kFALSE;
953  case kExtraSignals:
954  if( SetRejectExtraSignalsCut(value)) {
955  fCuts[kExtraSignals] = value;
956  UpdateCutString();
957  return kTRUE;
958  } else return kFALSE;
959  case kVertex:
960  if( SetVertexCut(value)) {
961  fCuts[kVertex] = value;
962  UpdateCutString();
963  return kTRUE;
964  } else return kFALSE;
965 
966  case kNCuts:
967  AliError("Cut id out of range");
968  return kFALSE;
969  }
970 
971  AliError("Cut id %d not recognized");
972  return kFALSE;
973 }
974 
977  // Print out current Cut Selection
978  for(Int_t ic = 0; ic < kNCuts; ic++) {
979  printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
980  }
981 }
982 
984  // Print out current Cut Selection with value
985  printf("\nEvent cutnumber \n");
986  for(Int_t ic = 0; ic < kNCuts; ic++) {
987  printf("%d",fCuts[ic]);
988  }
989  printf("\n\n");
990  printf("EnergyVar-enum: '%i', PeriodVar-enum: '%i' \n", fEnergyEnum, fPeriodEnum );
991  if (fIsHeavyIon == 0) {
992  printf("Running in pp mode \n");
993  if (fSpecialTrigger == 0){
994  if(fSpecialTriggerName.Contains("INT7")){
995  printf("\t only events triggered by V0AND will be analysed \n");
996  }else if(fSpecialTriggerName.Contains("INT8")){
997  printf("\t only events triggered by T0AND will be analysed \n");
998  }else if(!fSpecialTriggerName.IsNull()){
999  printf("\t only events triggered by %s will be analysed \n", fSpecialTriggerName.Data());
1000  }else{
1001  if (fSpecialSubTrigger == 0){
1002  printf("\t only events triggered by V0OR will be analysed \n");
1003  } else if (fSpecialSubTrigger == 1){
1004  printf("\t only events where SDD was present will be analysed \n");
1005  }
1006  }
1007  } else if (fSpecialTrigger == 1){
1008  if (fSpecialSubTrigger == 0){
1009  printf("\t only events triggered by V0AND will be analysed \n");
1010  } else if(fSpecialSubTrigger == 1){
1011  printf("\t only events where SDD was present will be analysed and triggered by VOAND\n");
1012  }
1013  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps");
1014  } else if (fSpecialTrigger > 1){
1015  printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
1016  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps\n\n");
1017  }
1018  if ( !(fCentralityMin == 0 && fCentralityMax == 0) && !(fCentralityMax < fCentralityMin) ){
1019  printf("\t Multiplicity cut %d - %d \n", fCentralityMin, fCentralityMax);
1020  }
1021  } else if (fIsHeavyIon == 1){
1022  printf("Running in PbPb mode \n");
1023  if (fDetectorCentrality == 0){
1024  printf("\t centrality selection based on V0M \n");
1025  } else if (fDetectorCentrality == 1){
1026  printf("\t centrality selection based on Cl1 \n");
1027  } else if (fDetectorCentrality == 2){
1028  printf("\t centrality selection based on ZNA \n");
1029  }
1030  if (fModCentralityClass == 0){
1031  printf("\t %d - %d \n", fCentralityMin*10, fCentralityMax*10);
1032  } else if ( fModCentralityClass == 1){
1033  printf("\t %d - %d \n", fCentralityMin*5, fCentralityMax*5);
1034  } else if ( fModCentralityClass == 2){
1035  printf("\t %d - %d \n", fCentralityMin, fCentralityMax);
1036  } else if (fModCentralityClass == 3){
1037  printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*10, fCentralityMax*10);
1038  } else if ( fModCentralityClass == 4){
1039  printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*5, fCentralityMax*5);
1040  } else if (fModCentralityClass == 5){
1041  printf("\t %d - %d, with overlapping Track mult in MC as data \n", fCentralityMin*10, fCentralityMax*10);
1042  } else if ( fModCentralityClass == 6){
1043  printf("\t %d - %d, with overlapping Track mult in MC as data \n", fCentralityMin*5, fCentralityMax*5);
1044  }
1045  if (fSpecialTrigger == 0){
1046  printf("\t only events triggered by kMB, kCentral, kSemiCentral will be analysed \n");
1047  } else if (fSpecialTrigger > 1){
1048  printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
1049  printf("\n\t SpecialTrigger is: %s\n", fSpecialTriggerName.Data());
1050  printf("\t SpecialSubTrigger is: %s\n", fSpecialSubTriggerName.Data());
1051  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps\n\n");
1052  }
1053  } else if (fIsHeavyIon == 2){
1054  printf("Running in pPb mode \n");
1055  if (fDetectorCentrality == 0){
1056  printf("\t centrality selection based on V0A \n");
1057  } else if (fDetectorCentrality == 1){
1058  printf("\t centrality selection based on Cl1 \n");
1059  } else if (fDetectorCentrality == 2){
1060  printf("\t centrality selection based on ZNA \n");
1061  }
1062  if (fModCentralityClass == 0){
1063  printf("\t %d - %d \n", fCentralityMin*10, fCentralityMax*10);
1064  } else if ( fModCentralityClass == 1){
1065  printf("\t %d - %d \n", fCentralityMin*5, fCentralityMax*5);
1066  } else if ( fModCentralityClass == 2){
1067  printf("\t %d - %d \n", fCentralityMin, fCentralityMax);
1068  }
1069  if (fSpecialTrigger == 0){
1070  printf("\t only events triggered by kINT7 will be analysed \n");
1071  } else if (fSpecialTrigger > 1){
1072  printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
1073  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps\n\n");
1074  }
1075  }
1076  if (fEnableVertexCut) printf("\t Vertex cut with |Z_{vtx}| <%2.2f \n",fMaxVertexZ);
1077  else printf("\t No vertex cut \n");
1078 
1079  if (fRemovePileUp ==1 ) {
1080  printf("\t Doing pile up removal \n");
1081  if (fRemovePileUpSPD ==1 ){
1082  printf("\t Doing pile up removal using SPD \n");
1083  }
1084  if (fDoPileUpRejectV0MTPCout ==1 ){
1085  printf("\t Doing extra pile up removal V0M vs TPCout \n");
1086  }
1088  printf("\t Doing extra past-future pile up removal\n");
1089  }
1090  }
1091 
1092  printf("MC event cuts: \n");
1093  if (fRejectExtraSignals == 0) printf("\t no rejection was applied \n");
1094  else if (fRejectExtraSignals == 1) printf("\t only MB header will be inspected \n");
1095  else if (fRejectExtraSignals == 4) printf("\t special handling for Jets embedded in MB events \n");
1096  else if (fRejectExtraSignals > 1) printf("\t special header have been selected \n");
1097  printf("\t maximum factor between jet and pt hard = %2.2f \n", fMaxFacPtHard);
1098 }
1099 
1102 { // Set Cut
1103  switch(isHeavyIon){
1104  case 0: // pp
1105  fIsHeavyIon=0;
1106  break;
1107  case 1: // V0M PbPb & XeXe
1108  // steps of 10%
1109  fIsHeavyIon=1;
1111  break;
1112  case 2: // CL1 PbPb & XeXe
1113  // steps of 10%
1114  fIsHeavyIon=1;
1116  break;
1117  case 3: // V0M PbPb & XeXe
1118  // steps of 5%
1119  // 0 -0%, 1-5%, 2-10%, 3-15%, 4-20%, 5-25%, 6-30%, 7-35%, 8-40%, 9-45%, a-50%, b-55%, c-60%, d-65%, e-70%, f-75%, g-80%, h-85%, i-90%, j-95%, k-100%
1120  fIsHeavyIon=1;
1123  break;
1124  case 4: // V0M PbPb & XeXe & primary track mult for MC different track array
1125  // steps of 10%
1126  fIsHeavyIon=1;
1129  break;
1130  case 5: // V0M PbPb & XeXe & primary track mult for MC
1131  // steps of 10%
1132  fIsHeavyIon=1;
1135  break;
1136  case 6: // V0M PbPb & XeXe & primary track mult for MC
1137  // steps of 5%
1138  // 0 -0%, 1-5%, 2-10%, 3-15%, 4-20%, 5-25%, 6-30%, 7-35%, 8-40%, 9-45%, a-50%, b-55%, c-60%, d-65%, e-70%, f-75%, g-80%, h-85%, i-90%, j-95%, k-100%
1139  fIsHeavyIon=1;
1142  break;
1143  case 7: // V0M PbPb & XeXe & primary track mult for MC different track array
1144  // steps of 5%
1145  // 0 -0%, 1-5%, 2-10%, 3-15%, 4-20%, 5-25%, 6-30%, 7-35%, 8-40%, 9-45%, a-50%, b-55%, c-60%, d-65%, e-70%, f-75%, g-80%, h-85%, i-90%, j-95%, k-100%
1146  fIsHeavyIon=1;
1149  break;
1150  case 8: // pPb V0A
1151  // steps of 10%
1152  fIsHeavyIon=2;
1154  break;
1155  case 9: // pPb CL1
1156  // steps of 10%
1157  fIsHeavyIon=2;
1159  break;
1160  case 10: // a: pPb V0A
1161  // steps of 5%
1162  // 0 -0%, 1-5%, 2-10%, 3-15%, 4-20%, 5-25%, 6-30%, 7-35%, 8-40%, 9-45%, a-50%, b-55%, c-60%, d-65%, e-70%, f-75%, g-80%, h-85%, i-90%, j-95%, k-100%
1163  fIsHeavyIon=2;
1166  break;
1167  case 11: // b: pPb CL1
1168  // steps of 5%
1169  // 0 -0%, 1-5%, 2-10%, 3-15%, 4-20%, 5-25%, 6-30%, 7-35%, 8-40%, 9-45%, a-50%, b-55%, c-60%, d-65%, e-70%, f-75%, g-80%, h-85%, i-90%, j-95%, k-100%
1170  fIsHeavyIon=2;
1173  break;
1174  case 12: // c: pPb V0A
1175  // steps of 1%
1176  // 0 -0%, 1-1%, 2-2%, 3-3%, 4-4%, 5-5%, 6-6%, 7-7%, 8-8%, 9-9%, a-10%, b-11%, c-12%, d-13%, e-14%, f-15%, g-16%, h-17%, i-18%, j-19%, k-20%
1177  fIsHeavyIon=2;
1180  break;
1181  case 13: // d: pPb CL1
1182  // steps of 1%
1183  // 0 -0%, 1-1%, 2-2%, 3-3%, 4-4%, 5-5%, 6-6%, 7-7%, 8-8%, 9-9%, a-10%, b-11%, c-12%, d-13%, e-14%, f-15%, g-16%, h-17%, i-18%, j-19%, k-20%
1184  fIsHeavyIon=2;
1187  break;
1188  case 14: // e: pPb ZNA
1189  // steps of 10%
1190  fIsHeavyIon=2;
1192  break;
1193  case 15: // f: pPb ZNA
1194  // steps of 5%
1195  // 0 -0%, 1-5%, 2-10%, 3-15%, 4-20%, 5-25%, 6-30%, 7-35%, 8-40%, 9-45%, a-50%, b-55%, c-60%, d-65%, e-70%, f-75%, g-80%, h-85%, i-90%, j-95%, k-100%
1196  fIsHeavyIon=2;
1199  break;
1200  case 16: // g: pPb CL1
1201  // steps of 1%
1202  // 0 -0%, 1-1%, 2-2%, 3-3%, 4-4%, 5-5%, 6-6%, 7-7%, 8-8%, 9-9%, a-10%, b-11%, c-12%, d-13%, e-14%, f-15%, g-16%, h-17%, i-18%, j-19%, k-20%
1203  fIsHeavyIon=2;
1206  break;
1207  case 17: // h: pp -> Sphericity < 0.5
1208  fIsHeavyIon=0;
1209  fUseSphericity=1;
1210  break;
1211  case 18: // i: pp -> Sphericity > 0.5
1212  fIsHeavyIon=0;
1213  fUseSphericity=2;
1214  break;
1215  case 19: // j: pp -> 0 < Sphericity > 1.0
1216  fIsHeavyIon=0;
1217  fUseSphericity=3;
1218  break;
1219  case 20: // k: pp -> 0 < Sphericity < 1.0 + mult cut < 20
1220  fIsHeavyIon=0;
1221  fUseSphericity=4;
1222  break;
1223  case 21: // l: pp ->0 < Sphericity < 1.0 + mult cut > 20
1224  fIsHeavyIon=0;
1225  fUseSphericity=5;
1226  break;
1227  case 22: // m: pp -> Sphericity < 0.5 + mult cut < 20
1228  fIsHeavyIon=0;
1229  fUseSphericity=6;
1230  break;
1231  case 23: // n: pp -> Sphericity < 0.5 + mult cut > 20
1232  fIsHeavyIon=0;
1233  fUseSphericity=7;
1234  break;
1235  case 24: // o: pp -> Sphericity > 0.5 + mult cut < 20
1236  fIsHeavyIon=0;
1237  fUseSphericity=8;
1238  break;
1239  case 25: // p: pp -> Sphericity > 0.5 + mult cut > 20
1240  fIsHeavyIon=0;
1241  fUseSphericity=9;
1242  break;
1243  case 26: // q: pp -> Sphericity < 0.3
1244  fIsHeavyIon=0;
1245  fUseSphericity=10;
1246  break;
1247  case 27: // r: pp -> Sphericity > 0.7
1248  fIsHeavyIon=0;
1249  fUseSphericity=11;
1250  break;
1251 
1252  default:
1253  AliError(Form("SetHeavyIon not defined %d",isHeavyIon));
1254  return kFALSE;
1255  }
1256  return kTRUE;
1257 }
1258 
1259 //___________________________________________________________________
1261 {
1262  // Set Cut
1263  if(minCentrality<0||minCentrality>20){
1264  AliError(Form("minCentrality not defined %d",minCentrality));
1265  return kFALSE;
1266  }
1267 
1268  fCentralityMin=minCentrality;
1269  return kTRUE;
1270 }
1271 
1272 //___________________________________________________________________
1274 {
1275  // Set Cut
1276  if(maxCentrality<0||maxCentrality>20){
1277  AliError(Form("maxCentrality not defined %d",maxCentrality));
1278  return kFALSE;
1279  }
1280  fCentralityMax=maxCentrality;
1281  return kTRUE;
1282 }
1283 
1286 {
1287  // Set Cut
1288  switch(selectSpecialTrigger){
1289  case 0:
1290  fSpecialTrigger=0; // V0OR
1291  break;
1292  case 1:
1293  fSpecialTrigger=1; // V0AND
1294  break;
1295 // case 2:
1296 // fSpecialTrigger=2; //
1297 // break;
1298  case 3:
1299  fSpecialTrigger=3; //specific centrality trigger selection
1300  fSpecialTriggerName="AliVEvent::kCentral/kSemiCentral/kMB";
1301  break;
1302  case 4:
1303  fSpecialTrigger=4; // trigger alias kTRD
1304  fOfflineTriggerMask=AliVEvent::kTRD;
1305  fTriggerSelectedManually = kTRUE;
1306  fSpecialTriggerName="AliVEvent::kTRD";
1307  break;
1308  case 5:
1309  fSpecialTrigger=5; // trigger alias kEMC
1310  fOfflineTriggerMask=AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMC1 ;
1311  fTriggerSelectedManually = kTRUE;
1313  SETBIT(fTriggersEMCALSelected, kL0);
1314  fSpecialTriggerName="AliVEvent::kEMC7/kEMC8/kEMC1";
1315  break;
1316  case 6:
1317  fSpecialTrigger=6; // trigger alias kPHI
1318  fOfflineTriggerMask=AliVEvent::kPHI7 | AliVEvent::kPHI1 | AliVEvent::kPHI8 | AliVEvent::kPHOSPb;
1319  fTriggerSelectedManually = kTRUE;
1320  fSpecialTriggerName="AliVEvent::kPHI7/kPHI1/kPHI8/kPHOSPb";
1321  break;
1322  case 7:
1323  fSpecialTrigger=7; // trigger alias kHighMult
1324  fOfflineTriggerMask=AliVEvent::kHighMult;
1325  fTriggerSelectedManually = kTRUE;
1326  fSpecialTriggerName="AliVEvent::kHighMult";
1327  break;
1328  case 8:
1329  fSpecialTrigger=8; // trigger alias kEMCEGA
1330  fOfflineTriggerMask=AliVEvent::kEMCEGA;
1331  fTriggerSelectedManually = kTRUE;
1333  SETBIT(fTriggersEMCALSelected, kG2);
1334  fSpecialTriggerName="AliVEvent::kEMCEGA";
1335  break;
1336  case 9:
1337  fSpecialTrigger=9; // trigger alias kEMCEJE
1338  fOfflineTriggerMask=AliVEvent::kEMCEJE;
1339  fTriggerSelectedManually = kTRUE;
1341  SETBIT(fTriggersEMCALSelected, kJ2);
1342  fSpecialTriggerName="AliVEvent::kEMCEJE";
1343  break;
1344  case 10: //CALO and CALOFAST
1345  fSpecialTrigger=10; // trigger alias kEMC
1346  fOfflineTriggerMask=AliVEvent::kCaloOnly;
1347  fTriggerSelectedManually = kTRUE;
1349  fSpecialTriggerName="AliVEvent::kCaloOnly";
1350  break;
1351  default:
1352  AliError("Warning: Special Trigger Not known");
1353  return 0;
1354  }
1355  return 1;
1356 }
1357 
1360 {
1361  // Set Cut
1362  if (fSpecialTrigger == 0){ //OR
1363  switch(selectSpecialSubTriggerClass){
1364  case 0://with VZERO
1365  fSpecialTrigger=0;
1367 // AliInfo("Info: Nothing to be done");
1368  break;
1369  case 3: //V0OR with SDD requested (will only work with LHC11a dataset)
1371 // cout << "V0OR with SDD requested" << endl;
1372  break;
1373  default:
1374  AliError("Warning: Special Subtrigger Class Not known");
1375  return 0;
1376  }
1377  } else if (fSpecialTrigger == 1){ //AND with different detectors
1378  switch(selectSpecialSubTriggerClass){
1379  case 0: //with VZERO general implementation of V0AND (periods LHC11c onwards)
1380  fSpecialTrigger=0;
1382  fOfflineTriggerMask=AliVEvent::kINT7;
1383  fTriggerSelectedManually = kTRUE;
1384  fSpecialTriggerName="AliVEvent::kINT7";
1385  break;
1386  case 1: //with TZERO
1387  fSpecialTrigger=0;
1389  fOfflineTriggerMask=AliVEvent::kINT8;
1390  fTriggerSelectedManually = kTRUE;
1391  fSpecialTriggerName="AliVEvent::kINT8";
1392  break;
1393  case 2: //with VZERO (will only work with LHC11a dataset)
1394  fSpecialTrigger=1;
1396 // AliInfo("Info: Nothing to be done");
1397  break;
1398  case 3: //V0AND with SDD requested (will only work with LHC11a dataset)
1399  fSpecialTrigger=1;
1401  break;
1402  default:
1403  AliError("Warning: Special Subtrigger Class Not known");
1404  return 0;
1405  }
1406  } else if (fSpecialTrigger == 3){ // Selecting kCentral and kSemiCentral from trigger classes, not aliases
1407  switch(selectSpecialSubTriggerClass){
1408  case 0: // all together
1411 // AliInfo("Info: Nothing to be done");
1412  break;
1413  case 1: // kCentral - no vertex restriction
1416  fSpecialSubTriggerName="CVHN";
1417 // cout << "kCentralOpen" << endl;
1418  break;
1419  case 2: // kCentral - T00 +- 10 cm
1422  fSpecialSubTriggerName="CCENT";
1423 // cout << "kCentralVertex" << endl;
1424  break;
1425  case 3: // kCentral - both
1428  fSpecialSubTriggerName="CVHN|CCENT|CSEMI|CVLN";
1429 // cout << "kCentral both" << endl;
1430  break;
1431  case 4: // kSemiCentral - no vertex restriction
1434  fSpecialSubTriggerName="CVLN";
1435 // cout << "kSemiCentralOpen" << endl;
1436  break;
1437  case 5: // kSemiCentral - T00 +- 10 cm
1440  fSpecialSubTriggerName="CSEMI";
1441 // cout << "kSemiCentralVertex" << endl;
1442  break;
1443  case 6: // kSemiCentral - both
1446  fSpecialSubTriggerName="CSEMI%CVLN";
1447 // cout << "kSemiCentral both" << endl;
1448  break;
1449  case 7: // kMB
1452  fSpecialSubTriggerName="CPBI1_|CPBI1-";
1453 // cout << "kMB 1" << endl;
1454  break;
1455  case 8: // kMB
1458  fSpecialSubTriggerName="CPBI2_|CPBI2-";
1459 // cout << "kMB 2" << endl;
1460  break;
1461  case 9: // kMB
1464  fSpecialSubTriggerName="CPBI2_@CPBI2-@CPBI2_@CPBI2-";
1465 // cout << "kMB both" << endl;
1466  break;
1467  case 10: // 0V0M
1468  fOfflineTriggerMask=AliVEvent::kINT7;
1469  fTriggerSelectedManually = kTRUE;
1472  fSpecialSubTriggerName="C0V0M";
1473  break;
1474  case 11: // 0V0L
1475  fOfflineTriggerMask=AliVEvent::kINT7;
1476  fTriggerSelectedManually = kTRUE;
1479  fSpecialSubTriggerName="C0V0L";
1480  break;
1481  case 12: // 0VHM
1482  fOfflineTriggerMask=AliVEvent::kINT7;
1483  fTriggerSelectedManually = kTRUE;
1486  fSpecialSubTriggerName="C0VHM";
1487  break;
1488  case 13: // VOL7
1489  fOfflineTriggerMask=AliVEvent::kINT7;
1490  fTriggerSelectedManually = kTRUE;
1493  fSpecialSubTriggerName="CV0L7";
1494  break;
1495  case 14: // 0STC
1496  fOfflineTriggerMask=AliVEvent::kINT7;
1497  fTriggerSelectedManually = kTRUE;
1500  fSpecialSubTriggerName="C0STC";
1501  break;
1502  default:
1503  AliError("Warning: Special Subtrigger Class Not known");
1504  return 0;
1505  }
1506  } else if (fSpecialTrigger == 4){ // Subdivision of TRD trigger classes
1507  switch(selectSpecialSubTriggerClass){
1508  case 0: // all together
1511 // AliInfo("Info: Nothing to be done");
1512  break;
1513  case 1: // 7WUHSH - V0AND with single electron in TRD & EMCAL
1516  fSpecialSubTriggerName="7WUHEE";
1517  break;
1518  case 2: // 8WUHSH - T0AND with single electron in TRD & EMCAL
1521  fSpecialSubTriggerName="8WUHEE";
1522  break;
1523  case 3: // 7WUHSE - V0AND with single high pt electron in TRD
1526  fSpecialSubTriggerName="7WUHSE";
1527  break;
1528  case 4: // 8WUHSE - T0AND with single high pt electron in TRD
1531  fSpecialSubTriggerName="8WUHSE";
1532  break;
1533  case 5: // 7WUHJE - V0AND with jet in TRD
1536  fSpecialSubTriggerName="7WUHJT";
1537  break;
1538  case 6: // 8WUHJE - T0AND with jet in TRD
1541  fSpecialSubTriggerName="8WUHJT";
1542  break;
1543  case 7: // 7WUHQU - V0AND with dielectron pair in TRD
1546  fSpecialSubTriggerName="7WUHQU";
1547  break;
1548  case 8: // 8WUHQU - T0AND with dielectron pair in TRD
1551  fSpecialSubTriggerName="8WUHQU";
1552  break;
1553  default:
1554  AliError("Warning: Special Subtrigger Class Not known");
1555  return 0;
1556  }
1557  } else if (fSpecialTrigger == 5){ // Subdivision of kEMC trigger classes
1558  switch(selectSpecialSubTriggerClass){
1559  case 0: // all together
1562 // AliInfo("Info: Nothing to be done");
1563  break;
1564  case 1: // CEMC1 - V0OR and EMCAL fired
1565  fOfflineTriggerMask=AliVEvent::kEMC1;
1566  fSpecialTriggerName="AliVEvent::kEMC1";
1569  fSpecialSubTriggerName="CEMC1";
1570  break;
1571  case 2: // CEMC7 - V0AND and EMCAL fired
1573  fOfflineTriggerMask=AliVEvent::kEMC7;
1574  fSpecialTriggerName="AliVEvent::kEMC7";
1576  fSpecialSubTriggerName="CEMC7";
1577  break;
1578  case 3: // CEMC8 - T0OR and EMCAL fired
1579  fOfflineTriggerMask=AliVEvent::kEMC8;
1580  fSpecialTriggerName="AliVEvent::kEMC8";
1583  fSpecialSubTriggerName="CEMC8";
1584  break;
1585  case 4: // CDMC1 - V0OR and DCAL fired
1586  fOfflineTriggerMask=AliVEvent::kEMC1;
1587  fSpecialTriggerName="AliVEvent::kEMC1";
1590  fSpecialSubTriggerName="CDMC1";
1591  break;
1592  case 5: // CDMC7 - V0AND and DCAL fired
1594  fOfflineTriggerMask=AliVEvent::kEMC7;
1595  fSpecialTriggerName="AliVEvent::kEMC7";
1597  fSpecialSubTriggerName="CDMC7";
1598  break;
1599  case 6: // CDMC8 - T0OR and DCAL fired
1600  fOfflineTriggerMask=AliVEvent::kEMC8;
1601  fSpecialTriggerName="AliVEvent::kEMC8";
1604  fSpecialSubTriggerName="CDMC8";
1605  break;
1606  default:
1607  AliError("Warning: Special Subtrigger Class Not known");
1608  return 0;
1609  }
1610  }else if (fSpecialTrigger == 6){ // Subdivision of kPHI trigger classes
1611  switch(selectSpecialSubTriggerClass){
1612  case 0: // all together
1615 // AliInfo("Info: Nothing to be done");
1616  break;
1617  case 1: // CEMC1 - V0OR and EMCAL fired
1618  fOfflineTriggerMask=AliVEvent::kPHI1;
1619  fSpecialTriggerName="AliVEvent::kPHI1";
1622  fSpecialSubTriggerName="CPHI1";
1623  break;
1624  case 2: // CEMC7 - V0AND and EMCAL fired
1626  fOfflineTriggerMask=AliVEvent::kPHI7;
1627  fSpecialTriggerName="AliVEvent::kPHI7";
1629  fSpecialSubTriggerName="CPHI7";
1630  break;
1631  case 3: // CEMC8 - T0OR and EMCAL fired
1632  fOfflineTriggerMask=AliVEvent::kPHI8;
1633  fSpecialTriggerName="AliVEvent::kPHI8";
1636  fSpecialSubTriggerName="CPHI8";
1637  break;
1638  default:
1639  AliError("Warning: Special Subtrigger Class Not known");
1640  return 0;
1641  }
1642  } else if (fSpecialTrigger == 7){ // Subdivision of kHighMult trigger classes
1643  switch(selectSpecialSubTriggerClass){
1644  case 0: // all together
1647 // AliInfo("Info: Nothing to be done");
1648  break;
1649  case 1: // CSHM1 - V0OR and high mult fired
1652  fSpecialSubTriggerName="CSHM1";
1653  break;
1654  case 2: // CSHM7 - V0AND and high mult fired
1657  fSpecialSubTriggerName="CSHM7";
1658  break;
1659  case 3: // CSHM8 - T0OR and high mult fired
1662  fSpecialSubTriggerName="CSHM8";
1663  break;
1664  case 4: // V0 high mult trigger
1666  fOfflineTriggerMask=AliVEvent::kAny;
1667  fSpecialTriggerName="V0Mult";
1669  fSpecialSubTriggerName="CVHMV0M-B-";
1670  break;
1671  case 5: // SPD high mult trigger
1673  fOfflineTriggerMask=AliVEvent::kAny;
1674  fSpecialTriggerName="SPMult";
1676  fSpecialSubTriggerName="CVHMSH2-B-";
1677  break;
1678  case 6: // V0 high mult trigger with pileup condition on
1680  fOfflineTriggerMask=AliVEvent::kAny;
1681  fSpecialTriggerName="V0Mult";
1683  fSpecialSubTriggerName="CVHMV0M-B-SPD2";
1684  break;
1685 
1686  default:
1687  AliError("Warning: Special Subtrigger Class Not known");
1688  return 0;
1689  }
1690  }else if (fSpecialTrigger == 8){ // Subdivision of kEMCEGA trigger classes
1691  switch(selectSpecialSubTriggerClass){
1692  case 0: // all together
1695 // AliInfo("Info: Nothing to be done");
1696  break;
1697  case 1: // 7EGA - CINT7 EGA
1700  fSpecialSubTriggerName="7EGA";
1702  SETBIT(fTriggersEMCALSelected, kG2);
1703  break;
1704  case 2: // 8EGA - CINT8 EGA
1707  fSpecialSubTriggerName="8EGA";
1709  SETBIT(fTriggersEMCALSelected, kG2);
1710  break;
1711  case 3: // 7EG1 - CINT7 EG1
1714  fSpecialSubTriggerName="7EG1";
1716  SETBIT(fTriggersEMCALSelected, kG1);
1717  break;
1718  case 4: // 8EG1 - CINT8 EG1
1721  fSpecialSubTriggerName="8EG1";
1723  SETBIT(fTriggersEMCALSelected, kG1);
1724  break;
1725  case 5: // 7EG2 - CINT7 EG2
1728  fSpecialSubTriggerName="7EG2";
1730  SETBIT(fTriggersEMCALSelected, kG2);
1731  break;
1732  case 6: // 8EG2 - CINT8 EG2
1735  fSpecialSubTriggerName="8EG2";
1737  SETBIT(fTriggersEMCALSelected, kG2);
1738  break;
1739  case 7: // 7DGA - CINT7 DGA
1742  fSpecialSubTriggerName="7DGA";
1744  SETBIT(fTriggersEMCALSelected, kG2);
1745  break;
1746  case 8: // 8DGA - CINT8 DGA
1749  fSpecialSubTriggerName="8DGA";
1751  SETBIT(fTriggersEMCALSelected, kG2);
1752  break;
1753  case 9: // 7DG1 - CINT7 DG1
1756  fSpecialSubTriggerName="7DG1";
1758  SETBIT(fTriggersEMCALSelected, kG1);
1759  break;
1760  case 10: // 8DG1 - CINT8 DG1
1763  fSpecialSubTriggerName="8DG1";
1765  SETBIT(fTriggersEMCALSelected, kG1);
1766  break;
1767  case 11: // 7DG2 - CINT7 DG2
1770  fSpecialSubTriggerName="7DG2";
1772  SETBIT(fTriggersEMCALSelected, kG2);
1773  break;
1774  case 12: // 8DG2 - CINT8 DG2
1777  fSpecialSubTriggerName="8DG2";
1779  SETBIT(fTriggersEMCALSelected, kG2);
1780  break;
1781 
1782  default:
1783  AliError("Warning: Special Subtrigger Class Not known");
1784  return 0;
1785  }
1786  } else if (fSpecialTrigger == 9){ // Subdivision of kEMCEGA trigger classes
1787  switch(selectSpecialSubTriggerClass){
1788  case 0: // all together
1791 // AliInfo("Info: Nothing to be done");
1792  break;
1793  case 1: // 7EJE - CINT7 EJE
1796  fSpecialSubTriggerName="7EJE";
1798  SETBIT(fTriggersEMCALSelected, kJ2);
1799  break;
1800  case 2: // 8EJE - CINT8 EJE
1803  fSpecialSubTriggerName="8EJE";
1805  SETBIT(fTriggersEMCALSelected, kJ2);
1806  break;
1807  case 3: // 7EJ1 - CINT7 EJ1
1810  fSpecialSubTriggerName="7EJ1";
1812  SETBIT(fTriggersEMCALSelected, kJ1);
1813  break;
1814  case 4: // 8EJ1 - CINT8 EJ1
1817  fSpecialSubTriggerName="8EJ1";
1819  SETBIT(fTriggersEMCALSelected, kJ1);
1820  break;
1821  case 5: // 7EJ2 - CINT7 EJ2
1824  fSpecialSubTriggerName="7EJ2";
1826  SETBIT(fTriggersEMCALSelected, kJ2);
1827  break;
1828  case 6: // 8EJ2 - CINT8 EJ2
1831  fSpecialSubTriggerName="8EJ2";
1833  SETBIT(fTriggersEMCALSelected, kJ2);
1834  break;
1835  case 7: // 7DJ1 - CINT7 DJ1
1838  fSpecialSubTriggerName="7DJ1";
1840  SETBIT(fTriggersEMCALSelected, kJ1);
1841  break;
1842  case 8: // 8DJ1 - CINT8 DJ1
1845  fSpecialSubTriggerName="8DJ1";
1847  SETBIT(fTriggersEMCALSelected, kJ1);
1848  break;
1849  case 9: // 7DJ2 - CINT7 DJ2
1852  fSpecialSubTriggerName="7DJ2";
1854  SETBIT(fTriggersEMCALSelected, kJ2);
1855  break;
1856  case 10: // 8DJ2 - CINT8 DJ2
1859  fSpecialSubTriggerName="8DJ2";
1861  SETBIT(fTriggersEMCALSelected, kJ2);
1862  break;
1863 
1864  default:
1865  AliError("Warning: Special Subtrigger Class Not known");
1866  return 0;
1867  }
1868  } else if (fSpecialTrigger == 10){ // Subdivision of kEMC trigger classes
1869  switch(selectSpecialSubTriggerClass){
1870  case 0: // all together
1873  fSpecialSubTriggerName="CINT7";
1874  fSpecialTriggerName="AliVEvent::kCaloOnly/INT7";
1875  break;
1876  case 1: // CEMC7 - V0AND and EMCAL fired
1879  fSpecialSubTriggerName="CEMC7-";
1880  fSpecialTriggerName="AliVEvent::kCaloOnly/EMC7";
1881  break;
1882  case 2: // CEMC7EG2 - V0AND and EMCAL fired
1885  fSpecialSubTriggerName="7EG2";
1886  fSpecialTriggerName="AliVEvent::kCaloOnly/7EG2";
1887  break;
1888  case 3: // CEMC7EG1 - V0AND and EMCAL fired
1891  fSpecialSubTriggerName="7EG1";
1892  fSpecialTriggerName="AliVEvent::kCaloOnly/7EG1";
1893  break;
1894  case 4: // CEMC7EJ2 - V0AND and EMCAL fired
1897  fSpecialSubTriggerName="7EJ2";
1898  fSpecialTriggerName="AliVEvent::kCaloOnly/7EJ2";
1899  break;
1900  case 5: // CEMC7EJ1 - V0AND and EMCAL fired
1903  fSpecialSubTriggerName="7EJ1";
1904  fSpecialTriggerName="AliVEvent::kCaloOnly/7EJ1";
1905  break;
1906  case 6: // CDMC7 - V0AND and DCAL fired
1909  fSpecialSubTriggerName="CDMC7-";
1910  fSpecialTriggerName="AliVEvent::kCaloOnly/DMC7";
1911  break;
1912  case 7: // CDMC7DG2 - V0AND and DCAL fired
1915  fSpecialSubTriggerName="7DG2";
1916  fSpecialTriggerName="AliVEvent::kCaloOnly/7DG2";
1917  break;
1918  case 8: // CDMC7DG1 - V0AND and DCAL fired
1921  fSpecialSubTriggerName="7DG1";
1922  fSpecialTriggerName="AliVEvent::kCaloOnly/7DG1";
1923  break;
1924  case 9: // CDMC7DJ2 - V0AND and DCAL fired
1927  fSpecialSubTriggerName="7DJ2";
1928  fSpecialTriggerName="AliVEvent::kCaloOnly/7DJ2";
1929  break;
1930  case 10: // DEMC7DJ1 - V0AND and DCAL fired - a
1933  fSpecialSubTriggerName="7DJ1";
1934  fSpecialTriggerName="AliVEvent::kCaloOnly/7DJ1";
1935  break;
1936  case 11: // CEMC8 - V0AND and EMCAL fired - b
1939  fSpecialSubTriggerName="CEMC8-";
1940  fSpecialTriggerName="AliVEvent::kCaloOnly/EMC8";
1941  break;
1942  case 12: // CEMC8EG2 - V0AND and EMCAL fired - c
1945  fSpecialSubTriggerName="8EG2";
1946  fSpecialTriggerName="AliVEvent::kCaloOnly/8EG2";
1947  break;
1948  case 13: // CEMC8EG1 - V0AND and EMCAL fired - d
1951  fSpecialSubTriggerName="8EG1";
1952  fSpecialTriggerName="AliVEvent::kCaloOnly/8EG1";
1953  break;
1954  case 14: // CEMC8EJ2 - V0AND and EMCAL fired - e
1957  fSpecialSubTriggerName="8EJ2";
1958  fSpecialTriggerName="AliVEvent::kCaloOnly/8EJ2";
1959  break;
1960  case 15: // CEMC8EJ1 - V0AND and EMCAL fired - f
1963  fSpecialSubTriggerName="8EJ1";
1964  fSpecialTriggerName="AliVEvent::kCaloOnly/8EJ1";
1965  break;
1966  case 16: // CDMC8 - V0AND and DCAL fired - g
1969  fSpecialSubTriggerName="CDMC8-";
1970  fSpecialTriggerName="AliVEvent::kCaloOnly/DMC8";
1971  break;
1972  case 17: // CDMC8DG2 - V0AND and DCAL fired - h
1975  fSpecialSubTriggerName="8DG2";
1976  fSpecialTriggerName="AliVEvent::kCaloOnly/8DG2";
1977  break;
1978  case 18: // CDMC8DG1 - V0AND and DCAL fired - i
1981  fSpecialSubTriggerName="8DG1";
1982  fSpecialTriggerName="AliVEvent::kCaloOnly/8DG1";
1983  break;
1984  case 19: // CDMC8DJ2 - V0AND and DCAL fired - j
1987  fSpecialSubTriggerName="8DJ2";
1988  fSpecialTriggerName="AliVEvent::kCaloOnly/8DJ2";
1989  break;
1990  case 20: // DEMC8DJ1 - V0AND and DCAL fired - k
1993  fSpecialSubTriggerName="8DJ1";
1994  fSpecialTriggerName="AliVEvent::kCaloOnly/8DJ1";
1995  break;
1996  default:
1997  AliError("Warning: Special Subtrigger Class Not known");
1998  return 0;
1999  }
2000  }
2001  return 1;
2002 }
2003 
2004 //________________________________________________________________________
2006 {
2007  // Set Cut
2008  fMultiplicityMethod=multiplicityMethod;
2009 
2010  // 0 Photon Multiplicity
2011  // 1 TPC Track multiplicity
2012  // 2 V0 Mult
2013  // 3 SPD Mult
2014 
2015  return kTRUE;
2016 }
2017 
2018 //________________________________________________________________________
2020 {// Set Cut
2021  switch(removePileUp){
2022  case 0:
2023  fRemovePileUp = kFALSE;
2024  break;
2025  case 1:
2026  fRemovePileUp = kTRUE;
2027  fRemovePileUpSPD = kTRUE;
2028  break;
2029  case 2:
2030  fRemovePileUp = kTRUE;
2031  fRemovePileUpSPD = kTRUE;
2034  break;
2035  case 3:
2036  fRemovePileUp = kTRUE;
2037  fRemovePileUpSPD = kTRUE;
2040  break;
2041  case 4:
2042  fRemovePileUp = kTRUE;
2043  fRemovePileUpSPD = kTRUE;
2046  break;
2047  case 5:
2048  fRemovePileUp = kTRUE;
2049  fRemovePileUpSPD = kTRUE;
2052  break;
2053  case 6:
2054  fRemovePileUp = kTRUE;
2055  fRemovePileUpSPD = kTRUE;
2056  fDoPileUpRejectV0MTPCout = kTRUE;
2057  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2058  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
2059  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
2060  if (fIsHeavyIon==1){
2061  if(fPeriodEnum == kLHC15o){
2062  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2063  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2064  break;
2065  }else{
2066  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
2067  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
2068  break;
2069  }
2070  } else if(fIsHeavyIon == 2){
2071  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
2072  fFPileUpRejectV0MTPCout->SetParameter(1,2.0);
2073  break;
2074  }else{
2075  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
2076  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
2077  break;
2078  }
2079  break;
2080  case 7:
2081  fRemovePileUp = kTRUE;
2082  fRemovePileUpSPD = kTRUE;
2083  fDoPileUpRejectV0MTPCout = kTRUE;
2084  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2085  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
2086  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
2087  if (fIsHeavyIon==1){
2088  if(fPeriodEnum == kLHC15o){
2089  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2090  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2091  break;
2092  }else{
2093  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2094  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
2095  break;
2096  }
2097  } else if(fIsHeavyIon == 2){
2098  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
2099  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
2100  break;
2101  }else{
2102  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
2103  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
2104  break;
2105  }
2106  break;
2107  case 8:
2108  fRemovePileUp = kTRUE;
2109  fRemovePileUpSPD = kTRUE;
2110  fDoPileUpRejectV0MTPCout = kTRUE;
2111  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2112  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
2113  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
2114  if (fIsHeavyIon==1){
2115  if(fPeriodEnum == kLHC15o){
2116  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2117  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2118  break;
2119  }else{
2120  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
2121  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
2122  break;
2123  }
2124  } else if(fIsHeavyIon == 2){
2125  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
2126  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
2127  break;
2128  }else{
2129  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
2130  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
2131  break;
2132  }
2133  break;
2134  case 9:
2135  fRemovePileUp = kTRUE;
2136  fRemovePileUpSPD = kTRUE;
2139  fDoPileUpRejectV0MTPCout = kTRUE;
2140  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2141  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
2142  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
2143  if (fIsHeavyIon==1){
2144  if(fPeriodEnum == kLHC15o){
2145  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2146  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2147  break;
2148  }else{
2149  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
2150  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
2151  break;
2152  }
2153  } else if(fIsHeavyIon == 2){
2154  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
2155  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
2156  break;
2157  }else{
2158  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
2159  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
2160  break;
2161  }
2162  break;
2163  case 10: // for Pb-Pb
2164  fRemovePileUp = kTRUE;
2165  fRemovePileUpSPD = kTRUE;
2166  fUtils->SetASPDCvsTCut(200.);
2167  fUtils->SetBSPDCvsTCut(7.);
2168  fDoPileUpRejectV0MTPCout = kTRUE;
2169  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2170  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2171  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2172  break;
2173  case 11: // for Pb-Pb
2174  fRemovePileUp = kTRUE;
2175  fRemovePileUpSPD = kFALSE;
2176  fDoPileUpRejectV0MTPCout = kTRUE;
2177  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2178  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2179  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2180  break;
2181  default:
2182  AliError("RemovePileUpCut not defined");
2183  return kFALSE;
2184  }
2185  return kTRUE;
2186 }
2187 
2188 //________________________________________________________________________
2190 
2191  switch(extraSignal){
2192  case 0:
2193  fRejectExtraSignals = 0;
2194  break; // No Rejection
2195  case 1:
2196  fRejectExtraSignals = 1;
2197  break; // MinBias Header
2198  case 2:
2199  fRejectExtraSignals = 2;
2200  break; // User String Array
2201  case 3:
2202  fRejectExtraSignals = 3;
2203  break; // Rejection for Gamma Correction only
2204  case 4:
2205  fRejectExtraSignals = 4;
2206  break; // Special handling of Jet weights for Jets embedded in MB events
2207  default:
2208  AliError(Form("Extra Signal Rejection not defined %d",extraSignal));
2209  return kFALSE;
2210  }
2211  return kTRUE;
2212 }
2213 
2214 //________________________________________________________________________
2216 
2217  switch(vertexCut){
2218  case 0: // no Vertex required // NOT fully working yet
2219  fEnableVertexCut = kFALSE;
2220  fMaxVertexZ = 1000;
2221  break;
2222  case 1: // vertex within +-15 cm
2223  fEnableVertexCut = kTRUE;
2224  fMaxVertexZ = 15;
2225  break;
2226  case 2: // vertex within +-12.5 cm
2227  fEnableVertexCut = kTRUE;
2228  fMaxVertexZ = 12.5;
2229  break;
2230  case 3: // vertex within +-10 cm
2231  fEnableVertexCut = kTRUE;
2232  fMaxVertexZ = 10.0;
2233  break;
2234  case 4: // vertex within +-7.5 cm
2235  fEnableVertexCut = kTRUE;
2236  fMaxVertexZ = 7.5;
2237  break;
2238  case 5: // vertex within +-5 cm
2239  fEnableVertexCut = kTRUE;
2240  fMaxVertexZ = 5.;
2241  break;
2242  default:
2243  AliError(Form("Vertex Cut not defined %d",vertexCut));
2244  return kFALSE;
2245  }
2246  return kTRUE;
2247 }
2248 
2249 //-------------------------------------------------------------
2251  if (fPeriodEnum == kLHC15n || // pp 5TeV
2252  fPeriodEnum == kLHC15o || // PbPb 5TeV
2253  fPeriodEnum == kLHC15k1a1 || fPeriodEnum == kLHC15k1a2 || fPeriodEnum == kLHC15k1a3 || fPeriodEnum == kLHC16j7 || // MC PbPb 5TeV LowIR
2254  fPeriodEnum == kLHC16g1 || fPeriodEnum == kLHC16g1a || fPeriodEnum == kLHC16g1b || fPeriodEnum == kLHC16g1c || // MC PbPb 5TeV general purpose
2255  fPeriodEnum == kLHC16g2 || // MC PbPb 5TeV EPOS-LHC
2256  fPeriodEnum == kLHC16g3 || // MC PbPb 5TeV DPMJET
2257  fPeriodEnum == kLHC16h4 || // MC PbPb 5TeV GA added pi0 and eta
2258  fPeriodEnum == kLHC16i1a || fPeriodEnum == kLHC16i1b || fPeriodEnum == kLHC16i1c || // MC PbPb 5TeV LF added (multi-)strange
2259  fPeriodEnum == kLHC16i2a || fPeriodEnum == kLHC16i2b || fPeriodEnum == kLHC16i2c || // MC PbPb 5TeV HF added hadronic decays
2260  fPeriodEnum == kLHC16i3a || fPeriodEnum == kLHC16i3b || fPeriodEnum == kLHC16i3c || // MC PbPb 5TeV HF added electron decays
2261  fPeriodEnum == kLHC16h2a || fPeriodEnum == kLHC16h2b || fPeriodEnum == kLHC16h2c || // MC PbPb 5TeV jet-jet
2263  fPeriodEnum == kLHC15g3a3 || fPeriodEnum == kLHC15g3c3 || // MC pp 13TeV
2264  fPeriodEnum == kLHC16qt || // pPb 5TeV LHC16qt
2265  fPeriodEnum == kLHC16r || fPeriodEnum == kLHC16s || // pPb 8TeV LHC16rs
2266  fPeriodEnum == kLHC17f2a || fPeriodEnum == kLHC17f2b || fPeriodEnum == kLHC17g8a || fPeriodEnum == kLHC18f3 || // MC pPb 5TeV LHC16qt
2268  fPeriodEnum == kLHC17f3 || fPeriodEnum == kLHC17f4 || // MC pPb 8TeV LHC16sr
2269  fPeriodEnum == kLHC17n || // Xe-Xe LHC17n
2270  fPeriodEnum == kLHC17j7 || // MC Xe-Xe LHC17n
2271  fPeriodEnum == kLHC17pq || // pp 5TeV LHC17pq
2272  fPeriodEnum == kLHC17l3b || fPeriodEnum == kLHC18j2 || // MC pp 5TeV LHC17pq
2273  fPeriodEnum == kLHC17l4b || // MC pp 5TeV LHC17pq
2274  fPeriodEnum == kLHC18b8 // MC Jet Jet pp 5TeV LHC17pq
2275  ){
2276  return kTRUE;
2277  } else {
2278  return kFALSE;
2279  }
2280 }
2281 
2282 //-------------------------------------------------------------
2284 { // Get Event Centrality
2285 
2286  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
2287  Int_t runnumber = event->GetRunNumber();
2288  if(esdEvent){
2290  AliMultSelection *MultSelection = (AliMultSelection*)event->FindListObject("MultSelection");
2291  if(!MultSelection){
2292  AliWarning ("AliMultSelection object not found !");
2293  return -1;
2294  }else{
2295  if(fDetectorCentrality==0){
2296  if(fIsHeavyIon==2){
2297  if (runnumber > 266329 && runnumber < 267139)
2298  return MultSelection->GetMultiplicityPercentile("V0C");// default for Pbp
2299  else
2300  return MultSelection->GetMultiplicityPercentile("V0A");// default for pPb
2301  } else {
2302  return MultSelection->GetMultiplicityPercentile("V0M");// default
2303  }
2304  } else if(fDetectorCentrality==1){
2305  return MultSelection->GetMultiplicityPercentile("CL1",kTRUE);
2306  } else if(fDetectorCentrality==2){
2307  if (runnumber > 266329 && runnumber < 267139)
2308  return MultSelection->GetMultiplicityPercentile("ZNC",kTRUE);
2309  else
2310  return MultSelection->GetMultiplicityPercentile("ZNA",kTRUE);
2311  }
2312  }
2313  }else{
2314  AliCentrality *fESDCentrality = (AliCentrality*)esdEvent->GetCentrality();
2315  if(fDetectorCentrality==0){
2316  if(fIsHeavyIon==2){
2317  if (runnumber > 196432 && runnumber < 197389)
2318  return fESDCentrality->GetCentralityPercentile("V0C"); // default for Pbp
2319  else
2320  return fESDCentrality->GetCentralityPercentile("V0A"); // default for pPb
2321  } else {
2322  return fESDCentrality->GetCentralityPercentile("V0M"); // default
2323  }
2324  } else if(fDetectorCentrality==1){
2325  return fESDCentrality->GetCentralityPercentile("CL1");
2326  } else if(fDetectorCentrality==2){
2327  if (runnumber > 196432 && runnumber < 197389)
2328  return fESDCentrality->GetCentralityPercentile("ZNC");
2329  else
2330  return fESDCentrality->GetCentralityPercentile("ZNA");
2331  }
2332  }
2333  }
2334 
2335  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
2336  if(aodEvent){
2338  AliMultSelection *MultSelection = (AliMultSelection*)aodEvent->FindListObject("MultSelection");
2339  if(!MultSelection){
2340  AliWarning ("AliMultSelection object not found !");
2341  return -1;
2342  } else{
2343  if(fDetectorCentrality==0){
2344  if(fIsHeavyIon==2) return MultSelection->GetMultiplicityPercentile("V0A");// default for pPb
2345  else return MultSelection->GetMultiplicityPercentile("V0M",kTRUE);
2346  }else if(fDetectorCentrality==1) return MultSelection->GetMultiplicityPercentile("CL1",kTRUE);
2347  else if(fDetectorCentrality==2) return MultSelection->GetMultiplicityPercentile("ZNA",kTRUE);
2348  }
2349  }else{
2350  if(aodEvent->GetHeader()){return ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();}
2351  }
2352  }
2353 
2354  return -1;
2355 }
2356 
2357 //_____________________________________________________________________________________
2358 Bool_t AliConvEventCuts::IsCentralitySelected(AliVEvent *event, AliMCEvent *mcEvent)
2359 {
2360  // Centrality Selection
2361  if(!fIsHeavyIon){
2362  if ((fCentralityMin == 0 && fCentralityMax == 0) || (fCentralityMin > fCentralityMax) ){
2363  return kTRUE;
2364  } else {
2365  Int_t primaryTracksPP[9] = { 0, 2, 5, 10, 15,
2366  30, 50, 100, 1000
2367  };
2368  Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
2369  if ( nprimaryTracks >= primaryTracksPP[fCentralityMin] && nprimaryTracks < primaryTracksPP[fCentralityMax]){
2370  return kTRUE;
2371  } else {
2372  return kFALSE;
2373  }
2374  return kFALSE;
2375  }
2376  }
2377  if(fCentralityMin == fCentralityMax ) return kTRUE;//0-100%
2378  else if ( fCentralityMax==0) fCentralityMax=10; //CentralityRange = fCentralityMin-10*multfactor
2380  if(centrality<0 && !mcEvent)return kFALSE;
2381  Double_t addMarginZNA = (fDetectorCentrality==2 && fCentralityMax==10) ? 2.0 : 0.0; // For ZNA multiplicity goes up to 101%
2382 
2383  Int_t centralityC=0;
2384  if (fModCentralityClass == 0){
2385  centralityC= Int_t(centrality);
2386  if(centralityC >= (fCentralityMin*10) && centralityC < (fCentralityMax*10 + addMarginZNA))
2387  return kTRUE;
2388  else return kFALSE;
2389  }
2390  else if (fModCentralityClass == 1){
2391  centralityC= Int_t(centrality);
2392  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2393  return kTRUE;
2394  } else return kFALSE;
2395  }
2396  else if (fModCentralityClass == 2){
2397  centralityC= Int_t(centrality);
2398  if(centralityC >= fCentralityMin && centralityC < fCentralityMax){
2399  return kTRUE;
2400  } else return kFALSE;
2401  }
2402  Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
2403  Int_t PrimaryTracks10[11][2] =
2404  {
2405  {9999,9999}, // 0 //1550 changed to 9999 on 9 Dec
2406  {1210, 928}, // 10
2407  { 817, 658}, // 20
2408  { 536, 435}, // 30
2409  { 337, 276}, // 40
2410  { 197, 162}, // 50
2411  { 106, 100}, // 60
2412  { 51, 44}, // 70
2413  { 21, 18}, // 80
2414  { 0, 0}, // 90
2415  { 0, 0}// 100 // only max accessible
2416  };
2417  Int_t PrimaryTracksLHC11h10[11][2] =
2418  {
2419  {9999,9999}, // 0 //1550 changed to 9999 on 9 Dec
2420  { 985, 928}, // 10
2421  { 661, 658}, // 20
2422  { 434, 435}, // 30
2423  { 275, 276}, // 40
2424  { 173, 162}, // 50
2425  { 100, 100}, // 60
2426  { 42, 44}, // 70
2427  { 19, 18}, // 80
2428  { 0, 0}, // 90
2429  { 0, 0}// 100 // only max accessible
2430  };
2431  Int_t PrimaryTracksLHC15o10[11][2] =
2432  {
2433  {2500, 2700}, // 0-10% cent class max # of tracks: max value of the data distribution
2434  {1498, 1498}, // 0-10% cent class min # of tracks
2435  {1012, 1012}, // 10-20
2436  { 669, 669}, // 20-30
2437  { 423, 423}, // 30-40
2438  { 251, 251}, // 40-50
2439  { 136, 136}, // 50-60
2440  { 67, 67}, // 60-70
2441  { 28, 28}, // 70-80
2442  { 0, 0}, // 80-90% cent class min # of tracks
2443  { 0, 0} // not used
2444  };
2445  Int_t PrimaryTracksLHC10h5[21][2] =
2446  {
2447  {9999,9999}, // 0 ///1550 changed to 9999 on 9 Dec
2448  {1485,1168}, // 5
2449  {1210, 928}, // 10
2450  { 995, 795}, // 15
2451  { 817, 658}, // 20
2452  { 666, 538}, // 25
2453  { 536, 435}, // 30
2454  { 428, 350}, // 35
2455  { 337, 276}, // 40
2456  { 260, 214}, // 45
2457  { 197, 162}, // 50
2458  { 147, 125}, // 55
2459  { 106, 100}, // 60
2460  { 75, 63}, // 65
2461  { 51, 44}, // 70
2462  { 34, 29}, // 75
2463  { 21, 18}, // 80
2464  { 13, 11}, // 85
2465  { 6, 6}, // 90
2466  { 3, 3}, // 95
2467  { 0, 0} // 100 only max accessible
2468  };
2469  Int_t PrimaryTracksLHC11h5[21][2] =
2470  {
2471  {9999,9999}, // 0 ///1550 changed to 9999 on 9 Dec
2472  {1166,1168}, // 5
2473  { 953, 928}, // 10
2474  { 805, 795}, // 15
2475  { 655, 658}, // 20
2476  { 535, 538}, // 25
2477  { 435, 435}, // 30
2478  { 349, 350}, // 35
2479  { 275, 276}, // 40
2480  { 214, 214}, // 45
2481  { 165, 162}, // 50
2482  { 127, 125}, // 55
2483  { 93, 100}, // 60
2484  { 64, 63}, // 65
2485  { 44, 44}, // 70
2486  { 30, 29}, // 75
2487  { 18, 18}, // 80
2488  { 11, 11}, // 85
2489  { 6, 6}, // 90
2490  { 3, 3}, // 95
2491  { 0, 0} // 100 only max accessible
2492  };
2493  Int_t PrimaryTracksLHC15o5[21][2] =
2494  {
2495  { 2500, 2700}, // 0-5% cent class max # of tracks: max value of the data distribution
2496  { 1827, 1827}, // 0-5% cent class min # of tracks
2497  { 1498, 1498}, // 5-10
2498  { 1234, 1234}, // 10-15
2499  { 1012, 1012}, // 15-20
2500  { 827, 827}, // 20-25
2501  { 669, 669}, // 25-30
2502  { 536, 536}, // 30-35
2503  { 423, 423}, // 35-40
2504  { 329, 329}, // 40-45
2505  { 251, 251}, // 45-50
2506  { 188, 188}, // 50-55
2507  { 136, 136}, // 55-60
2508  { 97, 97}, // 60-65
2509  { 67, 67}, // 65-70
2510  { 44, 44}, // 70-75
2511  { 28, 28}, // 75-80
2512  { 17, 17}, // 80-85
2513  { 10, 10}, // 85-90
2514  { 5, 5}, // 90-95 cent class minimum # of tracks
2515  { 0, 0} // 95-100
2516  };
2517  Int_t PrimaryTracksLHC17n10[11][2] =
2518  {
2519  {9999,9999}, // 0 // 1500 max in hist but set to real max
2520  { 800, 800}, // 10 // guess
2521  { 628, 628}, // 20
2522  { 350, 350}, // 30 // guess
2523  { 268, 268}, // 40
2524  { 200, 200}, // 50 // guess
2525  { 100, 100}, // 60 // guess
2526  { 51, 44}, // 70 // guess
2527  { 21, 18}, // 80 // guess
2528  { 0, 0}, // 90 // guess
2529  { 0, 0} // 100 // only max accessible
2530  };
2531 
2532  Int_t column = 0;
2533  if(event->IsA()==AliESDEvent::Class()) column = 0;
2534  if(event->IsA()==AliAODEvent::Class()) column = 1;
2535 
2536  if (fModCentralityClass == 3){
2537  if(mcEvent){
2538  // setting specific arry for LHC11h for MC track mult
2540  if(nprimaryTracks > PrimaryTracksLHC11h10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h10[fCentralityMin][column])
2541  return kTRUE;
2542  else return kFALSE;
2543  // setting specific arry for LHC17n for MC track mult
2544  } else if(fPeriodEnum == kLHC17j7 ){
2545  if(nprimaryTracks > PrimaryTracksLHC17n10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC17n10[fCentralityMin][column])
2546  return kTRUE;
2547  else return kFALSE;
2548  // settings for LHC15o MCs
2550  centralityC= Int_t(centrality/10);
2551  if(centralityC >= fCentralityMin && centralityC < fCentralityMax){
2552  if(fCentralityMin==0 && nprimaryTracks >= PrimaryTracksLHC15o10[0][column]) return kFALSE;
2553  else return kTRUE;
2554  } else return kFALSE;
2555  // setting specific arry for LHC10h for MC track mult
2556  } else {
2557  if(nprimaryTracks > PrimaryTracks10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracks10[fCentralityMin][column])
2558  return kTRUE;
2559  else return kFALSE;
2560  }
2561  }
2562  else{
2563  centralityC= Int_t(centrality/10);
2564  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2565  return kTRUE;
2566  else return kFALSE;
2567  }
2568  }
2569  else if (fModCentralityClass ==4){
2570  if(mcEvent){
2571  // setting specific arry for LHC11h for MC track mult
2573  if(nprimaryTracks > PrimaryTracksLHC11h5[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h5[fCentralityMin][column])
2574  return kTRUE;
2575  else return kFALSE;
2576  // settings for LHC15o MCs
2578  centralityC = Int_t(centrality);
2579  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2580  if(fCentralityMin==0 && nprimaryTracks >= PrimaryTracksLHC15o5[0][column]) return kFALSE;
2581  else return kTRUE;
2582  } else return kFALSE;
2583  // setting specific arry for LHC10h for MC track mult
2584  } else {
2585  if(nprimaryTracks > PrimaryTracksLHC10h5[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC10h5[fCentralityMin][column])
2586  return kTRUE;
2587  else return kFALSE;
2588  }
2589  }
2590  else{
2591  centralityC= Int_t(centrality);
2592  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2593  return kTRUE;
2594  } else return kFALSE;
2595  }
2596  }
2597 
2598  Int_t PrimaryTracksLHC11h10AltMin[11][2] =
2599  {
2600  {1550,1550}, // 0 - 0
2601  { 800, 800}, // 10 - 1
2602  { 600, 600}, // 20 - 2
2603  { 400, 400}, // 30 - 3
2604  { 240, 240}, // 40 - 4
2605  { 130, 130}, // 50 - 5
2606  { 90, 90}, // 60 - 6
2607  { 35, 35}, // 70 - 7
2608  { 15, 15}, // 80 - 8
2609  { 5, 5}, // 90 - 9
2610  { 0, 0} // 100 // only max accessible
2611  };
2612  Int_t PrimaryTracksLHC11h10AltMax[11][2] =
2613  {
2614  {1550,1550}, // 0 //1550 changed to 9999 on 9 Dec
2615  {1000,1000}, // 10
2616  { 700, 700}, // 20
2617  { 480, 480}, // 30
2618  { 300, 300}, // 40
2619  { 200, 200}, // 50
2620  { 120, 120}, // 60
2621  { 50, 50}, // 70
2622  { 22, 22}, // 80
2623  { 10, 10}, // 90
2624  { 0, 0} // 100 // only max accessible
2625  };
2626  Int_t PrimaryTracksLHC11h5AltMin[21][2] =
2627  {
2628  {1550,1550}, // 0
2629  {1000,1000}, // 5
2630  { 800, 800}, // 10
2631  { 700, 700}, // 15
2632  { 600, 600}, // 20
2633  { 500, 500}, // 25
2634  { 400, 400}, // 30
2635  { 300, 300}, // 35
2636  { 240, 240}, // 40
2637  { 180, 180}, // 45
2638  { 130, 130}, // 50
2639  { 127, 125}, // 55
2640  { 90, 90}, // 60
2641  { 55, 55}, // 65
2642  { 35, 35}, // 70
2643  { 25, 25}, // 75
2644  { 15, 15}, // 80
2645  { 11, 11}, // 85
2646  { 5, 5}, // 90
2647  { 0, 0}, // 95
2648  { 0, 0} // 100 only max accessible
2649  };
2650  Int_t PrimaryTracksLHC11h5AltMax[21][2] =
2651  {
2652  {1550,1550}, // 0
2653  {1250,1250}, // 5
2654  {1000,1000}, // 10
2655  { 805, 795}, // 15
2656  { 700, 700}, // 20
2657  { 585, 585}, // 25
2658  { 480, 480}, // 30
2659  { 380, 380}, // 35
2660  { 300, 300}, // 40
2661  { 235, 235}, // 45
2662  { 200, 200}, // 50
2663  { 140, 140}, // 55
2664  { 120, 120}, // 60
2665  { 70, 70}, // 65
2666  { 50, 50}, // 70
2667  { 35, 25}, // 75
2668  { 22, 22}, // 80
2669  { 15, 15}, // 85
2670  { 10, 10}, // 90
2671  { 5, 5}, // 95
2672  { 0, 0} // 100 only max accessible
2673  };
2674 
2675  if (fModCentralityClass == 5){
2676  if(mcEvent){
2677  // setting specific arry for LHC11h for MC track mult
2679  if(nprimaryTracks > PrimaryTracksLHC11h10AltMin[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h10AltMax[fCentralityMin][column])
2680  return kTRUE;
2681  else return kFALSE;
2682  // default return
2683  } else {
2684  return kFALSE;
2685  }
2686  } else {
2687  centralityC= Int_t(centrality/10);
2688  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2689  return kTRUE;
2690  else return kFALSE;
2691  }
2692  }
2693  else if (fModCentralityClass ==6){
2694  if(mcEvent){
2695  // setting specific arry for LHC11h for MC track mult
2697  if(nprimaryTracks > PrimaryTracksLHC11h5AltMin[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h5AltMax[fCentralityMin][column])
2698  return kTRUE;
2699  else return kFALSE;
2700  } else {
2701  return kFALSE;
2702  }
2703  } else{
2704  centralityC= Int_t(centrality);
2705  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2706  return kTRUE;
2707  } else return kFALSE;
2708  }
2709  }
2710 
2711  return kFALSE;
2712 }
2713 
2714 //________________________________________________________________________
2716  // Cut on z position of primary vertex
2717  Double_t fVertexZ=event->GetPrimaryVertex()->GetZ();
2718  Double_t fVertexZSPD = 0;
2719  AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2720  if(fESDEvent){
2721  fVertexZSPD = fESDEvent->GetPrimaryVertexSPD()->GetZ();
2722  }
2723  AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2724  if(fAODEvent){
2725  fVertexZSPD = fAODEvent->GetPrimaryVertexSPD()->GetZ();
2726  }
2727 
2728  if(TMath::Abs(fVertexZ)>fMaxVertexZ)return kFALSE;
2729 
2730 
2731  if (fPeriodEnum == kLHC11h){
2732  if (TMath::Abs(fVertexZ-fVertexZSPD) > 0.1) return kFALSE;
2733  }
2734  if (fIsHeavyIon == 2){
2735  if(!fUtils->IsVertexSelected2013pA(event)) return kFALSE;
2736  }
2737 
2738  return kTRUE;
2739 }
2740 
2741 //________________________________________________________________________
2743 {
2745  return kFALSE;
2746  TBits fIR1 = event->GetHeader()->GetIRInt1InteractionMap(); // IR1 contains V0 information (VIR)
2747  TBits fIR2 = event->GetHeader()->GetIRInt2InteractionMap(); // IR2 contains T0 information
2748  UShort_t bunchCrossings = event->GetBunchCrossNumber();
2750  for(Int_t i = 0; i<180;i++){
2751  if(fIR1.TestBitNumber(i))
2752  fHistoPastFutureBits->Fill((i*25)-90*25);
2753  }
2754  }
2755 
2756  Bool_t isOutOfBunchPileup = 0;
2757  Int_t pf1 = fPastFutureRejectionLow +bunchCrossings%4;
2758  Int_t pf2 = fPastFutureRejectionHigh+bunchCrossings%4;
2759  if(pf1 < -89) pf1 = -89;
2760  if(pf2 > 89) pf2 = 89;
2761  Int_t pf2maxForT0 = pf2;
2762  Int_t ir1skip = 0;
2763  for (Int_t i=pf1;i<=pf2;i++) {
2764  if (i==0) continue;
2765  if (i<=pf2maxForT0) isOutOfBunchPileup|=fIR2.TestBitNumber(90+i); // T0-based clean-up
2766  if (i>0 && i<=ir1skip) continue; // skip next 2 for old IR definitions
2767  isOutOfBunchPileup|=fIR1.TestBitNumber(90+i); // V0-based clean-up
2768  }
2769  return isOutOfBunchPileup;
2770 }
2771 //________________________________________________________________________
2772 
2774 {
2775  Bool_t isPileUpV0MTPCout=0;
2776 
2777  Double_t multV0M;
2778  Double_t valFunc;
2779  if (fIsHeavyIon==2){
2780  multV0M = event->GetVZEROData()->GetMTotV0A();
2781  }else{
2782  multV0M = event->GetVZEROData()->GetMTotV0A() + event->GetVZEROData()->GetMTotV0C() ;
2783  }
2784 
2785  if ( fFPileUpRejectV0MTPCout != 0x0 ){
2786  valFunc= fFPileUpRejectV0MTPCout->Eval(((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfTPCoutTracks());
2787  if (multV0M < valFunc ) isPileUpV0MTPCout=1;
2788  }
2789 
2790  return isPileUpV0MTPCout;
2791 
2792 }
2793 //________________________________________________________________________
2795  // returns number of contributors to the vertex
2796 
2797  AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2798  if(fESDEvent){
2799  if (fESDEvent->GetPrimaryVertex() != NULL){
2800  if(fESDEvent->GetPrimaryVertex()->GetNContributors()>0) {
2801  // cout << "accepted global" << fESDEvent->GetEventNumberInFile() << " with NCont: " << fESDEvent->GetPrimaryVertex()->GetNContributors() << endl;
2802  return fESDEvent->GetPrimaryVertex()->GetNContributors();
2803  }
2804  }
2805 
2806  if(fESDEvent->GetPrimaryVertexSPD() !=NULL){
2807  if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2808  // cout << "accepted SPD" << fESDEvent->GetEventNumberInFile() << " with NCont: " << fESDEvent->GetPrimaryVertexSPD()->GetNContributors() << endl;
2809  return fESDEvent->GetPrimaryVertexSPD()->GetNContributors();
2810  }else {
2811  AliWarning(Form("Number of contributors from bad vertex type:: %s",fESDEvent->GetPrimaryVertex()->GetName()));
2812  // cout << "rejected " << fESDEvent->GetEventNumberInFile() << endl;
2813  return 0;
2814  }
2815  }
2816  }
2817 
2818  AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2819  if(fAODEvent){
2820  if (fAODEvent->GetPrimaryVertex() != NULL){
2821  if(fAODEvent->GetPrimaryVertex()->GetNContributors()>0) {
2822  return fAODEvent->GetPrimaryVertex()->GetNContributors();
2823  }
2824  }
2825  if(fAODEvent->GetPrimaryVertexSPD() !=NULL){
2826  if(fAODEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2827  return fAODEvent->GetPrimaryVertexSPD()->GetNContributors();
2828  } else {
2829  AliWarning(Form("Number of contributors from bad vertex type:: %s",fAODEvent->GetPrimaryVertex()->GetName()));
2830  return 0;
2831  }
2832  }
2833  }
2834  // cout << "rejected " << fESDEvent->GetEventNumberInFile() << endl;
2835  return 0;
2836 }
2837 
2838 //________________________________________________________________________
2839 // Analysing Jet-Jet MC's
2840 //________________________________________________________________________
2841 Bool_t AliConvEventCuts::IsJetJetMCEventAccepted(AliMCEvent *mcEvent, Double_t& weight, AliVEvent* event ){
2842  AliGenCocktailEventHeader *cHeader = 0x0;
2843  Bool_t headerFound = kFALSE;
2844  weight = -1;
2845  fMaxPtJetMC = 0;
2846 
2847  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
2848  fPeriodEnum != kLHC17i3a1 && // LHC16ijklop GammaJet MC EMCal triggered
2849  fPeriodEnum != kLHC17i3c1 && // LHC16ijklop JetJet MC EMCal triggered
2850  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2851  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
2852  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2853  fPeriodEnum != kLHC17P1JJ && fPeriodEnum != kLHC17P1JJLowB && // LHC17X Jet Jet MC's
2854  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2855  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2856  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2857  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2858  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2859  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
2860  ){
2861 
2862  weight = 1;
2863  return kTRUE;
2864  }
2865 
2866  if(mcEvent){
2867  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2868  if(cHeader) headerFound = kTRUE;
2869  }else{
2870  //no mcEvent available -> not running on MC
2871  weight = 1;
2872  return kTRUE;
2873  }
2874 
2875  if(headerFound){
2876  TList *genHeaders = 0x0;
2877  if(cHeader) genHeaders = cHeader->GetHeaders();
2878  AliGenEventHeader* gh = 0;
2879  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2880  gh = (AliGenEventHeader*)genHeaders->At(i);
2881  TString GeneratorName = gh->GetName();
2882  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2883  Bool_t eventAccepted = kTRUE;
2884  TParticle * jet = 0;
2885  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(gh)->NTriggerJets();
2886  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
2887  Float_t tmpjet[]={0,0,0,0};
2888  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2889  dynamic_cast<AliGenPythiaEventHeader*>(gh)->TriggerJet(ijet, tmpjet);
2890  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2891  //Compare jet pT and pt Hard
2892  if(jet->Pt() > fMaxFacPtHard * ptHard){
2893  eventAccepted= kFALSE;
2894  }
2895  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2896  }
2897  if (jet) delete jet;
2898  if (mcEvent){
2899  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2900  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2901  if (!particle) continue;
2902  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2903  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2904  eventAccepted= kFALSE;
2905  }
2906  }
2907 
2908  }
2909  }
2910 
2912  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2913  21, 28, 36, 45, 57,
2914  70, 85, 99, 115, 132,
2915  150, 169, 190, 212, 235,
2916  1000000};
2917  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2918  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2919  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2920  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2921  Int_t bin = 0;
2922  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2923  if (bin < 20) weight = weightsBins[bin];
2924 
2925  } else if ( fPeriodEnum == kLHC16P1JJ || fPeriodEnum == kLHC17P1JJ ){
2926  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2927  21, 28, 36, 45, 57,
2928  70, 85, 99, 115, 132,
2929  150, 169, 190, 212, 235,
2930  1000000};
2931  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2932  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2933  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2934  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2935 
2936  Int_t bin = 0;
2937  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2938  if (bin < 20) weight = weightsBins[bin];
2939 
2940  } else if ( fPeriodEnum == kLHC16h3 ){
2941  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2942  21, 28, 36, 45, 57,
2943  70, 85, 99, 115, 132,
2944  150, 169, 190, 212, 235,
2945  1000000};
2946  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2947  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2948  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2949  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2950  Int_t bin = 0;
2951  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2952  if (bin < 20) weight = weightsBins[bin];
2953 
2954 
2955  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2956  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2957  21, 28, 36, 45, 57,
2958  70, 85, 1000};
2959  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2960  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2961  1.933238e-05, 1.562895e-05};
2962  Int_t bin = 0;
2963  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2964  if (bin < 12) weight = weightsBins[bin];
2965 
2966  } else if ( fPeriodEnum == kLHC15g1a ){
2967  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2968  84, 117, 152, 191, 1000000,
2969  5, 7, 9, 12, 16,
2970  21, 28, 36, 45, 57 };
2971  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2972  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2973  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2974  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2975 
2976  Int_t bin = 0;
2977  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2978  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2979  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2980  if (bin < 19) weight = weightsBins[bin];
2981 
2982  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2983  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2984  84, 117, 152, 191, 1000000,
2985  5, 7, 9, 12, 16,
2986  21, 28, 36, 45, 57 };
2987  // LHC15a3a
2988  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2989  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2990  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2991  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2992  Int_t bin = 0;
2993  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2994  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2995  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2996  if (bin < 19) weight = weightsBins[bin];
2997 
2998  } else if ( fPeriodEnum == kLHC12P2JJ ){
2999  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
3000  21, 28, 36, 45, 57,
3001  70, 85, 99, 115, 132,
3002  150, 169, 190, 212, 235,
3003  1000000};
3004  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
3005  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
3006  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
3007  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
3008  Int_t bin = 0;
3009  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3010  if (bin < 20) weight = weightsBins[bin];
3011 
3012  } else if ( fPeriodEnum == kLHC16c3a ){ // ALIROOT-5901
3013  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
3014  Double_t weightsBins[5] = { 6.731200e-03, 7.995602e-03, 6.778717e-03, 4.643571e-03, 6.014497e-03}; //preliminary estimates
3015  Int_t bin = 0;
3016  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3017  if (bin < 5) weight = weightsBins[bin];
3018 
3019  } else if (fPeriodEnum == kLHC16c3b ){ // ALIROOT-5901
3020  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
3021  Double_t weightsBins[6] = { 6.071458e-03, 3.941701e-03, 2.001984e-03, 9.862765e-04, 3.893911e-04, 1.865924e-04}; //preliminary estimates
3022  Int_t bin = 0;
3023  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3024  if (bin < 6) weight = weightsBins[bin];
3025 
3026  } else if (fPeriodEnum == kLHC16c3c ){ // ALIROOT-5901
3027  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
3028  Double_t weightsBins[7] = { 0.00151999, 0.000100346, 1.27688e-05, 1.82388e-06, 3.08506e-07, 6.00308e-08, 1.88414e-08}; //preliminary estimates
3029  Int_t bin = 0;
3030  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3031  if (bin < 7) weight = weightsBins[bin];
3032 
3033  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
3034  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
3035  84, 117, 152, 191, 234,
3036  1000};
3037  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
3038  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
3039  Int_t bin = 0;
3040  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3041  if (bin < 10) weight = weightsBins[bin];
3042  } else if ( fPeriodEnum == kLHC17g8a ){ // preliminary weights obtained from local running
3043  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16, 21, 28, 36, 45, 57, 70, 85, 99, 115, 132, 150, 169, 190, 212, 235, 10000};
3044  Double_t weightsBins[20] = {1.565930E+01, 4.598350E+00, 2.081240E+00, 7.744650E-01, 2.644240E-01, 1.002330E-01, 2.979190E-02, 9.696490E-03, 3.950930E-03, 1.333040E-03, 5.210630E-04, 1.927180E-04, 9.235930E-05, 4.346820E-05, 2.120660E-05, 1.073260E-05, 5.701210E-06, 3.047490E-06, 1.664780E-06, 2.123400E-06};
3045  Int_t bin = 0;
3046  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3047  if (bin < 20) weight = weightsBins[bin];
3048  } else if ( fPeriodEnum == kLHC16rP1JJ ){ // preliminary weights obtained from local running
3049  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16, 21, 28, 36, 45, 57, 70, 85, 99, 115, 132, 150, 169, 190, 212, 235, 10000};
3050  Double_t weightsBins[20] = {2.723740E+01, 8.127540E+00, 3.934400E+00, 1.492720E+00, 5.268010E-01, 2.033790E-01, 6.361520E-02, 2.256080E-02, 9.638840E-03, 3.372890E-03, 1.381980E-03, 5.121390E-04, 2.613120E-04, 1.260940E-04, 6.393150E-05, 3.386080E-05, 1.926040E-05, 1.046950E-05, 5.895950E-06, 8.658420E-06};
3051  Int_t bin = 0;
3052  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3053  if (bin < 20) weight = weightsBins[bin];
3054  } else if ( fPeriodEnum == kLHC16sP1JJ ){ // preliminary weights obtained from local running
3055  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16, 21, 28, 36, 45, 57, 70, 85, 99, 115, 132, 150, 169, 190, 212, 235, 10000};
3056  Double_t weightsBins[20] = {2.716550E+01, 8.121430E+00, 3.932100E+00, 1.492830E+00, 5.272190E-01, 2.023090E-01, 6.371860E-02, 2.245360E-02, 9.590340E-03, 3.369300E-03, 1.384470E-03, 5.119390E-04, 2.606910E-04, 1.259110E-04, 6.408650E-05, 3.396290E-05, 1.917340E-05, 1.044610E-05, 5.882680E-06, 8.672390E-06};
3057  Int_t bin = 0;
3058  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3059  if (bin < 20) weight = weightsBins[bin];
3060  } else if ( fPeriodEnum == kLHC17i3a1 ){ // weights obtained from ga_pp_mc_aod train 912
3061  Double_t ptHardBinRanges[7] = { 5, 11, 21, 36, 57, 84, 10000};
3062  Double_t weightsBins[6] = { 0.0002181, 3.13684e-05, 5.01515e-06, 9.50662e-07, 2.08186e-07, 7.96555e-08};
3063  Int_t bin = 0;
3064  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3065  if (bin < 6) weight = weightsBins[bin];
3066  } else if ( fPeriodEnum == kLHC17i3c1 ){ // preliminary weights obtained from local running
3067  Double_t ptHardBinRanges[9] = { 8, 10, 14, 19, 26, 35, 48, 66, 10000};
3068  Double_t weightsBins[8] = { 0.000813592, 0.00172074, 0.00187963, 0.00184331, 0.00142672, 0.0010083, 0.000599846, 0.000499877};
3069  Int_t bin = 0;
3070  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3071  if (bin < 8) weight = weightsBins[bin];
3072  } else {
3073  weight = 1;
3074  }
3075 
3076  if (weight == -1) return kFALSE;
3077  else return eventAccepted;
3078 
3079  }
3080  }
3081  } else {
3082  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
3083  TString eventHeaderName = eventHeader->ClassName();
3084  Bool_t eventAccepted = kFALSE;
3085  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
3086  eventAccepted = kTRUE;
3087  }else { //special case for pythia8jets embedded in EPOSLHC for AODs
3088  if(event->IsA()==AliAODEvent::Class()){
3089  AliAODMCHeader *mch = NULL;
3090  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
3091  if(aod){
3092  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
3093  if ( mch ){
3094  Int_t nGenerators = mch->GetNCocktailHeaders();
3095  if ( nGenerators > 0 ){
3096  for(Int_t igen = 0; igen < nGenerators; igen++)
3097  {
3098  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
3099  TString name = eventHeaderGen->GetName();
3100  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
3101  eventAccepted = kTRUE;
3102  eventHeader = eventHeaderGen;
3103  }
3104  }
3105  }
3106  }
3107  }
3108  }
3109  }
3110  if(eventAccepted){
3111  TParticle * jet = 0;
3112  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->NTriggerJets();
3113  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
3114  Float_t tmpjet[]={0,0,0,0};
3115  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
3116  dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->TriggerJet(ijet, tmpjet);
3117  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
3118  //Compare jet pT and pt Hard
3119  if(jet->Pt() > fMaxFacPtHard * ptHard){
3120  eventAccepted= kFALSE;
3121  }
3122  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
3123  }
3124  if (mcEvent){
3125  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
3126  TParticle* particle = (TParticle *)mcEvent->Particle(i);
3127  if (!particle) continue;
3128  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
3129  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
3130  eventAccepted= kFALSE;
3131  }
3132  }
3133 
3134  }
3135  }
3136 
3138  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
3139  21, 28, 36, 45, 57,
3140  70, 85, 99, 115, 132,
3141  150, 169, 190, 212, 235,
3142  1000000};
3143  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
3144  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
3145  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
3146  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
3147  Int_t bin = 0;
3148  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3149  if (bin < 20) weight = weightsBins[bin];
3150 
3151  } else if ( fPeriodEnum == kLHC16P1JJ || fPeriodEnum == kLHC17P1JJ){
3152  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
3153  21, 28, 36, 45, 57,
3154  70, 85, 99, 115, 132,
3155  150, 169, 190, 212, 235,
3156  1000000};
3157  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
3158  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
3159  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
3160  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
3161 
3162  Int_t bin = 0;
3163  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3164  if (bin < 20) weight = weightsBins[bin];
3165 
3166  } else if ( fPeriodEnum == kLHC16h3 ){
3167  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
3168  21, 28, 36, 45, 57,
3169  70, 85, 99, 115, 132,
3170  150, 169, 190, 212, 235,
3171  1000000};
3172  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
3173  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
3174  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
3175  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
3176  Int_t bin = 0;
3177  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3178  if (bin < 20) weight = weightsBins[bin];
3179 
3180 
3181  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
3182  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
3183  21, 28, 36, 45, 57,
3184  70, 85, 1000};
3185  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
3186  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
3187  1.933238e-05, 1.562895e-05};
3188  Int_t bin = 0;
3189  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3190  if (bin < 12) weight = weightsBins[bin];
3191 
3192  } else if ( fPeriodEnum == kLHC15g1a ){
3193  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
3194  84, 117, 152, 191, 1000000,
3195  5, 7, 9, 12, 16,
3196  21, 28, 36, 45, 57 };
3197  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
3198  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
3199  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
3200  0.0307759, 0.0087083, 0.0027664, 0.00106203};
3201 
3202  Int_t bin = 0;
3203  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
3204  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
3205  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3206  if (bin < 19) weight = weightsBins[bin];
3207 
3208  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
3209  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
3210  84, 117, 152, 191, 1000000,
3211  5, 7, 9, 12, 16,
3212  21, 28, 36, 45, 57 };
3213  // LHC15a3a
3214  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
3215  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
3216  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
3217  0.0307638, 0.00870635, 0.00276658, 0.00106229};
3218  Int_t bin = 0;
3219  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
3220  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
3221  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3222  if (bin < 19) weight = weightsBins[bin];
3223 
3224  } else if ( fPeriodEnum == kLHC12P2JJ ){
3225  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
3226  21, 28, 36, 45, 57,
3227  70, 85, 99, 115, 132,
3228  150, 169, 190, 212, 235,
3229  1000000};
3230  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
3231  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
3232  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
3233  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
3234  Int_t bin = 0;
3235  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3236  if (bin < 20) weight = weightsBins[bin];
3237 
3238  } else if ( fPeriodEnum == kLHC16c3a ){ //ALIROOT-5901
3239  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
3240  Double_t weightsBins[5] = { 6.731200e-03, 7.995602e-03, 6.778717e-03, 4.643571e-03, 6.014497e-03}; //preliminary estimates
3241  Int_t bin = 0;
3242  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3243  if (bin < 5) weight = weightsBins[bin];
3244 
3245  } else if (fPeriodEnum == kLHC16c3b ){ //ALIROOT-5901
3246  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
3247  Double_t weightsBins[6] = { 6.071458e-03, 3.941701e-03, 2.001984e-03, 9.862765e-04, 3.893911e-04, 1.865924e-04}; //preliminary estimates
3248  Int_t bin = 0;
3249  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3250  if (bin < 6) weight = weightsBins[bin];
3251 
3252  } else if (fPeriodEnum == kLHC16c3c ){ //ALIROOT-5901
3253  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
3254  Double_t weightsBins[7] = { 0.00151999, 0.000100346, 1.27688e-05, 1.82388e-06, 3.08506e-07, 6.00308e-08, 1.88414e-08}; //preliminary estimates
3255  Int_t bin = 0;
3256  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3257  if (bin < 7) weight = weightsBins[bin];
3258 
3259  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
3260  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
3261  84, 117, 152, 191, 234,
3262  1000};
3263  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
3264  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
3265  Int_t bin = 0;
3266  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3267  if (bin < 10) weight = weightsBins[bin];
3268  } else if ( fPeriodEnum == kLHC16rP1JJ ){ // preliminary weights obtained from local running
3269  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16, 21, 28, 36, 45, 57, 70, 85, 99, 115, 132, 150, 169, 190, 212, 235, 10000};
3270  Double_t weightsBins[20] = {2.723740E+01, 8.127540E+00, 3.934400E+00, 1.492720E+00, 5.268010E-01, 2.033790E-01, 6.361520E-02, 2.256080E-02, 9.638840E-03, 3.372890E-03, 1.381980E-03, 5.121390E-04, 2.613120E-04, 1.260940E-04, 6.393150E-05, 3.386080E-05, 1.926040E-05, 1.046950E-05, 5.895950E-06, 8.658420E-06};
3271  Int_t bin = 0;
3272  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3273  if (bin < 20) weight = weightsBins[bin];
3274  } else if ( fPeriodEnum == kLHC16sP1JJ ){ // preliminary weights obtained from local running
3275  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16, 21, 28, 36, 45, 57, 70, 85, 99, 115, 132, 150, 169, 190, 212, 235, 10000};
3276  Double_t weightsBins[20] = {2.716550E+01, 8.121430E+00, 3.932100E+00, 1.492830E+00, 5.272190E-01, 2.023090E-01, 6.371860E-02, 2.245360E-02, 9.590340E-03, 3.369300E-03, 1.384470E-03, 5.119390E-04, 2.606910E-04, 1.259110E-04, 6.408650E-05, 3.396290E-05, 1.917340E-05, 1.044610E-05, 5.882680E-06, 8.672390E-06};
3277  Int_t bin = 0;
3278  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3279  if (bin < 20) weight = weightsBins[bin];
3280  } else if ( fPeriodEnum == kLHC17i3a1 ){ // weights obtained from ga_pp_mc_aod train 912
3281  Double_t ptHardBinRanges[7] = { 5, 11, 21, 36, 57, 84, 10000};
3282  Double_t weightsBins[6] = { 0.0002181, 3.13684e-05, 5.01515e-06, 9.50662e-07, 2.08186e-07, 7.96555e-08};
3283  Int_t bin = 0;
3284  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3285  if (bin < 6) weight = weightsBins[bin];
3286  } else if ( fPeriodEnum == kLHC17i3c1 ){ // preliminary weights obtained from local running
3287  Double_t ptHardBinRanges[9] = { 8, 10, 14, 19, 26, 35, 48, 66, 10000};
3288  Double_t weightsBins[8] = { 0.000813592, 0.00172074, 0.00187963, 0.00184331, 0.00142672, 0.0010083, 0.000599846, 0.000499877};
3289  Int_t bin = 0;
3290  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3291  if (bin < 8) weight = weightsBins[bin];
3292  } else if ( fPeriodEnum == kLHC18b8 ){
3293  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16, 21, 28, 36, 45, 57, 70, 85, 99, 115, 132, 150, 169, 190, 212, 235, 10000};
3294  Double_t weightsBins[20] = { 16.1083, 4.60917, 2.15196, 0.782021, 0.26541,
3295  0.0978374, 0.0294286, 0.00989457, 0.0040615, 0.00135787,
3296  0.000531766, 0.000188772, 9.23331e-05, 4.30245e-05, 2.10196e-05,
3297  1.06695e-05, 5.78742e-06, 3.02897e-06, 1.62702e-06, 2.12118e-06 };
3298 
3299  Int_t bin = 0;
3300  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3301  if (bin < 20) weight = weightsBins[bin];
3302  } else {
3303  weight = 1;
3304  }
3305 
3306  if (weight == -1) return kFALSE;
3307  else return eventAccepted;
3308 
3309  } else {
3310  return kFALSE;
3311  }
3312  }
3313 
3314  return kFALSE;
3315 }
3316 
3317 //________________________________________________________________________
3318 // Analysing Jet-Jet MC's
3319 //________________________________________________________________________
3320 void AliConvEventCuts::GetXSectionAndNTrials(AliMCEvent *mcEvent, Float_t &XSection, Float_t &NTrials, AliVEvent* event){
3321 
3322  AliGenCocktailEventHeader *cHeader = 0x0;
3323  Bool_t headerFound = kFALSE;
3324  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
3325  fPeriodEnum != kLHC17i3a1 && // LHC16ijklop GammaJet MC EMCal triggered
3326  fPeriodEnum != kLHC17i3c1 && // LHC16ijklop JetJet MC EMCal triggered
3327  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
3328  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
3329  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
3330  fPeriodEnum != kLHC17P1JJ && fPeriodEnum != kLHC17P1JJLowB && // LHC17X Jet Jet MC's
3331  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
3332  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
3333  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
3334  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
3335  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
3336  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
3337  ){
3338  NTrials = -1;
3339  XSection = -1;
3340  return;
3341  }
3342 
3343  if(mcEvent){
3344  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
3345  if(cHeader) headerFound = kTRUE;
3346  }else{
3347  //no mcEvent available -> not running on MC
3348  NTrials = -1;
3349  XSection = -1;
3350  return;
3351  }
3352 
3353  if(headerFound){
3354  TList *genHeaders = 0x0;
3355  if(cHeader) genHeaders = cHeader->GetHeaders();
3356  AliGenEventHeader* gh = 0;
3357  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3358  gh = (AliGenEventHeader*)genHeaders->At(i);
3359  TString GeneratorName = gh->GetName();
3360  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
3361  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(gh);
3362  NTrials = gPythia->Trials();
3363  XSection = gPythia->GetXsection();
3364  return;
3365  }
3366  }
3367  } else {
3368  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
3369  if(eventHeader){
3370  TString eventHeaderName = eventHeader->ClassName();
3371  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
3372  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader);
3373  NTrials = gPythia->Trials();
3374  XSection = gPythia->GetXsection();
3375  return;
3376  }
3377  }
3378  }
3379  // the following part is necessary for pythia8jets embedded in EPOS for AODs
3380  if(event){
3381  if(event->IsA()==AliAODEvent::Class()){
3382  AliAODMCHeader *mch = NULL;
3383  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
3384  if(aod){
3385  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
3386  if ( mch ){
3387  Int_t nGenerators = mch->GetNCocktailHeaders();
3388  if ( nGenerators > 0 ){
3389  for(Int_t igen = 0; igen < nGenerators; igen++){
3390  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
3391  TString name = eventHeaderGen->GetName();
3392  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
3393  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeaderGen);
3394  NTrials = gPythia->Trials();
3395  XSection = gPythia->GetXsection();
3396  return;
3397  }
3398  }
3399  }
3400  }
3401  }
3402  }
3403  }
3404 
3405  NTrials = -1;
3406  XSection = -1;
3407  return;
3408 }
3409 
3410 
3411 //________________________________________________________________________
3412 // Analysing Jet-Jet MC's
3413 //________________________________________________________________________
3414 Float_t AliConvEventCuts::GetPtHard(AliMCEvent *mcEvent, AliVEvent* event){
3415  AliGenCocktailEventHeader *cHeader = 0x0;
3416  Bool_t headerFound = kFALSE;
3417 
3418  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
3419  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
3420  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
3421  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
3422  fPeriodEnum != kLHC17P1JJ && fPeriodEnum != kLHC17P1JJLowB && // LHC17X Jet Jet MC's
3423  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
3424  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
3425  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
3426  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
3427  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
3428  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
3429  ) return -1;
3430 
3431  if(mcEvent){
3432  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
3433  if(cHeader) headerFound = kTRUE;
3434  }else{
3435  //no mcEvent available -> not running on MC
3436  return -1;
3437  }
3438 
3439  if(headerFound){
3440  TList *genHeaders = 0x0;
3441  if(cHeader) genHeaders = cHeader->GetHeaders();
3442  AliGenEventHeader* gh = 0;
3443  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3444  gh = (AliGenEventHeader*)genHeaders->At(i);
3445  TString GeneratorName = gh->GetName();
3446  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
3447  return dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
3448  }
3449  }
3450  } else {
3451  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
3452  if(eventHeader){
3453  TString eventHeaderName = eventHeader->ClassName();
3454  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
3455  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
3456  }
3457  }
3458 
3459  if(event->IsA()==AliAODEvent::Class()){
3460  AliAODMCHeader *mch = NULL;
3461  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
3462  if(aod){
3463  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
3464  if ( mch ){
3465  Int_t nGenerators = mch->GetNCocktailHeaders();
3466  if ( nGenerators > 0 ){
3467  for(Int_t igen = 0; igen < nGenerators; igen++)
3468  {
3469  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
3470  TString name = eventHeaderGen->GetName();
3471  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
3472  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeaderGen)->GetPtHard();
3473  }
3474  }
3475  }
3476  }
3477  }
3478  }
3479  }
3480 
3481  return -1;
3482 }
3483 
3484 
3485 //________________________________________________________________________
3487  // abort if mimicing not enabled
3488 
3489  if (!fMimicTrigger) return kTRUE;
3490 
3491  Int_t runRangesEMCalL0 [52] = { 144871, 145288, 146375, 146382, // LHC11a
3492  146502, 148522, // LHC11a
3493  150209, 153056, 153911, 153915, // LHC11b,c,d
3494  158135, 158136, 158178, 158182, 160683,
3495  160764, 161139, 161256, 161379, 161457,
3496  161525, 161556, 161558, 161609, 161630,
3497  161724, // LHC11d,e
3498  173731, 177144, 177147, 177653, 177724, 178327, // LHC12x
3499  195180, // LHC13b-f
3500  197469, 197692, // LHC13g
3501  235195, // LHC15a-h
3502  244285, // LHC15i-LHC15m (235196-244284)
3503  244629, // LHC15n (244340-244628)
3504  245141, 246995, // LHC15o (244824-246994)
3505  255539, // LHC16i-k (255515-258574)
3506  258883, // LHC16l (258883-260187)
3507  260216, // LHC16m-p (260216-p)
3508  265015, 265309, // LHC16q (265015-265525)
3509  265589, 265785, // LHC16r (265589-266318)
3510  266405, // LHC16s (266405-267131)
3511  267161, // LHC16t (267161-267166)
3512  270531, // LHC17c-o (270531-281961)
3513  282008, // LHC17pq (282008-282441)
3514  282504 // 2018
3515  };
3516 
3517  Double_t thresholdEMCalL0[51] = { 2.11, 3.43, 1.71, 2.05, // LHC11a 7 TeV
3518  3.43, // LHC11a 2.76TeV
3519  1.94, 3.39, 4.01, 5.25, 5.5, // LHC11b, LHC11c, LHC11d
3520  2.05, 5.50, 2.05, 5.50, 2.05, 1.71, 5.50, 1.71, 5.50, 1.71, 5.50, 1.71, 5.50, 1.71, 5.50, 1.71,
3521  2.01, 1.75, 1.52, 2.01, 1.52, 1.85,
3522  3.2,
3523  /*2.01*/1.8, // LHC13g
3524  2000, // LS1
3525  1.8, // LHC15a-h
3526  5.0, // LHC15i-m
3527  5.0, // LHC15n
3528  1.0, 1.0, // LHC15o
3529  2.2, // LHC16i-k (255515-258574)
3530  2.2, // LHC16l (258883-260187)
3531  2.5, // LHC16m-p (260216-p)
3532  2.5, 2.5, // LHC16q (265015-265525)
3533  2.5, 2.5, // LHC16r (265589-266318)
3534  3.5, // LHC16s (266405-267131)
3535  2.5, // LHC16t (267161-267166)
3536  2.5, // LHC17c-o (270531-281961)
3537  2.5 // LHC17pq (282008-282441)
3538 // 2.5 // 2018
3539  };
3540 
3541  Double_t spreadEMCalL0[51] = { 0., 0., 0, 0, // LHC11a 7TeV
3542  /*0.7*/0.65, // LHC11a 2.76TeV
3543  0., 0., 0., 0., 0., // LHC11b, LHC11c, LHC11d
3544  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
3545  0., 0., 0., 0., 0.2, 0.2,/*0.,0.,*/
3546  0.1, // LHC13b-f
3547  /*0.1*/0.12, // LHC13g
3548  0., // LS1
3549  0.1, // LHC15a-h
3550  0.1, // LHC15i-m
3551  0.1, // LHC15n
3552  0.1, 0.1, // LHC15o
3553  0.2, // LHC16i-k (255515-258574)
3554  0.2, // LHC16l (258883-260187)
3555  0.1, // LHC16m-p (260216-p)
3556  0.1, 0.1, // LHC16q (265015-265525)
3557  0.1, 0.1, // LHC16r (265589-266318)
3558  0.1, // LHC16s (266405-267131)
3559  0.1, // LHC16t (267161-267166)
3560  0.1, // LHC17c-o (270531-281961)
3561  0.1 // LHC17pq (282008-282441)
3562 // 0.1 // 2018
3563  };
3564 
3565  Int_t runRangesEMCalL1[21] = { 179796, // LHC12c-i (EGA)
3566  195180, // LHC13b-f
3567  197469, 197692, // LHC13g
3568  235195, // LHC15a-h
3569  244285, // LHC15i-LHC15m (235196-244284)
3570  244629, // LHC15n (244340-244628)
3571  245141, 246995, // LHC15o (244824-246994)
3572  255539, // LHC16i-k (255515-258574)
3573  258883, // LHC16l (258883-260187)
3574  260216, // LHC16m-p (260216-p)
3575  265015, 265309, // LHC16q (265015-265525)
3576  265589, 265785, // LHC16r (265589-266318)
3577  266405, // LHC16s (266405-267131)
3578  267161, // LHC16t (267161-267166)
3579  270531, // LHC17c-o (270531-281961)
3580  282008, // LHC17pq (282008-282441)
3581  282504 // 2018
3582  };
3583 
3584  Double_t thresholdEMCalL1[20] = { 9.5/*8.398*/, // LHC12c-i (EGA)
3585  11.5, /*6.*/ // LHC13b-f
3586  5.5, // LHC13g
3587  2000.0, // LS1
3588  2000.0, // LHC15a-h
3589  5.0, // LHC15i-m
3590  5.0, // LHC15n
3591  2000.0, 10.0, // LHC15o
3592  8.8, // LHC16i-k (255515-258574)
3593  5.5, // LHC16l (258883-260187)
3594  8.8, // LHC16m-p (260216-)
3595  8.8, 10.8, // LHC16q (265015-265525)
3596  10.8, 7.8, // LHC16r (265589-266318)
3597  7.8, // LHC16s (266405-267131)
3598  7.8, // LHC16t (267161-267166)
3599  8.8, // LHC17c-o (270531-281961)
3600  8.8 // LHC17pq (282008-282441)
3601 // 8.8 // 2018
3602  };
3603  Double_t spreadEMCalL1[20] = { 1.0/*0.*/,
3604  0.5,
3605  /*0.4*/ 0.6,
3606  0.0, // LS1
3607  1.2, 0.8, // LHC16r (265589-266318)
3608  0.0, // LHC15a-h
3609  1.0, // LHC15i-m
3610  1.0, // LHC15n
3611  0.0, 1.0, // LHC15o
3612  1.0, // LHC16i-k (255515-258574)
3613  0.8, // LHC16l (258883-260187)
3614  1.0, // LHC16m-p (260216-)
3615  1.0, 1.2, // LHC16q (265015-265525)
3616  0.9, // LHC16s (266405-267131)
3617  0.9, // LHC16t (267161-267166)
3618  1.0, // LHC17c-o (270531-281961)
3619  1.0 // LHC17pq (282008-282441)
3620 // 1.0 // 2018
3621  };
3622 
3623  Int_t runRangesEMCalL1G2[21] = { 195180, // LHC13b-f
3624  197469, 197692, // LHC13g
3625  235195, // LHC15a-h
3626  244285, // LHC15i-LHC15m (235196-244284)
3627  244629, // LHC15n (244340-244628)
3628  245141, 246995, // LHC15o (244824-246994)
3629  255539, // LHC16i-k (255515-258574)
3630  258883, // LHC16l (258883-260187)
3631  260216, // LHC16m-p (260216-)
3632  265015, 265309, // LHC16q (265015-265525)
3633  265589, 265785, // LHC16r (265589-266318)
3634  266405, // LHC16s (266405-267131)
3635  267161, // LHC16t (267161-267166)
3636  270531, // LHC17c-o (270531-281961)
3637  282008, // LHC17pq (282008-282441)
3638  282504 // 2018
3639  };
3640 
3641  Double_t thresholdEMCalL1G2[19] = { 7.2, // LHC13b-f
3642  /*3.9*/3.75, // LHC13g
3643  2000.0, // LS1
3644  1.8, // LHC15a-h
3645  5.0, // LHC15i-m
3646  5.0, // LHC15n
3647  2000.0, 2000.0, // LHC15o
3648  3.9, // LHC16i-k (255515-258574)
3649  3.8, // LHC16l (258883-260187)
3650  3.9, // LHC16m-p (260216-)
3651  3.9, 6.3, // LHC16q (265015-265525)
3652  6.3, 5.3, // LHC16r (265589-266318)
3653  5.3, // LHC16s (266405-267131)
3654  5.3, // LHC16t (267161-267166)
3655  3.9, // LHC17c-o (270531-281961)
3656  3.9 // LHC17pq (282008-282441)
3657 // 3.9 // 2018
3658  };
3659  Double_t spreadEMCalL1G2[19] = { 0.3, // LHC13bf
3660  /*0.2*/0.25, // LHC13g
3661  0., // LS1
3662  0.1, // LHC15a-h
3663  0.1, // LHC15i-m
3664  0.1, // LHC15n
3665  0.1, 1.0, // LHC15o
3666  0.3, // LHC16i-k (255515-258574)
3667  0.3, // LHC16l (258883-260187)
3668  0.3, // LHC16m-p (260216-)
3669  0.3, 0.4, // LHC16q (265015-265525)
3670  0.4, 0.3, // LHC16r (265589-266318)
3671  0.3, // LHC16s (266405-267131)
3672  0.3, // LHC16t (267161-267166)
3673  0.3, // LHC17c-o (270531-281961)
3674  0.3 // LHC17pq (282008-282441)
3675 // 0.3 // 2018
3676  };
3677 
3678  Int_t runnumber = event->GetRunNumber();
3679 
3680  if (fSpecialTrigger == 5 ){
3681  if (runnumber < runRangesEMCalL0[0]) return kTRUE;
3682  Int_t binRun = 0;
3683  while (!(runnumber >= runRangesEMCalL0[binRun] && runnumber < runRangesEMCalL0[binRun+1] ) && binRun < 51 ){
3684 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << ":\t"<< thresholdEMCalL0[binRun] << "\t" << spreadEMCalL0[binRun] << endl;
3685  binRun++;
3686  }
3687  if (binRun==51) return kFALSE;
3688 // cout << runnumber << "\t"<< binRun << "\t"<< thresholdEMCalL0[binRun] << "\t" << spreadEMCalL0[binRun] << endl;
3689  Double_t threshold = thresholdEMCalL0[binRun];
3690 
3691  if (isMC && spreadEMCalL0[binRun] != 0.){
3692  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3693  triggerSmearing->SetParameter(0, 1/(spreadEMCalL0[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3694  triggerSmearing->SetParameter(1, thresholdEMCalL0[binRun]);
3695  triggerSmearing->SetParameter(2, spreadEMCalL0[binRun]);
3696  threshold = triggerSmearing->GetRandom();
3697  delete triggerSmearing;
3698  }
3699 
3700 // cout << "modified" << "\t"<< threshold << endl;
3701  Int_t nclus = 0;
3702  TClonesArray * arrClustersMimic = NULL;
3703  if(!fCorrTaskSetting.CompareTo("")){
3704  nclus = event->GetNumberOfCaloClusters();
3705  } else {
3706  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3707  if(!arrClustersMimic)
3708  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3709  nclus = arrClustersMimic->GetEntries();
3710  }
3711 
3712  if(nclus == 0) return kFALSE;
3713 
3714  // Loop over EMCal clusters
3715  Bool_t eventIsAccepted = kFALSE;
3716  for(Int_t i = 0; i < nclus; i++){
3717  if (eventIsAccepted) continue;
3718  AliVCluster* clus = NULL;
3719  if(event->IsA()==AliESDEvent::Class()){
3720  if(arrClustersMimic)
3721  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3722  else
3723  clus = event->GetCaloCluster(i);
3724  } else if(event->IsA()==AliAODEvent::Class()){
3725  if(arrClustersMimic)
3726  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3727  else
3728  clus = event->GetCaloCluster(i);
3729  }
3730 
3731  if (!clus){
3732  if(arrClustersMimic) delete clus;
3733  continue;
3734  }
3735  if (!clus->IsEMCAL()) {
3736  if(arrClustersMimic) delete clus;
3737  continue;
3738  }
3739  if (clus->GetM02()<0.1) {
3740  if(arrClustersMimic) delete clus;
3741  continue;
3742  }
3743  if (clus->GetNCells()<2) {
3744  if(arrClustersMimic) delete clus;
3745  continue;
3746  }
3747  if (clus->E() > threshold ){
3748 // cout << "found L0" << endl;
3749  eventIsAccepted = kTRUE;
3750  }
3751  if(arrClustersMimic)
3752  delete clus;
3753  }
3754  return eventIsAccepted;
3755 
3756  } else if (fSpecialTrigger == 6 ) {
3757 
3758  return kTRUE;
3759  } else if (fSpecialTrigger == 8 ) {
3760  if (fSpecialSubTriggerName.CompareTo("7EGA")==0 || fSpecialSubTriggerName.CompareTo("8EGA")==0 || fSpecialSubTriggerName.CompareTo("7EG1")==0 ||fSpecialSubTriggerName.CompareTo("8EG1")==0 ){
3761  if (runnumber < runRangesEMCalL1[0]) return kTRUE;
3762  Int_t binRun = 0;
3763  while (!(runnumber >= runRangesEMCalL1[binRun] && runnumber < runRangesEMCalL1[binRun+1] ) && binRun < 20 ){
3764 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL1[binRun] << "\t" << runRangesEMCalL1[binRun+1] << ":\t"<< thresholdEMCalL1[binRun]<<"\t"<< spreadEMCalL1[binRun]<< endl;
3765  binRun++;
3766  }
3767  if (binRun==20) return kFALSE;
3768  Double_t threshold = thresholdEMCalL1[binRun];
3769 
3770  if (isMC && spreadEMCalL1[binRun] != 0.){
3771  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3772  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3773  triggerSmearing->SetParameter(1, thresholdEMCalL1[binRun]);
3774  triggerSmearing->SetParameter(2, spreadEMCalL1[binRun]);
3775  threshold = triggerSmearing->GetRandom();
3776  delete triggerSmearing;
3777  }
3778 
3779 // cout << runnumber << "\t"<< binRun << "\t L1 \t"<< threshold << endl;
3780 
3781  TClonesArray * arrClustersMimic = NULL;
3782  Int_t nclus = 0;
3783  if(!fCorrTaskSetting.CompareTo("")){
3784  nclus = event->GetNumberOfCaloClusters();
3785  } else {
3786  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3787  if(!arrClustersMimic)
3788  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3789  nclus = arrClustersMimic->GetEntries();
3790  }
3791 
3792  if(nclus == 0) return kFALSE;
3793 
3794  // Loop over EMCal clusters
3795  Bool_t eventIsAccepted = kFALSE;
3796  for(Int_t i = 0; i < nclus; i++){
3797  if (eventIsAccepted) continue;
3798  AliVCluster* clus = NULL;
3799  if(event->IsA()==AliESDEvent::Class()){
3800  if(arrClustersMimic)
3801  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3802  else
3803  clus = event->GetCaloCluster(i);
3804  } else if(event->IsA()==AliAODEvent::Class()){
3805  if(arrClustersMimic)
3806  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3807  else
3808  clus = event->GetCaloCluster(i);
3809  }
3810  if (!clus) {
3811  if(arrClustersMimic) delete clus;
3812  continue;
3813  }
3814  if (!clus->IsEMCAL()) {
3815  if(arrClustersMimic) delete clus;
3816  continue;
3817  }
3818  if (clus->GetM02()<0.1) {
3819  if(arrClustersMimic) delete clus;
3820  continue;
3821  }
3822  if (clus->GetNCells()<2) {
3823  if(arrClustersMimic) delete clus;
3824  continue;
3825  }
3826  if (clus->E() > threshold ){
3827 // cout << "found L1G1\t" << clus->E() << endl;
3828  eventIsAccepted = kTRUE;
3829  }
3830  if(arrClustersMimic)
3831  delete clus;
3832  }
3833  return eventIsAccepted;
3834  } else if ( fSpecialSubTriggerName.CompareTo("7EG2")==0 ||fSpecialSubTriggerName.CompareTo("8EG2")==0 ){
3835  if (runnumber < runRangesEMCalL1G2[0]) return kTRUE;
3836  Int_t binRun = 0;
3837  while (!(runnumber >= runRangesEMCalL1G2[binRun] && runnumber < runRangesEMCalL1G2[binRun+1] ) && binRun < 19 ){
3838 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL1G2[binRun] << "\t" << runRangesEMCalL1G2[binRun+1] << ":\t"<< thresholdEMCalL1G2[binRun]<<"\t"<< spreadEMCalL1G2[binRun]<< endl;
3839  binRun++;
3840  }
3841 // cout << runnumber << "\t"<< binRun << "\t L2 \t"<< thresholdEMCalL1G2[binRun]<<"\t"<< spreadEMCalL1G2[binRun]<< endl;
3842  if (binRun==19) return kFALSE;
3843  Double_t threshold = thresholdEMCalL1G2[binRun];
3844  if (isMC && spreadEMCalL1G2[binRun] != 0.){
3845  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3846  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1G2[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3847  triggerSmearing->SetParameter(1, thresholdEMCalL1G2[binRun]);
3848  triggerSmearing->SetParameter(2, spreadEMCalL1G2[binRun]);
3849  threshold = triggerSmearing->GetRandom();
3850  delete triggerSmearing;
3851  }
3852 // cout << "\t L2 mod\t"<< threshold << endl;
3853 
3854  Int_t nclus = 0;
3855  TClonesArray * arrClustersMimic = NULL;
3856  if(!fCorrTaskSetting.CompareTo("")){
3857  nclus = event->GetNumberOfCaloClusters();
3858  } else {
3859  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3860  if(!arrClustersMimic)
3861  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3862  nclus = arrClustersMimic->GetEntries();
3863  }
3864 
3865  if(nclus == 0) return kFALSE;
3866 
3867  // Loop over EMCal clusters
3868  Bool_t eventIsAccepted = kFALSE;
3869  for(Int_t i = 0; i < nclus; i++){
3870  if (eventIsAccepted) continue;
3871  AliVCluster* clus = NULL;
3872  if(event->IsA()==AliESDEvent::Class()){
3873  if(arrClustersMimic)
3874  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3875  else
3876  clus = event->GetCaloCluster(i);
3877  } else if(event->IsA()==AliAODEvent::Class()){
3878  if(arrClustersMimic)
3879  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3880  else
3881  clus = event->GetCaloCluster(i);
3882  }
3883  if (!clus) {
3884  if(arrClustersMimic) delete clus;
3885  continue;
3886  }
3887  if (!clus->IsEMCAL()) {
3888  if(arrClustersMimic) delete clus;
3889  continue;
3890  }
3891  if (clus->GetM02()<0.1) {
3892  if(arrClustersMimic) delete clus;
3893  continue;
3894  }
3895  if (clus->GetNCells()<2) {
3896  if(arrClustersMimic) delete clus;
3897  continue;
3898  }
3899  if (clus->E() > threshold ){
3900 // cout << "found L1G2" << endl;
3901  eventIsAccepted = kTRUE;
3902  }
3903  if(arrClustersMimic)
3904  delete clus;
3905  }
3906  return eventIsAccepted;
3907  }
3908  return kTRUE;
3909  } else if (fSpecialTrigger == 9 ) {
3910  return kTRUE;
3911  } else {
3912  return kTRUE;
3913  }
3914 
3915  return kTRUE;
3916 }
3917 
3918 
3919 //________________________________________________________________________
3921 {
3922 
3923  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
3924 
3925 
3926  UInt_t isSelected = AliVEvent::kAny;
3927 
3928  if (fInputHandler==NULL) return kFALSE;
3929  if( fInputHandler->GetEventSelection() || event->IsA()==AliAODEvent::Class()) {
3930 
3931  TString firedTrigClass = event->GetFiredTriggerClasses();
3932  // if no trigger has been selected manually, select kAny in case of presel (also important for AOD filtering!)
3933  // in other cases select standards depending on system
3935  if (fPreSelCut) fOfflineTriggerMask = AliVEvent::kAny;
3936  else {
3937  if (fIsHeavyIon == 1){
3938  fOfflineTriggerMask = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
3939  } else if (fIsHeavyIon == 2){
3940  fOfflineTriggerMask = AliVEvent::kINT7;
3941  } else {
3942  fOfflineTriggerMask = AliVEvent::kMB;
3943  }
3944  }
3945  }
3946 
3947  // in case of MC switch to kAny if no MB/INT7/INT8 has been selected
3948  if(isMC){
3949  if( fIsHeavyIon == 0){
3950  if( fOfflineTriggerMask != AliVEvent::kMB && fOfflineTriggerMask != AliVEvent::kINT7 && fOfflineTriggerMask != AliVEvent::kINT8 ){
3951  fOfflineTriggerMask = AliVEvent::kAny;
3952  }
3953  }else{
3954  fOfflineTriggerMask = AliVEvent::kAny;
3955  }
3956  }
3957 
3958  if (fOfflineTriggerMask){
3959  isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
3960  if (isSelected && !fPreSelCut){
3961 // cout << firedTrigClass.Data() << endl;
3962 // cout << "Special trigger: "<< fSpecialTrigger << " initialized " << fEMCALTrigInitialized << endl;
3963 // if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3964 // if (!fEMCALTrigInitialized ) InitializeEMCALTrigger(event);
3965 // fTriggersEMCAL= GetTriggerList();
3966 // }
3967  if (fSpecialSubTrigger>0 && !isMC){
3968  if (!firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 0;
3969  if (fRejectTriggerOverlap){
3970  // trigger rejection EMC1,7,8
3971  if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC7") == 0){
3972  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3973  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC1") == 0){
3974  if (fInputHandler->IsEventSelected() & AliVEvent::kMB) isSelected = 0;
3975  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC8") == 0){
3976  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3977  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CDMC7") == 0){
3978  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3979  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CDMC1") == 0){
3980  if (fInputHandler->IsEventSelected() & AliVEvent::kMB) isSelected = 0;
3981  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CDMC8") == 0){
3982  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3983  }
3984  // trigger rejection EGA
3985  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EGA") == 0){
3986  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3987  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3988  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EGA") == 0){
3989  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3990  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3991  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7DGA") == 0){
3992  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3993  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3994  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8DGA") == 0){
3995  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3996  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3997  }
3998  // trigger rejection EG1 & EG2
3999  // EG1 is the trigger with the highest threshold
4000  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
4001 // cout << firedTrigClass.Data() << endl;
4002  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
4003 // cout << "INT7? " << isSelected << endl;
4004  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4005 // cout << "CEM7? " << isSelected << endl;
4006  if (firedTrigClass.Contains("7EG2")) isSelected = 0;
4007 // cout << "7EG2? " << isSelected << endl;
4008  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
4009  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
4010  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4011  if (firedTrigClass.Contains("8EG2")) isSelected = 0;
4012  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
4013 // cout << firedTrigClass.Data() << endl;
4014  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
4015 // cout << "INT7? " << isSelected << endl;
4016  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4017 // cout << "CEM7? " << isSelected << endl;
4018  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
4019  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
4020  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4021  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7DG1") == 0){
4022  // cout << firedTrigClass.Data() << endl;
4023  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
4024  // cout << "INT7? " << isSelected << endl;
4025  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4026  // cout << "CEM7? " << isSelected << endl;
4027  if (firedTrigClass.Contains("7DG2")) isSelected = 0;
4028  // cout << "7EG2? " << isSelected << endl;
4029  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8DG1") == 0){
4030  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
4031  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4032  if (firedTrigClass.Contains("8DG2")) isSelected = 0;
4033  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7DG2") == 0){
4034  // cout << firedTrigClass.Data() << endl;
4035  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
4036  // cout << "INT7? " << isSelected << endl;
4037  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4038  // cout << "CEM7? " << isSelected << endl;
4039  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8DG2") == 0){
4040  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
4041  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4042  }
4043  if (fSpecialTrigger == 10 && (fInputHandler->IsEventSelected() & AliVEvent::kCaloOnly) ){
4044  // trigger rejection L0 triggers
4045  if (fSpecialSubTriggerName.CompareTo("CEMC7-") == 0){
4046  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4047  } else if (fSpecialSubTriggerName.CompareTo("CEMC1-") == 0){
4048  if (firedTrigClass.Contains("INT1-")) isSelected = 0;
4049  } else if (fSpecialSubTriggerName.CompareTo("CEMC8-") == 0){
4050  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4051  } else if (fSpecialSubTriggerName.CompareTo("CDMC7-") == 0){
4052  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4053  } else if (fSpecialSubTriggerName.CompareTo("CDMC1-") == 0){
4054  if (firedTrigClass.Contains("INT1-")) isSelected = 0;
4055  } else if (fSpecialSubTriggerName.CompareTo("CDMC8-") == 0){
4056  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4057  }
4058  // trigger rejection EGA
4059  if (fSpecialSubTriggerName.CompareTo("7EGA") == 0){
4060  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4061  if (firedTrigClass.Contains("EMC7-")) isSelected = 0;
4062  } else if (fSpecialSubTriggerName.CompareTo("8EGA") == 0){
4063  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4064  if (firedTrigClass.Contains("EMC8-")) isSelected = 0;
4065  } else if (fSpecialSubTriggerName.CompareTo("7DGA") == 0){
4066  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4067  if (firedTrigClass.Contains("EMC7-")) isSelected = 0;
4068  } else if (fSpecialSubTriggerName.CompareTo("8DGA") == 0){
4069  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4070  if (firedTrigClass.Contains("EMC8-")) isSelected = 0;
4071  }
4072  // trigger rejection L1 triggers
4073  if(fSpecialSubTriggerName.CompareTo("7EG1") == 0){
4074  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4075  if (firedTrigClass.Contains("EMC7-")) isSelected = 0;
4076  if (firedTrigClass.Contains("7EG2")) isSelected = 0;
4077  } else if (fSpecialSubTriggerName.CompareTo("8EG1") == 0){
4078  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4079  if (firedTrigClass.Contains("EMC8-")) isSelected = 0;
4080  if (firedTrigClass.Contains("8EG2")) isSelected = 0;
4081  } else if (fSpecialSubTriggerName.CompareTo("7EG2") == 0){
4082  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4083  if (firedTrigClass.Contains("EMC7-")) isSelected = 0;
4084  } else if (fSpecialSubTriggerName.CompareTo("8EG2") == 0){
4085  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4086  if (firedTrigClass.Contains("EMC8-")) isSelected = 0;
4087  } else if (fSpecialSubTriggerName.CompareTo("7DG1") == 0){
4088  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4089  if (firedTrigClass.Contains("DMC7-")) isSelected = 0;
4090  if (firedTrigClass.Contains("7DG2")) isSelected = 0;
4091  } else if (fSpecialSubTriggerName.CompareTo("8DG1") == 0){
4092  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4093  if (firedTrigClass.Contains("DMC8-")) isSelected = 0;
4094  if (firedTrigClass.Contains("8DG2")) isSelected = 0;
4095  } else if (fSpecialSubTriggerName.CompareTo("7DG2") == 0){
4096  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4097  if (firedTrigClass.Contains("DMC7-")) isSelected = 0;
4098  } else if (fSpecialSubTriggerName.CompareTo("8DG2") == 0){
4099  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4100  if (firedTrigClass.Contains("DMC8-")) isSelected = 0;
4101  }
4102  }
4103  }
4104  if (isSelected != 0 ){
4105 // cout << "I am here" << " :" << fSpecialSubTriggerName.Data() <<endl;
4106  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9 ){
4108  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassesCorrelated->Fill(0);
4109  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassesCorrelated->Fill(1);
4110  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassesCorrelated->Fill(2);
4111  if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC7) && firedTrigClass.Contains("EMC"))hTriggerClassesCorrelated->Fill(3);
4112  if (firedTrigClass.Contains("7EJE") || firedTrigClass.Contains("8EJE")) hTriggerClassesCorrelated->Fill(4);
4113  if (firedTrigClass.Contains("7EJ1") || firedTrigClass.Contains("8EJ1")) hTriggerClassesCorrelated->Fill(5);
4114  if (firedTrigClass.Contains("7EJ2") || firedTrigClass.Contains("8EJ2")) hTriggerClassesCorrelated->Fill(6);
4115  if (firedTrigClass.Contains("7EGA") || firedTrigClass.Contains("8EGA")) hTriggerClassesCorrelated->Fill(7);
4116  if (firedTrigClass.Contains("7EG1") || firedTrigClass.Contains("8EG1")) hTriggerClassesCorrelated->Fill(8);
4117  if (firedTrigClass.Contains("7EG2") || firedTrigClass.Contains("8EG2")) hTriggerClassesCorrelated->Fill(9);
4118  if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC7) && firedTrigClass.Contains("DMC"))hTriggerClassesCorrelated->Fill(10);
4119  if (firedTrigClass.Contains("7DJE") || firedTrigClass.Contains("8DJE")) hTriggerClassesCorrelated->Fill(11);
4120  if (firedTrigClass.Contains("7DJ1") || firedTrigClass.Contains("8DJ1")) hTriggerClassesCorrelated->Fill(12);
4121  if (firedTrigClass.Contains("7DJ2") || firedTrigClass.Contains("8DJ2")) hTriggerClassesCorrelated->Fill(13);
4122  if (firedTrigClass.Contains("7DGA") || firedTrigClass.Contains("8DGA")) hTriggerClassesCorrelated->Fill(14);
4123  if (firedTrigClass.Contains("7DG1") || firedTrigClass.Contains("8DG1")) hTriggerClassesCorrelated->Fill(15);
4124  if (firedTrigClass.Contains("7DG2") || firedTrigClass.Contains("8DG2")) hTriggerClassesCorrelated->Fill(16);
4125  }
4126  } else if ( fSpecialTrigger == 10 ){
4128  if (fInputHandler->IsEventSelected() & AliVEvent::kCaloOnly){
4129  hTriggerClassesCorrelated->Fill(0);
4130  if (firedTrigClass.Contains("INT7-"))hTriggerClassesCorrelated->Fill(1);
4131  if (firedTrigClass.Contains("EMC1-"))hTriggerClassesCorrelated->Fill(2);
4132  if (firedTrigClass.Contains("EMC7-")|| firedTrigClass.Contains("EMC8-"))hTriggerClassesCorrelated->Fill(3);
4133  if (firedTrigClass.Contains("7EJE") || firedTrigClass.Contains("8EJE")) hTriggerClassesCorrelated->Fill(4);
4134  if (firedTrigClass.Contains("7EJ1") || firedTrigClass.Contains("8EJ1")) hTriggerClassesCorrelated->Fill(5);
4135  if (firedTrigClass.Contains("7EJ2") || firedTrigClass.Contains("8EJ2")) hTriggerClassesCorrelated->Fill(6);
4136  if (firedTrigClass.Contains("7EGA") || firedTrigClass.Contains("8EGA")) hTriggerClassesCorrelated->Fill(7);
4137  if (firedTrigClass.Contains("7EG1") || firedTrigClass.Contains("8EG1")) hTriggerClassesCorrelated->Fill(8);
4138  if (firedTrigClass.Contains("7EG2") || firedTrigClass.Contains("8EG2")) hTriggerClassesCorrelated->Fill(9);
4139  if (firedTrigClass.Contains("DMC7-")|| firedTrigClass.Contains("DMC8-"))hTriggerClassesCorrelated->Fill(10);
4140  if (firedTrigClass.Contains("7DJE") || firedTrigClass.Contains("8DJE")) hTriggerClassesCorrelated->Fill(11);
4141  if (firedTrigClass.Contains("7DJ1") || firedTrigClass.Contains("8DJ1")) hTriggerClassesCorrelated->Fill(12);
4142  if (firedTrigClass.Contains("7DJ2") || firedTrigClass.Contains("8DJ2")) hTriggerClassesCorrelated->Fill(13);
4143  if (firedTrigClass.Contains("7DGA") || firedTrigClass.Contains("8DGA")) hTriggerClassesCorrelated->Fill(14);
4144  if (firedTrigClass.Contains("7DG1") || firedTrigClass.Contains("8DG1")) hTriggerClassesCorrelated->Fill(15);
4145  if (firedTrigClass.Contains("7DG2") || firedTrigClass.Contains("8DG2")) hTriggerClassesCorrelated->Fill(16);
4146  }
4147  }
4148  }
4149  }
4150 
4151  } else if (isMC){
4152  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
4153 // isSelected = 0;
4154 // if (fTriggersEMCAL > 0)cout << "Special Trigger " << fSpecialTrigger << " triggers: " << fTriggersEMCAL << " selected triggers: " << fTriggersEMCALSelected << " run number: " <<event->GetRunNumber()<<endl;
4155 // if (fTriggersEMCAL&fTriggersEMCALSelected){
4156 // cout << "accepted ++++++++++++++++++++" << endl;
4157  isSelected = 1;
4158 // }
4159  }
4160  }
4161  //if for specific centrality trigger selection
4162  if(fSpecialSubTrigger == 1){
4163  if(fSpecialSubTriggerName.Contains("|") && GetCentrality(event) <= 10.){
4164  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("|");
4165  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
4166  TObjString *NameClass = (TObjString*)ClassesList->At(i);
4167  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
4168  }
4169  } else if(fSpecialSubTriggerName.Contains("%")){
4170  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("%");
4171  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
4172  TObjString *NameClass = (TObjString*)ClassesList->At(i);
4173  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
4174  }
4175  } else if(fSpecialSubTriggerName.Contains("@")){
4176  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("@");
4177  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
4178  TObjString *NameClass = (TObjString*)ClassesList->At(i);
4179  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
4180  }
4181  } else if(fSpecialSubTriggerName.Contains("&")){ //logic AND of two classes
4182  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("&");
4183  TString CheckClass = "";
4184  for (Int_t i=0; i<ClassesList->GetEntriesFast(); i++){
4185  TObjString *NameClass = (TObjString*)ClassesList->At(i);
4186  if (firedTrigClass.Contains(NameClass->GetString())) CheckClass+="1";
4187  else CheckClass+="0";
4188  }
4189  if(CheckClass.Contains("0")) isSelected = 0;
4190  }
4191  else if(firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 1;
4192  }
4193  }
4194  }
4195  }
4196  fIsSDDFired = !(fInputHandler->IsEventSelected() & AliVEvent::kFastOnly);
4197 
4198  Bool_t mimickedTrigger = kTRUE;
4199  if (fMimicTrigger) mimickedTrigger = MimicTrigger(event, isMC);
4200 // cout << "mimicked decision \t" << mimickedTrigger << "expect decision? "<< fMimicTrigger<< endl;
4201 
4202  // Fill Histogram
4203  if(hTriggerClass){
4204  if (fIsSDDFired) hTriggerClass->Fill(34);
4205  if (mimickedTrigger){
4206  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
4207  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
4208  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
4209  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClass->Fill(3);
4210  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClass->Fill(4);
4211  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
4212  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
4213  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
4214  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
4215  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
4216  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
4217  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClass->Fill(8);
4218  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClass->Fill(9);
4219  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClass->Fill(9);
4220  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClass->Fill(10);
4221  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClass->Fill(10);
4222  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClass->Fill(11);
4223  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClass->Fill(12);
4224  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClass->Fill(13);
4225  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClass->Fill(13);
4226  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClass->Fill(13);
4227  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClass->Fill(14);
4228  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClass->Fill(15);
4229  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClass->Fill(16);
4230  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClass->Fill(17);
4231  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClass->Fill(18);
4232  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClass->Fill(19);
4233  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClass->Fill(20);
4234  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClass->Fill(20);
4235  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClass->Fill(21);
4236  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClass->Fill(22);
4237  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClass->Fill(23);
4238  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClass->Fill(24);
4239  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClass->Fill(25);
4240  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClass->Fill(26);
4241  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClass->Fill(27);
4242  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClass->Fill(28);
4243  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(29);
4244  if (fInputHandler->IsEventSelected() & AliVEvent::kCaloOnly)hTriggerClass->Fill(30);
4245  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(31);
4246  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(32);
4247  if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(35);
4248  }
4249  if (mimickedTrigger && fMimicTrigger) hTriggerClass->Fill(36);
4250  }
4251 
4252  if(hTriggerClassSelected && isSelected){
4253  if (mimickedTrigger){
4254  if (!fIsSDDFired) hTriggerClassSelected->Fill(33);
4255  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
4256  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
4257  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
4258  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
4259  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
4260  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
4261  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
4262  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
4263  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
4264  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
4265  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
4266  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
4267  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
4268  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
4269  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
4270  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
4271  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
4272  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
4273  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
4274  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
4275  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
4276  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
4277  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
4278  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
4279  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
4280  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
4281  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
4282  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
4283  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
4284  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
4285  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
4286  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
4287  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
4288  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
4289  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
4290  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
4291  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClassSelected->Fill(28);
4292  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(29);
4293  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(30);
4294  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(31);
4295  }
4296  if (mimickedTrigger && fMimicTrigger) hTriggerClassSelected->Fill(34);
4297  }
4298 
4299  if(!isSelected)return kFALSE;
4300  if (fMimicTrigger)
4301  if (!mimickedTrigger ) return kFALSE;
4302  return kTRUE;
4303 
4304 }
4305 
4306 //________________________________________________________________________
4308  // returns TString with current cut number
4309  return fCutStringRead;
4310 }
4311 
4312 //________________________________________________________________________
4313 void AliConvEventCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliVEvent *event){
4314 
4315  if(fNotRejectedStart){
4316  delete[] fNotRejectedStart;
4317  fNotRejectedStart = NULL;
4318  }
4319  if(fNotRejectedEnd){
4320  delete[] fNotRejectedEnd;
4321  fNotRejectedEnd = NULL;
4322  }
4323  if(fGeneratorNames){
4324  delete[] fGeneratorNames;
4325  fGeneratorNames = NULL;
4326  }
4327 
4328  if(rejection == 0) return; // No Rejection
4329 
4330  AliGenCocktailEventHeader *cHeader = 0x0;
4331  AliAODMCHeader *cHeaderAOD = 0x0;
4332  Bool_t headerFound = kFALSE;
4333  AliMCEvent *fMCEvent = 0x0;
4334  TClonesArray *fMCEventAOD = 0x0;
4335  if(event->IsA()==AliMCEvent::Class()){
4336  if(dynamic_cast<AliMCEvent*>(event)){
4337  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(dynamic_cast<AliMCEvent*>(event)->GenEventHeader());
4338  fMCEvent = dynamic_cast<AliMCEvent*>(event);
4339  if(cHeader) headerFound = kTRUE;
4340  }
4341  }
4342  if(event->IsA()==AliAODEvent::Class()){ // event is a AODEvent in case of AOD
4343  cHeaderAOD = dynamic_cast<AliAODMCHeader*>(event->FindListObject(AliAODMCHeader::StdBranchName()));
4344  fMCEventAOD = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4345  if(cHeaderAOD) headerFound = kTRUE;
4346  }
4347 
4348  if (fDebugLevel > 0 ) cout << "event starts here" << endl;
4349  if(headerFound){
4350  TList *genHeaders = 0x0;
4351  if(cHeader) genHeaders = cHeader->GetHeaders();
4352  if(cHeaderAOD){
4353  genHeaders = cHeaderAOD->GetCocktailHeaders();
4354  if(genHeaders->GetEntries()==1){
4356  return;
4357  }
4358  }
4359  AliGenEventHeader* gh = 0;
4360  fnHeaders = 0;
4361  Int_t firstindexA = 0;
4362  Int_t lastindexA = -1;
4363  if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
4364  if(rejection == 2 || rejection == 4){ // TList of Headers Names
4365  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
4366  gh = (AliGenEventHeader*)genHeaders->At(i);
4367  TString GeneratorName = gh->GetName();
4368  lastindexA = lastindexA + gh->NProduced();
4369  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
4370  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
4371  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
4372  if (fDebugLevel > 0 ) cout << GeneratorInList.Data() << endl;
4373  if(GeneratorInList.Contains(GeneratorName) ){
4374  if (fDebugLevel > 0 ) cout << "accepted" << endl;
4375  if (GeneratorInList.BeginsWith("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
4376  if(fMCEvent){
4377  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4378  if (fDebugLevel > 2 )cout << "number of produced particle: " << gh->NProduced() << endl;
4379  if (fDebugLevel > 2 )cout << "pdg-code of first particle: " << fMCEvent->Particle(firstindexA)->GetPdgCode() << endl;
4380  if (fMCEvent->Particle(firstindexA)->GetPdgCode() == fAddedSignalPDGCode ) {
4381  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindexA+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
4382  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4383  fnHeaders++;
4384  continue;
4385  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4386  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
4387  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4388  fnHeaders++;
4389  continue;
4390  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4391  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
4392  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4393  fnHeaders++;
4394  continue;
4395 
4396  }
4397  continue;
4398  }
4399  } else {
4400  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
4401  fnHeaders++;
4402  continue;
4403  }
4404  }
4405  if ( fMCEventAOD){
4406  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA));
4407  if (aodMCParticle && (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c) ){
4408  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
4409  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0){
4410  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA+10));
4411  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
4412  if (fDebugLevel > 0 ) cout << "cond 1: " << fnHeaders << endl;
4413  fnHeaders++;
4414  continue;
4415  }
4416  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4417  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
4418  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4419  fnHeaders++;
4420  continue;
4421  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4422  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
4423  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4424  fnHeaders++;
4425  continue;
4426 
4427  }
4428  continue;
4429  }
4430  } else {
4431  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
4432  fnHeaders++;
4433  continue;
4434  }
4435  }
4436  continue;
4437  }
4438  if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
4439  if (fDebugLevel > 0 ) cout << "cond 3: "<< fnHeaders << endl;
4440  fnHeaders++;
4441  continue;
4442  }
4443  }
4444  }
4445  firstindexA = firstindexA + gh->NProduced();
4446  }
4447  }
4448  if (fDebugLevel > 0 ) cout << "number of headers: " <<fnHeaders << endl;
4449 
4453 
4454  if(rejection == 1 || rejection == 3){
4455  fNotRejectedStart[0] = 0;
4456  fNotRejectedEnd[0] = ((AliGenEventHeader*)genHeaders->At(0))->NProduced()-1;
4457  fGeneratorNames[0] = ((AliGenEventHeader*)genHeaders->At(0))->GetName();
4458  if (fDebugLevel > 0 ) cout << 0 << "\t" <<fGeneratorNames[0] << "\t" << fNotRejectedStart[0] << "\t" <<fNotRejectedEnd[0] << endl;
4459  return;
4460  }
4461 
4462  Int_t firstindex = 0;
4463  Int_t lastindex = -1;
4464  Int_t number = 0;
4465 
4466  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
4467  gh = (AliGenEventHeader*)genHeaders->At(i);
4468  TString GeneratorName = gh->GetName();
4469  lastindex = lastindex + gh->NProduced();
4470  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
4471  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
4472  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
4473  if(GeneratorInList.Contains(GeneratorName) ){
4474  if (GeneratorInList.Contains("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
4475  if(fMCEvent){
4476  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4477  if (fMCEvent->Particle(firstindex)->GetPdgCode() == fAddedSignalPDGCode ) {
4478  if (fDebugLevel > 0 ) cout << "produced " << gh->NProduced() << " with box generator" << endl;
4479  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindex+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
4480  if (fDebugLevel > 0 ) cout << "one of them was a pi0 or eta" << endl;
4481  fNotRejectedStart[number] = firstindex;
4482  fNotRejectedEnd[number] = lastindex;
4483  fGeneratorNames[number] = GeneratorName;
4484  number++;
4485  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4486  continue;
4487  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4488  fNotRejectedStart[number] = firstindex;
4489  fNotRejectedEnd[number] = lastindex;
4490  fGeneratorNames[number] = GeneratorName;
4491  number++;
4492  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4493  continue;
4494  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4495  fNotRejectedStart[number] = firstindex;
4496  fNotRejectedEnd[number] = lastindex;
4497  fGeneratorNames[number] = GeneratorName;
4498  number++;
4499  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4500  continue;
4501  }
4502  }
4503  continue;
4504  } else {
4505  fNotRejectedStart[number] = firstindex;
4506  fNotRejectedEnd[number] = lastindex;
4507  fGeneratorNames[number] = GeneratorName;
4508  number++;
4509  continue;
4510  }
4511  }
4512  if ( fMCEventAOD){
4513  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex));
4514  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4515  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
4516  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0) {
4517  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex+10));
4518  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
4519  fNotRejectedEnd[number] = lastindex;
4520  fNotRejectedStart[number] = firstindex;
4521  fGeneratorNames[number] = GeneratorName;
4522  number++;
4523  }
4524  continue;
4525  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4526  fNotRejectedStart[number] = firstindex;
4527  fNotRejectedEnd[number] = lastindex;
4528  fGeneratorNames[number] = GeneratorName;
4529  number++;
4530  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4531  continue;
4532  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4533  fNotRejectedStart[number] = firstindex;
4534  fNotRejectedEnd[number] = lastindex;
4535  fGeneratorNames[number] = GeneratorName;
4536  number++;
4537  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4538  continue;
4539  }
4540  continue;
4541  }
4542  } else {
4543  fNotRejectedStart[number] = firstindex;
4544  fNotRejectedEnd[number] = lastindex;
4545  fGeneratorNames[number] = GeneratorName;
4546  number++;
4547  continue;
4548  }
4549  }
4550  continue;
4551  } else if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
4552  fNotRejectedStart[number] = firstindex;
4553  fNotRejectedEnd[number] = lastindex;
4554  fGeneratorNames[number] = GeneratorName;
4555  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4556  number++;
4557  continue;
4558  }
4559 
4560  }
4561  }
4562  firstindex = firstindex + gh->NProduced();
4563  }
4564  if (fDebugLevel > 0 ) {
4565  for (Int_t i = 0; i < number; i++){
4566  cout << i << "\t" <<fGeneratorNames[i] << "\t" << fNotRejectedStart[i] << "\t" <<fNotRejectedEnd[i] << endl;
4567  }
4568  }
4569  } else { // No Cocktail Header Found
4570  fNotRejectedStart = new Int_t[1];
4571  fNotRejectedEnd = new Int_t[1];
4572 
4573  fnHeaders = 1;
4574  fNotRejectedStart[0] = 0;
4575  fNotRejectedEnd[0] = static_cast<AliMCEvent*>(event)->GetNumberOfPrimaries()-1;
4576  if (rejection > 1){
4577  fNotRejectedStart[0] = -1;
4578  fNotRejectedEnd[0] = -1;
4579  }
4580 
4581  fGeneratorNames = new TString[1];
4582  fGeneratorNames[0] = "NoCocktailGeneratorFound";
4583 // SetRejectExtraSignalsCut(0);
4584  }
4585 
4586 }
4587 
4588 //_________________________________________________________________________
4589 Int_t AliConvEventCuts::IsParticleFromBGEvent(Int_t index, AliMCEvent *mcEvent, AliVEvent *InputEvent, Int_t debug ){
4590 
4591  // if (debug > 2 ) cout << index << endl;
4592  if(index < 0) return 0; // No Particle
4593 
4594  Int_t accepted = 0;
4595  if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
4596  if(!mcEvent) return 0; // no mcEvent available, return 0
4597  if(index >= mcEvent->GetNumberOfPrimaries()){ // initial particle is secondary particle
4598  if( ((TParticle*)mcEvent->Particle(index))->GetMother(0) < 0) return 0; // material particle, return 0
4599  return IsParticleFromBGEvent(((TParticle*)mcEvent->Particle(index))->GetMother(0),mcEvent,InputEvent, debug);
4600  }
4601  for(Int_t i = 0;i<fnHeaders;i++){
4602  // if (debug > 2 ) cout << "header " << fGeneratorNames[i].Data() << ":"<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
4603  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
4604  if (debug > 1 ) cout << "accepted:" << index << "\t header " << fGeneratorNames[i].Data() << ": "<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
4605  accepted = 1;
4606  if(i == 0) accepted = 2; // MB Header
4607  }
4608  }
4609  if (debug > 1 && !accepted) cout << "rejected:" << index << endl;
4610  }
4611  else if(InputEvent->IsA()==AliAODEvent::Class()){
4612  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
4613  if (AODMCTrackArray){
4614  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
4615  if(!aodMCParticle) return 0; // no particle
4616  if(!aodMCParticle->IsPrimary()){
4617  if( aodMCParticle->GetMother() < 0) return 0;// material particle, return 0
4618  return IsParticleFromBGEvent(aodMCParticle->GetMother(),mcEvent,InputEvent, debug);
4619  }
4620  index = TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index))->GetLabel());
4621  for(Int_t i = 0;i<fnHeaders;i++){
4622  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
4623  accepted = 1;
4624  if(i == 0) accepted = 2; // MB Header
4625  }
4626  }
4627  }
4628  }
4629 
4630  return accepted;
4631 }
4632 
4633 //_________________________________________________________________________
4634 Int_t AliConvEventCuts::IsEventAcceptedByCut(AliConvEventCuts *ReaderCuts, AliVEvent *event, AliMCEvent *mcEvent, Int_t isHeavyIon, Bool_t isEMCALAnalysis){
4635 
4636  Bool_t isMC = kFALSE;
4637  if (mcEvent){isMC = kTRUE;}
4638 
4639  if ( !IsTriggerSelected(event, isMC) )
4640  return 3;
4641 
4642  if( !(IsCentralitySelected(event,mcEvent)))
4643  return 1; // Check Centrality --> Not Accepted => eventQuality = 1
4644 
4645  Bool_t hasV0And = ReaderCuts->HasV0AND();
4646  Bool_t isSDDFired = ReaderCuts->IsSDDFired();
4647 
4648  if( ( (IsSpecialTrigger() == 0 && IsSpecialSubTrigger() == 1) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !isSDDFired && !mcEvent)
4649  //if V0OR with SDD requested or V0AND with SDD request but the SDD has not fired
4650  return 7; // V0 with SDD requested but no fired
4651 
4652  if( ( (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 0) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !hasV0And)
4653  //if V0AND (only) or V0AND with SDD requested but V0AND requested but no fired
4654  return 8; // V0AND requested but no fired
4655 
4656 
4657  if( (IsSpecialTrigger() == 2 || IsSpecialTrigger() == 3) && !isSDDFired && !mcEvent)
4658  return 7; // With SDD requested but no fired
4659 
4660  if( (IsSpecialTrigger() == 1 || IsSpecialTrigger() == 3) && !hasV0And)
4661  return 8; // V0AND requested but no fired
4662 
4663  // Special EMCAL checks due to hardware issues in LHC11a
4664  if (isEMCALAnalysis || IsSpecialTrigger() == 5 || IsSpecialTrigger() == 8 || IsSpecialTrigger() == 9 ){
4665  Int_t runnumber = event->GetRunNumber();
4666  if ((runnumber>=144871) && (runnumber<=146860)) {
4667 
4668  AliVCaloCells *cells = event->GetEMCALCells();
4669  const Short_t nCells = cells->GetNumberOfCells();
4670 
4671  if (event->IsA()==AliESDEvent::Class()) AliAnalysisManager::GetAnalysisManager()->LoadBranch("EMCALCells.");
4672 
4673  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
4674  if (!fInputHandler) return 3;
4675 
4676  // count cells above threshold
4677  Int_t nCellCount[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
4678  for(Int_t iCell=0; iCell<nCells; ++iCell) {
4679  Short_t cellId = cells->GetCellNumber(iCell);
4680  Double_t cellE = cells->GetCellAmplitude(cellId);
4681  Int_t sm = cellId / (24*48);
4682  if (cellE>0.1) ++nCellCount[sm];
4683  }
4684 
4685  Bool_t fIsLedEvent = kFALSE;
4686  if (nCellCount[4] > 100) {
4687  fIsLedEvent = kTRUE;
4688  } else {
4689  if ((runnumber>=146858) && (runnumber<=146860)) {
4690  if ((fInputHandler->IsEventSelected() & AliVEvent::kMB) && (nCellCount[3]>=21))
4691  fIsLedEvent = kTRUE;
4692  else if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC1) && (nCellCount[3]>=35))
4693  fIsLedEvent = kTRUE;
4694  }
4695  }
4696  if (fIsLedEvent) {
4697  return 9;
4698  }
4699  }
4700  }
4701 
4702  // SPD clusters vs tracklets to check for pileup/background
4703  Int_t nClustersLayer0 = event->GetNumberOfITSClusters(0);
4704  Int_t nClustersLayer1 = event->GetNumberOfITSClusters(1);
4705  Int_t nTracklets = event->GetMultiplicity()->GetNumberOfTracklets();
4706  if(hSPDClusterTrackletBackgroundBefore) hSPDClusterTrackletBackgroundBefore->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
4707 
4708 
4709  Double_t distZMax = 0;
4710  if(event->IsA()==AliESDEvent::Class()){
4711  Int_t nPileVert = ((AliESDEvent*)event)->GetNumberOfPileupVerticesSPD();
4712  if (hNPileupVertices) hNPileupVertices->Fill(nPileVert);
4713  if (nPileVert > 0){
4714  for(Int_t i=0; i<nPileVert;i++){
4715  const AliESDVertex* pv= ((AliESDEvent*)event)->GetPileupVertexSPD(i);
4716  Int_t nc2 = pv->GetNContributors();
4717  if(nc2>=3){
4718  Double_t z1 = ((AliESDEvent*)event)->GetPrimaryVertexSPD()->GetZ();
4719  Double_t z2 = pv->GetZ();
4720  Double_t distZ = z2-z1;
4721  if (TMath::Abs(distZMax) < TMath::Abs(distZ) ){
4722  distZMax = distZ;
4723  }
4724  }
4725  }
4726  if (hPileupVertexToPrimZ) hPileupVertexToPrimZ->Fill(distZMax);
4727  }
4728  }
4729  if(GetPastFutureLowBC()!=0 && GetPastFutureHighBC()!=0 ){
4730  if(IsOutOfBunchPileupPastFuture(event))
4731  return 12;
4732  }
4733 
4734  if( isHeavyIon != 2 && GetIsFromPileupSPD()){
4735  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.) ){
4737  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
4738  }
4739  if (fUtils->IsSPDClusterVsTrackletBG(event)){
4741  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
4742  }
4743  }
4744  if(isHeavyIon == 2 && GetIsFromPileupSPD()){
4745  if(fUtils->IsPileUpEvent(event) ){
4747  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
4748  }
4749  if (fUtils->IsSPDClusterVsTrackletBG(event)){
4751  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
4752  }
4753  }
4754 
4756  if( IsPileUpV0MTPCout(event) ){
4757  return 13;
4758  }
4759  }
4760 
4761  if(fUseSphericity > 0){
4762  Double_t eventSphericity = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetSphericity();
4763  if(eventSphericity == -1) return 14;
4764  if(fUseSphericity == 1 && eventSphericity>0.5){
4765  return 14;
4766  }
4767  if(fUseSphericity == 2 && eventSphericity<0.5){
4768  return 14;
4769  }
4770  if(fUseSphericity == 3 && eventSphericity==-1){
4771  return 14;
4772  }
4773  Int_t nPrimTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
4774  if(fUseSphericity == 4 && (eventSphericity==-1 || nPrimTracks > 20)){
4775  return 14;
4776  }
4777  if(fUseSphericity == 5 && (eventSphericity==-1 || nPrimTracks < 20)){
4778  return 14;
4779  }
4780  if(fUseSphericity == 6 && (eventSphericity>0.5 || nPrimTracks > 20)){
4781  return 14;
4782  }
4783  if(fUseSphericity == 7 && (eventSphericity>0.5 || nPrimTracks < 20)){
4784  return 14;
4785  }
4786  if(fUseSphericity == 8 && (eventSphericity<0.5 || nPrimTracks > 20)){
4787  return 14;
4788  }
4789  if(fUseSphericity == 9 && (eventSphericity<0.5 || nPrimTracks < 20)){
4790  return 14;
4791  }
4792  if(fUseSphericity == 10 && eventSphericity>0.3){
4793  return 14;
4794  }
4795  if(fUseSphericity == 11 && eventSphericity<0.7){
4796  return 14;
4797  }
4798  }
4799 
4800  if(hCentrality)hCentrality->Fill(GetCentrality(event));
4801 
4802  if(hVertexZ)hVertexZ->Fill(event->GetPrimaryVertex()->GetZ());
4803 // if(hCentralityVsNumberOfPrimaryTracks)
4804 // hCentralityVsNumberOfPrimaryTracks->Fill(GetCentrality(event),
4805 // ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
4806 // ->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks());
4807 
4808  if(fIsHeavyIon == 1){
4809  AliEventplane *EventPlane = event->GetEventplane();
4810  fEventPlaneAngle = EventPlane->GetEventplane("V0",event,2);
4811  if(hEventPlaneAngle)hEventPlaneAngle->Fill(TMath::Abs(fEventPlaneAngle));
4812  }
4813  if(hSPDClusterTrackletBackground) hSPDClusterTrackletBackground->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
4814 
4815  return 0;
4816 }
4817 
4818 
4819 //_________________________________________________________________________
4821 
4822  AliInfo("Inside the GetWeightForCentralityFlattening function");
4823  Double_t centrality = 0.;
4824  //obtain centrality for ESD or AOD
4825  if(!event || event->IsA()==AliESDEvent::Class()){
4826  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
4827  if(esdEvent){
4828  AliCentrality *fESDCentrality=(AliCentrality*)esdEvent->GetCentrality();
4829  if(fDetectorCentrality==0 && fIsHeavyIon==1){
4830  centrality = fESDCentrality->GetCentralityPercentile("V0M"); // default for PbPb
4831  }
4832  }
4833  } else if(event->IsA()==AliAODEvent::Class()){
4834  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
4835  if(aodEvent){
4836  if(aodEvent->GetHeader()){
4837  centrality = ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();
4838  }
4839  }
4840  }
4841 
4842  //Get the maximum vlaue from the reference distribution and interpolated value
4843  Float_t GetValueForWeight = 1.;
4844  Float_t maximum = 1.;
4845  Double_t weightCentrality = 1.;
4846  Bool_t CorrCentrLoop = kFALSE;
4847 
4848  //depending on the value of the flag, flattening in different cent. range
4849  if ( fDoCentralityFlat == 1 && (centrality >= 0. && centrality <= 20.) ){
4850  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4851  maximum = hCentralityNotFlat->GetMaximum();
4852  CorrCentrLoop = kTRUE;
4853  } else if ( fDoCentralityFlat == 8 ){
4854  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4855  maximum = hCentralityNotFlat->GetMaximum();
4856  CorrCentrLoop = kTRUE;
4857  } else {
4858  CorrCentrLoop = kFALSE;
4859  }
4860 
4861  if (CorrCentrLoop && GetValueForWeight != 0. && maximum !=0. && isfinite(GetValueForWeight) && isfinite(maximum) ){
4862  weightCentrality = maximum/GetValueForWeight;
4863  if (!isfinite(GetValueForWeight)) weightCentrality = 1.;
4864  if (!isfinite(weightCentrality)) weightCentrality = 1.;
4865  }
4866 
4867  return weightCentrality;
4868 }
4869 
4870 //_________________________________________________________________________
4872 
4873  Double_t weightMult = 1.;
4874 
4875  if (hReweightMultData == NULL || hReweightMultMC == NULL ) return weightMult;
4876 
4877  // get mult values for weights
4878  Float_t valueMultData = -1.;
4879  Float_t valueMultMC = -1.;
4880  valueMultData = hReweightMultData->Interpolate(mult);
4881  valueMultMC = hReweightMultMC->Interpolate(mult);
4882 
4883  // calculate relative error for data and MC
4884  Float_t valueMC = 0;
4885  Float_t valueData = 0;
4886  Float_t errorMC = 0;
4887  Float_t errorData = 0;
4888  valueMC = hReweightMultMC->GetBinContent(hReweightMultMC->FindBin(mult));
4889  valueData = hReweightMultData->GetBinContent(hReweightMultData->FindBin(mult));
4890  errorMC = hReweightMultMC->GetBinError(hReweightMultMC->FindBin(mult));
4891  errorData = hReweightMultData->GetBinError(hReweightMultData->FindBin(mult));
4892  Float_t relativeErrorMC = 1;
4893  Float_t relativeErrorData = 1;
4894  if(valueMC!=0) relativeErrorMC = errorMC / valueMC;
4895  if(valueData!=0) relativeErrorData = errorData / valueData;
4896 
4903  fPeriodEnum == kLHC16i3a || fPeriodEnum == kLHC16i3b || fPeriodEnum == kLHC16i3c ) { // For these periods allow larger statistical error in the MC to apply the multiplicity weight
4904 
4905  if (relativeErrorData < 0.6 && relativeErrorMC < 0.6 ){