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