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