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