AliPhysics  41af4b0 (41af4b0)
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 == NULL) AliError(Form("%s was not contained in %s", fNameHistoReweightingMultData.Data(),fPathReweightingMult.Data() ));
764  hReweightMultData = new TH1D(*hReweightMultDatatemp);
765  if (hReweightMultData) AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingMultData.Data(),fPathReweightingMult.Data() ));
766  else AliWarning(Form("%s not found in %s", fNameHistoReweightingMultData.Data() ,fPathReweightingMult.Data()));
767  hReweightMultData->SetDirectory(0);
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 == NULL) AliError(Form("%s was not contained in %s", fNameHistoReweightingMultMC.Data(),fPathReweightingMult.Data() ));
773  hReweightMultMC = new TH1D(*hReweightMultMCtemp);
774  if (hReweightMultData) AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingMultMC.Data(),fPathReweightingMult.Data() ));
775  else AliWarning(Form("%s not found in %s", fNameHistoReweightingMultMC.Data() ,fPathReweightingMult.Data()));
776  hReweightMultMC->SetDirectory(0);
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 -> Sphericity > 0.5
1216  fIsHeavyIon=0;
1217  fUseSphericity=3;
1218  break;
1219 
1220  default:
1221  AliError(Form("SetHeavyIon not defined %d",isHeavyIon));
1222  return kFALSE;
1223  }
1224  return kTRUE;
1225 }
1226 
1227 //___________________________________________________________________
1229 {
1230  // Set Cut
1231  if(minCentrality<0||minCentrality>20){
1232  AliError(Form("minCentrality not defined %d",minCentrality));
1233  return kFALSE;
1234  }
1235 
1236  fCentralityMin=minCentrality;
1237  return kTRUE;
1238 }
1239 
1240 //___________________________________________________________________
1242 {
1243  // Set Cut
1244  if(maxCentrality<0||maxCentrality>20){
1245  AliError(Form("maxCentrality not defined %d",maxCentrality));
1246  return kFALSE;
1247  }
1248  fCentralityMax=maxCentrality;
1249  return kTRUE;
1250 }
1251 
1254 {
1255  // Set Cut
1256  switch(selectSpecialTrigger){
1257  case 0:
1258  fSpecialTrigger=0; // V0OR
1259  break;
1260  case 1:
1261  fSpecialTrigger=1; // V0AND
1262  break;
1263 // case 2:
1264 // fSpecialTrigger=2; //
1265 // break;
1266  case 3:
1267  fSpecialTrigger=3; //specific centrality trigger selection
1268  fSpecialTriggerName="AliVEvent::kCentral/kSemiCentral/kMB";
1269  break;
1270  case 4:
1271  fSpecialTrigger=4; // trigger alias kTRD
1272  fOfflineTriggerMask=AliVEvent::kTRD;
1273  fTriggerSelectedManually = kTRUE;
1274  fSpecialTriggerName="AliVEvent::kTRD";
1275  break;
1276  case 5:
1277  fSpecialTrigger=5; // trigger alias kEMC
1278  fOfflineTriggerMask=AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMC1 ;
1279  fTriggerSelectedManually = kTRUE;
1281  SETBIT(fTriggersEMCALSelected, kL0);
1282  fSpecialTriggerName="AliVEvent::kEMC7/kEMC8/kEMC1";
1283  break;
1284  case 6:
1285  fSpecialTrigger=6; // trigger alias kPHI
1286  fOfflineTriggerMask=AliVEvent::kPHI7 | AliVEvent::kPHI1 | AliVEvent::kPHI8 | AliVEvent::kPHOSPb;
1287  fTriggerSelectedManually = kTRUE;
1288  fSpecialTriggerName="AliVEvent::kPHI7/kPHI1/kPHI8/kPHOSPb";
1289  break;
1290  case 7:
1291  fSpecialTrigger=7; // trigger alias kHighMult
1292  fOfflineTriggerMask=AliVEvent::kHighMult;
1293  fTriggerSelectedManually = kTRUE;
1294  fSpecialTriggerName="AliVEvent::kHighMult";
1295  break;
1296  case 8:
1297  fSpecialTrigger=8; // trigger alias kEMCEGA
1298  fOfflineTriggerMask=AliVEvent::kEMCEGA;
1299  fTriggerSelectedManually = kTRUE;
1301  SETBIT(fTriggersEMCALSelected, kG2);
1302  fSpecialTriggerName="AliVEvent::kEMCEGA";
1303  break;
1304  case 9:
1305  fSpecialTrigger=9; // trigger alias kEMCEJE
1306  fOfflineTriggerMask=AliVEvent::kEMCEJE;
1307  fTriggerSelectedManually = kTRUE;
1309  SETBIT(fTriggersEMCALSelected, kJ2);
1310  fSpecialTriggerName="AliVEvent::kEMCEJE";
1311  break;
1312  case 10: //CALO and CALOFAST
1313  fSpecialTrigger=10; // trigger alias kEMC
1314  fOfflineTriggerMask=AliVEvent::kCaloOnly;
1315  fTriggerSelectedManually = kTRUE;
1317  fSpecialTriggerName="AliVEvent::kCaloOnly";
1318  break;
1319  default:
1320  AliError("Warning: Special Trigger Not known");
1321  return 0;
1322  }
1323  return 1;
1324 }
1325 
1328 {
1329  // Set Cut
1330  if (fSpecialTrigger == 0){ //OR
1331  switch(selectSpecialSubTriggerClass){
1332  case 0://with VZERO
1333  fSpecialTrigger=0;
1335 // AliInfo("Info: Nothing to be done");
1336  break;
1337  case 3: //V0OR with SDD requested (will only work with LHC11a dataset)
1339 // cout << "V0OR with SDD requested" << endl;
1340  break;
1341  default:
1342  AliError("Warning: Special Subtrigger Class Not known");
1343  return 0;
1344  }
1345  } else if (fSpecialTrigger == 1){ //AND with different detectors
1346  switch(selectSpecialSubTriggerClass){
1347  case 0: //with VZERO general implementation of V0AND (periods LHC11c onwards)
1348  fSpecialTrigger=0;
1350  fOfflineTriggerMask=AliVEvent::kINT7;
1351  fTriggerSelectedManually = kTRUE;
1352  fSpecialTriggerName="AliVEvent::kINT7";
1353  break;
1354  case 1: //with TZERO
1355  fSpecialTrigger=0;
1357  fOfflineTriggerMask=AliVEvent::kINT8;
1358  fTriggerSelectedManually = kTRUE;
1359  fSpecialTriggerName="AliVEvent::kINT8";
1360  break;
1361  case 2: //with VZERO (will only work with LHC11a dataset)
1362  fSpecialTrigger=1;
1364 // AliInfo("Info: Nothing to be done");
1365  break;
1366  case 3: //V0AND with SDD requested (will only work with LHC11a dataset)
1367  fSpecialTrigger=1;
1369  break;
1370  default:
1371  AliError("Warning: Special Subtrigger Class Not known");
1372  return 0;
1373  }
1374  } else if (fSpecialTrigger == 3){ // Selecting kCentral and kSemiCentral from trigger classes, not aliases
1375  switch(selectSpecialSubTriggerClass){
1376  case 0: // all together
1379 // AliInfo("Info: Nothing to be done");
1380  break;
1381  case 1: // kCentral - no vertex restriction
1384  fSpecialSubTriggerName="CVHN";
1385 // cout << "kCentralOpen" << endl;
1386  break;
1387  case 2: // kCentral - T00 +- 10 cm
1390  fSpecialSubTriggerName="CCENT";
1391 // cout << "kCentralVertex" << endl;
1392  break;
1393  case 3: // kCentral - both
1396  fSpecialSubTriggerName="CVHN|CCENT|CSEMI|CVLN";
1397 // cout << "kCentral both" << endl;
1398  break;
1399  case 4: // kSemiCentral - no vertex restriction
1402  fSpecialSubTriggerName="CVLN";
1403 // cout << "kSemiCentralOpen" << endl;
1404  break;
1405  case 5: // kSemiCentral - T00 +- 10 cm
1408  fSpecialSubTriggerName="CSEMI";
1409 // cout << "kSemiCentralVertex" << endl;
1410  break;
1411  case 6: // kSemiCentral - both
1414  fSpecialSubTriggerName="CSEMI%CVLN";
1415 // cout << "kSemiCentral both" << endl;
1416  break;
1417  case 7: // kMB
1420  fSpecialSubTriggerName="CPBI1_|CPBI1-";
1421 // cout << "kMB 1" << endl;
1422  break;
1423  case 8: // kMB
1426  fSpecialSubTriggerName="CPBI2_|CPBI2-";
1427 // cout << "kMB 2" << endl;
1428  break;
1429  case 9: // kMB
1432  fSpecialSubTriggerName="CPBI2_@CPBI2-@CPBI2_@CPBI2-";
1433 // cout << "kMB both" << endl;
1434  break;
1435  case 10: // 0V0M
1436  fOfflineTriggerMask=AliVEvent::kINT7;
1437  fTriggerSelectedManually = kTRUE;
1440  fSpecialSubTriggerName="C0V0M";
1441  break;
1442  case 11: // 0V0L
1443  fOfflineTriggerMask=AliVEvent::kINT7;
1444  fTriggerSelectedManually = kTRUE;
1447  fSpecialSubTriggerName="C0V0L";
1448  break;
1449  case 12: // 0VHM
1450  fOfflineTriggerMask=AliVEvent::kINT7;
1451  fTriggerSelectedManually = kTRUE;
1454  fSpecialSubTriggerName="C0VHM";
1455  break;
1456  case 13: // VOL7
1457  fOfflineTriggerMask=AliVEvent::kINT7;
1458  fTriggerSelectedManually = kTRUE;
1461  fSpecialSubTriggerName="CV0L7";
1462  break;
1463  case 14: // 0STC
1464  fOfflineTriggerMask=AliVEvent::kINT7;
1465  fTriggerSelectedManually = kTRUE;
1468  fSpecialSubTriggerName="C0STC";
1469  break;
1470  default:
1471  AliError("Warning: Special Subtrigger Class Not known");
1472  return 0;
1473  }
1474  } else if (fSpecialTrigger == 4){ // Subdivision of TRD trigger classes
1475  switch(selectSpecialSubTriggerClass){
1476  case 0: // all together
1479 // AliInfo("Info: Nothing to be done");
1480  break;
1481  case 1: // 7WUHSH - V0AND with single electron in TRD & EMCAL
1484  fSpecialSubTriggerName="7WUHEE";
1485  break;
1486  case 2: // 8WUHSH - T0AND with single electron in TRD & EMCAL
1489  fSpecialSubTriggerName="8WUHEE";
1490  break;
1491  case 3: // 7WUHSE - V0AND with single high pt electron in TRD
1494  fSpecialSubTriggerName="7WUHSE";
1495  break;
1496  case 4: // 8WUHSE - T0AND with single high pt electron in TRD
1499  fSpecialSubTriggerName="8WUHSE";
1500  break;
1501  case 5: // 7WUHJE - V0AND with jet in TRD
1504  fSpecialSubTriggerName="7WUHJT";
1505  break;
1506  case 6: // 8WUHJE - T0AND with jet in TRD
1509  fSpecialSubTriggerName="8WUHJT";
1510  break;
1511  case 7: // 7WUHQU - V0AND with dielectron pair in TRD
1514  fSpecialSubTriggerName="7WUHQU";
1515  break;
1516  case 8: // 8WUHQU - T0AND with dielectron pair in TRD
1519  fSpecialSubTriggerName="8WUHQU";
1520  break;
1521  default:
1522  AliError("Warning: Special Subtrigger Class Not known");
1523  return 0;
1524  }
1525  } else if (fSpecialTrigger == 5){ // Subdivision of kEMC trigger classes
1526  switch(selectSpecialSubTriggerClass){
1527  case 0: // all together
1530 // AliInfo("Info: Nothing to be done");
1531  break;
1532  case 1: // CEMC1 - V0OR and EMCAL fired
1533  fOfflineTriggerMask=AliVEvent::kEMC1;
1534  fSpecialTriggerName="AliVEvent::kEMC1";
1537  fSpecialSubTriggerName="CEMC1";
1538  break;
1539  case 2: // CEMC7 - V0AND and EMCAL fired
1541  fOfflineTriggerMask=AliVEvent::kEMC7;
1542  fSpecialTriggerName="AliVEvent::kEMC7";
1544  fSpecialSubTriggerName="CEMC7";
1545  break;
1546  case 3: // CEMC8 - T0OR and EMCAL fired
1547  fOfflineTriggerMask=AliVEvent::kEMC8;
1548  fSpecialTriggerName="AliVEvent::kEMC8";
1551  fSpecialSubTriggerName="CEMC8";
1552  break;
1553  case 4: // CDMC1 - V0OR and DCAL fired
1554  fOfflineTriggerMask=AliVEvent::kEMC1;
1555  fSpecialTriggerName="AliVEvent::kEMC1";
1558  fSpecialSubTriggerName="CDMC1";
1559  break;
1560  case 5: // CDMC7 - V0AND and DCAL fired
1562  fOfflineTriggerMask=AliVEvent::kEMC7;
1563  fSpecialTriggerName="AliVEvent::kEMC7";
1565  fSpecialSubTriggerName="CDMC7";
1566  break;
1567  case 6: // CDMC8 - T0OR and DCAL fired
1568  fOfflineTriggerMask=AliVEvent::kEMC8;
1569  fSpecialTriggerName="AliVEvent::kEMC8";
1572  fSpecialSubTriggerName="CDMC8";
1573  break;
1574  default:
1575  AliError("Warning: Special Subtrigger Class Not known");
1576  return 0;
1577  }
1578  }else if (fSpecialTrigger == 6){ // Subdivision of kPHI trigger classes
1579  switch(selectSpecialSubTriggerClass){
1580  case 0: // all together
1583 // AliInfo("Info: Nothing to be done");
1584  break;
1585  case 1: // CEMC1 - V0OR and EMCAL fired
1586  fOfflineTriggerMask=AliVEvent::kPHI1;
1587  fSpecialTriggerName="AliVEvent::kPHI1";
1590  fSpecialSubTriggerName="CPHI1";
1591  break;
1592  case 2: // CEMC7 - V0AND and EMCAL fired
1594  fOfflineTriggerMask=AliVEvent::kPHI7;
1595  fSpecialTriggerName="AliVEvent::kPHI7";
1597  fSpecialSubTriggerName="CPHI7";
1598  break;
1599  case 3: // CEMC8 - T0OR and EMCAL fired
1600  fOfflineTriggerMask=AliVEvent::kPHI8;
1601  fSpecialTriggerName="AliVEvent::kPHI8";
1604  fSpecialSubTriggerName="CPHI8";
1605  break;
1606  default:
1607  AliError("Warning: Special Subtrigger Class Not known");
1608  return 0;
1609  }
1610  } else if (fSpecialTrigger == 7){ // Subdivision of kHighMult trigger classes
1611  switch(selectSpecialSubTriggerClass){
1612  case 0: // all together
1615 // AliInfo("Info: Nothing to be done");
1616  break;
1617  case 1: // CSHM1 - V0OR and high mult fired
1620  fSpecialSubTriggerName="CSHM1";
1621  break;
1622  case 2: // CSHM7 - V0AND and high mult fired
1625  fSpecialSubTriggerName="CSHM7";
1626  break;
1627  case 3: // CSHM8 - T0OR and high mult fired
1630  fSpecialSubTriggerName="CSHM8";
1631  break;
1632  case 4: // V0 high mult trigger
1634  fOfflineTriggerMask=AliVEvent::kAny;
1635  fSpecialTriggerName="V0Mult";
1637  fSpecialSubTriggerName="CVHMV0M-B-";
1638  break;
1639  case 5: // SPD high mult trigger
1641  fOfflineTriggerMask=AliVEvent::kAny;
1642  fSpecialTriggerName="SPMult";
1644  fSpecialSubTriggerName="CVHMSH2-B-";
1645  break;
1646  case 6: // V0 high mult trigger with pileup condition on
1648  fOfflineTriggerMask=AliVEvent::kAny;
1649  fSpecialTriggerName="V0Mult";
1651  fSpecialSubTriggerName="CVHMV0M-B-SPD2";
1652  break;
1653 
1654  default:
1655  AliError("Warning: Special Subtrigger Class Not known");
1656  return 0;
1657  }
1658  }else if (fSpecialTrigger == 8){ // Subdivision of kEMCEGA trigger classes
1659  switch(selectSpecialSubTriggerClass){
1660  case 0: // all together
1663 // AliInfo("Info: Nothing to be done");
1664  break;
1665  case 1: // 7EGA - CINT7 EGA
1668  fSpecialSubTriggerName="7EGA";
1670  SETBIT(fTriggersEMCALSelected, kG2);
1671  break;
1672  case 2: // 8EGA - CINT8 EGA
1675  fSpecialSubTriggerName="8EGA";
1677  SETBIT(fTriggersEMCALSelected, kG2);
1678  break;
1679  case 3: // 7EG1 - CINT7 EG1
1682  fSpecialSubTriggerName="7EG1";
1684  SETBIT(fTriggersEMCALSelected, kG1);
1685  break;
1686  case 4: // 8EG1 - CINT8 EG1
1689  fSpecialSubTriggerName="8EG1";
1691  SETBIT(fTriggersEMCALSelected, kG1);
1692  break;
1693  case 5: // 7EG2 - CINT7 EG2
1696  fSpecialSubTriggerName="7EG2";
1698  SETBIT(fTriggersEMCALSelected, kG2);
1699  break;
1700  case 6: // 8EG2 - CINT8 EG2
1703  fSpecialSubTriggerName="8EG2";
1705  SETBIT(fTriggersEMCALSelected, kG2);
1706  break;
1707  case 7: // 7DGA - CINT7 DGA
1710  fSpecialSubTriggerName="7DGA";
1712  SETBIT(fTriggersEMCALSelected, kG2);
1713  break;
1714  case 8: // 8DGA - CINT8 DGA
1717  fSpecialSubTriggerName="8DGA";
1719  SETBIT(fTriggersEMCALSelected, kG2);
1720  break;
1721  case 9: // 7DG1 - CINT7 DG1
1724  fSpecialSubTriggerName="7DG1";
1726  SETBIT(fTriggersEMCALSelected, kG1);
1727  break;
1728  case 10: // 8DG1 - CINT8 DG1
1731  fSpecialSubTriggerName="8DG1";
1733  SETBIT(fTriggersEMCALSelected, kG1);
1734  break;
1735  case 11: // 7DG2 - CINT7 DG2
1738  fSpecialSubTriggerName="7DG2";
1740  SETBIT(fTriggersEMCALSelected, kG2);
1741  break;
1742  case 12: // 8DG2 - CINT8 DG2
1745  fSpecialSubTriggerName="8DG2";
1747  SETBIT(fTriggersEMCALSelected, kG2);
1748  break;
1749 
1750  default:
1751  AliError("Warning: Special Subtrigger Class Not known");
1752  return 0;
1753  }
1754  } else if (fSpecialTrigger == 9){ // Subdivision of kEMCEGA trigger classes
1755  switch(selectSpecialSubTriggerClass){
1756  case 0: // all together
1759 // AliInfo("Info: Nothing to be done");
1760  break;
1761  case 1: // 7EJE - CINT7 EJE
1764  fSpecialSubTriggerName="7EJE";
1766  SETBIT(fTriggersEMCALSelected, kJ2);
1767  break;
1768  case 2: // 8EJE - CINT8 EJE
1771  fSpecialSubTriggerName="8EJE";
1773  SETBIT(fTriggersEMCALSelected, kJ2);
1774  break;
1775  case 3: // 7EJ1 - CINT7 EJ1
1778  fSpecialSubTriggerName="7EJ1";
1780  SETBIT(fTriggersEMCALSelected, kJ1);
1781  break;
1782  case 4: // 8EJ1 - CINT8 EJ1
1785  fSpecialSubTriggerName="8EJ1";
1787  SETBIT(fTriggersEMCALSelected, kJ1);
1788  break;
1789  case 5: // 7EJ2 - CINT7 EJ2
1792  fSpecialSubTriggerName="7EJ2";
1794  SETBIT(fTriggersEMCALSelected, kJ2);
1795  break;
1796  case 6: // 8EJ2 - CINT8 EJ2
1799  fSpecialSubTriggerName="8EJ2";
1801  SETBIT(fTriggersEMCALSelected, kJ2);
1802  break;
1803  case 7: // 7DJ1 - CINT7 DJ1
1806  fSpecialSubTriggerName="7DJ1";
1808  SETBIT(fTriggersEMCALSelected, kJ1);
1809  break;
1810  case 8: // 8DJ1 - CINT8 DJ1
1813  fSpecialSubTriggerName="8DJ1";
1815  SETBIT(fTriggersEMCALSelected, kJ1);
1816  break;
1817  case 9: // 7DJ2 - CINT7 DJ2
1820  fSpecialSubTriggerName="7DJ2";
1822  SETBIT(fTriggersEMCALSelected, kJ2);
1823  break;
1824  case 10: // 8DJ2 - CINT8 DJ2
1827  fSpecialSubTriggerName="8DJ2";
1829  SETBIT(fTriggersEMCALSelected, kJ2);
1830  break;
1831 
1832  default:
1833  AliError("Warning: Special Subtrigger Class Not known");
1834  return 0;
1835  }
1836  } else if (fSpecialTrigger == 10){ // Subdivision of kEMC trigger classes
1837  switch(selectSpecialSubTriggerClass){
1838  case 0: // all together
1841  fSpecialSubTriggerName="CINT7";
1842  fSpecialTriggerName="AliVEvent::kCaloOnly/INT7";
1843  break;
1844  case 1: // CEMC7 - V0AND and EMCAL fired
1847  fSpecialSubTriggerName="CEMC7-";
1848  fSpecialTriggerName="AliVEvent::kCaloOnly/EMC7";
1849  break;
1850  case 2: // CEMC7EG2 - V0AND and EMCAL fired
1853  fSpecialSubTriggerName="7EG2";
1854  fSpecialTriggerName="AliVEvent::kCaloOnly/7EG2";
1855  break;
1856  case 3: // CEMC7EG1 - V0AND and EMCAL fired
1859  fSpecialSubTriggerName="7EG1";
1860  fSpecialTriggerName="AliVEvent::kCaloOnly/7EG1";
1861  break;
1862  case 4: // CEMC7EJ2 - V0AND and EMCAL fired
1865  fSpecialSubTriggerName="7EJ2";
1866  fSpecialTriggerName="AliVEvent::kCaloOnly/7EJ2";
1867  break;
1868  case 5: // CEMC7EJ1 - V0AND and EMCAL fired
1871  fSpecialSubTriggerName="7EJ1";
1872  fSpecialTriggerName="AliVEvent::kCaloOnly/7EJ1";
1873  break;
1874  case 6: // CDMC7 - V0AND and DCAL fired
1877  fSpecialSubTriggerName="CDMC7-";
1878  fSpecialTriggerName="AliVEvent::kCaloOnly/DMC7";
1879  break;
1880  case 7: // CDMC7DG2 - V0AND and DCAL fired
1883  fSpecialSubTriggerName="7DG2";
1884  fSpecialTriggerName="AliVEvent::kCaloOnly/7DG2";
1885  break;
1886  case 8: // CDMC7DG1 - V0AND and DCAL fired
1889  fSpecialSubTriggerName="7DG1";
1890  fSpecialTriggerName="AliVEvent::kCaloOnly/7DG1";
1891  break;
1892  case 9: // CDMC7DJ2 - V0AND and DCAL fired
1895  fSpecialSubTriggerName="7DJ2";
1896  fSpecialTriggerName="AliVEvent::kCaloOnly/7DJ2";
1897  break;
1898  case 10: // DEMC7DJ1 - V0AND and DCAL fired - a
1901  fSpecialSubTriggerName="7DJ1";
1902  fSpecialTriggerName="AliVEvent::kCaloOnly/7DJ1";
1903  break;
1904  case 11: // CEMC8 - V0AND and EMCAL fired - b
1907  fSpecialSubTriggerName="CEMC8-";
1908  fSpecialTriggerName="AliVEvent::kCaloOnly/EMC8";
1909  break;
1910  case 12: // CEMC8EG2 - V0AND and EMCAL fired - c
1913  fSpecialSubTriggerName="8EG2";
1914  fSpecialTriggerName="AliVEvent::kCaloOnly/8EG2";
1915  break;
1916  case 13: // CEMC8EG1 - V0AND and EMCAL fired - d
1919  fSpecialSubTriggerName="8EG1";
1920  fSpecialTriggerName="AliVEvent::kCaloOnly/8EG1";
1921  break;
1922  case 14: // CEMC8EJ2 - V0AND and EMCAL fired - e
1925  fSpecialSubTriggerName="8EJ2";
1926  fSpecialTriggerName="AliVEvent::kCaloOnly/8EJ2";
1927  break;
1928  case 15: // CEMC8EJ1 - V0AND and EMCAL fired - f
1931  fSpecialSubTriggerName="8EJ1";
1932  fSpecialTriggerName="AliVEvent::kCaloOnly/8EJ1";
1933  break;
1934  case 16: // CDMC8 - V0AND and DCAL fired - g
1937  fSpecialSubTriggerName="CDMC8-";
1938  fSpecialTriggerName="AliVEvent::kCaloOnly/DMC8";
1939  break;
1940  case 17: // CDMC8DG2 - V0AND and DCAL fired - h
1943  fSpecialSubTriggerName="8DG2";
1944  fSpecialTriggerName="AliVEvent::kCaloOnly/8DG2";
1945  break;
1946  case 18: // CDMC8DG1 - V0AND and DCAL fired - i
1949  fSpecialSubTriggerName="8DG1";
1950  fSpecialTriggerName="AliVEvent::kCaloOnly/8DG1";
1951  break;
1952  case 19: // CDMC8DJ2 - V0AND and DCAL fired - j
1955  fSpecialSubTriggerName="8DJ2";
1956  fSpecialTriggerName="AliVEvent::kCaloOnly/8DJ2";
1957  break;
1958  case 20: // DEMC8DJ1 - V0AND and DCAL fired - k
1961  fSpecialSubTriggerName="8DJ1";
1962  fSpecialTriggerName="AliVEvent::kCaloOnly/8DJ1";
1963  break;
1964  default:
1965  AliError("Warning: Special Subtrigger Class Not known");
1966  return 0;
1967  }
1968  }
1969  return 1;
1970 }
1971 
1972 //________________________________________________________________________
1974 {
1975  // Set Cut
1976  fMultiplicityMethod=multiplicityMethod;
1977 
1978  // 0 Photon Multiplicity
1979  // 1 TPC Track multiplicity
1980  // 2 V0 Mult
1981  // 3 SPD Mult
1982 
1983  return kTRUE;
1984 }
1985 
1986 //________________________________________________________________________
1988 {// Set Cut
1989  switch(removePileUp){
1990  case 0:
1991  fRemovePileUp = kFALSE;
1992  break;
1993  case 1:
1994  fRemovePileUp = kTRUE;
1995  fRemovePileUpSPD = kTRUE;
1996  break;
1997  case 2:
1998  fRemovePileUp = kTRUE;
1999  fRemovePileUpSPD = kTRUE;
2002  break;
2003  case 3:
2004  fRemovePileUp = kTRUE;
2005  fRemovePileUpSPD = kTRUE;
2008  break;
2009  case 4:
2010  fRemovePileUp = kTRUE;
2011  fRemovePileUpSPD = kTRUE;
2014  break;
2015  case 5:
2016  fRemovePileUp = kTRUE;
2017  fRemovePileUpSPD = kTRUE;
2020  break;
2021  case 6:
2022  fRemovePileUp = kTRUE;
2023  fRemovePileUpSPD = kTRUE;
2024  fDoPileUpRejectV0MTPCout = kTRUE;
2025  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2026  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
2027  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
2028  if (fIsHeavyIon==1){
2029  if(fPeriodEnum == kLHC15o){
2030  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2031  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2032  break;
2033  }else{
2034  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
2035  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
2036  break;
2037  }
2038  } else if(fIsHeavyIon == 2){
2039  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
2040  fFPileUpRejectV0MTPCout->SetParameter(1,2.0);
2041  break;
2042  }else{
2043  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
2044  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
2045  break;
2046  }
2047  break;
2048  case 7:
2049  fRemovePileUp = kTRUE;
2050  fRemovePileUpSPD = kTRUE;
2051  fDoPileUpRejectV0MTPCout = kTRUE;
2052  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2053  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
2054  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
2055  if (fIsHeavyIon==1){
2056  if(fPeriodEnum == kLHC15o){
2057  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2058  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2059  break;
2060  }else{
2061  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2062  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
2063  break;
2064  }
2065  } else if(fIsHeavyIon == 2){
2066  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
2067  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
2068  break;
2069  }else{
2070  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
2071  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
2072  break;
2073  }
2074  break;
2075  case 8:
2076  fRemovePileUp = kTRUE;
2077  fRemovePileUpSPD = kTRUE;
2078  fDoPileUpRejectV0MTPCout = kTRUE;
2079  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2080  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
2081  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
2082  if (fIsHeavyIon==1){
2083  if(fPeriodEnum == kLHC15o){
2084  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2085  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2086  break;
2087  }else{
2088  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
2089  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
2090  break;
2091  }
2092  } else if(fIsHeavyIon == 2){
2093  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
2094  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
2095  break;
2096  }else{
2097  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
2098  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
2099  break;
2100  }
2101  break;
2102  case 9:
2103  fRemovePileUp = kTRUE;
2104  fRemovePileUpSPD = kTRUE;
2107  fDoPileUpRejectV0MTPCout = kTRUE;
2108  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2109  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
2110  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
2111  if (fIsHeavyIon==1){
2112  if(fPeriodEnum == kLHC15o){
2113  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2114  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2115  break;
2116  }else{
2117  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
2118  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
2119  break;
2120  }
2121  } else if(fIsHeavyIon == 2){
2122  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
2123  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
2124  break;
2125  }else{
2126  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
2127  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
2128  break;
2129  }
2130  break;
2131  case 10: // for Pb-Pb
2132  fRemovePileUp = kTRUE;
2133  fRemovePileUpSPD = kTRUE;
2134  fUtils->SetASPDCvsTCut(200.);
2135  fUtils->SetBSPDCvsTCut(7.);
2136  fDoPileUpRejectV0MTPCout = kTRUE;
2137  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2138  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2139  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2140  break;
2141  case 11: // for Pb-Pb
2142  fRemovePileUp = kTRUE;
2143  fRemovePileUpSPD = kFALSE;
2144  fDoPileUpRejectV0MTPCout = kTRUE;
2145  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
2146  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
2147  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
2148  break;
2149  default:
2150  AliError("RemovePileUpCut not defined");
2151  return kFALSE;
2152  }
2153  return kTRUE;
2154 }
2155 
2156 //________________________________________________________________________
2158 
2159  switch(extraSignal){
2160  case 0:
2161  fRejectExtraSignals = 0;
2162  break; // No Rejection
2163  case 1:
2164  fRejectExtraSignals = 1;
2165  break; // MinBias Header
2166  case 2:
2167  fRejectExtraSignals = 2;
2168  break; // User String Array
2169  case 3:
2170  fRejectExtraSignals = 3;
2171  break; // Rejection for Gamma Correction only
2172  case 4:
2173  fRejectExtraSignals = 4;
2174  break; // Special handling of Jet weights for Jets embedded in MB events
2175  default:
2176  AliError(Form("Extra Signal Rejection not defined %d",extraSignal));
2177  return kFALSE;
2178  }
2179  return kTRUE;
2180 }
2181 
2182 //________________________________________________________________________
2184 
2185  switch(vertexCut){
2186  case 0: // no Vertex required // NOT fully working yet
2187  fEnableVertexCut = kFALSE;
2188  fMaxVertexZ = 1000;
2189  break;
2190  case 1: // vertex within +-15 cm
2191  fEnableVertexCut = kTRUE;
2192  fMaxVertexZ = 15;
2193  break;
2194  case 2: // vertex within +-12.5 cm
2195  fEnableVertexCut = kTRUE;
2196  fMaxVertexZ = 12.5;
2197  break;
2198  case 3: // vertex within +-10 cm
2199  fEnableVertexCut = kTRUE;
2200  fMaxVertexZ = 10.0;
2201  break;
2202  case 4: // vertex within +-7.5 cm
2203  fEnableVertexCut = kTRUE;
2204  fMaxVertexZ = 7.5;
2205  break;
2206  case 5: // vertex within +-5 cm
2207  fEnableVertexCut = kTRUE;
2208  fMaxVertexZ = 5.;
2209  break;
2210  default:
2211  AliError(Form("Vertex Cut not defined %d",vertexCut));
2212  return kFALSE;
2213  }
2214  return kTRUE;
2215 }
2216 
2217 //-------------------------------------------------------------
2219  if (fPeriodEnum == kLHC15n || // pp 5TeV
2220  fPeriodEnum == kLHC15o || // PbPb 5TeV
2221  fPeriodEnum == kLHC15k1a1 || fPeriodEnum == kLHC15k1a2 || fPeriodEnum == kLHC15k1a3 || fPeriodEnum == kLHC16j7 || // MC PbPb 5TeV LowIR
2222  fPeriodEnum == kLHC16g1 || fPeriodEnum == kLHC16g1a || fPeriodEnum == kLHC16g1b || fPeriodEnum == kLHC16g1c || // MC PbPb 5TeV general purpose
2223  fPeriodEnum == kLHC16g2 || // MC PbPb 5TeV EPOS-LHC
2224  fPeriodEnum == kLHC16g3 || // MC PbPb 5TeV DPMJET
2225  fPeriodEnum == kLHC16h4 || // MC PbPb 5TeV GA added pi0 and eta
2226  fPeriodEnum == kLHC16i1a || fPeriodEnum == kLHC16i1b || fPeriodEnum == kLHC16i1c || // MC PbPb 5TeV LF added (multi-)strange
2227  fPeriodEnum == kLHC16i2a || fPeriodEnum == kLHC16i2b || fPeriodEnum == kLHC16i2c || // MC PbPb 5TeV HF added hadronic decays
2228  fPeriodEnum == kLHC16i3a || fPeriodEnum == kLHC16i3b || fPeriodEnum == kLHC16i3c || // MC PbPb 5TeV HF added electron decays
2229  fPeriodEnum == kLHC16h2a || fPeriodEnum == kLHC16h2b || fPeriodEnum == kLHC16h2c || // MC PbPb 5TeV jet-jet
2231  fPeriodEnum == kLHC15g3a3 || fPeriodEnum == kLHC15g3c3 || // MC pp 13TeV
2232  fPeriodEnum == kLHC16qt || // pPb 5TeV LHC16qt
2233  fPeriodEnum == kLHC16r || fPeriodEnum == kLHC16s || // pPb 8TeV LHC16rs
2234  fPeriodEnum == kLHC17f2a || fPeriodEnum == kLHC17f2b || fPeriodEnum == kLHC17g8a || fPeriodEnum == kLHC18f3 || // MC pPb 5TeV LHC16qt
2236  fPeriodEnum == kLHC17f3 || fPeriodEnum == kLHC17f4 || // MC pPb 8TeV LHC16sr
2237  fPeriodEnum == kLHC17n || // Xe-Xe LHC17n
2238  fPeriodEnum == kLHC17j7 || // MC Xe-Xe LHC17n
2239  fPeriodEnum == kLHC17pq || // pp 5TeV LHC17pq
2240  fPeriodEnum == kLHC17l3b || // MC pp 5TeV LHC17pq
2241  fPeriodEnum == kLHC17l4b || // MC pp 5TeV LHC17pq
2242  fPeriodEnum == kLHC18b8 // MC Jet Jet pp 5TeV LHC17pq
2243  ){
2244  return kTRUE;
2245  } else {
2246  return kFALSE;
2247  }
2248 }
2249 
2250 //-------------------------------------------------------------
2252 { // Get Event Centrality
2253 
2254  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
2255  Int_t runnumber = event->GetRunNumber();
2256  if(esdEvent){
2258  AliMultSelection *MultSelection = (AliMultSelection*)event->FindListObject("MultSelection");
2259  if(!MultSelection){
2260  AliWarning ("AliMultSelection object not found !");
2261  return -1;
2262  }else{
2263  if(fDetectorCentrality==0){
2264  if(fIsHeavyIon==2){
2265  if (runnumber > 266329 && runnumber < 267139)
2266  return MultSelection->GetMultiplicityPercentile("V0C");// default for Pbp
2267  else
2268  return MultSelection->GetMultiplicityPercentile("V0A");// default for pPb
2269  } else {
2270  return MultSelection->GetMultiplicityPercentile("V0M");// default
2271  }
2272  } else if(fDetectorCentrality==1){
2273  return MultSelection->GetMultiplicityPercentile("CL1",kTRUE);
2274  } else if(fDetectorCentrality==2){
2275  if (runnumber > 266329 && runnumber < 267139)
2276  return MultSelection->GetMultiplicityPercentile("ZNC",kTRUE);
2277  else
2278  return MultSelection->GetMultiplicityPercentile("ZNA",kTRUE);
2279  }
2280  }
2281  }else{
2282  AliCentrality *fESDCentrality = (AliCentrality*)esdEvent->GetCentrality();
2283  if(fDetectorCentrality==0){
2284  if(fIsHeavyIon==2){
2285  if (runnumber > 196432 && runnumber < 197389)
2286  return fESDCentrality->GetCentralityPercentile("V0C"); // default for Pbp
2287  else
2288  return fESDCentrality->GetCentralityPercentile("V0A"); // default for pPb
2289  } else {
2290  return fESDCentrality->GetCentralityPercentile("V0M"); // default
2291  }
2292  } else if(fDetectorCentrality==1){
2293  return fESDCentrality->GetCentralityPercentile("CL1");
2294  } else if(fDetectorCentrality==2){
2295  if (runnumber > 196432 && runnumber < 197389)
2296  return fESDCentrality->GetCentralityPercentile("ZNC");
2297  else
2298  return fESDCentrality->GetCentralityPercentile("ZNA");
2299  }
2300  }
2301  }
2302 
2303  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
2304  if(aodEvent){
2306  AliMultSelection *MultSelection = (AliMultSelection*)aodEvent->FindListObject("MultSelection");
2307  if(!MultSelection){
2308  AliWarning ("AliMultSelection object not found !");
2309  return -1;
2310  } else{
2311  if(fDetectorCentrality==0){
2312  if(fIsHeavyIon==2) return MultSelection->GetMultiplicityPercentile("V0A");// default for pPb
2313  else return MultSelection->GetMultiplicityPercentile("V0M",kTRUE);
2314  }else if(fDetectorCentrality==1) return MultSelection->GetMultiplicityPercentile("CL1",kTRUE);
2315  else if(fDetectorCentrality==2) return MultSelection->GetMultiplicityPercentile("ZNA",kTRUE);
2316  }
2317  }else{
2318  if(aodEvent->GetHeader()){return ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();}
2319  }
2320  }
2321 
2322  return -1;
2323 }
2324 
2325 //_____________________________________________________________________________________
2326 Bool_t AliConvEventCuts::IsCentralitySelected(AliVEvent *event, AliMCEvent *mcEvent)
2327 {
2328  // Centrality Selection
2329  if(!fIsHeavyIon){
2330  if ((fCentralityMin == 0 && fCentralityMax == 0) || (fCentralityMin > fCentralityMax) ){
2331  return kTRUE;
2332  } else {
2333  Int_t primaryTracksPP[9] = { 0, 2, 5, 10, 15,
2334  30, 50, 100, 1000
2335  };
2336  Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
2337  if ( nprimaryTracks >= primaryTracksPP[fCentralityMin] && nprimaryTracks < primaryTracksPP[fCentralityMax]){
2338  return kTRUE;
2339  } else {
2340  return kFALSE;
2341  }
2342  return kFALSE;
2343  }
2344  }
2345  if(fCentralityMin == fCentralityMax ) return kTRUE;//0-100%
2346  else if ( fCentralityMax==0) fCentralityMax=10; //CentralityRange = fCentralityMin-10*multfactor
2348  if(centrality<0 && !mcEvent)return kFALSE;
2349  Double_t addMarginZNA = (fDetectorCentrality==2 && fCentralityMax==10) ? 2.0 : 0.0; // For ZNA multiplicity goes up to 101%
2350 
2351  Int_t centralityC=0;
2352  if (fModCentralityClass == 0){
2353  centralityC= Int_t(centrality);
2354  if(centralityC >= (fCentralityMin*10) && centralityC < (fCentralityMax*10 + addMarginZNA))
2355  return kTRUE;
2356  else return kFALSE;
2357  }
2358  else if (fModCentralityClass == 1){
2359  centralityC= Int_t(centrality);
2360  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2361  return kTRUE;
2362  } else return kFALSE;
2363  }
2364  else if (fModCentralityClass == 2){
2365  centralityC= Int_t(centrality);
2366  if(centralityC >= fCentralityMin && centralityC < fCentralityMax){
2367  return kTRUE;
2368  } else return kFALSE;
2369  }
2370  Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
2371  Int_t PrimaryTracks10[11][2] =
2372  {
2373  {9999,9999}, // 0 //1550 changed to 9999 on 9 Dec
2374  {1210, 928}, // 10
2375  { 817, 658}, // 20
2376  { 536, 435}, // 30
2377  { 337, 276}, // 40
2378  { 197, 162}, // 50
2379  { 106, 100}, // 60
2380  { 51, 44}, // 70
2381  { 21, 18}, // 80
2382  { 0, 0}, // 90
2383  { 0, 0}// 100 // only max accessible
2384  };
2385  Int_t PrimaryTracksLHC11h10[11][2] =
2386  {
2387  {9999,9999}, // 0 //1550 changed to 9999 on 9 Dec
2388  { 985, 928}, // 10
2389  { 661, 658}, // 20
2390  { 434, 435}, // 30
2391  { 275, 276}, // 40
2392  { 173, 162}, // 50
2393  { 100, 100}, // 60
2394  { 42, 44}, // 70
2395  { 19, 18}, // 80
2396  { 0, 0}, // 90
2397  { 0, 0}// 100 // only max accessible
2398  };
2399  Int_t PrimaryTracksLHC15o10[11][2] =
2400  {
2401  {2500, 2700}, // 0-10% cent class max # of tracks: max value of the data distribution
2402  {1498, 1498}, // 0-10% cent class min # of tracks
2403  {1012, 1012}, // 10-20
2404  { 669, 669}, // 20-30
2405  { 423, 423}, // 30-40
2406  { 251, 251}, // 40-50
2407  { 136, 136}, // 50-60
2408  { 67, 67}, // 60-70
2409  { 28, 28}, // 70-80
2410  { 0, 0}, // 80-90% cent class min # of tracks
2411  { 0, 0} // not used
2412  };
2413  Int_t PrimaryTracksLHC10h5[21][2] =
2414  {
2415  {9999,9999}, // 0 ///1550 changed to 9999 on 9 Dec
2416  {1485,1168}, // 5
2417  {1210, 928}, // 10
2418  { 995, 795}, // 15
2419  { 817, 658}, // 20
2420  { 666, 538}, // 25
2421  { 536, 435}, // 30
2422  { 428, 350}, // 35
2423  { 337, 276}, // 40
2424  { 260, 214}, // 45
2425  { 197, 162}, // 50
2426  { 147, 125}, // 55
2427  { 106, 100}, // 60
2428  { 75, 63}, // 65
2429  { 51, 44}, // 70
2430  { 34, 29}, // 75
2431  { 21, 18}, // 80
2432  { 13, 11}, // 85
2433  { 6, 6}, // 90
2434  { 3, 3}, // 95
2435  { 0, 0} // 100 only max accessible
2436  };
2437  Int_t PrimaryTracksLHC11h5[21][2] =
2438  {
2439  {9999,9999}, // 0 ///1550 changed to 9999 on 9 Dec
2440  {1166,1168}, // 5
2441  { 953, 928}, // 10
2442  { 805, 795}, // 15
2443  { 655, 658}, // 20
2444  { 535, 538}, // 25
2445  { 435, 435}, // 30
2446  { 349, 350}, // 35
2447  { 275, 276}, // 40
2448  { 214, 214}, // 45
2449  { 165, 162}, // 50
2450  { 127, 125}, // 55
2451  { 93, 100}, // 60
2452  { 64, 63}, // 65
2453  { 44, 44}, // 70
2454  { 30, 29}, // 75
2455  { 18, 18}, // 80
2456  { 11, 11}, // 85
2457  { 6, 6}, // 90
2458  { 3, 3}, // 95
2459  { 0, 0} // 100 only max accessible
2460  };
2461  Int_t PrimaryTracksLHC15o5[21][2] =
2462  {
2463  { 2500, 2700}, // 0-5% cent class max # of tracks: max value of the data distribution
2464  { 1827, 1827}, // 0-5% cent class min # of tracks
2465  { 1498, 1498}, // 5-10
2466  { 1234, 1234}, // 10-15
2467  { 1012, 1012}, // 15-20
2468  { 827, 827}, // 20-25
2469  { 669, 669}, // 25-30
2470  { 536, 536}, // 30-35
2471  { 423, 423}, // 35-40
2472  { 329, 329}, // 40-45
2473  { 251, 251}, // 45-50
2474  { 188, 188}, // 50-55
2475  { 136, 136}, // 55-60
2476  { 97, 97}, // 60-65
2477  { 67, 67}, // 65-70
2478  { 44, 44}, // 70-75
2479  { 28, 28}, // 75-80
2480  { 17, 17}, // 80-85
2481  { 10, 10}, // 85-90
2482  { 5, 5}, // 90-95 cent class minimum # of tracks
2483  { 0, 0} // 95-100
2484  };
2485  Int_t PrimaryTracksLHC17n10[11][2] =
2486  {
2487  {9999,9999}, // 0 // 1500 max in hist but set to real max
2488  { 800, 800}, // 10 // guess
2489  { 628, 628}, // 20
2490  { 350, 350}, // 30 // guess
2491  { 268, 268}, // 40
2492  { 200, 200}, // 50 // guess
2493  { 100, 100}, // 60 // guess
2494  { 51, 44}, // 70 // guess
2495  { 21, 18}, // 80 // guess
2496  { 0, 0}, // 90 // guess
2497  { 0, 0} // 100 // only max accessible
2498  };
2499 
2500  Int_t column = 0;
2501  if(event->IsA()==AliESDEvent::Class()) column = 0;
2502  if(event->IsA()==AliAODEvent::Class()) column = 1;
2503 
2504  if (fModCentralityClass == 3){
2505  if(mcEvent){
2506  // setting specific arry for LHC11h for MC track mult
2508  if(nprimaryTracks > PrimaryTracksLHC11h10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h10[fCentralityMin][column])
2509  return kTRUE;
2510  else return kFALSE;
2511  // setting specific arry for LHC17n for MC track mult
2512  } else if(fPeriodEnum == kLHC17j7 ){
2513  if(nprimaryTracks > PrimaryTracksLHC17n10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC17n10[fCentralityMin][column])
2514  return kTRUE;
2515  else return kFALSE;
2516  // settings for LHC15o MCs
2518  centralityC= Int_t(centrality/10);
2519  if(centralityC >= fCentralityMin && centralityC < fCentralityMax){
2520  if(fCentralityMin==0 && nprimaryTracks >= PrimaryTracksLHC15o10[0][column]) return kFALSE;
2521  else return kTRUE;
2522  } else return kFALSE;
2523  // setting specific arry for LHC10h for MC track mult
2524  } else {
2525  if(nprimaryTracks > PrimaryTracks10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracks10[fCentralityMin][column])
2526  return kTRUE;
2527  else return kFALSE;
2528  }
2529  }
2530  else{
2531  centralityC= Int_t(centrality/10);
2532  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2533  return kTRUE;
2534  else return kFALSE;
2535  }
2536  }
2537  else if (fModCentralityClass ==4){
2538  if(mcEvent){
2539  // setting specific arry for LHC11h for MC track mult
2541  if(nprimaryTracks > PrimaryTracksLHC11h5[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h5[fCentralityMin][column])
2542  return kTRUE;
2543  else return kFALSE;
2544  // settings for LHC15o MCs
2546  centralityC = Int_t(centrality);
2547  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2548  if(fCentralityMin==0 && nprimaryTracks >= PrimaryTracksLHC15o5[0][column]) return kFALSE;
2549  else return kTRUE;
2550  } else return kFALSE;
2551  // setting specific arry for LHC10h for MC track mult
2552  } else {
2553  if(nprimaryTracks > PrimaryTracksLHC10h5[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC10h5[fCentralityMin][column])
2554  return kTRUE;
2555  else return kFALSE;
2556  }
2557  }
2558  else{
2559  centralityC= Int_t(centrality);
2560  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2561  return kTRUE;
2562  } else return kFALSE;
2563  }
2564  }
2565 
2566  Int_t PrimaryTracksLHC11h10AltMin[11][2] =
2567  {
2568  {1550,1550}, // 0 - 0
2569  { 800, 800}, // 10 - 1
2570  { 600, 600}, // 20 - 2
2571  { 400, 400}, // 30 - 3
2572  { 240, 240}, // 40 - 4
2573  { 130, 130}, // 50 - 5
2574  { 90, 90}, // 60 - 6
2575  { 35, 35}, // 70 - 7
2576  { 15, 15}, // 80 - 8
2577  { 5, 5}, // 90 - 9
2578  { 0, 0} // 100 // only max accessible
2579  };
2580  Int_t PrimaryTracksLHC11h10AltMax[11][2] =
2581  {
2582  {1550,1550}, // 0 //1550 changed to 9999 on 9 Dec
2583  {1000,1000}, // 10
2584  { 700, 700}, // 20
2585  { 480, 480}, // 30
2586  { 300, 300}, // 40
2587  { 200, 200}, // 50
2588  { 120, 120}, // 60
2589  { 50, 50}, // 70
2590  { 22, 22}, // 80
2591  { 10, 10}, // 90
2592  { 0, 0} // 100 // only max accessible
2593  };
2594  Int_t PrimaryTracksLHC11h5AltMin[21][2] =
2595  {
2596  {1550,1550}, // 0
2597  {1000,1000}, // 5
2598  { 800, 800}, // 10
2599  { 700, 700}, // 15
2600  { 600, 600}, // 20
2601  { 500, 500}, // 25
2602  { 400, 400}, // 30
2603  { 300, 300}, // 35
2604  { 240, 240}, // 40
2605  { 180, 180}, // 45
2606  { 130, 130}, // 50
2607  { 127, 125}, // 55
2608  { 90, 90}, // 60
2609  { 55, 55}, // 65
2610  { 35, 35}, // 70
2611  { 25, 25}, // 75
2612  { 15, 15}, // 80
2613  { 11, 11}, // 85
2614  { 5, 5}, // 90
2615  { 0, 0}, // 95
2616  { 0, 0} // 100 only max accessible
2617  };
2618  Int_t PrimaryTracksLHC11h5AltMax[21][2] =
2619  {
2620  {1550,1550}, // 0
2621  {1250,1250}, // 5
2622  {1000,1000}, // 10
2623  { 805, 795}, // 15
2624  { 700, 700}, // 20
2625  { 585, 585}, // 25
2626  { 480, 480}, // 30
2627  { 380, 380}, // 35
2628  { 300, 300}, // 40
2629  { 235, 235}, // 45
2630  { 200, 200}, // 50
2631  { 140, 140}, // 55
2632  { 120, 120}, // 60
2633  { 70, 70}, // 65
2634  { 50, 50}, // 70
2635  { 35, 25}, // 75
2636  { 22, 22}, // 80
2637  { 15, 15}, // 85
2638  { 10, 10}, // 90
2639  { 5, 5}, // 95
2640  { 0, 0} // 100 only max accessible
2641  };
2642 
2643  if (fModCentralityClass == 5){
2644  if(mcEvent){
2645  // setting specific arry for LHC11h for MC track mult
2647  if(nprimaryTracks > PrimaryTracksLHC11h10AltMin[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h10AltMax[fCentralityMin][column])
2648  return kTRUE;
2649  else return kFALSE;
2650  // default return
2651  } else {
2652  return kFALSE;
2653  }
2654  } else {
2655  centralityC= Int_t(centrality/10);
2656  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2657  return kTRUE;
2658  else return kFALSE;
2659  }
2660  }
2661  else if (fModCentralityClass ==6){
2662  if(mcEvent){
2663  // setting specific arry for LHC11h for MC track mult
2665  if(nprimaryTracks > PrimaryTracksLHC11h5AltMin[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h5AltMax[fCentralityMin][column])
2666  return kTRUE;
2667  else return kFALSE;
2668  } else {
2669  return kFALSE;
2670  }
2671  } else{
2672  centralityC= Int_t(centrality);
2673  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2674  return kTRUE;
2675  } else return kFALSE;
2676  }
2677  }
2678 
2679  return kFALSE;
2680 }
2681 
2682 //________________________________________________________________________
2684  // Cut on z position of primary vertex
2685  Double_t fVertexZ=event->GetPrimaryVertex()->GetZ();
2686  Double_t fVertexZSPD = 0;
2687  AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2688  if(fESDEvent){
2689  fVertexZSPD = fESDEvent->GetPrimaryVertexSPD()->GetZ();
2690  }
2691  AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2692  if(fAODEvent){
2693  fVertexZSPD = fAODEvent->GetPrimaryVertexSPD()->GetZ();
2694  }
2695 
2696  if(TMath::Abs(fVertexZ)>fMaxVertexZ)return kFALSE;
2697 
2698 
2699  if (fPeriodEnum == kLHC11h){
2700  if (TMath::Abs(fVertexZ-fVertexZSPD) > 0.1) return kFALSE;
2701  }
2702  if (fIsHeavyIon == 2){
2703  if(!fUtils->IsVertexSelected2013pA(event)) return kFALSE;
2704  }
2705 
2706  return kTRUE;
2707 }
2708 
2709 //________________________________________________________________________
2711 {
2713  return kFALSE;
2714  TBits fIR1 = event->GetHeader()->GetIRInt1InteractionMap(); // IR1 contains V0 information (VIR)
2715  TBits fIR2 = event->GetHeader()->GetIRInt2InteractionMap(); // IR2 contains T0 information
2716  UShort_t bunchCrossings = event->GetBunchCrossNumber();
2718  for(Int_t i = 0; i<180;i++){
2719  if(fIR1.TestBitNumber(i))
2720  fHistoPastFutureBits->Fill((i*25)-90*25);
2721  }
2722  }
2723 
2724  Bool_t isOutOfBunchPileup = 0;
2725  Int_t pf1 = fPastFutureRejectionLow +bunchCrossings%4;
2726  Int_t pf2 = fPastFutureRejectionHigh+bunchCrossings%4;
2727  if(pf1 < -89) pf1 = -89;
2728  if(pf2 > 89) pf2 = 89;
2729  Int_t pf2maxForT0 = pf2;
2730  Int_t ir1skip = 0;
2731  for (Int_t i=pf1;i<=pf2;i++) {
2732  if (i==0) continue;
2733  if (i<=pf2maxForT0) isOutOfBunchPileup|=fIR2.TestBitNumber(90+i); // T0-based clean-up
2734  if (i>0 && i<=ir1skip) continue; // skip next 2 for old IR definitions
2735  isOutOfBunchPileup|=fIR1.TestBitNumber(90+i); // V0-based clean-up
2736  }
2737  return isOutOfBunchPileup;
2738 }
2739 //________________________________________________________________________
2740 
2742 {
2743  Bool_t isPileUpV0MTPCout=0;
2744 
2745  Double_t multV0M;
2746  Double_t valFunc;
2747  if (fIsHeavyIon==2){
2748  multV0M = event->GetVZEROData()->GetMTotV0A();
2749  }else{
2750  multV0M = event->GetVZEROData()->GetMTotV0A() + event->GetVZEROData()->GetMTotV0C() ;
2751  }
2752 
2753  if ( fFPileUpRejectV0MTPCout != 0x0 ){
2754  valFunc= fFPileUpRejectV0MTPCout->Eval(((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfTPCoutTracks());
2755  if (multV0M < valFunc ) isPileUpV0MTPCout=1;
2756  }
2757 
2758  return isPileUpV0MTPCout;
2759 
2760 }
2761 //________________________________________________________________________
2763  // returns number of contributors to the vertex
2764 
2765  AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2766  if(fESDEvent){
2767  if (fESDEvent->GetPrimaryVertex() != NULL){
2768  if(fESDEvent->GetPrimaryVertex()->GetNContributors()>0) {
2769  // cout << "accepted global" << fESDEvent->GetEventNumberInFile() << " with NCont: " << fESDEvent->GetPrimaryVertex()->GetNContributors() << endl;
2770  return fESDEvent->GetPrimaryVertex()->GetNContributors();
2771  }
2772  }
2773 
2774  if(fESDEvent->GetPrimaryVertexSPD() !=NULL){
2775  if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2776  // cout << "accepted SPD" << fESDEvent->GetEventNumberInFile() << " with NCont: " << fESDEvent->GetPrimaryVertexSPD()->GetNContributors() << endl;
2777  return fESDEvent->GetPrimaryVertexSPD()->GetNContributors();
2778  }else {
2779  AliWarning(Form("Number of contributors from bad vertex type:: %s",fESDEvent->GetPrimaryVertex()->GetName()));
2780  // cout << "rejected " << fESDEvent->GetEventNumberInFile() << endl;
2781  return 0;
2782  }
2783  }
2784  }
2785 
2786  AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2787  if(fAODEvent){
2788  if (fAODEvent->GetPrimaryVertex() != NULL){
2789  if(fAODEvent->GetPrimaryVertex()->GetNContributors()>0) {
2790  return fAODEvent->GetPrimaryVertex()->GetNContributors();
2791  }
2792  }
2793  if(fAODEvent->GetPrimaryVertexSPD() !=NULL){
2794  if(fAODEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2795  return fAODEvent->GetPrimaryVertexSPD()->GetNContributors();
2796  } else {
2797  AliWarning(Form("Number of contributors from bad vertex type:: %s",fAODEvent->GetPrimaryVertex()->GetName()));
2798  return 0;
2799  }
2800  }
2801  }
2802  // cout << "rejected " << fESDEvent->GetEventNumberInFile() << endl;
2803  return 0;
2804 }
2805 
2806 //________________________________________________________________________
2807 // Analysing Jet-Jet MC's
2808 //________________________________________________________________________
2809 Bool_t AliConvEventCuts::IsJetJetMCEventAccepted(AliMCEvent *mcEvent, Double_t& weight, AliVEvent* event ){
2810  AliGenCocktailEventHeader *cHeader = 0x0;
2811  Bool_t headerFound = kFALSE;
2812  weight = -1;
2813  fMaxPtJetMC = 0;
2814 
2815  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
2816  fPeriodEnum != kLHC17i3a1 && // LHC16ijklop GammaJet MC EMCal triggered
2817  fPeriodEnum != kLHC17i3c1 && // LHC16ijklop JetJet MC EMCal triggered
2818  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2819  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
2820  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2821  fPeriodEnum != kLHC17P1JJ && fPeriodEnum != kLHC17P1JJLowB && // LHC17X Jet Jet MC's
2822  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2823  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2824  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2825  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2826  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2827  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
2828  ){
2829 
2830  weight = 1;
2831  return kTRUE;
2832  }
2833 
2834  if(mcEvent){
2835  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2836  if(cHeader) headerFound = kTRUE;
2837  }else{
2838  //no mcEvent available -> not running on MC
2839  weight = 1;
2840  return kTRUE;
2841  }
2842 
2843  if(headerFound){
2844  TList *genHeaders = 0x0;
2845  if(cHeader) genHeaders = cHeader->GetHeaders();
2846  AliGenEventHeader* gh = 0;
2847  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2848  gh = (AliGenEventHeader*)genHeaders->At(i);
2849  TString GeneratorName = gh->GetName();
2850  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2851  Bool_t eventAccepted = kTRUE;
2852  TParticle * jet = 0;
2853  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(gh)->NTriggerJets();
2854  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
2855  Float_t tmpjet[]={0,0,0,0};
2856  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2857  dynamic_cast<AliGenPythiaEventHeader*>(gh)->TriggerJet(ijet, tmpjet);
2858  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2859  //Compare jet pT and pt Hard
2860  if(jet->Pt() > fMaxFacPtHard * ptHard){
2861  eventAccepted= kFALSE;
2862  }
2863  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2864  }
2865  if (jet) delete jet;
2866  if (mcEvent){
2867  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2868  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2869  if (!particle) continue;
2870  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2871  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2872  eventAccepted= kFALSE;
2873  }
2874  }
2875 
2876  }
2877  }
2878 
2880  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2881  21, 28, 36, 45, 57,
2882  70, 85, 99, 115, 132,
2883  150, 169, 190, 212, 235,
2884  1000000};
2885  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2886  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2887  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2888  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2889  Int_t bin = 0;
2890  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2891  if (bin < 20) weight = weightsBins[bin];
2892 
2893  } else if ( fPeriodEnum == kLHC16P1JJ || fPeriodEnum == kLHC17P1JJ ){
2894  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2895  21, 28, 36, 45, 57,
2896  70, 85, 99, 115, 132,
2897  150, 169, 190, 212, 235,
2898  1000000};
2899  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2900  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2901  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2902  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2903 
2904  Int_t bin = 0;
2905  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2906  if (bin < 20) weight = weightsBins[bin];
2907 
2908  } else if ( fPeriodEnum == kLHC16h3 ){
2909  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2910  21, 28, 36, 45, 57,
2911  70, 85, 99, 115, 132,
2912  150, 169, 190, 212, 235,
2913  1000000};
2914  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2915  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2916  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2917  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2918  Int_t bin = 0;
2919  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2920  if (bin < 20) weight = weightsBins[bin];
2921 
2922 
2923  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2924  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2925  21, 28, 36, 45, 57,
2926  70, 85, 1000};
2927  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2928  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2929  1.933238e-05, 1.562895e-05};
2930  Int_t bin = 0;
2931  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2932  if (bin < 12) weight = weightsBins[bin];
2933 
2934  } else if ( fPeriodEnum == kLHC15g1a ){
2935  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2936  84, 117, 152, 191, 1000000,
2937  5, 7, 9, 12, 16,
2938  21, 28, 36, 45, 57 };
2939  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2940  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2941  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2942  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2943 
2944  Int_t bin = 0;
2945  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2946  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2947  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2948  if (bin < 19) weight = weightsBins[bin];
2949 
2950  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2951  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2952  84, 117, 152, 191, 1000000,
2953  5, 7, 9, 12, 16,
2954  21, 28, 36, 45, 57 };
2955  // LHC15a3a
2956  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2957  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2958  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2959  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2960  Int_t bin = 0;
2961  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2962  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2963  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2964  if (bin < 19) weight = weightsBins[bin];
2965 
2966  } else if ( fPeriodEnum == kLHC12P2JJ ){
2967  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2968  21, 28, 36, 45, 57,
2969  70, 85, 99, 115, 132,
2970  150, 169, 190, 212, 235,
2971  1000000};
2972  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
2973  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
2974  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
2975  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
2976  Int_t bin = 0;
2977  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2978  if (bin < 20) weight = weightsBins[bin];
2979 
2980  } else if ( fPeriodEnum == kLHC16c3a ){ // ALIROOT-5901
2981  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
2982  Double_t weightsBins[5] = { 6.731200e-03, 7.995602e-03, 6.778717e-03, 4.643571e-03, 6.014497e-03}; //preliminary estimates
2983  Int_t bin = 0;
2984  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2985  if (bin < 5) weight = weightsBins[bin];
2986 
2987  } else if (fPeriodEnum == kLHC16c3b ){ // ALIROOT-5901
2988  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
2989  Double_t weightsBins[6] = { 6.071458e-03, 3.941701e-03, 2.001984e-03, 9.862765e-04, 3.893911e-04, 1.865924e-04}; //preliminary estimates
2990  Int_t bin = 0;
2991  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2992  if (bin < 6) weight = weightsBins[bin];
2993 
2994  } else if (fPeriodEnum == kLHC16c3c ){ // ALIROOT-5901
2995  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
2996  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
2997  Int_t bin = 0;
2998  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2999  if (bin < 7) weight = weightsBins[bin];
3000 
3001  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
3002  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
3003  84, 117, 152, 191, 234,
3004  1000};
3005  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
3006  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
3007  Int_t bin = 0;
3008  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3009  if (bin < 10) weight = weightsBins[bin];
3010  } else if ( fPeriodEnum == kLHC17g8a ){ // preliminary weights obtained from local running
3011  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};
3012  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};
3013  Int_t bin = 0;
3014  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3015  if (bin < 20) weight = weightsBins[bin];
3016  } else if ( fPeriodEnum == kLHC16rP1JJ ){ // preliminary weights obtained from local running
3017  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};
3018  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};
3019  Int_t bin = 0;
3020  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3021  if (bin < 20) weight = weightsBins[bin];
3022  } else if ( fPeriodEnum == kLHC16sP1JJ ){ // preliminary weights obtained from local running
3023  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};
3024  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};
3025  Int_t bin = 0;
3026  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3027  if (bin < 20) weight = weightsBins[bin];
3028  } else if ( fPeriodEnum == kLHC17i3a1 ){ // weights obtained from ga_pp_mc_aod train 912
3029  Double_t ptHardBinRanges[7] = { 5, 11, 21, 36, 57, 84, 10000};
3030  Double_t weightsBins[6] = { 0.0002181, 3.13684e-05, 5.01515e-06, 9.50662e-07, 2.08186e-07, 7.96555e-08};
3031  Int_t bin = 0;
3032  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3033  if (bin < 6) weight = weightsBins[bin];
3034  } else if ( fPeriodEnum == kLHC17i3c1 ){ // preliminary weights obtained from local running
3035  Double_t ptHardBinRanges[9] = { 8, 10, 14, 19, 26, 35, 48, 66, 10000};
3036  Double_t weightsBins[8] = { 0.000813592, 0.00172074, 0.00187963, 0.00184331, 0.00142672, 0.0010083, 0.000599846, 0.000499877};
3037  Int_t bin = 0;
3038  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3039  if (bin < 8) weight = weightsBins[bin];
3040  } else {
3041  weight = 1;
3042  }
3043 
3044  if (weight == -1) return kFALSE;
3045  else return eventAccepted;
3046 
3047  }
3048  }
3049  } else {
3050  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
3051  TString eventHeaderName = eventHeader->ClassName();
3052  Bool_t eventAccepted = kFALSE;
3053  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
3054  eventAccepted = kTRUE;
3055  }else { //special case for pythia8jets embedded in EPOSLHC for AODs
3056  if(event->IsA()==AliAODEvent::Class()){
3057  AliAODMCHeader *mch = NULL;
3058  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
3059  if(aod){
3060  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
3061  if ( mch ){
3062  Int_t nGenerators = mch->GetNCocktailHeaders();
3063  if ( nGenerators > 0 ){
3064  for(Int_t igen = 0; igen < nGenerators; igen++)
3065  {
3066  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
3067  TString name = eventHeaderGen->GetName();
3068  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
3069  eventAccepted = kTRUE;
3070  eventHeader = eventHeaderGen;
3071  }
3072  }
3073  }
3074  }
3075  }
3076  }
3077  }
3078  if(eventAccepted){
3079  TParticle * jet = 0;
3080  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->NTriggerJets();
3081  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
3082  Float_t tmpjet[]={0,0,0,0};
3083  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
3084  dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->TriggerJet(ijet, tmpjet);
3085  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
3086  //Compare jet pT and pt Hard
3087  if(jet->Pt() > fMaxFacPtHard * ptHard){
3088  eventAccepted= kFALSE;
3089  }
3090  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
3091  }
3092  if (mcEvent){
3093  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
3094  TParticle* particle = (TParticle *)mcEvent->Particle(i);
3095  if (!particle) continue;
3096  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
3097  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
3098  eventAccepted= kFALSE;
3099  }
3100  }
3101 
3102  }
3103  }
3104 
3106  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
3107  21, 28, 36, 45, 57,
3108  70, 85, 99, 115, 132,
3109  150, 169, 190, 212, 235,
3110  1000000};
3111  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
3112  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
3113  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
3114  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
3115  Int_t bin = 0;
3116  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3117  if (bin < 20) weight = weightsBins[bin];
3118 
3119  } else if ( fPeriodEnum == kLHC16P1JJ || fPeriodEnum == kLHC17P1JJ){
3120  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
3121  21, 28, 36, 45, 57,
3122  70, 85, 99, 115, 132,
3123  150, 169, 190, 212, 235,
3124  1000000};
3125  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
3126  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
3127  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
3128  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
3129 
3130  Int_t bin = 0;
3131  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3132  if (bin < 20) weight = weightsBins[bin];
3133 
3134  } else if ( fPeriodEnum == kLHC16h3 ){
3135  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
3136  21, 28, 36, 45, 57,
3137  70, 85, 99, 115, 132,
3138  150, 169, 190, 212, 235,
3139  1000000};
3140  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
3141  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
3142  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
3143  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
3144  Int_t bin = 0;
3145  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3146  if (bin < 20) weight = weightsBins[bin];
3147 
3148 
3149  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
3150  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
3151  21, 28, 36, 45, 57,
3152  70, 85, 1000};
3153  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
3154  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
3155  1.933238e-05, 1.562895e-05};
3156  Int_t bin = 0;
3157  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3158  if (bin < 12) weight = weightsBins[bin];
3159 
3160  } else if ( fPeriodEnum == kLHC15g1a ){
3161  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
3162  84, 117, 152, 191, 1000000,
3163  5, 7, 9, 12, 16,
3164  21, 28, 36, 45, 57 };
3165  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
3166  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
3167  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
3168  0.0307759, 0.0087083, 0.0027664, 0.00106203};
3169 
3170  Int_t bin = 0;
3171  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
3172  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
3173  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3174  if (bin < 19) weight = weightsBins[bin];
3175 
3176  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
3177  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
3178  84, 117, 152, 191, 1000000,
3179  5, 7, 9, 12, 16,
3180  21, 28, 36, 45, 57 };
3181  // LHC15a3a
3182  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
3183  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
3184  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
3185  0.0307638, 0.00870635, 0.00276658, 0.00106229};
3186  Int_t bin = 0;
3187  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
3188  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
3189  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3190  if (bin < 19) weight = weightsBins[bin];
3191 
3192  } else if ( fPeriodEnum == kLHC12P2JJ ){
3193  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
3194  21, 28, 36, 45, 57,
3195  70, 85, 99, 115, 132,
3196  150, 169, 190, 212, 235,
3197  1000000};
3198  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
3199  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
3200  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
3201  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
3202  Int_t bin = 0;
3203  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3204  if (bin < 20) weight = weightsBins[bin];
3205 
3206  } else if ( fPeriodEnum == kLHC16c3a ){ //ALIROOT-5901
3207  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
3208  Double_t weightsBins[5] = { 6.731200e-03, 7.995602e-03, 6.778717e-03, 4.643571e-03, 6.014497e-03}; //preliminary estimates
3209  Int_t bin = 0;
3210  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3211  if (bin < 5) weight = weightsBins[bin];
3212 
3213  } else if (fPeriodEnum == kLHC16c3b ){ //ALIROOT-5901
3214  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
3215  Double_t weightsBins[6] = { 6.071458e-03, 3.941701e-03, 2.001984e-03, 9.862765e-04, 3.893911e-04, 1.865924e-04}; //preliminary estimates
3216  Int_t bin = 0;
3217  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3218  if (bin < 6) weight = weightsBins[bin];
3219 
3220  } else if (fPeriodEnum == kLHC16c3c ){ //ALIROOT-5901
3221  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
3222  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
3223  Int_t bin = 0;
3224  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3225  if (bin < 7) weight = weightsBins[bin];
3226 
3227  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
3228  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
3229  84, 117, 152, 191, 234,
3230  1000};
3231  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
3232  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
3233  Int_t bin = 0;
3234  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3235  if (bin < 10) weight = weightsBins[bin];
3236  } else if ( fPeriodEnum == kLHC16rP1JJ ){ // preliminary weights obtained from local running
3237  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};
3238  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};
3239  Int_t bin = 0;
3240  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3241  if (bin < 20) weight = weightsBins[bin];
3242  } else if ( fPeriodEnum == kLHC16sP1JJ ){ // preliminary weights obtained from local running
3243  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};
3244  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};
3245  Int_t bin = 0;
3246  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3247  if (bin < 20) weight = weightsBins[bin];
3248  } else if ( fPeriodEnum == kLHC17i3a1 ){ // weights obtained from ga_pp_mc_aod train 912
3249  Double_t ptHardBinRanges[7] = { 5, 11, 21, 36, 57, 84, 10000};
3250  Double_t weightsBins[6] = { 0.0002181, 3.13684e-05, 5.01515e-06, 9.50662e-07, 2.08186e-07, 7.96555e-08};
3251  Int_t bin = 0;
3252  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3253  if (bin < 6) weight = weightsBins[bin];
3254  } else if ( fPeriodEnum == kLHC17i3c1 ){ // preliminary weights obtained from local running
3255  Double_t ptHardBinRanges[9] = { 8, 10, 14, 19, 26, 35, 48, 66, 10000};
3256  Double_t weightsBins[8] = { 0.000813592, 0.00172074, 0.00187963, 0.00184331, 0.00142672, 0.0010083, 0.000599846, 0.000499877};
3257  Int_t bin = 0;
3258  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3259  if (bin < 8) weight = weightsBins[bin];
3260  } else if ( fPeriodEnum == kLHC18b8 ){
3261  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};
3262  Double_t weightsBins[20] = { 16.1083, 4.60917, 2.15196, 0.782021, 0.26541,
3263  0.0978374, 0.0294286, 0.00989457, 0.0040615, 0.00135787,
3264  0.000531766, 0.000188772, 9.23331e-05, 4.30245e-05, 2.10196e-05,
3265  1.06695e-05, 5.78742e-06, 3.02897e-06, 1.62702e-06, 2.12118e-06 };
3266 
3267  Int_t bin = 0;
3268  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3269  if (bin < 20) weight = weightsBins[bin];
3270  } else {
3271  weight = 1;
3272  }
3273 
3274  if (weight == -1) return kFALSE;
3275  else return eventAccepted;
3276 
3277  } else {
3278  return kFALSE;
3279  }
3280  }
3281 
3282  return kFALSE;
3283 }
3284 
3285 //________________________________________________________________________
3286 // Analysing Jet-Jet MC's
3287 //________________________________________________________________________
3288 void AliConvEventCuts::GetXSectionAndNTrials(AliMCEvent *mcEvent, Float_t &XSection, Float_t &NTrials, AliVEvent* event){
3289 
3290  AliGenCocktailEventHeader *cHeader = 0x0;
3291  Bool_t headerFound = kFALSE;
3292  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
3293  fPeriodEnum != kLHC17i3a1 && // LHC16ijklop GammaJet MC EMCal triggered
3294  fPeriodEnum != kLHC17i3c1 && // LHC16ijklop JetJet MC EMCal triggered
3295  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
3296  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
3297  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
3298  fPeriodEnum != kLHC17P1JJ && fPeriodEnum != kLHC17P1JJLowB && // LHC17X Jet Jet MC's
3299  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
3300  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
3301  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
3302  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
3303  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
3304  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
3305  ){
3306  NTrials = -1;
3307  XSection = -1;
3308  return;
3309  }
3310 
3311  if(mcEvent){
3312  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
3313  if(cHeader) headerFound = kTRUE;
3314  }else{
3315  //no mcEvent available -> not running on MC
3316  NTrials = -1;
3317  XSection = -1;
3318  return;
3319  }
3320 
3321  if(headerFound){
3322  TList *genHeaders = 0x0;
3323  if(cHeader) genHeaders = cHeader->GetHeaders();
3324  AliGenEventHeader* gh = 0;
3325  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3326  gh = (AliGenEventHeader*)genHeaders->At(i);
3327  TString GeneratorName = gh->GetName();
3328  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
3329  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(gh);
3330  NTrials = gPythia->Trials();
3331  XSection = gPythia->GetXsection();
3332  return;
3333  }
3334  }
3335  } else {
3336  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
3337  if(eventHeader){
3338  TString eventHeaderName = eventHeader->ClassName();
3339  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
3340  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader);
3341  NTrials = gPythia->Trials();
3342  XSection = gPythia->GetXsection();
3343  return;
3344  }
3345  }
3346  }
3347  // the following part is necessary for pythia8jets embedded in EPOS for AODs
3348  if(event){
3349  if(event->IsA()==AliAODEvent::Class()){
3350  AliAODMCHeader *mch = NULL;
3351  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
3352  if(aod){
3353  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
3354  if ( mch ){
3355  Int_t nGenerators = mch->GetNCocktailHeaders();
3356  if ( nGenerators > 0 ){
3357  for(Int_t igen = 0; igen < nGenerators; igen++){
3358  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
3359  TString name = eventHeaderGen->GetName();
3360  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
3361  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeaderGen);
3362  NTrials = gPythia->Trials();
3363  XSection = gPythia->GetXsection();
3364  return;
3365  }
3366  }
3367  }
3368  }
3369  }
3370  }
3371  }
3372 
3373  NTrials = -1;
3374  XSection = -1;
3375  return;
3376 }
3377 
3378 
3379 //________________________________________________________________________
3380 // Analysing Jet-Jet MC's
3381 //________________________________________________________________________
3382 Float_t AliConvEventCuts::GetPtHard(AliMCEvent *mcEvent, AliVEvent* event){
3383  AliGenCocktailEventHeader *cHeader = 0x0;
3384  Bool_t headerFound = kFALSE;
3385 
3386  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
3387  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
3388  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
3389  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
3390  fPeriodEnum != kLHC17P1JJ && fPeriodEnum != kLHC17P1JJLowB && // LHC17X Jet Jet MC's
3391  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
3392  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
3393  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
3394  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
3395  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
3396  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
3397  ) return -1;
3398 
3399  if(mcEvent){
3400  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
3401  if(cHeader) headerFound = kTRUE;
3402  }else{
3403  //no mcEvent available -> not running on MC
3404  return -1;
3405  }
3406 
3407  if(headerFound){
3408  TList *genHeaders = 0x0;
3409  if(cHeader) genHeaders = cHeader->GetHeaders();
3410  AliGenEventHeader* gh = 0;
3411  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3412  gh = (AliGenEventHeader*)genHeaders->At(i);
3413  TString GeneratorName = gh->GetName();
3414  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
3415  return dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
3416  }
3417  }
3418  } else {
3419  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
3420  if(eventHeader){
3421  TString eventHeaderName = eventHeader->ClassName();
3422  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
3423  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
3424  }
3425  }
3426 
3427  if(event->IsA()==AliAODEvent::Class()){
3428  AliAODMCHeader *mch = NULL;
3429  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
3430  if(aod){
3431  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
3432  if ( mch ){
3433  Int_t nGenerators = mch->GetNCocktailHeaders();
3434  if ( nGenerators > 0 ){
3435  for(Int_t igen = 0; igen < nGenerators; igen++)
3436  {
3437  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
3438  TString name = eventHeaderGen->GetName();
3439  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
3440  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeaderGen)->GetPtHard();
3441  }
3442  }
3443  }
3444  }
3445  }
3446  }
3447  }
3448 
3449  return -1;
3450 }
3451 
3452 
3453 //________________________________________________________________________
3455  // abort if mimicing not enabled
3456 
3457  if (!fMimicTrigger) return kTRUE;
3458 
3459  Int_t runRangesEMCalL0 [52] = { 144871, 145288, 146375, 146382, // LHC11a
3460  146502, 148522, // LHC11a
3461  150209, 153056, 153911, 153915, // LHC11b,c,d
3462  158135, 158136, 158178, 158182, 160683,
3463  160764, 161139, 161256, 161379, 161457,
3464  161525, 161556, 161558, 161609, 161630,
3465  161724, // LHC11d,e
3466  173731, 177144, 177147, 177653, 177724, 178327, // LHC12x
3467  195180, // LHC13b-f
3468  197469, 197692, // LHC13g
3469  235195, // LHC15a-h
3470  244285, // LHC15i-LHC15m (235196-244284)
3471  244629, // LHC15n (244340-244628)
3472  245141, 246995, // LHC15o (244824-246994)
3473  255539, // LHC16i-k (255515-258574)
3474  258883, // LHC16l (258883-260187)
3475  260216, // LHC16m-p (260216-p)
3476  265015, 265309, // LHC16q (265015-265525)
3477  265589, 265785, // LHC16r (265589-266318)
3478  266405, // LHC16s (266405-267131)
3479  267161, // LHC16t (267161-267166)
3480  270531, // LHC17c-o (270531-281961)
3481  282008, // LHC17pq (282008-282441)
3482  282504 // 2018
3483  };
3484 
3485  Double_t thresholdEMCalL0[51] = { 2.11, 3.43, 1.71, 2.05, // LHC11a 7 TeV
3486  3.43, // LHC11a 2.76TeV
3487  1.94, 3.39, 4.01, 5.25, 5.5, // LHC11b, LHC11c, LHC11d
3488  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,
3489  2.01, 1.75, 1.52, 2.01, 1.52, 1.85,
3490  3.2,
3491  /*2.01*/1.8, // LHC13g
3492  2000, // LS1
3493  1.8, // LHC15a-h
3494  5.0, // LHC15i-m
3495  5.0, // LHC15n
3496  1.0, 1.0, // LHC15o
3497  2.2, // LHC16i-k (255515-258574)
3498  2.2, // LHC16l (258883-260187)
3499  2.5, // LHC16m-p (260216-p)
3500  2.5, 2.5, // LHC16q (265015-265525)
3501  2.5, 2.5, // LHC16r (265589-266318)
3502  3.5, // LHC16s (266405-267131)
3503  2.5, // LHC16t (267161-267166)
3504  2.5, // LHC17c-o (270531-281961)
3505  2.5 // LHC17pq (282008-282441)
3506 // 2.5 // 2018
3507  };
3508 
3509  Double_t spreadEMCalL0[51] = { 0., 0., 0, 0, // LHC11a 7TeV
3510  /*0.7*/0.65, // LHC11a 2.76TeV
3511  0., 0., 0., 0., 0., // LHC11b, LHC11c, LHC11d
3512  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
3513  0., 0., 0., 0., 0.2, 0.2,/*0.,0.,*/
3514  0.1, // LHC13b-f
3515  /*0.1*/0.12, // LHC13g
3516  0., // LS1
3517  0.1, // LHC15a-h
3518  0.1, // LHC15i-m
3519  0.1, // LHC15n
3520  0.1, 0.1, // LHC15o
3521  0.2, // LHC16i-k (255515-258574)
3522  0.2, // LHC16l (258883-260187)
3523  0.1, // LHC16m-p (260216-p)
3524  0.1, 0.1, // LHC16q (265015-265525)
3525  0.1, 0.1, // LHC16r (265589-266318)
3526  0.1, // LHC16s (266405-267131)
3527  0.1, // LHC16t (267161-267166)
3528  0.1, // LHC17c-o (270531-281961)
3529  0.1 // LHC17pq (282008-282441)
3530 // 0.1 // 2018
3531  };
3532 
3533  Int_t runRangesEMCalL1[21] = { 179796, // LHC12c-i (EGA)
3534  195180, // LHC13b-f
3535  197469, 197692, // LHC13g
3536  235195, // LHC15a-h
3537  244285, // LHC15i-LHC15m (235196-244284)
3538  244629, // LHC15n (244340-244628)
3539  245141, 246995, // LHC15o (244824-246994)
3540  255539, // LHC16i-k (255515-258574)
3541  258883, // LHC16l (258883-260187)
3542  260216, // LHC16m-p (260216-p)
3543  265015, 265309, // LHC16q (265015-265525)
3544  265589, 265785, // LHC16r (265589-266318)
3545  266405, // LHC16s (266405-267131)
3546  267161, // LHC16t (267161-267166)
3547  270531, // LHC17c-o (270531-281961)
3548  282008, // LHC17pq (282008-282441)
3549  282504 // 2018
3550  };
3551 
3552  Double_t thresholdEMCalL1[20] = { 9.5/*8.398*/, // LHC12c-i (EGA)
3553  11.5, /*6.*/ // LHC13b-f
3554  5.5, // LHC13g
3555  2000.0, // LS1
3556  2000.0, // LHC15a-h
3557  5.0, // LHC15i-m
3558  5.0, // LHC15n
3559  2000.0, 10.0, // LHC15o
3560  8.8, // LHC16i-k (255515-258574)
3561  5.5, // LHC16l (258883-260187)
3562  8.8, // LHC16m-p (260216-)
3563  8.8, 10.8, // LHC16q (265015-265525)
3564  10.8, 7.8, // LHC16r (265589-266318)
3565  7.8, // LHC16s (266405-267131)
3566  7.8, // LHC16t (267161-267166)
3567  8.8, // LHC17c-o (270531-281961)
3568  8.8 // LHC17pq (282008-282441)
3569 // 8.8 // 2018
3570  };
3571  Double_t spreadEMCalL1[20] = { 1.0/*0.*/,
3572  0.5,
3573  /*0.4*/ 0.6,
3574  0.0, // LS1
3575  1.2, 0.8, // LHC16r (265589-266318)
3576  0.0, // LHC15a-h
3577  1.0, // LHC15i-m
3578  1.0, // LHC15n
3579  0.0, 1.0, // LHC15o
3580  1.0, // LHC16i-k (255515-258574)
3581  0.8, // LHC16l (258883-260187)
3582  1.0, // LHC16m-p (260216-)
3583  1.0, 1.2, // LHC16q (265015-265525)
3584  0.9, // LHC16s (266405-267131)
3585  0.9, // LHC16t (267161-267166)
3586  1.0, // LHC17c-o (270531-281961)
3587  1.0 // LHC17pq (282008-282441)
3588 // 1.0 // 2018
3589  };
3590 
3591  Int_t runRangesEMCalL1G2[21] = { 195180, // LHC13b-f
3592  197469, 197692, // LHC13g
3593  235195, // LHC15a-h
3594  244285, // LHC15i-LHC15m (235196-244284)
3595  244629, // LHC15n (244340-244628)
3596  245141, 246995, // LHC15o (244824-246994)
3597  255539, // LHC16i-k (255515-258574)
3598  258883, // LHC16l (258883-260187)
3599  260216, // LHC16m-p (260216-)
3600  265015, 265309, // LHC16q (265015-265525)
3601  265589, 265785, // LHC16r (265589-266318)
3602  266405, // LHC16s (266405-267131)
3603  267161, // LHC16t (267161-267166)
3604  270531, // LHC17c-o (270531-281961)
3605  282008, // LHC17pq (282008-282441)
3606  282504 // 2018
3607  };
3608 
3609  Double_t thresholdEMCalL1G2[19] = { 7.2, // LHC13b-f
3610  /*3.9*/3.75, // LHC13g
3611  2000.0, // LS1
3612  1.8, // LHC15a-h
3613  5.0, // LHC15i-m
3614  5.0, // LHC15n
3615  2000.0, 2000.0, // LHC15o
3616  3.9, // LHC16i-k (255515-258574)
3617  3.8, // LHC16l (258883-260187)
3618  3.9, // LHC16m-p (260216-)
3619  3.9, 6.3, // LHC16q (265015-265525)
3620  6.3, 5.3, // LHC16r (265589-266318)
3621  5.3, // LHC16s (266405-267131)
3622  5.3, // LHC16t (267161-267166)
3623  3.9, // LHC17c-o (270531-281961)
3624  3.9 // LHC17pq (282008-282441)
3625 // 3.9 // 2018
3626  };
3627  Double_t spreadEMCalL1G2[19] = { 0.3, // LHC13bf
3628  /*0.2*/0.25, // LHC13g
3629  0., // LS1
3630  0.1, // LHC15a-h
3631  0.1, // LHC15i-m
3632  0.1, // LHC15n
3633  0.1, 1.0, // LHC15o
3634  0.3, // LHC16i-k (255515-258574)
3635  0.3, // LHC16l (258883-260187)
3636  0.3, // LHC16m-p (260216-)
3637  0.3, 0.4, // LHC16q (265015-265525)
3638  0.4, 0.3, // LHC16r (265589-266318)
3639  0.3, // LHC16s (266405-267131)
3640  0.3, // LHC16t (267161-267166)
3641  0.3, // LHC17c-o (270531-281961)
3642  0.3 // LHC17pq (282008-282441)
3643 // 0.3 // 2018
3644  };
3645 
3646  Int_t runnumber = event->GetRunNumber();
3647 
3648  if (fSpecialTrigger == 5 ){
3649  if (runnumber < runRangesEMCalL0[0]) return kTRUE;
3650  Int_t binRun = 0;
3651  while (!(runnumber >= runRangesEMCalL0[binRun] && runnumber < runRangesEMCalL0[binRun+1] ) && binRun < 51 ){
3652 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << ":\t"<< thresholdEMCalL0[binRun] << "\t" << spreadEMCalL0[binRun] << endl;
3653  binRun++;
3654  }
3655  if (binRun==51) return kFALSE;
3656 // cout << runnumber << "\t"<< binRun << "\t"<< thresholdEMCalL0[binRun] << "\t" << spreadEMCalL0[binRun] << endl;
3657  Double_t threshold = thresholdEMCalL0[binRun];
3658 
3659  if (isMC && spreadEMCalL0[binRun] != 0.){
3660  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3661  triggerSmearing->SetParameter(0, 1/(spreadEMCalL0[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3662  triggerSmearing->SetParameter(1, thresholdEMCalL0[binRun]);
3663  triggerSmearing->SetParameter(2, spreadEMCalL0[binRun]);
3664  threshold = triggerSmearing->GetRandom();
3665  delete triggerSmearing;
3666  }
3667 
3668 // cout << "modified" << "\t"<< threshold << endl;
3669  Int_t nclus = 0;
3670  TClonesArray * arrClustersMimic = NULL;
3671  if(!fCorrTaskSetting.CompareTo("")){
3672  nclus = event->GetNumberOfCaloClusters();
3673  } else {
3674  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3675  if(!arrClustersMimic)
3676  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3677  nclus = arrClustersMimic->GetEntries();
3678  }
3679 
3680  if(nclus == 0) return kFALSE;
3681 
3682  // Loop over EMCal clusters
3683  Bool_t eventIsAccepted = kFALSE;
3684  for(Int_t i = 0; i < nclus; i++){
3685  if (eventIsAccepted) continue;
3686  AliVCluster* clus = NULL;
3687  if(event->IsA()==AliESDEvent::Class()){
3688  if(arrClustersMimic)
3689  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3690  else
3691  clus = event->GetCaloCluster(i);
3692  } else if(event->IsA()==AliAODEvent::Class()){
3693  if(arrClustersMimic)
3694  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3695  else
3696  clus = event->GetCaloCluster(i);
3697  }
3698 
3699  if (!clus){
3700  if(arrClustersMimic) delete clus;
3701  continue;
3702  }
3703  if (!clus->IsEMCAL()) {
3704  if(arrClustersMimic) delete clus;
3705  continue;
3706  }
3707  if (clus->GetM02()<0.1) {
3708  if(arrClustersMimic) delete clus;
3709  continue;
3710  }
3711  if (clus->GetNCells()<2) {
3712  if(arrClustersMimic) delete clus;
3713  continue;
3714  }
3715  if (clus->E() > threshold ){
3716 // cout << "found L0" << endl;
3717  eventIsAccepted = kTRUE;
3718  }
3719  if(arrClustersMimic)
3720  delete clus;
3721  }
3722  return eventIsAccepted;
3723 
3724  } else if (fSpecialTrigger == 6 ) {
3725 
3726  return kTRUE;
3727  } else if (fSpecialTrigger == 8 ) {
3728  if (fSpecialSubTriggerName.CompareTo("7EGA")==0 || fSpecialSubTriggerName.CompareTo("8EGA")==0 || fSpecialSubTriggerName.CompareTo("7EG1")==0 ||fSpecialSubTriggerName.CompareTo("8EG1")==0 ){
3729  if (runnumber < runRangesEMCalL1[0]) return kTRUE;
3730  Int_t binRun = 0;
3731  while (!(runnumber >= runRangesEMCalL1[binRun] && runnumber < runRangesEMCalL1[binRun+1] ) && binRun < 20 ){
3732 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL1[binRun] << "\t" << runRangesEMCalL1[binRun+1] << ":\t"<< thresholdEMCalL1[binRun]<<"\t"<< spreadEMCalL1[binRun]<< endl;
3733  binRun++;
3734  }
3735  if (binRun==20) return kFALSE;
3736  Double_t threshold = thresholdEMCalL1[binRun];
3737 
3738  if (isMC && spreadEMCalL1[binRun] != 0.){
3739  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3740  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3741  triggerSmearing->SetParameter(1, thresholdEMCalL1[binRun]);
3742  triggerSmearing->SetParameter(2, spreadEMCalL1[binRun]);
3743  threshold = triggerSmearing->GetRandom();
3744  delete triggerSmearing;
3745  }
3746 
3747 // cout << runnumber << "\t"<< binRun << "\t L1 \t"<< threshold << endl;
3748 
3749  TClonesArray * arrClustersMimic = NULL;
3750  Int_t nclus = 0;
3751  if(!fCorrTaskSetting.CompareTo("")){
3752  nclus = event->GetNumberOfCaloClusters();
3753  } else {
3754  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3755  if(!arrClustersMimic)
3756  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3757  nclus = arrClustersMimic->GetEntries();
3758  }
3759 
3760  if(nclus == 0) return kFALSE;
3761 
3762  // Loop over EMCal clusters
3763  Bool_t eventIsAccepted = kFALSE;
3764  for(Int_t i = 0; i < nclus; i++){
3765  if (eventIsAccepted) continue;
3766  AliVCluster* clus = NULL;
3767  if(event->IsA()==AliESDEvent::Class()){
3768  if(arrClustersMimic)
3769  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3770  else
3771  clus = event->GetCaloCluster(i);
3772  } else if(event->IsA()==AliAODEvent::Class()){
3773  if(arrClustersMimic)
3774  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3775  else
3776  clus = event->GetCaloCluster(i);
3777  }
3778  if (!clus) {
3779  if(arrClustersMimic) delete clus;
3780  continue;
3781  }
3782  if (!clus->IsEMCAL()) {
3783  if(arrClustersMimic) delete clus;
3784  continue;
3785  }
3786  if (clus->GetM02()<0.1) {
3787  if(arrClustersMimic) delete clus;
3788  continue;
3789  }
3790  if (clus->GetNCells()<2) {
3791  if(arrClustersMimic) delete clus;
3792  continue;
3793  }
3794  if (clus->E() > threshold ){
3795 // cout << "found L1G1\t" << clus->E() << endl;
3796  eventIsAccepted = kTRUE;
3797  }
3798  if(arrClustersMimic)
3799  delete clus;
3800  }
3801  return eventIsAccepted;
3802  } else if ( fSpecialSubTriggerName.CompareTo("7EG2")==0 ||fSpecialSubTriggerName.CompareTo("8EG2")==0 ){
3803  if (runnumber < runRangesEMCalL1G2[0]) return kTRUE;
3804  Int_t binRun = 0;
3805  while (!(runnumber >= runRangesEMCalL1G2[binRun] && runnumber < runRangesEMCalL1G2[binRun+1] ) && binRun < 19 ){
3806 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL1G2[binRun] << "\t" << runRangesEMCalL1G2[binRun+1] << ":\t"<< thresholdEMCalL1G2[binRun]<<"\t"<< spreadEMCalL1G2[binRun]<< endl;
3807  binRun++;
3808  }
3809 // cout << runnumber << "\t"<< binRun << "\t L2 \t"<< thresholdEMCalL1G2[binRun]<<"\t"<< spreadEMCalL1G2[binRun]<< endl;
3810  if (binRun==19) return kFALSE;
3811  Double_t threshold = thresholdEMCalL1G2[binRun];
3812  if (isMC && spreadEMCalL1G2[binRun] != 0.){
3813  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3814  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1G2[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3815  triggerSmearing->SetParameter(1, thresholdEMCalL1G2[binRun]);
3816  triggerSmearing->SetParameter(2, spreadEMCalL1G2[binRun]);
3817  threshold = triggerSmearing->GetRandom();
3818  delete triggerSmearing;
3819  }
3820 // cout << "\t L2 mod\t"<< threshold << endl;
3821 
3822  Int_t nclus = 0;
3823  TClonesArray * arrClustersMimic = NULL;
3824  if(!fCorrTaskSetting.CompareTo("")){
3825  nclus = event->GetNumberOfCaloClusters();
3826  } else {
3827  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3828  if(!arrClustersMimic)
3829  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3830  nclus = arrClustersMimic->GetEntries();
3831  }
3832 
3833  if(nclus == 0) return kFALSE;
3834 
3835  // Loop over EMCal clusters
3836  Bool_t eventIsAccepted = kFALSE;
3837  for(Int_t i = 0; i < nclus; i++){
3838  if (eventIsAccepted) continue;
3839  AliVCluster* clus = NULL;
3840  if(event->IsA()==AliESDEvent::Class()){
3841  if(arrClustersMimic)
3842  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3843  else
3844  clus = event->GetCaloCluster(i);
3845  } else if(event->IsA()==AliAODEvent::Class()){
3846  if(arrClustersMimic)
3847  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3848  else
3849  clus = event->GetCaloCluster(i);
3850  }
3851  if (!clus) {
3852  if(arrClustersMimic) delete clus;
3853  continue;
3854  }
3855  if (!clus->IsEMCAL()) {
3856  if(arrClustersMimic) delete clus;
3857  continue;
3858  }
3859  if (clus->GetM02()<0.1) {
3860  if(arrClustersMimic) delete clus;
3861  continue;
3862  }
3863  if (clus->GetNCells()<2) {
3864  if(arrClustersMimic) delete clus;
3865  continue;
3866  }
3867  if (clus->E() > threshold ){
3868 // cout << "found L1G2" << endl;
3869  eventIsAccepted = kTRUE;
3870  }
3871  if(arrClustersMimic)
3872  delete clus;
3873  }
3874  return eventIsAccepted;
3875  }
3876  return kTRUE;
3877  } else if (fSpecialTrigger == 9 ) {
3878  return kTRUE;
3879  } else {
3880  return kTRUE;
3881  }
3882 
3883  return kTRUE;
3884 }
3885 
3886 
3887 //________________________________________________________________________
3889 {
3890 
3891  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
3892 
3893 
3894  UInt_t isSelected = AliVEvent::kAny;
3895 
3896  if (fInputHandler==NULL) return kFALSE;
3897  if( fInputHandler->GetEventSelection() || event->IsA()==AliAODEvent::Class()) {
3898 
3899  TString firedTrigClass = event->GetFiredTriggerClasses();
3900  // if no trigger has been selected manually, select kAny in case of presel (also important for AOD filtering!)
3901  // in other cases select standards depending on system
3903  if (fPreSelCut) fOfflineTriggerMask = AliVEvent::kAny;
3904  else {
3905  if (fIsHeavyIon == 1){
3906  fOfflineTriggerMask = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
3907  } else if (fIsHeavyIon == 2){
3908  fOfflineTriggerMask = AliVEvent::kINT7;
3909  } else {
3910  fOfflineTriggerMask = AliVEvent::kMB;
3911  }
3912  }
3913  }
3914 
3915  // in case of MC switch to kAny if no MB/INT7/INT8 has been selected
3916  if(isMC){
3917  if( fIsHeavyIon == 0){
3918  if( fOfflineTriggerMask != AliVEvent::kMB && fOfflineTriggerMask != AliVEvent::kINT7 && fOfflineTriggerMask != AliVEvent::kINT8 ){
3919  fOfflineTriggerMask = AliVEvent::kAny;
3920  }
3921  }else{
3922  fOfflineTriggerMask = AliVEvent::kAny;
3923  }
3924  }
3925 
3926  if (fOfflineTriggerMask){
3927  isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
3928  if (isSelected && !fPreSelCut){
3929 // cout << firedTrigClass.Data() << endl;
3930 // cout << "Special trigger: "<< fSpecialTrigger << " initialized " << fEMCALTrigInitialized << endl;
3931 // if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3932 // if (!fEMCALTrigInitialized ) InitializeEMCALTrigger(event);
3933 // fTriggersEMCAL= GetTriggerList();
3934 // }
3935  if (fSpecialSubTrigger>0 && !isMC){
3936  if (!firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 0;
3937  if (fRejectTriggerOverlap){
3938  // trigger rejection EMC1,7,8
3939  if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC7") == 0){
3940  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3941  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC1") == 0){
3942  if (fInputHandler->IsEventSelected() & AliVEvent::kMB) isSelected = 0;
3943  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC8") == 0){
3944  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3945  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CDMC7") == 0){
3946  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3947  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CDMC1") == 0){
3948  if (fInputHandler->IsEventSelected() & AliVEvent::kMB) isSelected = 0;
3949  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CDMC8") == 0){
3950  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3951  }
3952  // trigger rejection EGA
3953  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EGA") == 0){
3954  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3955  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3956  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EGA") == 0){
3957  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3958  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3959  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7DGA") == 0){
3960  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3961  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3962  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8DGA") == 0){
3963  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3964  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3965  }
3966  // trigger rejection EG1 & EG2
3967  // EG1 is the trigger with the highest threshold
3968  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3969 // cout << firedTrigClass.Data() << endl;
3970  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3971 // cout << "INT7? " << isSelected << endl;
3972  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3973 // cout << "CEM7? " << isSelected << endl;
3974  if (firedTrigClass.Contains("7EG2")) isSelected = 0;
3975 // cout << "7EG2? " << isSelected << endl;
3976  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3977  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3978  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3979  if (firedTrigClass.Contains("8EG2")) isSelected = 0;
3980  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3981 // cout << firedTrigClass.Data() << endl;
3982  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3983 // cout << "INT7? " << isSelected << endl;
3984  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3985 // cout << "CEM7? " << isSelected << endl;
3986  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3987  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3988  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3989  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7DG1") == 0){
3990  // cout << firedTrigClass.Data() << endl;
3991  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3992  // cout << "INT7? " << isSelected << endl;
3993  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3994  // cout << "CEM7? " << isSelected << endl;
3995  if (firedTrigClass.Contains("7DG2")) isSelected = 0;
3996  // cout << "7EG2? " << isSelected << endl;
3997  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8DG1") == 0){
3998  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3999  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4000  if (firedTrigClass.Contains("8DG2")) isSelected = 0;
4001  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7DG2") == 0){
4002  // cout << firedTrigClass.Data() << endl;
4003  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
4004  // cout << "INT7? " << isSelected << endl;
4005  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4006  // cout << "CEM7? " << isSelected << endl;
4007  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8DG2") == 0){
4008  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
4009  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
4010  }
4011  if (fSpecialTrigger == 10 && (fInputHandler->IsEventSelected() & AliVEvent::kCaloOnly) ){
4012  // trigger rejection L0 triggers
4013  if (fSpecialSubTriggerName.CompareTo("CEMC7-") == 0){
4014  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4015  } else if (fSpecialSubTriggerName.CompareTo("CEMC1-") == 0){
4016  if (firedTrigClass.Contains("INT1-")) isSelected = 0;
4017  } else if (fSpecialSubTriggerName.CompareTo("CEMC8-") == 0){
4018  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4019  } else if (fSpecialSubTriggerName.CompareTo("CDMC7-") == 0){
4020  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4021  } else if (fSpecialSubTriggerName.CompareTo("CDMC1-") == 0){
4022  if (firedTrigClass.Contains("INT1-")) isSelected = 0;
4023  } else if (fSpecialSubTriggerName.CompareTo("CDMC8-") == 0){
4024  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4025  }
4026  // trigger rejection EGA
4027  if (fSpecialSubTriggerName.CompareTo("7EGA") == 0){
4028  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4029  if (firedTrigClass.Contains("EMC7-")) isSelected = 0;
4030  } else if (fSpecialSubTriggerName.CompareTo("8EGA") == 0){
4031  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4032  if (firedTrigClass.Contains("EMC8-")) isSelected = 0;
4033  } else if (fSpecialSubTriggerName.CompareTo("7DGA") == 0){
4034  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4035  if (firedTrigClass.Contains("EMC7-")) isSelected = 0;
4036  } else if (fSpecialSubTriggerName.CompareTo("8DGA") == 0){
4037  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4038  if (firedTrigClass.Contains("EMC8-")) isSelected = 0;
4039  }
4040  // trigger rejection L1 triggers
4041  if(fSpecialSubTriggerName.CompareTo("7EG1") == 0){
4042  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4043  if (firedTrigClass.Contains("EMC7-")) isSelected = 0;
4044  if (firedTrigClass.Contains("7EG2")) isSelected = 0;
4045  } else if (fSpecialSubTriggerName.CompareTo("8EG1") == 0){
4046  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4047  if (firedTrigClass.Contains("EMC8-")) isSelected = 0;
4048  if (firedTrigClass.Contains("8EG2")) isSelected = 0;
4049  } else if (fSpecialSubTriggerName.CompareTo("7EG2") == 0){
4050  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4051  if (firedTrigClass.Contains("EMC7-")) isSelected = 0;
4052  } else if (fSpecialSubTriggerName.CompareTo("8EG2") == 0){
4053  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4054  if (firedTrigClass.Contains("EMC8-")) isSelected = 0;
4055  } else if (fSpecialSubTriggerName.CompareTo("7DG1") == 0){
4056  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4057  if (firedTrigClass.Contains("DMC7-")) isSelected = 0;
4058  if (firedTrigClass.Contains("7DG2")) isSelected = 0;
4059  } else if (fSpecialSubTriggerName.CompareTo("8DG1") == 0){
4060  if (firedTrigClass.Contains("INT8-")) isSelected = 0;
4061  if (firedTrigClass.Contains("DMC8-")) isSelected = 0;
4062  if (firedTrigClass.Contains("8DG2")) isSelected = 0;
4063  } else if (fSpecialSubTriggerName.CompareTo("7DG2") == 0){
4064  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4065  if (firedTrigClass.Contains("DMC7-")) isSelected = 0;
4066  } else if (fSpecialSubTriggerName.CompareTo("8DG2") == 0){
4067  if (firedTrigClass.Contains("INT7-")) isSelected = 0;
4068  if (firedTrigClass.Contains("DMC8-")) isSelected = 0;
4069  }
4070  }
4071  }
4072  if (isSelected != 0 ){
4073 // cout << "I am here" << " :" << fSpecialSubTriggerName.Data() <<endl;
4074  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9 ){
4076  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassesCorrelated->Fill(0);
4077  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassesCorrelated->Fill(1);
4078  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassesCorrelated->Fill(2);
4079  if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC7) && firedTrigClass.Contains("EMC"))hTriggerClassesCorrelated->Fill(3);
4080  if (firedTrigClass.Contains("7EJE") || firedTrigClass.Contains("8EJE")) hTriggerClassesCorrelated->Fill(4);
4081  if (firedTrigClass.Contains("7EJ1") || firedTrigClass.Contains("8EJ1")) hTriggerClassesCorrelated->Fill(5);
4082  if (firedTrigClass.Contains("7EJ2") || firedTrigClass.Contains("8EJ2")) hTriggerClassesCorrelated->Fill(6);
4083  if (firedTrigClass.Contains("7EGA") || firedTrigClass.Contains("8EGA")) hTriggerClassesCorrelated->Fill(7);
4084  if (firedTrigClass.Contains("7EG1") || firedTrigClass.Contains("8EG1")) hTriggerClassesCorrelated->Fill(8);
4085  if (firedTrigClass.Contains("7EG2") || firedTrigClass.Contains("8EG2")) hTriggerClassesCorrelated->Fill(9);
4086  if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC7) && firedTrigClass.Contains("DMC"))hTriggerClassesCorrelated->Fill(10);
4087  if (firedTrigClass.Contains("7DJE") || firedTrigClass.Contains("8DJE")) hTriggerClassesCorrelated->Fill(11);
4088  if (firedTrigClass.Contains("7DJ1") || firedTrigClass.Contains("8DJ1")) hTriggerClassesCorrelated->Fill(12);
4089  if (firedTrigClass.Contains("7DJ2") || firedTrigClass.Contains("8DJ2")) hTriggerClassesCorrelated->Fill(13);
4090  if (firedTrigClass.Contains("7DGA") || firedTrigClass.Contains("8DGA")) hTriggerClassesCorrelated->Fill(14);
4091  if (firedTrigClass.Contains("7DG1") || firedTrigClass.Contains("8DG1")) hTriggerClassesCorrelated->Fill(15);
4092  if (firedTrigClass.Contains("7DG2") || firedTrigClass.Contains("8DG2")) hTriggerClassesCorrelated->Fill(16);
4093  }
4094  } else if ( fSpecialTrigger == 10 ){
4096  if (fInputHandler->IsEventSelected() & AliVEvent::kCaloOnly){
4097  hTriggerClassesCorrelated->Fill(0);
4098  if (firedTrigClass.Contains("INT7-"))hTriggerClassesCorrelated->Fill(1);
4099  if (firedTrigClass.Contains("EMC1-"))hTriggerClassesCorrelated->Fill(2);
4100  if (firedTrigClass.Contains("EMC7-")|| firedTrigClass.Contains("EMC8-"))hTriggerClassesCorrelated->Fill(3);
4101  if (firedTrigClass.Contains("7EJE") || firedTrigClass.Contains("8EJE")) hTriggerClassesCorrelated->Fill(4);
4102  if (firedTrigClass.Contains("7EJ1") || firedTrigClass.Contains("8EJ1")) hTriggerClassesCorrelated->Fill(5);
4103  if (firedTrigClass.Contains("7EJ2") || firedTrigClass.Contains("8EJ2")) hTriggerClassesCorrelated->Fill(6);
4104  if (firedTrigClass.Contains("7EGA") || firedTrigClass.Contains("8EGA")) hTriggerClassesCorrelated->Fill(7);
4105  if (firedTrigClass.Contains("7EG1") || firedTrigClass.Contains("8EG1")) hTriggerClassesCorrelated->Fill(8);
4106  if (firedTrigClass.Contains("7EG2") || firedTrigClass.Contains("8EG2")) hTriggerClassesCorrelated->Fill(9);
4107  if (firedTrigClass.Contains("DMC7-")|| firedTrigClass.Contains("DMC8-"))hTriggerClassesCorrelated->Fill(10);
4108  if (firedTrigClass.Contains("7DJE") || firedTrigClass.Contains("8DJE")) hTriggerClassesCorrelated->Fill(11);
4109  if (firedTrigClass.Contains("7DJ1") || firedTrigClass.Contains("8DJ1")) hTriggerClassesCorrelated->Fill(12);
4110  if (firedTrigClass.Contains("7DJ2") || firedTrigClass.Contains("8DJ2")) hTriggerClassesCorrelated->Fill(13);
4111  if (firedTrigClass.Contains("7DGA") || firedTrigClass.Contains("8DGA")) hTriggerClassesCorrelated->Fill(14);
4112  if (firedTrigClass.Contains("7DG1") || firedTrigClass.Contains("8DG1")) hTriggerClassesCorrelated->Fill(15);
4113  if (firedTrigClass.Contains("7DG2") || firedTrigClass.Contains("8DG2")) hTriggerClassesCorrelated->Fill(16);
4114  }
4115  }
4116  }
4117  }
4118 
4119  } else if (isMC){
4120  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
4121 // isSelected = 0;
4122 // if (fTriggersEMCAL > 0)cout << "Special Trigger " << fSpecialTrigger << " triggers: " << fTriggersEMCAL << " selected triggers: " << fTriggersEMCALSelected << " run number: " <<event->GetRunNumber()<<endl;
4123 // if (fTriggersEMCAL&fTriggersEMCALSelected){
4124 // cout << "accepted ++++++++++++++++++++" << endl;
4125  isSelected = 1;
4126 // }
4127  }
4128  }
4129  //if for specific centrality trigger selection
4130  if(fSpecialSubTrigger == 1){
4131  if(fSpecialSubTriggerName.Contains("|") && GetCentrality(event) <= 10.){
4132  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("|");
4133  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
4134  TObjString *NameClass = (TObjString*)ClassesList->At(i);
4135  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
4136  }
4137  } else if(fSpecialSubTriggerName.Contains("%")){
4138  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("%");
4139  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
4140  TObjString *NameClass = (TObjString*)ClassesList->At(i);
4141  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
4142  }
4143  } else if(fSpecialSubTriggerName.Contains("@")){
4144  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("@");
4145  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
4146  TObjString *NameClass = (TObjString*)ClassesList->At(i);
4147  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
4148  }
4149  } else if(fSpecialSubTriggerName.Contains("&")){ //logic AND of two classes
4150  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("&");
4151  TString CheckClass = "";
4152  for (Int_t i=0; i<ClassesList->GetEntriesFast(); i++){
4153  TObjString *NameClass = (TObjString*)ClassesList->At(i);
4154  if (firedTrigClass.Contains(NameClass->GetString())) CheckClass+="1";
4155  else CheckClass+="0";
4156  }
4157  if(CheckClass.Contains("0")) isSelected = 0;
4158  }
4159  else if(firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 1;
4160  }
4161  }
4162  }
4163  }
4164  fIsSDDFired = !(fInputHandler->IsEventSelected() & AliVEvent::kFastOnly);
4165 
4166  Bool_t mimickedTrigger = kTRUE;
4167  if (fMimicTrigger) mimickedTrigger = MimicTrigger(event, isMC);
4168 // cout << "mimicked decision \t" << mimickedTrigger << "expect decision? "<< fMimicTrigger<< endl;
4169 
4170  // Fill Histogram
4171  if(hTriggerClass){
4172  if (fIsSDDFired) hTriggerClass->Fill(34);
4173  if (mimickedTrigger){
4174  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
4175  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
4176  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
4177  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClass->Fill(3);
4178  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClass->Fill(4);
4179  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
4180  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
4181  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
4182  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
4183  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
4184  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
4185  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClass->Fill(8);
4186  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClass->Fill(9);
4187  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClass->Fill(9);
4188  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClass->Fill(10);
4189  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClass->Fill(10);
4190  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClass->Fill(11);
4191  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClass->Fill(12);
4192  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClass->Fill(13);
4193  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClass->Fill(13);
4194  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClass->Fill(13);
4195  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClass->Fill(14);
4196  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClass->Fill(15);
4197  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClass->Fill(16);
4198  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClass->Fill(17);
4199  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClass->Fill(18);
4200  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClass->Fill(19);
4201  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClass->Fill(20);
4202  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClass->Fill(20);
4203  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClass->Fill(21);
4204  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClass->Fill(22);
4205  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClass->Fill(23);
4206  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClass->Fill(24);
4207  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClass->Fill(25);
4208  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClass->Fill(26);
4209  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClass->Fill(27);
4210  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClass->Fill(28);
4211  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(29);
4212  if (fInputHandler->IsEventSelected() & AliVEvent::kCaloOnly)hTriggerClass->Fill(30);
4213  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(31);
4214  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(32);
4215  if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(35);
4216  }
4217  if (mimickedTrigger && fMimicTrigger) hTriggerClass->Fill(36);
4218  }
4219 
4220  if(hTriggerClassSelected && isSelected){
4221  if (mimickedTrigger){
4222  if (!fIsSDDFired) hTriggerClassSelected->Fill(33);
4223  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
4224  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
4225  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
4226  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
4227  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
4228  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
4229  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
4230  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
4231  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
4232  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
4233  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
4234  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
4235  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
4236  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
4237  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
4238  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
4239  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
4240  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
4241  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
4242  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
4243  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
4244  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
4245  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
4246  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
4247  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
4248  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
4249  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
4250  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
4251  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
4252  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
4253  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
4254  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
4255  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
4256  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
4257  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
4258  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
4259  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClassSelected->Fill(28);
4260  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(29);
4261  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(30);
4262  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(31);
4263  }
4264  if (mimickedTrigger && fMimicTrigger) hTriggerClassSelected->Fill(34);
4265  }
4266 
4267  if(!isSelected)return kFALSE;
4268  if (fMimicTrigger)
4269  if (!mimickedTrigger ) return kFALSE;
4270  return kTRUE;
4271 
4272 }
4273 
4274 //________________________________________________________________________
4276  // returns TString with current cut number
4277  return fCutStringRead;
4278 }
4279 
4280 //________________________________________________________________________
4281 void AliConvEventCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliVEvent *event){
4282 
4283  if(fNotRejectedStart){
4284  delete[] fNotRejectedStart;
4285  fNotRejectedStart = NULL;
4286  }
4287  if(fNotRejectedEnd){
4288  delete[] fNotRejectedEnd;
4289  fNotRejectedEnd = NULL;
4290  }
4291  if(fGeneratorNames){
4292  delete[] fGeneratorNames;
4293  fGeneratorNames = NULL;
4294  }
4295 
4296  if(rejection == 0) return; // No Rejection
4297 
4298  AliGenCocktailEventHeader *cHeader = 0x0;
4299  AliAODMCHeader *cHeaderAOD = 0x0;
4300  Bool_t headerFound = kFALSE;
4301  AliMCEvent *fMCEvent = 0x0;
4302  TClonesArray *fMCEventAOD = 0x0;
4303  if(event->IsA()==AliMCEvent::Class()){
4304  if(dynamic_cast<AliMCEvent*>(event)){
4305  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(dynamic_cast<AliMCEvent*>(event)->GenEventHeader());
4306  fMCEvent = dynamic_cast<AliMCEvent*>(event);
4307  if(cHeader) headerFound = kTRUE;
4308  }
4309  }
4310  if(event->IsA()==AliAODEvent::Class()){ // event is a AODEvent in case of AOD
4311  cHeaderAOD = dynamic_cast<AliAODMCHeader*>(event->FindListObject(AliAODMCHeader::StdBranchName()));
4312  fMCEventAOD = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4313  if(cHeaderAOD) headerFound = kTRUE;
4314  }
4315 
4316  if (fDebugLevel > 0 ) cout << "event starts here" << endl;
4317  if(headerFound){
4318  TList *genHeaders = 0x0;
4319  if(cHeader) genHeaders = cHeader->GetHeaders();
4320  if(cHeaderAOD){
4321  genHeaders = cHeaderAOD->GetCocktailHeaders();
4322  if(genHeaders->GetEntries()==1){
4324  return;
4325  }
4326  }
4327  AliGenEventHeader* gh = 0;
4328  fnHeaders = 0;
4329  Int_t firstindexA = 0;
4330  Int_t lastindexA = -1;
4331  if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
4332  if(rejection == 2 || rejection == 4){ // TList of Headers Names
4333  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
4334  gh = (AliGenEventHeader*)genHeaders->At(i);
4335  TString GeneratorName = gh->GetName();
4336  lastindexA = lastindexA + gh->NProduced();
4337  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
4338  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
4339  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
4340  if (fDebugLevel > 0 ) cout << GeneratorInList.Data() << endl;
4341  if(GeneratorInList.Contains(GeneratorName) ){
4342  if (fDebugLevel > 0 ) cout << "accepted" << endl;
4343  if (GeneratorInList.BeginsWith("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
4344  if(fMCEvent){
4345  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4346  if (fDebugLevel > 2 )cout << "number of produced particle: " << gh->NProduced() << endl;
4347  if (fDebugLevel > 2 )cout << "pdg-code of first particle: " << fMCEvent->Particle(firstindexA)->GetPdgCode() << endl;
4348  if (fMCEvent->Particle(firstindexA)->GetPdgCode() == fAddedSignalPDGCode ) {
4349  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindexA+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
4350  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4351  fnHeaders++;
4352  continue;
4353  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4354  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
4355  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4356  fnHeaders++;
4357  continue;
4358  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4359  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
4360  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4361  fnHeaders++;
4362  continue;
4363 
4364  }
4365  continue;
4366  }
4367  } else {
4368  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
4369  fnHeaders++;
4370  continue;
4371  }
4372  }
4373  if ( fMCEventAOD){
4374  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA));
4375  if (aodMCParticle && (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c) ){
4376  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
4377  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0){
4378  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA+10));
4379  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
4380  if (fDebugLevel > 0 ) cout << "cond 1: " << fnHeaders << endl;
4381  fnHeaders++;
4382  continue;
4383  }
4384  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4385  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
4386  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4387  fnHeaders++;
4388  continue;
4389  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4390  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
4391  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4392  fnHeaders++;
4393  continue;
4394 
4395  }
4396  continue;
4397  }
4398  } else {
4399  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
4400  fnHeaders++;
4401  continue;
4402  }
4403  }
4404  continue;
4405  }
4406  if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
4407  if (fDebugLevel > 0 ) cout << "cond 3: "<< fnHeaders << endl;
4408  fnHeaders++;
4409  continue;
4410  }
4411  }
4412  }
4413  firstindexA = firstindexA + gh->NProduced();
4414  }
4415  }
4416  if (fDebugLevel > 0 ) cout << "number of headers: " <<fnHeaders << endl;
4417 
4421 
4422  if(rejection == 1 || rejection == 3){
4423  fNotRejectedStart[0] = 0;
4424  fNotRejectedEnd[0] = ((AliGenEventHeader*)genHeaders->At(0))->NProduced()-1;
4425  fGeneratorNames[0] = ((AliGenEventHeader*)genHeaders->At(0))->GetName();
4426  if (fDebugLevel > 0 ) cout << 0 << "\t" <<fGeneratorNames[0] << "\t" << fNotRejectedStart[0] << "\t" <<fNotRejectedEnd[0] << endl;
4427  return;
4428  }
4429 
4430  Int_t firstindex = 0;
4431  Int_t lastindex = -1;
4432  Int_t number = 0;
4433 
4434  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
4435  gh = (AliGenEventHeader*)genHeaders->At(i);
4436  TString GeneratorName = gh->GetName();
4437  lastindex = lastindex + gh->NProduced();
4438  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
4439  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
4440  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
4441  if(GeneratorInList.Contains(GeneratorName) ){
4442  if (GeneratorInList.Contains("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
4443  if(fMCEvent){
4444  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4445  if (fMCEvent->Particle(firstindex)->GetPdgCode() == fAddedSignalPDGCode ) {
4446  if (fDebugLevel > 0 ) cout << "produced " << gh->NProduced() << " with box generator" << endl;
4447  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindex+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
4448  if (fDebugLevel > 0 ) cout << "one of them was a pi0 or eta" << endl;
4449  fNotRejectedStart[number] = firstindex;
4450  fNotRejectedEnd[number] = lastindex;
4451  fGeneratorNames[number] = GeneratorName;
4452  number++;
4453  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4454  continue;
4455  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4456  fNotRejectedStart[number] = firstindex;
4457  fNotRejectedEnd[number] = lastindex;
4458  fGeneratorNames[number] = GeneratorName;
4459  number++;
4460  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4461  continue;
4462  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4463  fNotRejectedStart[number] = firstindex;
4464  fNotRejectedEnd[number] = lastindex;
4465  fGeneratorNames[number] = GeneratorName;
4466  number++;
4467  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4468  continue;
4469  }
4470  }
4471  continue;
4472  } else {
4473  fNotRejectedStart[number] = firstindex;
4474  fNotRejectedEnd[number] = lastindex;
4475  fGeneratorNames[number] = GeneratorName;
4476  number++;
4477  continue;
4478  }
4479  }
4480  if ( fMCEventAOD){
4481  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex));
4482  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4483  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
4484  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0) {
4485  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex+10));
4486  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
4487  fNotRejectedEnd[number] = lastindex;
4488  fNotRejectedStart[number] = firstindex;
4489  fGeneratorNames[number] = GeneratorName;
4490  number++;
4491  }
4492  continue;
4493  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4494  fNotRejectedStart[number] = firstindex;
4495  fNotRejectedEnd[number] = lastindex;
4496  fGeneratorNames[number] = GeneratorName;
4497  number++;
4498  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4499  continue;
4500  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4501  fNotRejectedStart[number] = firstindex;
4502  fNotRejectedEnd[number] = lastindex;
4503  fGeneratorNames[number] = GeneratorName;
4504  number++;
4505  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4506  continue;
4507  }
4508  continue;
4509  }
4510  } else {
4511  fNotRejectedStart[number] = firstindex;
4512  fNotRejectedEnd[number] = lastindex;
4513  fGeneratorNames[number] = GeneratorName;
4514  number++;
4515  continue;
4516  }
4517  }
4518  continue;
4519  } else if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
4520  fNotRejectedStart[number] = firstindex;
4521  fNotRejectedEnd[number] = lastindex;
4522  fGeneratorNames[number] = GeneratorName;
4523  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4524  number++;
4525  continue;
4526  }
4527 
4528  }
4529  }
4530  firstindex = firstindex + gh->NProduced();
4531  }
4532  if (fDebugLevel > 0 ) {
4533  for (Int_t i = 0; i < number; i++){
4534  cout << i << "\t" <<fGeneratorNames[i] << "\t" << fNotRejectedStart[i] << "\t" <<fNotRejectedEnd[i] << endl;
4535  }
4536  }
4537  } else { // No Cocktail Header Found
4538  fNotRejectedStart = new Int_t[1];
4539  fNotRejectedEnd = new Int_t[1];
4540 
4541  fnHeaders = 1;
4542  fNotRejectedStart[0] = 0;
4543  fNotRejectedEnd[0] = static_cast<AliMCEvent*>(event)->GetNumberOfPrimaries()-1;
4544  if (rejection > 1){
4545  fNotRejectedStart[0] = -1;
4546  fNotRejectedEnd[0] = -1;
4547  }
4548 
4549  fGeneratorNames = new TString[1];
4550  fGeneratorNames[0] = "NoCocktailGeneratorFound";
4551 // SetRejectExtraSignalsCut(0);
4552  }
4553 
4554 }
4555 
4556 //_________________________________________________________________________
4557 Int_t AliConvEventCuts::IsParticleFromBGEvent(Int_t index, AliMCEvent *mcEvent, AliVEvent *InputEvent, Int_t debug ){
4558 
4559  // if (debug > 2 ) cout << index << endl;
4560  if(index < 0) return 0; // No Particle
4561 
4562  Int_t accepted = 0;
4563  if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
4564  if(!mcEvent) return 0; // no mcEvent available, return 0
4565  if(index >= mcEvent->GetNumberOfPrimaries()){ // initial particle is secondary particle
4566  if( ((TParticle*)mcEvent->Particle(index))->GetMother(0) < 0) return 0; // material particle, return 0
4567  return IsParticleFromBGEvent(((TParticle*)mcEvent->Particle(index))->GetMother(0),mcEvent,InputEvent, debug);
4568  }
4569  for(Int_t i = 0;i<fnHeaders;i++){
4570  // if (debug > 2 ) cout << "header " << fGeneratorNames[i].Data() << ":"<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
4571  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
4572  if (debug > 1 ) cout << "accepted:" << index << "\t header " << fGeneratorNames[i].Data() << ": "<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
4573  accepted = 1;
4574  if(i == 0) accepted = 2; // MB Header
4575  }
4576  }
4577  if (debug > 1 && !accepted) cout << "rejected:" << index << endl;
4578  }
4579  else if(InputEvent->IsA()==AliAODEvent::Class()){
4580  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
4581  if (AODMCTrackArray){
4582  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
4583  if(!aodMCParticle) return 0; // no particle
4584  if(!aodMCParticle->IsPrimary()){
4585  if( aodMCParticle->GetMother() < 0) return 0;// material particle, return 0
4586  return IsParticleFromBGEvent(aodMCParticle->GetMother(),mcEvent,InputEvent, debug);
4587  }
4588  index = TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index))->GetLabel());
4589  for(Int_t i = 0;i<fnHeaders;i++){
4590  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
4591  accepted = 1;
4592  if(i == 0) accepted = 2; // MB Header
4593  }
4594  }
4595  }
4596  }
4597 
4598  return accepted;
4599 }
4600 
4601 //_________________________________________________________________________
4602 Int_t AliConvEventCuts::IsEventAcceptedByCut(AliConvEventCuts *ReaderCuts, AliVEvent *event, AliMCEvent *mcEvent, Int_t isHeavyIon, Bool_t isEMCALAnalysis){
4603 
4604  Bool_t isMC = kFALSE;
4605  if (mcEvent){isMC = kTRUE;}
4606 
4607  if ( !IsTriggerSelected(event, isMC) )
4608  return 3;
4609 
4610  if( !(IsCentralitySelected(event,mcEvent)))
4611  return 1; // Check Centrality --> Not Accepted => eventQuality = 1
4612 
4613  Bool_t hasV0And = ReaderCuts->HasV0AND();
4614  Bool_t isSDDFired = ReaderCuts->IsSDDFired();
4615 
4616  if( ( (IsSpecialTrigger() == 0 && IsSpecialSubTrigger() == 1) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !isSDDFired && !mcEvent)
4617  //if V0OR with SDD requested or V0AND with SDD request but the SDD has not fired
4618  return 7; // V0 with SDD requested but no fired
4619 
4620  if( ( (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 0) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !hasV0And)
4621  //if V0AND (only) or V0AND with SDD requested but V0AND requested but no fired
4622  return 8; // V0AND requested but no fired
4623 
4624 
4625  if( (IsSpecialTrigger() == 2 || IsSpecialTrigger() == 3) && !isSDDFired && !mcEvent)
4626  return 7; // With SDD requested but no fired
4627 
4628  if( (IsSpecialTrigger() == 1 || IsSpecialTrigger() == 3) && !hasV0And)
4629  return 8; // V0AND requested but no fired
4630 
4631  // Special EMCAL checks due to hardware issues in LHC11a
4632  if (isEMCALAnalysis || IsSpecialTrigger() == 5 || IsSpecialTrigger() == 8 || IsSpecialTrigger() == 9 ){
4633  Int_t runnumber = event->GetRunNumber();
4634  if ((runnumber>=144871) && (runnumber<=146860)) {
4635 
4636  AliVCaloCells *cells = event->GetEMCALCells();
4637  const Short_t nCells = cells->GetNumberOfCells();
4638 
4639  if (event->IsA()==AliESDEvent::Class()) AliAnalysisManager::GetAnalysisManager()->LoadBranch("EMCALCells.");
4640 
4641  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
4642  if (!fInputHandler) return 3;
4643 
4644  // count cells above threshold
4645  Int_t nCellCount[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
4646  for(Int_t iCell=0; iCell<nCells; ++iCell) {
4647  Short_t cellId = cells->GetCellNumber(iCell);
4648  Double_t cellE = cells->GetCellAmplitude(cellId);
4649  Int_t sm = cellId / (24*48);
4650  if (cellE>0.1) ++nCellCount[sm];
4651  }
4652 
4653  Bool_t fIsLedEvent = kFALSE;
4654  if (nCellCount[4] > 100) {
4655  fIsLedEvent = kTRUE;
4656  } else {
4657  if ((runnumber>=146858) && (runnumber<=146860)) {
4658  if ((fInputHandler->IsEventSelected() & AliVEvent::kMB) && (nCellCount[3]>=21))
4659  fIsLedEvent = kTRUE;
4660  else if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC1) && (nCellCount[3]>=35))
4661  fIsLedEvent = kTRUE;
4662  }
4663  }
4664  if (fIsLedEvent) {
4665  return 9;
4666  }
4667  }
4668  }
4669 
4670  // SPD clusters vs tracklets to check for pileup/background
4671  Int_t nClustersLayer0 = event->GetNumberOfITSClusters(0);
4672  Int_t nClustersLayer1 = event->GetNumberOfITSClusters(1);
4673  Int_t nTracklets = event->GetMultiplicity()->GetNumberOfTracklets();
4674  if(hSPDClusterTrackletBackgroundBefore) hSPDClusterTrackletBackgroundBefore->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
4675 
4676 
4677  Double_t distZMax = 0;
4678  if(event->IsA()==AliESDEvent::Class()){
4679  Int_t nPileVert = ((AliESDEvent*)event)->GetNumberOfPileupVerticesSPD();
4680  if (hNPileupVertices) hNPileupVertices->Fill(nPileVert);
4681  if (nPileVert > 0){
4682  for(Int_t i=0; i<nPileVert;i++){
4683  const AliESDVertex* pv= ((AliESDEvent*)event)->GetPileupVertexSPD(i);
4684  Int_t nc2 = pv->GetNContributors();
4685  if(nc2>=3){
4686  Double_t z1 = ((AliESDEvent*)event)->GetPrimaryVertexSPD()->GetZ();
4687  Double_t z2 = pv->GetZ();
4688  Double_t distZ = z2-z1;
4689  if (TMath::Abs(distZMax) < TMath::Abs(distZ) ){
4690  distZMax = distZ;
4691  }
4692  }
4693  }
4694  if (hPileupVertexToPrimZ) hPileupVertexToPrimZ->Fill(distZMax);
4695  }
4696  }
4697  if(GetPastFutureLowBC()!=0 && GetPastFutureHighBC()!=0 ){
4698  if(IsOutOfBunchPileupPastFuture(event))
4699  return 12;
4700  }
4701 
4702  if( isHeavyIon != 2 && GetIsFromPileupSPD()){
4703  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.) ){
4705  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
4706  }
4707  if (fUtils->IsSPDClusterVsTrackletBG(event)){
4709  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
4710  }
4711  }
4712  if(isHeavyIon == 2 && GetIsFromPileupSPD()){
4713  if(fUtils->IsPileUpEvent(event) ){
4715  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
4716  }
4717  if (fUtils->IsSPDClusterVsTrackletBG(event)){
4719  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
4720  }
4721  }
4722 
4724  if( IsPileUpV0MTPCout(event) ){
4725  return 13;
4726  }
4727  }
4728 
4729  if(fUseSphericity != 0){
4730  if(fUseSphericity == 1 && ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetSphericity()>0.5){
4731  return 14;
4732  }
4733  if(fUseSphericity == 2 && ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetSphericity()<0.5){
4734  return 14;
4735  }
4736  if(fUseSphericity == 3 && ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetSphericity()==-1){
4737  return 14;
4738  }
4739  }
4740 
4741  if(hCentrality)hCentrality->Fill(GetCentrality(event));
4742 
4743  if(hVertexZ)hVertexZ->Fill(event->GetPrimaryVertex()->GetZ());
4744 // if(hCentralityVsNumberOfPrimaryTracks)
4745 // hCentralityVsNumberOfPrimaryTracks->Fill(GetCentrality(event),
4746 // ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
4747 // ->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks());
4748 
4749  if(fIsHeavyIon == 1){
4750  AliEventplane *EventPlane = event->GetEventplane();
4751  fEventPlaneAngle = EventPlane->GetEventplane("V0",event,2);
4752  if(hEventPlaneAngle)hEventPlaneAngle->Fill(TMath::Abs(fEventPlaneAngle));
4753  }
4754  if(hSPDClusterTrackletBackground) hSPDClusterTrackletBackground->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
4755 
4756  return 0;
4757 }
4758 
4759 
4760 //_________________________________________________________________________
4762 
4763  AliInfo("Inside the GetWeightForCentralityFlattening function");
4764  Double_t centrality = 0.;
4765  //obtain centrality for ESD or AOD
4766  if(!event || event->IsA()==AliESDEvent::Class()){
4767  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
4768  if(esdEvent){
4769  AliCentrality *fESDCentrality=(AliCentrality*)esdEvent->GetCentrality();
4770  if(fDetectorCentrality==0 && fIsHeavyIon==1){
4771  centrality = fESDCentrality->GetCentralityPercentile("V0M"); // default for PbPb
4772  }
4773  }
4774  } else if(event->IsA()==AliAODEvent::Class()){
4775  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
4776  if(aodEvent){
4777  if(aodEvent->GetHeader()){
4778  centrality = ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();
4779  }
4780  }
4781  }
4782 
4783  //Get the maximum vlaue from the reference distribution and interpolated value
4784  Float_t GetValueForWeight = 1.;
4785  Float_t maximum = 1.;
4786  Double_t weightCentrality = 1.;
4787  Bool_t CorrCentrLoop = kFALSE;
4788 
4789  //depending on the value of the flag, flattening in different cent. range
4790  if ( fDoCentralityFlat == 1 && (centrality >= 0. && centrality <= 20.) ){
4791  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4792  maximum = hCentralityNotFlat->GetMaximum();
4793  CorrCentrLoop = kTRUE;
4794  } else if ( fDoCentralityFlat == 8 ){
4795  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4796  maximum = hCentralityNotFlat->GetMaximum();
4797  CorrCentrLoop = kTRUE;
4798  } else {
4799  CorrCentrLoop = kFALSE;
4800  }
4801 
4802  if (CorrCentrLoop && GetValueForWeight != 0. && maximum !=0. && isfinite(GetValueForWeight) && isfinite(maximum) ){
4803  weightCentrality = maximum/GetValueForWeight;
4804  if (!isfinite(GetValueForWeight)) weightCentrality = 1.;
4805  if (!isfinite(weightCentrality)) weightCentrality = 1.;
4806  }
4807 
4808  return weightCentrality;
4809 }
4810 
4811 //_________________________________________________________________________
4813 
4814  Double_t weightMult = 1.;
4815 
4816  Float_t valueMultData = -1.;
4817  Float_t valueMultMC = -1.;
4818 
4819  if (hReweightMultData == NULL || hReweightMultMC == NULL ) return weightMult;
4820 
4821  valueMultData = hReweightMultData->Interpolate(mult);
4822  valueMultMC = hReweightMultMC->Interpolate(mult);
4823 
4824  Float_t relativeErrorMC = hReweightMultMC->GetBinError(hReweightMultMC->FindBin(mult))/hReweightMultMC->GetBinContent(hReweightMultMC->FindBin(mult));
4825  Float_t relativeErrorData = hReweightMultData->GetBinError(hReweightMultData->FindBin(mult))/hReweightMultData->GetBinContent(hReweightMultData->FindBin(mult));
4826 
4827  if (relativeErrorData < 0.2 && relativeErrorMC < 0.2 ){
4828  if (isfinite(valueMultData) && isfinite(valueMultMC) ){
4829  weightMult = valueMultData/valueMultMC;
4830  }
4831  }
4832 
4833  return weightMult;
4834 }
4835 
4836 
4837 
4838 //_________________________________________________________________________
4839 Float_t AliConvEventCuts::GetWeightForMeson(Int_t index, AliMCEvent *mcEvent, AliVEvent *event){
4840 
4841  if(index < 0) return 0; // No Particle
4842 
4843  // check if MC production should be weighted. If it is with added particles check that particle is not rejected
4844  Int_t kCaseGen = 0;
4845  if (fPeriodEnum == kLHC13d2 || fPeriodEnum == kLHC13d2b || // LHC10h MCs
4846  fPeriodEnum == kLHC14a1a || fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c || // LHC11h MCs
4847  fPeriodEnum == kLHC13e7 || fPeriodEnum == kLHC13b2_efix || fPeriodEnum == kLHC14b2 || // LHC13bc MCs
4848  fPeriodEnum == kLHC14e2b || // LHC12[a-i] pass 1 MCs
4849  fPeriodEnum == kLHC12f1a || fPeriodEnum == kLHC12f1b || fPeriodEnum == kLHC12i3 || // LHC11a MCs
4850  fPeriodEnum == kLHC16h4 ) // LHC15o MC
4851  kCaseGen = 1; // added particles MC
4853  kCaseGen = 2; // regular MC
4854  if (kCaseGen == 0) return 1.;
4855  if(kCaseGen==1 && !IsParticleFromBGEvent(index, mcEvent, event)) return 1.;
4856 
4857  // get pT and pdg code
4858  Double_t mesonPt = 0;
4859  //Double_t mesonMass = 0;
4860  Int_t PDGCode = 0;
4861  if(!event || event->IsA()==AliESDEvent::Class()){
4862  mesonPt = ((TParticle*)mcEvent->Particle(index))->Pt();
4863  //mesonMass = ((TParticle*)mcEvent->Particle(index))->GetCalcMass();
4864  PDGCode = ((TParticle*)mcEvent->Particle(index))->GetPdgCode();
4865  } else if(event->IsA()==AliAODEvent::Class()){
4866  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4867  if (AODMCTrackArray){
4868  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
4869  mesonPt = aodMCParticle->Pt();
4870  //mesonMass = aodMCParticle->GetCalcMass();
4871  PDGCode = aodMCParticle->GetPdgCode();
4872  } else {
4873  return 1;
4874  }
4875  }
4876 
4877  // get MC value
4878  Float_t functionResultMC = 1.;
4879  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0){
4880  functionResultMC = hReweightMCHistPi0->Interpolate(mesonPt);
4881  }
4882  if ( PDGCode == 221 && fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0){
4883  functionResultMC = hReweightMCHistEta->Interpolate(mesonPt);
4884  }
4885  if ( PDGCode == 310 && fDoReweightHistoMCK0s && hReweightMCHistK0s!= 0x0){
4886  functionResultMC = hReweightMCHistK0s->Interpolate(mesonPt);
4887  }
4888 
4889  // get data value
4890  Float_t functionResultData = 1;
4891  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && fFitDataPi0!= 0x0){