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