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