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