AliPhysics  bba8f44 (bba8f44)
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 != kLHC16c2 && fPeriodEnum != kLHC16c2_plus // 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 == kLHC16c2 || fPeriodEnum == kLHC16c2_plus ){
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 
2677  } else if ( fPeriodEnum == kLHC17g8a ){ // preliminary weights obtained from local running
2678  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};
2679  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};
2680  Int_t bin = 0;
2681  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2682  if (bin < 20) weight = weightsBins[bin];
2683  } else if ( fPeriodEnum == kLHC17g8b ){ // preliminary weights obtained from local running
2684  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};
2685  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};
2686  Int_t bin = 0;
2687  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2688  if (bin < 20) weight = weightsBins[bin];
2689  } else if ( fPeriodEnum == kLHC17g8c ){ // preliminary weights obtained from local running
2690  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};
2691  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};
2692  Int_t bin = 0;
2693  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2694  if (bin < 20) weight = weightsBins[bin];
2695 
2696  } else {
2697  weight = 1;
2698  }
2699 
2700  if (weight == -1) return kFALSE;
2701  else return eventAccepted;
2702 
2703  }
2704  }
2705  } else {
2706  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2707  TString eventHeaderName = eventHeader->ClassName();
2708  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2709  Bool_t eventAccepted = kTRUE;
2710  TParticle * jet = 0;
2711  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->NTriggerJets();
2712  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
2713  Float_t tmpjet[]={0,0,0,0};
2714  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2715  dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->TriggerJet(ijet, tmpjet);
2716  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2717  //Compare jet pT and pt Hard
2718  if(jet->Pt() > fMaxFacPtHard * ptHard){
2719  eventAccepted= kFALSE;
2720  }
2721  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2722  }
2723  if (mcEvent){
2724  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2725  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2726  if (!particle) continue;
2727  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2728  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2729  eventAccepted= kFALSE;
2730  }
2731  }
2732 
2733  }
2734  }
2735 
2736  if ( fPeriodEnum == kLHC16P1JJLowB) {
2737  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2738  21, 28, 36, 45, 57,
2739  70, 85, 99, 115, 132,
2740  150, 169, 190, 212, 235,
2741  1000000};
2742  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2743  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2744  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2745  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2746  Int_t bin = 0;
2747  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2748  if (bin < 20) weight = weightsBins[bin];
2749 
2750  } else if ( fPeriodEnum == kLHC16P1JJ ){
2751  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2752  21, 28, 36, 45, 57,
2753  70, 85, 99, 115, 132,
2754  150, 169, 190, 212, 235,
2755  1000000};
2756  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2757  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2758  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2759  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2760 
2761  Int_t bin = 0;
2762  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2763  if (bin < 20) weight = weightsBins[bin];
2764 
2765  } else if ( fPeriodEnum == kLHC16h3 ){
2766  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2767  21, 28, 36, 45, 57,
2768  70, 85, 99, 115, 132,
2769  150, 169, 190, 212, 235,
2770  1000000};
2771  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2772  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2773  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2774  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2775  Int_t bin = 0;
2776  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2777  if (bin < 20) weight = weightsBins[bin];
2778 
2779 
2780  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2781  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2782  21, 28, 36, 45, 57,
2783  70, 85, 1000};
2784  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2785  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2786  1.933238e-05, 1.562895e-05};
2787  Int_t bin = 0;
2788  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2789  if (bin < 12) weight = weightsBins[bin];
2790 
2791  } else if ( fPeriodEnum == kLHC15g1a ){
2792  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2793  84, 117, 152, 191, 1000000,
2794  5, 7, 9, 12, 16,
2795  21, 28, 36, 45, 57 };
2796  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2797  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2798  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2799  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2800 
2801  Int_t bin = 0;
2802  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2803  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2804  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2805  if (bin < 19) weight = weightsBins[bin];
2806 
2807  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2808  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2809  84, 117, 152, 191, 1000000,
2810  5, 7, 9, 12, 16,
2811  21, 28, 36, 45, 57 };
2812  // LHC15a3a
2813  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2814  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2815  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2816  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2817  Int_t bin = 0;
2818  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2819  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2820  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2821  if (bin < 19) weight = weightsBins[bin];
2822 
2823  } else if ( fPeriodEnum == kLHC16c2 || fPeriodEnum == kLHC16c2_plus ){
2824  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2825  21, 28, 36, 45, 57,
2826  70, 85, 99, 115, 132,
2827  150, 169, 190, 212, 235,
2828  1000000};
2829  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
2830  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
2831  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
2832  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
2833  Int_t bin = 0;
2834  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2835  if (bin < 20) weight = weightsBins[bin];
2836 
2837  } else if ( fPeriodEnum == kLHC16c3a ){
2838  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
2839  Double_t weightsBins[5] = { 0.00672445, 0.00799158, 0.00678934, 0.00463908, 0.00600068}; //preliminary estimates
2840  Int_t bin = 0;
2841  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2842  if (bin < 5) weight = weightsBins[bin];
2843 
2844  } else if (fPeriodEnum == kLHC16c3b ){
2845  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
2846  Double_t weightsBins[6] = { 0.00608281, 0.00393646, 0.00200138, 0.000986267, 0.000389051, 0.0001863}; //preliminary estimates
2847  Int_t bin = 0;
2848  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2849  if (bin < 6) weight = weightsBins[bin];
2850 
2851  } else if (fPeriodEnum == kLHC16c3c ){
2852  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
2853  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
2854  Int_t bin = 0;
2855  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2856  if (bin < 7) weight = weightsBins[bin];
2857 
2858  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
2859  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
2860  84, 117, 152, 191, 234,
2861  1000};
2862  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
2863  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
2864  Int_t bin = 0;
2865  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2866  if (bin < 10) weight = weightsBins[bin];
2867  } else {
2868  weight = 1;
2869  }
2870 
2871  if (weight == -1) return kFALSE;
2872  else return eventAccepted;
2873 
2874  } else {
2875  return kFALSE;
2876  }
2877  }
2878 
2879  return kFALSE;
2880 }
2881 
2882 //________________________________________________________________________
2883 // Analysing Jet-Jet MC's
2884 //________________________________________________________________________
2885 void AliConvEventCuts::GetXSectionAndNTrials(AliMCEvent *mcEvent, Float_t &XSection, Float_t &NTrials){
2886 
2887  AliGenCocktailEventHeader *cHeader = 0x0;
2888  Bool_t headerFound = kFALSE;
2889 
2890  if ( fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2891  fPeriodEnum != kLHC17g8b && fPeriodEnum != kLHC17g8c && // LHC16sr pPb 8TeV JetJet MC's
2892  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2893  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2894  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2895  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2896  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2897  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2898  fPeriodEnum != kLHC16c2 && fPeriodEnum != kLHC16c2_plus // LHC12 JetJet MC
2899  ){
2900  NTrials = -1;
2901  XSection = -1;
2902  return;
2903  }
2904 
2905  if(mcEvent){
2906  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2907  if(cHeader) headerFound = kTRUE;
2908  }else{
2909  //no mcEvent available -> not running on MC
2910  NTrials = -1;
2911  XSection = -1;
2912  return;
2913  }
2914 
2915  if(headerFound){
2916  TList *genHeaders = 0x0;
2917  if(cHeader) genHeaders = cHeader->GetHeaders();
2918  AliGenEventHeader* gh = 0;
2919  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2920  gh = (AliGenEventHeader*)genHeaders->At(i);
2921  TString GeneratorName = gh->GetName();
2922  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2923  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(gh);
2924  NTrials = gPythia->Trials();
2925  XSection = gPythia->GetXsection();
2926  return;
2927  }
2928  }
2929  } else {
2930  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2931  if(eventHeader){
2932  TString eventHeaderName = eventHeader->ClassName();
2933  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2934  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader);
2935  NTrials = gPythia->Trials();
2936  XSection = gPythia->GetXsection();
2937  return;
2938  }
2939  }
2940  }
2941 
2942  NTrials = -1;
2943  XSection = -1;
2944  return;
2945 }
2946 
2947 
2948 //________________________________________________________________________
2949 // Analysing Jet-Jet MC's
2950 //________________________________________________________________________
2952  AliGenCocktailEventHeader *cHeader = 0x0;
2953  Bool_t headerFound = kFALSE;
2954 
2955  if ( fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2956  fPeriodEnum != kLHC17g8b && fPeriodEnum != kLHC17g8c && // LHC16sr pPb 8TeV JetJet MC's
2957  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2958  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2959  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2960  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2961  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2962  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2963  fPeriodEnum != kLHC16c2 && fPeriodEnum != kLHC16c2_plus // LHC12 JetJet MC
2964  ) return -1;
2965 
2966  if(mcEvent){
2967  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2968  if(cHeader) headerFound = kTRUE;
2969  }else{
2970  //no mcEvent available -> not running on MC
2971  return -1;
2972  }
2973 
2974  if(headerFound){
2975  TList *genHeaders = 0x0;
2976  if(cHeader) genHeaders = cHeader->GetHeaders();
2977  AliGenEventHeader* gh = 0;
2978  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2979  gh = (AliGenEventHeader*)genHeaders->At(i);
2980  TString GeneratorName = gh->GetName();
2981  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2982  return dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
2983  }
2984  }
2985  } else {
2986  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2987  if(eventHeader){
2988  TString eventHeaderName = eventHeader->ClassName();
2989  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2990  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
2991  }
2992  }
2993  }
2994 
2995  return -1;
2996 }
2997 
2998 
2999 //________________________________________________________________________
3001  // abort if mimicing not enabled
3002 
3003  if (!fMimicTrigger) return kTRUE;
3004 
3005  Int_t runRangesEMCalL0 [35] = { 144871, 145288, 146375, 146382, // LHC11a
3006  146502, 148522, // LHC11a
3007  150209, 153056, 153911, 153915, // LHC11b,c,d
3008  158135, 158136, 158178, 158182, 160683,
3009  160764, 161139, 161256, 161379, 161457,
3010  161525, 161556, 161558, 161609, 161630,
3011  161724, // LHC11d,e
3012  173731, 177144, 177147, 177653, 177724, 178327,
3013  195180, // LHC13b-f
3014  197469, 197692 // LHC13g
3015  };
3016 
3017  Double_t thresholdEMCalL0[34] = { 2.11, 3.43, 1.71, 2.05, // LHC11a 7 TeV
3018  3.43, // LHC11a 2.76TeV
3019  1.94, 3.39, 4.01, 5.25, 5.5, // LHC11b, LHC11c, LHC11d
3020  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,
3021  2.01, 1.75, 1.52, 2.01, 1.52, 1.85,
3022  3.2,
3023  /*2.01*/1.8
3024  };
3025  Double_t spreadEMCalL0[34] = { 0., 0., 0, 0, // LHC11a 7TeV
3026  /*0.7*/0.65, // LHC11a 2.76TeV
3027  0., 0., 0., 0., 0., // LHC11b, LHC11c, LHC11d
3028  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
3029  0., 0., 0., 0., 0.2, 0.2,/*0.,0.,*/
3030  0.1,
3031  /*0.1*/0.12
3032  };
3033 
3034  Int_t runRangesEMCalL1[4] = { 179796, // LHC12c-i
3035  195180, // LHC13b-f
3036  197469, 197692 // LHC13g
3037  };
3038 
3039  Double_t thresholdEMCalL1[3] = { 9.5/*8.398*/, 11.5, /*6.*/5.5};
3040  Double_t spreadEMCalL1[3] = { 1.0/*0.*/, 0.5, /*0.4*/0.6};
3041 
3042  Int_t runRangesEMCalL1G2[3] = { 195180, // LHC13b-f
3043  197469, 197692 // LHC13g
3044  };
3045 
3046  Double_t thresholdEMCalL1G2[2] = { 7.2, /*3.9*/3.75};
3047  Double_t spreadEMCalL1G2[2] = { 0.3, /*0.2*/0.25};
3048 
3049  Int_t runnumber = event->GetRunNumber();
3050 
3051  if (fSpecialTrigger == 5 ){
3052  if (runnumber < runRangesEMCalL0[0]) return kTRUE;
3053  Int_t binRun = 0;
3054  while (!(runnumber >= runRangesEMCalL0[binRun] && runnumber < runRangesEMCalL0[binRun+1] ) && binRun < 34 ){
3055 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << endl;
3056  binRun++;
3057  }
3058  if (binRun==34) return kFALSE;
3059  Double_t threshold = thresholdEMCalL0[binRun];
3060 
3061  if (isMC && spreadEMCalL0[binRun] != 0.){
3062  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3063  triggerSmearing->SetParameter(0, 1/(spreadEMCalL0[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3064  triggerSmearing->SetParameter(1, thresholdEMCalL0[binRun]);
3065  triggerSmearing->SetParameter(2, spreadEMCalL0[binRun]);
3066  threshold = triggerSmearing->GetRandom();
3067  delete triggerSmearing;
3068  }
3069 
3070 // cout << runnumber << "\t"<< binRun << "\t"<< threshold << endl;
3071  Int_t nclus = 0;
3072  TClonesArray * arrClustersMimic = NULL;
3073  if(!fCorrTaskSetting.CompareTo("")){
3074  nclus = event->GetNumberOfCaloClusters();
3075  } else {
3076  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3077  if(!arrClustersMimic)
3078  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3079  nclus = arrClustersMimic->GetEntries();
3080  }
3081 
3082  if(nclus == 0) return kFALSE;
3083 
3084  // Loop over EMCal clusters
3085  Bool_t eventIsAccepted = kFALSE;
3086  for(Int_t i = 0; i < nclus; i++){
3087  AliVCluster* clus = NULL;
3088  if(event->IsA()==AliESDEvent::Class()){
3089  if(arrClustersMimic)
3090  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3091  else
3092  clus = event->GetCaloCluster(i);
3093  } else if(event->IsA()==AliAODEvent::Class()){
3094  if(arrClustersMimic)
3095  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3096  else
3097  clus = event->GetCaloCluster(i);
3098  }
3099 
3100  if (!clus) continue;
3101  if (!clus->IsEMCAL()) continue;
3102  if (clus->GetM02()<0.1) continue;
3103  if (clus->GetNCells()<2) continue;
3104  if (clus->E() > threshold ){
3105 // cout << "found L0" << endl;
3106  eventIsAccepted = kTRUE;
3107  }
3108  }
3109  return eventIsAccepted;
3110 
3111  } else if (fSpecialTrigger == 6 ) {
3112 
3113  return kTRUE;
3114  } else if (fSpecialTrigger == 8 ) {
3115  if (fSpecialSubTriggerName.CompareTo("7EGA")==0 || fSpecialSubTriggerName.CompareTo("8EGA")==0 || fSpecialSubTriggerName.CompareTo("7EG1")==0 ||fSpecialSubTriggerName.CompareTo("8EG1")==0 ){
3116  if (runnumber < runRangesEMCalL1[0]) return kTRUE;
3117  Int_t binRun = 0;
3118  while (!(runnumber >= runRangesEMCalL1[binRun] && runnumber < runRangesEMCalL1[binRun+1] ) && binRun < 3 ){
3119  // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << endl;
3120  binRun++;
3121  }
3122  if (binRun==3) return kFALSE;
3123  Double_t threshold = thresholdEMCalL1[binRun];
3124 
3125  if (isMC && spreadEMCalL1[binRun] != 0.){
3126  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3127  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3128  triggerSmearing->SetParameter(1, thresholdEMCalL1[binRun]);
3129  triggerSmearing->SetParameter(2, spreadEMCalL1[binRun]);
3130  threshold = triggerSmearing->GetRandom();
3131  delete triggerSmearing;
3132  }
3133 
3134 // cout << runnumber << "\t"<< binRun << "\t L1 \t"<< threshold << endl;
3135 
3136  TClonesArray * arrClustersMimic = NULL;
3137  Int_t nclus = 0;
3138  if(!fCorrTaskSetting.CompareTo("")){
3139  nclus = event->GetNumberOfCaloClusters();
3140  } else {
3141  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3142  if(!arrClustersMimic)
3143  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3144  nclus = arrClustersMimic->GetEntries();
3145  }
3146 
3147  if(nclus == 0) return kFALSE;
3148 
3149  // Loop over EMCal clusters
3150  Bool_t eventIsAccepted = kFALSE;
3151  for(Int_t i = 0; i < nclus; i++){
3152  AliVCluster* clus = NULL;
3153  if(event->IsA()==AliESDEvent::Class()){
3154  if(arrClustersMimic)
3155  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3156  else
3157  clus = event->GetCaloCluster(i);
3158  } else if(event->IsA()==AliAODEvent::Class()){
3159  if(arrClustersMimic)
3160  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3161  else
3162  clus = event->GetCaloCluster(i);
3163  }
3164  if (!clus) continue;
3165  if (!clus->IsEMCAL()) continue;
3166  if (clus->GetM02()<0.1) continue;
3167  if (clus->GetNCells()<2) continue;
3168  if (clus->E() > threshold ){
3169 // cout << "found L1G1" << endl;
3170  eventIsAccepted = kTRUE;
3171  }
3172  }
3173  return eventIsAccepted;
3174  } else if ( fSpecialSubTriggerName.CompareTo("7EG2")==0 ||fSpecialSubTriggerName.CompareTo("8EG2")==0 ){
3175  if (runnumber < runRangesEMCalL1G2[0]) return kTRUE;
3176  Int_t binRun = 0;
3177  while (!(runnumber >= runRangesEMCalL1G2[binRun] && runnumber < runRangesEMCalL1G2[binRun+1] ) && binRun < 2 ){
3178  // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << endl;
3179  binRun++;
3180  }
3181  if (binRun==2) return kFALSE;
3182  Double_t threshold = thresholdEMCalL1G2[binRun];
3183  if (isMC && spreadEMCalL1G2[binRun] != 0.){
3184  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3185  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1G2[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3186  triggerSmearing->SetParameter(1, thresholdEMCalL1G2[binRun]);
3187  triggerSmearing->SetParameter(2, spreadEMCalL1G2[binRun]);
3188  threshold = triggerSmearing->GetRandom();
3189  delete triggerSmearing;
3190  }
3191 // cout << runnumber << "\t"<< binRun << "\t L2 \t"<< threshold << endl;
3192 
3193  Int_t nclus = 0;
3194  TClonesArray * arrClustersMimic = NULL;
3195  if(!fCorrTaskSetting.CompareTo("")){
3196  nclus = event->GetNumberOfCaloClusters();
3197  } else {
3198  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3199  if(!arrClustersMimic)
3200  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3201  nclus = arrClustersMimic->GetEntries();
3202  }
3203 
3204  if(nclus == 0) return kFALSE;
3205 
3206  // Loop over EMCal clusters
3207  Bool_t eventIsAccepted = kFALSE;
3208  for(Int_t i = 0; i < nclus; i++){
3209  AliVCluster* clus = NULL;
3210  if(event->IsA()==AliESDEvent::Class()){
3211  if(arrClustersMimic)
3212  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3213  else
3214  clus = event->GetCaloCluster(i);
3215  } else if(event->IsA()==AliAODEvent::Class()){
3216  if(arrClustersMimic)
3217  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3218  else
3219  clus = event->GetCaloCluster(i);
3220  }
3221  if (!clus) continue;
3222  if (!clus->IsEMCAL()) continue;
3223  if (clus->GetM02()<0.1) continue;
3224  if (clus->GetNCells()<2) continue;
3225  if (clus->E() > threshold ){
3226 // cout << "found L1G2" << endl;
3227  eventIsAccepted = kTRUE;
3228  }
3229  }
3230  return eventIsAccepted;
3231  }
3232  return kTRUE;
3233  } else if (fSpecialTrigger == 9 ) {
3234  return kTRUE;
3235  } else {
3236  return kTRUE;
3237  }
3238 
3239  return kTRUE;
3240 }
3241 
3242 
3243 //________________________________________________________________________
3245 {
3246 
3247  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
3248 
3249 
3250  UInt_t isSelected = AliVEvent::kAny;
3251 
3252  if (fInputHandler==NULL) return kFALSE;
3253  if( fInputHandler->GetEventSelection() || event->IsA()==AliAODEvent::Class()) {
3254 
3255  TString firedTrigClass = event->GetFiredTriggerClasses();
3256  // if no trigger has been selected manually, select kAny in case of presel (also important for AOD filtering!)
3257  // in other cases select standards depending on system
3259  if (fPreSelCut) fOfflineTriggerMask = AliVEvent::kAny;
3260  else {
3261  if (fIsHeavyIon == 1){
3262  fOfflineTriggerMask = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
3263  } else if (fIsHeavyIon == 2){
3264  fOfflineTriggerMask = AliVEvent::kINT7;
3265  } else {
3266  fOfflineTriggerMask = AliVEvent::kMB;
3267  }
3268  }
3269  }
3270 
3271  // in case of MC switch to kAny if no MB/INT7/INT8 has been selected
3272  if(isMC){
3273  if( fIsHeavyIon == 0){
3274  if( fOfflineTriggerMask != AliVEvent::kMB && fOfflineTriggerMask != AliVEvent::kINT7 && fOfflineTriggerMask != AliVEvent::kINT8 ){
3275  fOfflineTriggerMask = AliVEvent::kAny;
3276  }
3277  }else{
3278  fOfflineTriggerMask = AliVEvent::kAny;
3279  }
3280  }
3281 
3282  if (fOfflineTriggerMask){
3283  isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
3284  if (isSelected && !fPreSelCut){
3285 // cout << firedTrigClass.Data() << endl;
3286 // cout << "Special trigger: "<< fSpecialTrigger << " initialized " << fEMCALTrigInitialized << endl;
3287 // if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3288 // if (!fEMCALTrigInitialized ) InitializeEMCALTrigger(event);
3289 // fTriggersEMCAL= GetTriggerList();
3290 // }
3291  if (fSpecialSubTrigger>0 && !isMC){
3292  if (!firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 0;
3293  if (fRejectTriggerOverlap){
3294  // trigger rejection EMC1,7,8
3295  if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC7") == 0){
3296  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3297  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC1") == 0){
3298  if (fInputHandler->IsEventSelected() & AliVEvent::kMB) isSelected = 0;
3299  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC8") == 0){
3300  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3301  }
3302  // trigger rejection EGA
3303  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EGA") == 0){
3304  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3305  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3306  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EGA") == 0){
3307  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3308  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3309  }
3310  // trigger rejection EG1 & EG2
3311  if (fPeriodEnum == kLHC13g){
3312  // EG1 is the trigger with the highest threshold
3313  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3314 // cout << firedTrigClass.Data() << endl;
3315  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3316 // cout << "INT7? " << isSelected << endl;
3317  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3318 // cout << "CEM7? " << isSelected << endl;
3319  if (firedTrigClass.Contains("7EG2")) isSelected = 0;
3320 // cout << "7EG2? " << isSelected << endl;
3321  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3322  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3323  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3324  if (firedTrigClass.Contains("8EG2")) isSelected = 0;
3325  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3326 // cout << firedTrigClass.Data() << endl;
3327  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3328 // cout << "INT7? " << isSelected << endl;
3329  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3330 // cout << "CEM7? " << isSelected << endl;
3331  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3332  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3333  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3334  }
3335  } else {
3336  // EG2 is the trigger with the highest threshold
3337  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3338  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3339  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3340  if (firedTrigClass.Contains("7EG1")) isSelected = 0;
3341  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3342  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3343  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3344  if (firedTrigClass.Contains("8EG1")) isSelected = 0;
3345  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3346  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3347  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3348  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3349  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3350  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3351  }
3352  }
3353  }
3354  if (isSelected != 0 ){
3355 // cout << "I am here" << " :" << fSpecialSubTriggerName.Data() <<endl;
3356  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9 ){
3358  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassesCorrelated->Fill(0);
3359  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassesCorrelated->Fill(1);
3360  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassesCorrelated->Fill(2);
3361  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassesCorrelated->Fill(3);
3362  if (firedTrigClass.Contains("7EJE") || firedTrigClass.Contains("8EJE")) hTriggerClassesCorrelated->Fill(4);
3363  if (firedTrigClass.Contains("7EJ1") || firedTrigClass.Contains("8EJ1")) hTriggerClassesCorrelated->Fill(5);
3364  if (firedTrigClass.Contains("7EJ2") || firedTrigClass.Contains("8EJ2")) hTriggerClassesCorrelated->Fill(6);
3365  if (firedTrigClass.Contains("7EGA") || firedTrigClass.Contains("8EGA")) hTriggerClassesCorrelated->Fill(7);
3366  if (firedTrigClass.Contains("7EG1") || firedTrigClass.Contains("8EG1")) hTriggerClassesCorrelated->Fill(8);
3367  if (firedTrigClass.Contains("7EG2") || firedTrigClass.Contains("8EG2")) hTriggerClassesCorrelated->Fill(9);
3368  }
3369  }
3370  }
3371 
3372  } else if (isMC){
3373  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3374 // isSelected = 0;
3375 // if (fTriggersEMCAL > 0)cout << "Special Trigger " << fSpecialTrigger << " triggers: " << fTriggersEMCAL << " selected triggers: " << fTriggersEMCALSelected << " run number: " <<event->GetRunNumber()<<endl;
3376 // if (fTriggersEMCAL&fTriggersEMCALSelected){
3377 // cout << "accepted ++++++++++++++++++++" << endl;
3378  isSelected = 1;
3379 // }
3380  }
3381  }
3382  //if for specific centrality trigger selection
3383  if(fSpecialSubTrigger == 1){
3384  if(fSpecialSubTriggerName.Contains("|") && GetCentrality(event) <= 10.){
3385  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("|");
3386  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3387  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3388  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3389  }
3390  } else if(fSpecialSubTriggerName.Contains("%")){
3391  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("%");
3392  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3393  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3394  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3395  }
3396  } else if(fSpecialSubTriggerName.Contains("@")){
3397  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("@");
3398  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3399  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3400  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3401  }
3402  } else if(fSpecialSubTriggerName.Contains("&")){ //logic AND of two classes
3403  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("&");
3404  TString CheckClass = "";
3405  for (Int_t i=0; i<ClassesList->GetEntriesFast(); i++){
3406  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3407  if (firedTrigClass.Contains(NameClass->GetString())) CheckClass+="1";
3408  else CheckClass+="0";
3409  }
3410  if(CheckClass.Contains("0")) isSelected = 0;
3411  }
3412  else if(firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 1;
3413  }
3414  }
3415  }
3416  }
3417  fIsSDDFired = !(fInputHandler->IsEventSelected() & AliVEvent::kFastOnly);
3418 
3419  Bool_t mimickedTrigger = kTRUE;
3420  if (fMimicTrigger) mimickedTrigger = MimicTrigger(event, isMC);
3421 // cout << "mimicked decision \t" << mimickedTrigger << "expect decision? "<< fMimicTrigger<< endl;
3422 
3423  // Fill Histogram
3424  if(hTriggerClass){
3425  if (fIsSDDFired) hTriggerClass->Fill(33);
3426  if (mimickedTrigger){
3427  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
3428  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
3429  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
3430  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClass->Fill(3);
3431  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClass->Fill(4);
3432  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
3433  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
3434  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
3435  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
3436  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
3437  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
3438  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClass->Fill(8);
3439  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClass->Fill(9);
3440  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClass->Fill(9);
3441  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClass->Fill(10);
3442  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClass->Fill(10);
3443  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClass->Fill(11);
3444  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClass->Fill(12);
3445  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClass->Fill(13);
3446  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClass->Fill(13);
3447  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClass->Fill(13);
3448  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClass->Fill(14);
3449  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClass->Fill(15);
3450  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClass->Fill(16);
3451  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClass->Fill(17);
3452  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClass->Fill(18);
3453  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClass->Fill(19);
3454  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClass->Fill(20);
3455  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClass->Fill(20);
3456  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClass->Fill(21);
3457  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClass->Fill(22);
3458  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClass->Fill(23);
3459  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClass->Fill(24);
3460  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClass->Fill(25);
3461  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClass->Fill(26);
3462  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClass->Fill(27);
3463  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClass->Fill(28);
3464  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(29);
3465  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(30);
3466  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(31);
3467  if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(34);
3468  }
3469  if (mimickedTrigger && fMimicTrigger) hTriggerClass->Fill(35);
3470  }
3471 
3472  if(hTriggerClassSelected && isSelected){
3473  if (mimickedTrigger){
3474  if (!fIsSDDFired) hTriggerClassSelected->Fill(33);
3475  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
3476  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
3477  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
3478  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
3479  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
3480  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
3481  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
3482  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
3483  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
3484  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
3485  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
3486  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
3487  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
3488  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
3489  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
3490  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
3491  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
3492  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
3493  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
3494  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
3495  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
3496  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
3497  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
3498  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
3499  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
3500  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
3501  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
3502  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
3503  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
3504  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
3505  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
3506  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
3507  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
3508  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
3509  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
3510  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
3511  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClassSelected->Fill(28);
3512  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(29);
3513  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(30);
3514  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(31);
3515  }
3516  if (mimickedTrigger && fMimicTrigger) hTriggerClassSelected->Fill(34);
3517  }
3518 
3519  if(!isSelected)return kFALSE;
3520  if (fMimicTrigger)
3521  if (!mimickedTrigger ) return kFALSE;
3522  return kTRUE;
3523 
3524 }
3525 
3526 //________________________________________________________________________
3528  // returns TString with current cut number
3529  return fCutStringRead;
3530 }
3531 
3532 //________________________________________________________________________
3533 void AliConvEventCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliVEvent *event){
3534 
3535  if(fNotRejectedStart){
3536  delete[] fNotRejectedStart;
3537  fNotRejectedStart = NULL;
3538  }
3539  if(fNotRejectedEnd){
3540  delete[] fNotRejectedEnd;
3541  fNotRejectedEnd = NULL;
3542  }
3543  if(fGeneratorNames){
3544  delete[] fGeneratorNames;
3545  fGeneratorNames = NULL;
3546  }
3547 
3548  if(rejection == 0) return; // No Rejection
3549 
3550  AliGenCocktailEventHeader *cHeader = 0x0;
3551  AliAODMCHeader *cHeaderAOD = 0x0;
3552  Bool_t headerFound = kFALSE;
3553  AliMCEvent *fMCEvent = 0x0;
3554  TClonesArray *fMCEventAOD = 0x0;
3555  if(event->IsA()==AliMCEvent::Class()){
3556  if(dynamic_cast<AliMCEvent*>(event)){
3557  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(dynamic_cast<AliMCEvent*>(event)->GenEventHeader());
3558  fMCEvent = dynamic_cast<AliMCEvent*>(event);
3559  if(cHeader) headerFound = kTRUE;
3560  }
3561  }
3562  if(event->IsA()==AliAODEvent::Class()){ // event is a AODEvent in case of AOD
3563  cHeaderAOD = dynamic_cast<AliAODMCHeader*>(event->FindListObject(AliAODMCHeader::StdBranchName()));
3564  fMCEventAOD = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
3565  if(cHeaderAOD) headerFound = kTRUE;
3566  }
3567 
3568  if (fDebugLevel > 0 ) cout << "event starts here" << endl;
3569  if(headerFound){
3570  TList *genHeaders = 0x0;
3571  if(cHeader) genHeaders = cHeader->GetHeaders();
3572  if(cHeaderAOD){
3573  genHeaders = cHeaderAOD->GetCocktailHeaders();
3574  if(genHeaders->GetEntries()==1){
3576  return;
3577  }
3578  }
3579  AliGenEventHeader* gh = 0;
3580  fnHeaders = 0;
3581  Int_t firstindexA = 0;
3582  Int_t lastindexA = -1;
3583  if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
3584  if(rejection == 2){ // TList of Headers Names
3585  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3586  gh = (AliGenEventHeader*)genHeaders->At(i);
3587  TString GeneratorName = gh->GetName();
3588  lastindexA = lastindexA + gh->NProduced();
3589  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
3590  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
3591  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
3592  if (fDebugLevel > 0 ) cout << GeneratorInList.Data() << endl;
3593  if(GeneratorInList.Contains(GeneratorName) ){
3594  if (fDebugLevel > 0 ) cout << "accepted" << endl;
3595  if (GeneratorInList.BeginsWith("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
3596  if(fMCEvent){
3597  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
3598  if (fDebugLevel > 2 )cout << "number of produced particle: " << gh->NProduced() << endl;
3599  if (fDebugLevel > 2 )cout << "pdg-code of first particle: " << fMCEvent->Particle(firstindexA)->GetPdgCode() << endl;
3600  if (fMCEvent->Particle(firstindexA)->GetPdgCode() == fAddedSignalPDGCode ) {
3601  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindexA+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
3602  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3603  fnHeaders++;
3604  continue;
3605  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
3606  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
3607  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3608  fnHeaders++;
3609  continue;
3610  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
3611  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
3612  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3613  fnHeaders++;
3614  continue;
3615 
3616  }
3617  continue;
3618  }
3619  } else {
3620  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
3621  fnHeaders++;
3622  continue;
3623  }
3624  }
3625  if ( fMCEventAOD){
3626  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA));
3627  if (aodMCParticle && (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c) ){
3628  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
3629  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0){
3630  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA+10));
3631  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
3632  if (fDebugLevel > 0 ) cout << "cond 1: " << fnHeaders << endl;
3633  fnHeaders++;
3634  continue;
3635  }
3636  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
3637  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
3638  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3639  fnHeaders++;
3640  continue;
3641  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
3642  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
3643  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3644  fnHeaders++;
3645  continue;
3646 
3647  }
3648  continue;
3649  }
3650  } else {
3651  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
3652  fnHeaders++;
3653  continue;
3654  }
3655  }
3656  continue;
3657  }
3658  if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
3659  if (fDebugLevel > 0 ) cout << "cond 3: "<< fnHeaders << endl;
3660  fnHeaders++;
3661  continue;
3662  }
3663  }
3664  }
3665  firstindexA = firstindexA + gh->NProduced();
3666  }
3667  }
3668  if (fDebugLevel > 0 ) cout << "number of headers: " <<fnHeaders << endl;
3669 
3673 
3674  if(rejection == 1 || rejection == 3){
3675  fNotRejectedStart[0] = 0;
3676  fNotRejectedEnd[0] = ((AliGenEventHeader*)genHeaders->At(0))->NProduced()-1;
3677  fGeneratorNames[0] = ((AliGenEventHeader*)genHeaders->At(0))->GetName();
3678  if (fDebugLevel > 0 ) cout << 0 << "\t" <<fGeneratorNames[0] << "\t" << fNotRejectedStart[0] << "\t" <<fNotRejectedEnd[0] << endl;
3679  return;
3680  }
3681 
3682  Int_t firstindex = 0;
3683  Int_t lastindex = -1;
3684  Int_t number = 0;
3685 
3686  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3687  gh = (AliGenEventHeader*)genHeaders->At(i);
3688  TString GeneratorName = gh->GetName();
3689  lastindex = lastindex + gh->NProduced();
3690  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
3691  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
3692  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
3693  if(GeneratorInList.Contains(GeneratorName) ){
3694  if (GeneratorInList.Contains("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
3695  if(fMCEvent){
3696  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
3697  if (fMCEvent->Particle(firstindex)->GetPdgCode() == fAddedSignalPDGCode ) {
3698  if (fDebugLevel > 0 ) cout << "produced " << gh->NProduced() << " with box generator" << endl;
3699  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindex+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
3700  if (fDebugLevel > 0 ) cout << "one of them was a pi0 or eta" << endl;
3701  fNotRejectedStart[number] = firstindex;
3702  fNotRejectedEnd[number] = lastindex;
3703  fGeneratorNames[number] = GeneratorName;
3704  number++;
3705  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3706  continue;
3707  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
3708  fNotRejectedStart[number] = firstindex;
3709  fNotRejectedEnd[number] = lastindex;
3710  fGeneratorNames[number] = GeneratorName;
3711  number++;
3712  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3713  continue;
3714  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
3715  fNotRejectedStart[number] = firstindex;
3716  fNotRejectedEnd[number] = lastindex;
3717  fGeneratorNames[number] = GeneratorName;
3718  number++;
3719  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3720  continue;
3721  }
3722  }
3723  continue;
3724  } else {
3725  fNotRejectedStart[number] = firstindex;
3726  fNotRejectedEnd[number] = lastindex;
3727  fGeneratorNames[number] = GeneratorName;
3728  number++;
3729  continue;
3730  }
3731  }
3732  if ( fMCEventAOD){
3733  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex));
3734  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
3735  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
3736  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0) {
3737  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex+10));
3738  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
3739  fNotRejectedEnd[number] = lastindex;
3740  fNotRejectedStart[number] = firstindex;
3741  fGeneratorNames[number] = GeneratorName;
3742  number++;
3743  }
3744  continue;
3745  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
3746  fNotRejectedStart[number] = firstindex;
3747  fNotRejectedEnd[number] = lastindex;
3748  fGeneratorNames[number] = GeneratorName;
3749  number++;
3750  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3751  continue;
3752  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
3753  fNotRejectedStart[number] = firstindex;
3754  fNotRejectedEnd[number] = lastindex;
3755  fGeneratorNames[number] = GeneratorName;
3756  number++;
3757  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3758  continue;
3759  }
3760  continue;
3761  }
3762  } else {
3763  fNotRejectedStart[number] = firstindex;
3764  fNotRejectedEnd[number] = lastindex;
3765  fGeneratorNames[number] = GeneratorName;
3766  number++;
3767  continue;
3768  }
3769  }
3770  continue;
3771  } else if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
3772  fNotRejectedStart[number] = firstindex;
3773  fNotRejectedEnd[number] = lastindex;
3774  fGeneratorNames[number] = GeneratorName;
3775  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3776  number++;
3777  continue;
3778  }
3779 
3780  }
3781  }
3782  firstindex = firstindex + gh->NProduced();
3783  }
3784  if (fDebugLevel > 0 ) {
3785  for (Int_t i = 0; i < number; i++){
3786  cout << i << "\t" <<fGeneratorNames[i] << "\t" << fNotRejectedStart[i] << "\t" <<fNotRejectedEnd[i] << endl;
3787  }
3788  }
3789  } else { // No Cocktail Header Found
3790  fNotRejectedStart = new Int_t[1];
3791  fNotRejectedEnd = new Int_t[1];
3792 
3793  fnHeaders = 1;
3794  fNotRejectedStart[0] = 0;
3795  fNotRejectedEnd[0] = static_cast<AliMCEvent*>(event)->GetNumberOfPrimaries()-1;
3796  if (rejection > 1){
3797  fNotRejectedStart[0] = -1;
3798  fNotRejectedEnd[0] = -1;
3799  }
3800 
3801  fGeneratorNames = new TString[1];
3802  fGeneratorNames[0] = "NoCocktailGeneratorFound";
3803 // SetRejectExtraSignalsCut(0);
3804  }
3805 
3806 }
3807 
3808 //_________________________________________________________________________
3809 Int_t AliConvEventCuts::IsParticleFromBGEvent(Int_t index, AliMCEvent *mcEvent, AliVEvent *InputEvent, Int_t debug ){
3810 
3811  // if (debug > 2 ) cout << index << endl;
3812  if(index < 0) return 0; // No Particle
3813 
3814  Int_t accepted = 0;
3815  if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
3816  if(!mcEvent) return 0; // no mcEvent available, return 0
3817  if(index >= mcEvent->GetNumberOfPrimaries()){ // initial particle is secondary particle
3818  if( ((TParticle*)mcEvent->Particle(index))->GetMother(0) < 0) return 0; // material particle, return 0
3819  return IsParticleFromBGEvent(((TParticle*)mcEvent->Particle(index))->GetMother(0),mcEvent,InputEvent, debug);
3820  }
3821  for(Int_t i = 0;i<fnHeaders;i++){
3822  // if (debug > 2 ) cout << "header " << fGeneratorNames[i].Data() << ":"<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
3823  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
3824  if (debug > 1 ) cout << "accepted:" << index << "\t header " << fGeneratorNames[i].Data() << ": "<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
3825  accepted = 1;
3826  if(i == 0) accepted = 2; // MB Header
3827  }
3828  }
3829  if (debug > 1 && !accepted) cout << "rejected:" << index << endl;
3830  }
3831  else if(InputEvent->IsA()==AliAODEvent::Class()){
3832  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3833  if (AODMCTrackArray){
3834  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
3835  if(!aodMCParticle) return 0; // no particle
3836  if(!aodMCParticle->IsPrimary()){
3837  if( aodMCParticle->GetMother() < 0) return 0;// material particle, return 0
3838  return IsParticleFromBGEvent(aodMCParticle->GetMother(),mcEvent,InputEvent, debug);
3839  }
3840  index = TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index))->GetLabel());
3841  for(Int_t i = 0;i<fnHeaders;i++){
3842  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
3843  accepted = 1;
3844  if(i == 0) accepted = 2; // MB Header
3845  }
3846  }
3847  }
3848  }
3849 
3850  return accepted;
3851 }
3852 
3853 //_________________________________________________________________________
3854 Int_t AliConvEventCuts::IsEventAcceptedByCut(AliConvEventCuts *ReaderCuts, AliVEvent *event, AliMCEvent *mcEvent, Int_t isHeavyIon, Bool_t isEMCALAnalysis){
3855 
3856  Bool_t isMC = kFALSE;
3857  if (mcEvent){isMC = kTRUE;}
3858 
3859  if ( !IsTriggerSelected(event, isMC) )
3860  return 3;
3861 
3862  if( !(IsCentralitySelected(event,mcEvent)))
3863  return 1; // Check Centrality --> Not Accepted => eventQuality = 1
3864 
3865  Bool_t hasV0And = ReaderCuts->HasV0AND();
3866  Bool_t isSDDFired = ReaderCuts->IsSDDFired();
3867 
3868  if( ( (IsSpecialTrigger() == 0 && IsSpecialSubTrigger() == 1) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !isSDDFired && !mcEvent)
3869  //if V0OR with SDD requested or V0AND with SDD request but the SDD has not fired
3870  return 7; // V0 with SDD requested but no fired
3871 
3872  if( ( (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 0) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !hasV0And)
3873  //if V0AND (only) or V0AND with SDD requested but V0AND requested but no fired
3874  return 8; // V0AND requested but no fired
3875 
3876 
3877  if( (IsSpecialTrigger() == 2 || IsSpecialTrigger() == 3) && !isSDDFired && !mcEvent)
3878  return 7; // With SDD requested but no fired
3879 
3880  if( (IsSpecialTrigger() == 1 || IsSpecialTrigger() == 3) && !hasV0And)
3881  return 8; // V0AND requested but no fired
3882 
3883  // Special EMCAL checks due to hardware issues in LHC11a
3884  if (isEMCALAnalysis || IsSpecialTrigger() == 5 || IsSpecialTrigger() == 8 || IsSpecialTrigger() == 9 ){
3885  Int_t runnumber = event->GetRunNumber();
3886  if ((runnumber>=144871) && (runnumber<=146860)) {
3887 
3888  AliVCaloCells *cells = event->GetEMCALCells();
3889  const Short_t nCells = cells->GetNumberOfCells();
3890 
3891  if (event->IsA()==AliESDEvent::Class()) AliAnalysisManager::GetAnalysisManager()->LoadBranch("EMCALCells.");
3892 
3893  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
3894  if (!fInputHandler) return 3;
3895 
3896  // count cells above threshold
3897  Int_t nCellCount[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
3898  for(Int_t iCell=0; iCell<nCells; ++iCell) {
3899  Short_t cellId = cells->GetCellNumber(iCell);
3900  Double_t cellE = cells->GetCellAmplitude(cellId);
3901  Int_t sm = cellId / (24*48);
3902  if (cellE>0.1) ++nCellCount[sm];
3903  }
3904 
3905  Bool_t fIsLedEvent = kFALSE;
3906  if (nCellCount[4] > 100) {
3907  fIsLedEvent = kTRUE;
3908  } else {
3909  if ((runnumber>=146858) && (runnumber<=146860)) {
3910  if ((fInputHandler->IsEventSelected() & AliVEvent::kMB) && (nCellCount[3]>=21))
3911  fIsLedEvent = kTRUE;
3912  else if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC1) && (nCellCount[3]>=35))
3913  fIsLedEvent = kTRUE;
3914  }
3915  }
3916  if (fIsLedEvent) {
3917  return 9;
3918  }
3919  }
3920  }
3921 
3922  // SPD clusters vs tracklets to check for pileup/background
3923  Int_t nClustersLayer0 = event->GetNumberOfITSClusters(0);
3924  Int_t nClustersLayer1 = event->GetNumberOfITSClusters(1);
3925  Int_t nTracklets = event->GetMultiplicity()->GetNumberOfTracklets();
3926  if(hSPDClusterTrackletBackgroundBefore) hSPDClusterTrackletBackgroundBefore->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
3927 
3928 
3929  Double_t distZMax = 0;
3930  if(event->IsA()==AliESDEvent::Class()){
3931  Int_t nPileVert = ((AliESDEvent*)event)->GetNumberOfPileupVerticesSPD();
3932  if (hNPileupVertices) hNPileupVertices->Fill(nPileVert);
3933  if (nPileVert > 0){
3934  for(Int_t i=0; i<nPileVert;i++){
3935  const AliESDVertex* pv= ((AliESDEvent*)event)->GetPileupVertexSPD(i);
3936  Int_t nc2 = pv->GetNContributors();
3937  if(nc2>=3){
3938  Double_t z1 = ((AliESDEvent*)event)->GetPrimaryVertexSPD()->GetZ();
3939  Double_t z2 = pv->GetZ();
3940  Double_t distZ = z2-z1;
3941  if (TMath::Abs(distZMax) < TMath::Abs(distZ) ){
3942  distZMax = distZ;
3943  }
3944  }
3945  }
3946  if (hPileupVertexToPrimZ) hPileupVertexToPrimZ->Fill(distZMax);
3947  }
3948  }
3949  if(GetPastFutureLowBC()!=0 && GetPastFutureHighBC()!=0 ){
3950  if(IsOutOfBunchPileupPastFuture(event))
3951  return 12;
3952  }
3953 
3954  if( isHeavyIon != 2 && GetIsFromPileup()){
3955  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.) ){
3957  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
3958  }
3959  if (fUtils->IsSPDClusterVsTrackletBG(event)){
3961  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
3962  }
3963  }
3964  if(isHeavyIon == 2 && GetIsFromPileup()){
3965  if(fUtils->IsPileUpEvent(event) ){
3967  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
3968  }
3969  if (fUtils->IsSPDClusterVsTrackletBG(event)){
3971  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
3972  }
3973  }
3974 
3976  if( IsPileUpV0MTPCout(event) ){
3977  return 13;
3978  }
3979  }
3980 
3981  if(hCentrality)hCentrality->Fill(GetCentrality(event));
3982 
3983  if(hVertexZ)hVertexZ->Fill(event->GetPrimaryVertex()->GetZ());
3984 // if(hCentralityVsNumberOfPrimaryTracks)
3985 // hCentralityVsNumberOfPrimaryTracks->Fill(GetCentrality(event),
3986 // ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
3987 // ->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks());
3988 
3989  if(fIsHeavyIon == 1){
3990  AliEventplane *EventPlane = event->GetEventplane();
3991  fEventPlaneAngle = EventPlane->GetEventplane("V0",event,2);
3992  if(hEventPlaneAngle)hEventPlaneAngle->Fill(TMath::Abs(fEventPlaneAngle));
3993  }
3994  if(hSPDClusterTrackletBackground) hSPDClusterTrackletBackground->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
3995 
3996  return 0;
3997 }
3998 
3999 
4000 //_________________________________________________________________________
4002 
4003  AliInfo("Inside the GetWeightForCentralityFlattening function");
4004  Double_t centrality = 0.;
4005  //obtain centrality for ESD or AOD
4006  if(!event || event->IsA()==AliESDEvent::Class()){
4007  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
4008  if(esdEvent){
4009  AliCentrality *fESDCentrality=(AliCentrality*)esdEvent->GetCentrality();
4010  if(fDetectorCentrality==0 && fIsHeavyIon==1){
4011  centrality = fESDCentrality->GetCentralityPercentile("V0M"); // default for PbPb
4012  }
4013  }
4014  } else if(event->IsA()==AliAODEvent::Class()){
4015  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
4016  if(aodEvent){
4017  if(aodEvent->GetHeader()){
4018  centrality = ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();
4019  }
4020  }
4021  }
4022 
4023  //Get the maximum vlaue from the reference distribution and interpolated value
4024  Float_t GetValueForWeight = 1.;
4025  Float_t maximum = 1.;
4026  Double_t weightCentrality = 1.;
4027  Bool_t CorrCentrLoop = kFALSE;
4028 
4029  //depending on the value of the flag, flattening in different cent. range
4030  if ( fDoCentralityFlat == 1 && (centrality >= 0. && centrality <= 20.) ){
4031  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4032  maximum = hCentralityNotFlat->GetMaximum();
4033  CorrCentrLoop = kTRUE;
4034  } else if ( fDoCentralityFlat == 8 ){
4035  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4036  maximum = hCentralityNotFlat->GetMaximum();
4037  CorrCentrLoop = kTRUE;
4038  } else {
4039  CorrCentrLoop = kFALSE;
4040  }
4041 
4042  if (CorrCentrLoop && GetValueForWeight != 0. && maximum !=0. && isfinite(GetValueForWeight) && isfinite(maximum) ){
4043  weightCentrality = maximum/GetValueForWeight;
4044  if (!isfinite(GetValueForWeight)) weightCentrality = 1.;
4045  if (!isfinite(weightCentrality)) weightCentrality = 1.;
4046  }
4047 
4048  return weightCentrality;
4049 }
4050 
4051 //_________________________________________________________________________
4053 
4054  Double_t weightMult = 1.;
4055 
4056  Float_t valueMultData = -1.;
4057  Float_t valueMultMC = -1.;
4058 
4059  if (hReweightMultData == NULL || hReweightMultMC == NULL ) return weightMult;
4060 
4061  valueMultData = hReweightMultData->Interpolate(mult);
4062  valueMultMC = hReweightMultMC->Interpolate(mult);
4063 
4064  Float_t relativeErrorMC = hReweightMultMC->GetBinError(hReweightMultMC->FindBin(mult))/hReweightMultMC->GetBinContent(hReweightMultMC->FindBin(mult));
4065  Float_t relativeErrorData = hReweightMultData->GetBinError(hReweightMultData->FindBin(mult))/hReweightMultData->GetBinContent(hReweightMultData->FindBin(mult));
4066 
4067  if (relativeErrorData < 0.2 && relativeErrorMC < 0.2 ){
4068  if (isfinite(valueMultData) && isfinite(valueMultMC) ){
4069  weightMult = valueMultData/valueMultMC;
4070  }
4071  }
4072 
4073  return weightMult;
4074 }
4075 
4076 
4077 
4078 //_________________________________________________________________________
4079 Float_t AliConvEventCuts::GetWeightForMeson(Int_t index, AliMCEvent *mcEvent, AliVEvent *event){
4080  if (!( fPeriodEnum == kLHC13d2 || fPeriodEnum == kLHC13d2b || // LHC10h MCs
4081  fPeriodEnum == kLHC14a1a || fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c || // LHC11h MCs
4082  fPeriodEnum == kLHC13e7 || fPeriodEnum == kLHC13b2_efix || fPeriodEnum == kLHC14b2 || // LHC13bc MCs
4083  fPeriodEnum == kLHC14e2a || fPeriodEnum == kLHC14e2b || fPeriodEnum == kLHC14e2c || // LHC12[a-i] pass 1 MCs
4084  fPeriodEnum == kLHC12f1a || fPeriodEnum == kLHC12f1b || fPeriodEnum == kLHC12i3 // LHC11a MCs
4085  ) ) return 1.;
4086  Int_t kCaseGen = 0;
4087 
4088  if(index < 0) return 0; // No Particle
4089 
4090  if (IsParticleFromBGEvent(index, mcEvent, event)){
4093  kCaseGen = 1;
4094  }
4095  }
4096  if (kCaseGen == 0) return 1;
4097 
4098  Double_t mesonPt = 0;
4099  //Double_t mesonMass = 0;
4100  Int_t PDGCode = 0;
4101  if(!event || event->IsA()==AliESDEvent::Class()){
4102  mesonPt = ((TParticle*)mcEvent->Particle(index))->Pt();
4103  //mesonMass = ((TParticle*)mcEvent->Particle(index))->GetCalcMass();
4104  PDGCode = ((TParticle*)mcEvent->Particle(index))->GetPdgCode();
4105  } else if(event->IsA()==AliAODEvent::Class()){
4106  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4107  if (AODMCTrackArray){
4108  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
4109  mesonPt = aodMCParticle->Pt();
4110  //mesonMass = aodMCParticle->GetCalcMass();
4111  PDGCode = aodMCParticle->GetPdgCode();
4112  } else {
4113  return 1;
4114  }
4115  }
4116 
4117  Float_t functionResultMC = 1.;
4118  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0){
4119  functionResultMC = hReweightMCHistPi0->Interpolate(mesonPt);
4120  }
4121  if ( PDGCode == 221 && fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0){
4122  functionResultMC = hReweightMCHistEta->Interpolate(mesonPt);
4123  }
4124  if ( PDGCode == 310 && fDoReweightHistoMCK0s && hReweightMCHistK0s!= 0x0){
4125  functionResultMC = hReweightMCHistK0s->Interpolate(mesonPt);
4126  }
4127 
4128  Float_t functionResultData = 1;
4129  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && fFitDataPi0!= 0x0){
4130  functionResultData = fFitDataPi0->Eval(mesonPt);
4131  }
4132  if ( PDGCode == 221 && fDoReweightHistoMCEta && fFitDataEta!= 0x0){
4133  functionResultData = fFitDataEta->Eval(mesonPt);
4134  }
4135  if ( PDGCode == 310 && fDoReweightHistoMCK0s && fFitDataK0s!= 0x0){
4136  functionResultData = fFitDataK0s->Eval(mesonPt);
4137  }
4138 
4139  Double_t weight = 1;
4140  if (PDGCode == 111 || PDGCode == 221){
4141  if (functionResultData != 0. && functionResultMC != 0. && isfinite(functionResultData) && isfinite(functionResultMC)){
4142  weight = functionResultData/functionResultMC;
4143  if ( kCaseGen == 3){
4144  if (PDGCode == 111){
4145  if (!(fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0 && PDGCode == 111)){
4146  weight = 1.;
4147  }
4148  }
4149  if (PDGCode == 221){
4150  if (!(fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0 && PDGCode == 221)){
4151  weight = 1.;
4152  }
4153  }
4154  }
4155  if (!isfinite(functionResultData)) weight = 1.;
4156  if (!isfinite(weight)) weight = 1.;
4157  }
4158  } else if (PDGCode == 310 && functionResultMC != 0 && isfinite(functionResultMC)){
4159  weight = functionResultMC;
4160  }
4161  return weight;
4162 }
4163 
4164 
4167 
4168  if( fPeriodEnum == kLHC13bc || // mainly minimum bias
4169  fPeriodEnum == kLHC13de || // mainly triggered
4170  fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus || // MC Pythia 6 (Jet-Jet), anchor LHC13b-e
4171  fPeriodEnum == kLHC13b2_efix || //MC DPMJET, anchr LHC13b+c
4172  fPeriodEnum == kLHC13e7 || //MC HIJING, anchr LHC13b+c
4173  fPeriodEnum == kLHC14b2 //MC HIJING, anchr LHC13b+c
4174  ){
4175  printf(" Gamma Conversion Cuts %s :: pPb Run doing Eta Shift of %f \n\n",(GetCutNumber()).Data(),-0.465);
4176  SetEtaShift(-0.465);
4177  } else if( fPeriodEnum == kLHC13f ) {
4178  printf(" Gamma Conversion Cuts %s :: Pbp Run doing Eta Shift of %f \n\n",(GetCutNumber()).Data(),0.465);
4179  SetEtaShift(+0.465);
4180  }
4181  else printf(" Gamma Conversion Cuts %s :: Automatic Eta Shift requested but Period is not known -> No Shift \n\n",(GetCutNumber()).Data());
4182 }
4183 
4184 //________________________________________________________________________
4185 AliEMCALTriggerPatchInfo* AliConvEventCuts::GetMainTriggerPatch()
4186 {
4187  //get main trigger match; if not known yet, look for it and cache
4188 
4190  return fMainTriggerPatchEMCAL;
4191 
4192  if (!fTriggerPatchInfo) {
4193  AliError(Form("%s: fTriggerPatchInfo not available",GetName()));
4194  return 0;
4195  }
4196 
4197  //number of patches in event
4198  Int_t nPatch = fTriggerPatchInfo->GetEntries();
4199 
4200  //extract main trigger patch
4201  AliEMCALTriggerPatchInfo *patch;
4202  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
4203  patch = (AliEMCALTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
4204  if (patch->IsMainTrigger()) {
4205  fMainTriggerPatchEMCAL = patch;
4206  break;
4207  }
4208  }
4209 
4210  return fMainTriggerPatchEMCAL;
4211 }
4212 
4213 
4214 //________________________________________________________________________
4216 {
4217 // cout << "entered EMCAL trigger initialization" << endl;
4218 
4219  // Init the analysis.
4220  if (fCaloTriggersName.IsNull()){
4221  if (event->IsA()==AliESDEvent::Class()){
4222  fCaloTriggersName = "EMCALTrigger";
4223  } else {
4224  fCaloTriggersName = "emcalTrigger";
4225  }
4226  }
4227 
4228  if (!fCaloTriggersName.IsNull() && !fCaloTriggers) {
4229  fCaloTriggers = dynamic_cast<AliVCaloTrigger*>(event->FindListObject(fCaloTriggersName));
4230  if (!fCaloTriggers) {
4231  AliError(Form("%s: Could not retrieve calo triggers %s!", GetName(), fCaloTriggersName.Data()));
4232  return;
4233  }
4234  }
4235 
4236  if (fCaloTriggerPatchInfoName.IsNull()){
4237  if (event->IsA()==AliESDEvent::Class()){
4238  fCaloTriggerPatchInfoName = "EmcalTriggers";
4239  } else {
4240  fCaloTriggerPatchInfoName = "EmcalTriggers";
4241  }
4242  }
4243 
4244  if (!fCaloTriggerPatchInfoName.IsNull() && !fTriggerPatchInfo) {
4245  fTriggerPatchInfo = GetArrayFromEvent(event, fCaloTriggerPatchInfoName.Data(), "AliEMCALTriggerPatchInfo");
4246  if (!fTriggerPatchInfo) {
4247  AliError(Form("%s: Could not retrieve calo trigger patch info %s!", GetName(), fCaloTriggerPatchInfoName.Data()));
4248  return;
4249  }
4250 
4251  }
4252 
4253  fEMCALTrigInitialized = kTRUE;
4254 }
4255 
4256 //________________________________________________________________________
4258  if (!fTriggerPatchInfo)
4259  return 0;
4260  //number of patches in event
4261  Int_t nPatch = fTriggerPatchInfo->GetEntries();
4262 
4263  //loop over patches to define trigger type of event
4264  Int_t nG1 = 0;
4265  Int_t nG2 = 0;
4266  Int_t nJ1 = 0;
4267  Int_t nJ2 = 0;
4268  Int_t nL0 = 0;
4269  AliEMCALTriggerPatchInfo *patch;
4270 // if (nPatch> 0) {cout << "NEW Triggers in this event*********************************" << endl;}
4271  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
4272  patch = (AliEMCALTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
4273 // cout << "Patch energy: "<<patch->GetPatchE() << "\t ADC counts: " << patch->GetADCAmp() << endl;
4274 // cout << "Phi: " << patch->GetPhiMin() << " - " << patch->GetPhiMax() << " delta phi: " <<TMath::Abs(patch->GetPhiMin()-patch->GetPhiMax())<< endl;
4275 // cout << "Eta: " << patch->GetEtaMin() << " - " << patch->GetEtaMax() << " delta eta: " <<TMath::Abs(patch->GetEtaMin()-patch->GetEtaMax())<< endl;
4276  if (patch->IsGammaHigh()){
4277 // cout << "fired L1GA high" << endl;
4278  nG1++;
4279  }
4280  if (patch->IsGammaLow()){
4281 // cout << "fired L1GA low" << endl;
4282  nG2++;
4283  }
4284  if (patch->IsJetHigh()){
4285 // cout << "fired L1JE high" << endl;
4286  nJ1++;
4287  }
4288  if (patch->IsJetLow()){
4289 // cout << "fired L1JE low" << endl;
4290  nJ2++;
4291  }
4292  if (patch->IsLevel0()){
4293 // cout << "fired L0" << endl;
4294  nL0++;
4295  }
4296 // cout << patch->GetPatchE() << "\t" << patch->GetADCAmp() << "\t" << patch->IsGammaHigh() << "\t" << patch->IsGammaLow()
4297 // << "\t" << patch->IsJetHigh() << "\t" << patch->IsJetLow() << "\t" << patch->IsLevel0()
4298 // << "\t" << patch->GetPhiMin() << "\t" << patch->GetPhiMax() << "\t" << TMath::Abs(patch->GetPhiMin()-patch->GetPhiMax())
4299 // << "\t" << patch->GetEtaMin() << "\t" << patch->GetEtaMax() << "\t" << TMath::Abs(patch->GetEtaMin()-patch->GetEtaMax()) << endl;
4300  }
4301 
4302  if (nPatch > 0){
4303  AliDebug(2, "Patch summary: ");
4304  AliDebug(2, Form("Number of patches: %d", nPatch));
4305  AliDebug(2, Form("Level0: [%d]" ,nL0));
4306  AliDebug(2, Form("Jet: low[%d], high[%d]" ,nJ2, nJ1));
4307  AliDebug(2, Form("Gamma: low[%d], high[%d]" ,nG2, nG1));
4308  }
4309 
4310 // if (nPatch > 0){
4311 // cout << Form("Number of patches: %d", nPatch) << endl;
4312 // cout << Form("Level0: [%d]" ,nL0) << endl;
4313 // cout << Form("Jet: low[%d], high[%d]" ,nJ2, nJ1) << endl;
4314 // cout << Form("Gamma: low[%d], high[%d]" ,nG2, nG1) << endl;
4315 // }
4316 
4317  ULong_t triggers(0);
4318  if (nG1>0)
4319  SETBIT(triggers, kG1);
4320  if (nG2>0)
4321  SETBIT(triggers, kG2);
4322  if (nJ1>0)
4323  SETBIT(triggers, kJ1);
4324  if (nJ2>0)
4325  SETBIT(triggers, kJ2);
4326  if (nL0>0)
4327  SETBIT(triggers, kL0);
4328  return triggers;
4329 }
4330 
4331 //________________________________________________________________________
4333  // Check if event has a given trigger type
4334  if(t == kND){
4335  return fTriggersEMCAL == 0;
4336  }
4337  return TESTBIT(fTriggersEMCAL, int(t));
4338 }
4339 
4340 
4341 //________________________________________________________________________
4342 TClonesArray *AliConvEventCuts::GetArrayFromEvent(AliVEvent* event, const char *name, const char *clname)
4343 {
4344  // Get array from event.
4345 
4346  TClonesArray *arr = 0;
4347  TString sname(name);
4348  if (!sname.IsNull()) {
4349  arr = dynamic_cast<TClonesArray*>(event->FindListObject(sname));
4350  if (!arr) {
4351  AliWarning(Form("%s: Could not retrieve array with name %s!", GetName(), name));
4352  return 0;
4353  }
4354  } else {
4355  return 0;
4356  }
4357 
4358  if (!clname)
4359  return arr;
4360 
4361  TString objname(arr->GetClass()->GetName());
4362  TClass cls(objname);
4363  if (!cls.InheritsFrom(clname)) {
4364  AliWarning(Form("%s: Objects of type %s in %s are not inherited from %s!",
4365  GetName(), cls.GetName(), name, clname));
4366  return 0;
4367  }
4368  return arr;
4369 }
4370 
4371 //_________________________________________________________________________
4372 Bool_t AliConvEventCuts::IsConversionPrimaryESD( AliMCEvent *mcEvent, Long_t eventpos, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ){
4373 
4374  if (eventpos < 0) return kFALSE;
4375  TParticle* particle = (TParticle *)mcEvent->Particle(eventpos);
4376  if (!particle) return kFALSE;
4377  if (TMath::Abs(particle->GetPdgCode()) == 11 ){
4378  if (particle->GetMother(0) != -1){
4379  TParticle* particleMother = (TParticle *)mcEvent->Particle(particle->GetMother(0));
4380  if (particleMother){
4381  if (TMath::Abs(particleMother->GetPdgCode()) == 22)
4382  particle = particleMother;
4383  }
4384  }
4385  }
4386  if (particle->GetMother(0) != -1){
4387  Double_t deltaX = particle->Vx() - prodVtxX;
4388  Double_t deltaY = particle->Vy() - prodVtxY;
4389  Double_t deltaZ = particle->Vz() - prodVtxZ;
4390 
4391  //Double_t realRadius2D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY);
4392  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
4393 
4394 
4395  Bool_t dalitzCand = kFALSE;
4396 
4397  TParticle* firstmother = (TParticle *)mcEvent->Particle(particle->GetMother(0));
4398  if (!firstmother) return kFALSE;
4399  Int_t pdgCodeFirstMother = firstmother->GetPdgCode();
4400  Bool_t intDecay = kFALSE;
4401  if ( pdgCodeFirstMother == 111 || pdgCodeFirstMother == 221 ) intDecay = kTRUE;
4402  if ( intDecay && TMath::Abs(particle->GetPdgCode()) == 11 ){
4403  dalitzCand = kTRUE;
4404 // cout << "dalitz candidate found" << endl;
4405  }
4406 
4407  Long_t source = particle->GetMother(0);
4408  Bool_t foundExcludedPart = kFALSE;
4409  Bool_t foundShower = kFALSE;
4410  Int_t pdgCodeMotherPrev = 0;
4411  Int_t pdgCodeMotherPPrevMother = 0;
4412  Int_t depth = 0;
4413  if (dalitzCand || realRadius3D < fSecProdBoundary ){
4414 // if (particle->GetPdgCode() == 22){
4415 // cout << endl << endl << "new particle: " << eventpos <<endl;
4416 // cout << particle->GetPdgCode() << "\t" << particle->R() << "\t" << realRadius2D << "\t" << realRadius3D << endl;
4417 // }
4418  while (depth < 20){
4419  TParticle* mother = (TParticle *)mcEvent->Particle(source);
4420  source = mother->GetMother(0);
4421 // if (particle->GetPdgCode() == 22)cout << "eventposition: "<< source << endl;
4422  Int_t pdgCodeMother = mother->GetPdgCode();
4423 // if (particle->GetPdgCode() == 22)cout << "Previous mothers: " << pdgCodeMother << "\t"<< pdgCodeMotherPrev<< "\t" << pdgCodeMotherPPrevMother << endl;
4424  if (pdgCodeMother == pdgCodeMotherPrev && pdgCodeMother == pdgCodeMotherPPrevMother) depth = 20;
4425  if (TMath::Abs(pdgCodeMother) == 11 && TMath::Abs(pdgCodeMotherPrev) == 22 && TMath::Abs(pdgCodeMotherPPrevMother) == 11 ){
4426  foundShower = kTRUE;
4427  depth =20;
4428  }
4429  if (TMath::Abs(pdgCodeMother) == 22 && TMath::Abs(pdgCodeMotherPrev) == 11 && TMath::Abs(pdgCodeMotherPPrevMother) == 22 ){
4430  foundShower = kTRUE;
4431  depth =20;
4432  }
4433 
4434  // particles to be excluded:
4435  // K0s - 310
4436  // K0l - 130
4437  // K+/- - 321
4438  // Lambda - 3122
4439  // Sigma0 - 3212
4440  // Sigma+/- - 3222, 3112
4441  // Cascades - 3322, 3312
4442  if (TMath::Abs(pdgCodeMother) == 310 || TMath::Abs(pdgCodeMother) == 130 || TMath::Abs(pdgCodeMother) == 321 ||
4443  TMath::Abs(pdgCodeMother) == 3122 || TMath::Abs(pdgCodeMother) == 3212 || TMath::Abs(pdgCodeMother) == 3222 ||
4444  TMath::Abs(pdgCodeMother) == 3112 || TMath::Abs(pdgCodeMother) == 3322 || TMath::Abs(pdgCodeMother) == 3312
4445  ) {
4446  foundExcludedPart = kTRUE;
4447  }
4448 // if (particle->GetPdgCode() == 22)cout << mother->GetPdgCode() << "\t" << source << "\t" << foundExcludedPart<< endl;
4449  pdgCodeMotherPPrevMother = pdgCodeMotherPrev;
4450  pdgCodeMotherPrev = pdgCodeMother;
4451  if (source == -1) depth = 20;
4452 
4453 // if (particle->GetPdgCode() == 22)cout << depth << endl;
4454  depth++;
4455  }
4456  }
4457  if (foundExcludedPart){
4458 // if (particle->GetPdgCode() == 22)cout << "This is definitely a secondary, manually excluded" << endl;
4459  return kFALSE;
4460  } else if (dalitzCand && realRadius3D < fSecProdBoundary ){
4461 // if (particle->GetPdgCode() == 22)cout << "This was a decay via a virtual photon" << endl;
4462  return kTRUE;
4463  } else if (foundShower){
4464 // if (particle->GetPdgCode() == 22)cout << "This is a shower" << endl;
4465  return kFALSE;
4466  } else if (realRadius3D >= fSecProdBoundary){
4467 // cout << "This is a secondary, to large production radius" << endl;
4468  return kFALSE;
4469  }
4470  }
4471 
4472  return kTRUE;
4473 }
4474 
4475 //_________________________________________________________________________
4476 Bool_t AliConvEventCuts::IsConversionPrimaryAOD(AliVEvent *event, AliAODMCParticle* AODMCParticle, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ){
4477 
4478  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4479  if (AODMCTrackArray == NULL) return kFALSE;
4480  AliAODMCParticle* currentParticle = AODMCParticle;
4481  if (TMath::Abs(currentParticle->GetPdgCode()) == 11 ){
4482  if (currentParticle->GetMother() != -1){
4483  AliAODMCParticle* particleMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(currentParticle->GetMother()));
4484  if (particleMother){
4485  if (TMath::Abs(particleMother->GetPdgCode()) == 22)
4486  currentParticle = particleMother;
4487  }
4488  }
4489  }
4490  if (currentParticle->GetMother() > -1){
4491  Double_t deltaX = currentParticle->Xv() - prodVtxX;
4492  Double_t deltaY = currentParticle->Yv() - prodVtxY;
4493  Double_t deltaZ = currentParticle->Zv() - prodVtxZ;
4494 
4495  //Double_t realRadius2D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY);
4496  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
4497 
4498  Bool_t dalitzCand = kFALSE;
4499 
4500  AliAODMCParticle* firstmother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(currentParticle->GetMother()));
4501  if (!firstmother) return kFALSE;
4502  Int_t pdgCodeFirstMother = firstmother->GetPdgCode();
4503  Bool_t intDecay = kFALSE;
4504  if ( pdgCodeFirstMother == 111 || pdgCodeFirstMother == 221 ) intDecay = kTRUE;
4505  if ( intDecay && TMath::Abs(currentParticle->GetPdgCode()) == 11 ){
4506  dalitzCand = kTRUE;
4507 // cout << "dalitz candidate found" << endl;
4508  }
4509 
4510  Long_t source = currentParticle->GetMother();
4511  Bool_t foundExcludedPart = kFALSE;
4512  Bool_t foundShower = kFALSE;
4513  Int_t pdgCodeMotherPrev = 0;
4514  Int_t pdgCodeMotherPPrevMother = 0;
4515  Int_t depth = 0;
4516  if (dalitzCand || realRadius3D < fSecProdBoundary ){
4517 // if (currentParticle->GetPdgCode() == 22){
4518 // cout << endl << endl << "new particle: " << eventpos <<endl;
4519 // cout << currentParticle->GetPdgCode() << "\t" << currentParticle->R() << "\t" << realRadius2D << "\t" << realRadius3D << endl;
4520 // }
4521  while (depth < 20){
4522  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(source));
4523  source = mother->GetMother();
4524 // if (currentParticle->GetPdgCode() == 22)cout << "eventposition: "<< source << endl;
4525  Int_t pdgCodeMother = mother->GetPdgCode();
4526 // if (currentParticle->GetPdgCode() == 22)cout << "Previous mothers: " << pdgCodeMother << "\t"<< pdgCodeMotherPrev<< "\t" << pdgCodeMotherPPrevMother << endl;
4527  if (pdgCodeMother == pdgCodeMotherPrev && pdgCodeMother == pdgCodeMotherPPrevMother) depth = 20;
4528  if (TMath::Abs(pdgCodeMother) == 11 && TMath::Abs(pdgCodeMotherPrev) == 22 && TMath::Abs(pdgCodeMotherPPrevMother) == 11 ){
4529  foundShower = kTRUE;
4530  depth =20;
4531  }
4532  if (TMath::Abs(pdgCodeMother) == 22 && TMath::Abs(pdgCodeMotherPrev) == 11 && TMath::Abs(pdgCodeMotherPPrevMother) == 22 ){
4533  foundShower = kTRUE;
4534  depth =20;
4535  }
4536 
4537  // particles to be excluded:
4538  // K0s - 310
4539  // K0l - 130
4540  // K+/- - 321
4541  // Lambda - 3122
4542  // Sigma0 - 3212
4543  // Sigma+/- - 3222, 3112
4544  // Cascades - 3322, 3312
4545  if (TMath::Abs(pdgCodeMother) == 310 || TMath::Abs(pdgCodeMother) == 130 || TMath::Abs(pdgCodeMother) == 321 ||
4546  TMath::Abs(pdgCodeMother) == 3122 || TMath::Abs(pdgCodeMother) == 3212 || TMath::Abs(pdgCodeMother) == 3222 ||
4547  TMath::Abs(pdgCodeMother) == 3112 || TMath::Abs(pdgCodeMother) == 3322 || TMath::Abs(pdgCodeMother) == 3312)
4548  {
4549  foundExcludedPart = kTRUE;
4550  }
4551 // if (currentParticle->GetPdgCode() == 22)cout << mother->GetPdgCode() << "\t" << source << "\t" << foundExcludedPart<< endl;
4552  pdgCodeMotherPPrevMother = pdgCodeMotherPrev;
4553  pdgCodeMotherPrev = pdgCodeMother;
4554  if (source == -1) depth = 20;
4555 
4556 // if (currentParticle->GetPdgCode() == 22)cout << depth << endl;
4557  depth++;
4558  }
4559  }
4560  if (foundExcludedPart){
4561 // if (currentParticle->GetPdgCode() == 22)cout << "This is definitely a secondary, manually excluded" << endl;
4562  return kFALSE;
4563  } else if (dalitzCand && realRadius3D < fSecProdBoundary ){
4564 // if (currentParticle->GetPdgCode() == 22)cout << "This was a decay via a virtual photon" << endl;
4565  return kTRUE;
4566  } else if (foundShower){
4567 // if (currentParticle->GetPdgCode() == 22)cout << "This is a shower" << endl;
4568  return kFALSE;
4569  } else if (realRadius3D >= fSecProdBoundary){
4570 // cout << "This is a secondary, too large production radius" << endl;
4571  return kFALSE;
4572  }
4573  }
4574 
4575  return kTRUE;
4576 }
4577 
4578 
4579 //________________________________________________________________________
4580 Int_t AliConvEventCuts::SecondaryClassificationPhoton( TParticle *particle, AliMCEvent* mcEvent, Bool_t isConversion ){
4581  if (particle != NULL && mcEvent != NULL){
4582  Int_t pdgSecondary = 0;
4583  if (!isConversion){
4584  //Bool_t hasMother = kFALSE;
4585  //Bool_t hasGrandMother = kFALSE;
4586  Long_t motherID = particle->GetMother(0);
4587  Long_t grandMotherID = -1;
4588  // is the photon a direct photons, without a mother?
4589  if (motherID > -1){
4590  //hasMother = kTRUE;
4591  grandMotherID = mcEvent->Particle(motherID)->GetMother(0);
4592  // is the meson a primary?
4593  if (grandMotherID > -1){
4594  //hasGrandMother = kTRUE;
4595  pdgSecondary = mcEvent->Particle(grandMotherID)->GetPdgCode();
4596  }
4597  }
4598  } else {
4599  //Bool_t hasMother = kFALSE;
4600  //Bool_t hasGrandMother = kFALSE;
4601  //Bool_t hasGreatGrandMother = kFALSE;
4602  Long_t motherID = particle->GetMother(0);
4603  Long_t grandMotherID = -1;
4604  Long_t greatGrandMotherID = -1;
4605  // is the electron a direct electron, without a mother?
4606  if (motherID > -1){
4607  //hasMother = kTRUE;
4608  grandMotherID = mcEvent->Particle(motherID)->GetMother(0);
4609  // is the photon a direct photons, without a mother?
4610  if (grandMotherID > -1){
4611  //hasGrandMother = kTRUE;
4612  greatGrandMotherID = mcEvent->Particle(grandMotherID)->GetMother(0);
4613  // is the meson a primary?
4614  if (greatGrandMotherID > -1){
4615  //hasGreatGrandMother = kTRUE;
4616  pdgSecondary = mcEvent->Particle(greatGrandMotherID)->GetPdgCode();
4617  }
4618  }
4619  }
4620  }
4621  // is the secondary photon from a lambda
4622  if (TMath::Abs(pdgSecondary) == 3122 )
4623  return 3;
4624  // is the secondary photon from a K0s
4625  else if ( TMath::Abs(pdgSecondary) == 310 )
4626  return 2;
4627  // is the secondary photon from a K0l
4628  else if ( TMath::Abs(pdgSecondary) == 130 )
4629  return 5;
4630  // is the secondary photon from a eta
4631  else if ( TMath::Abs(pdgSecondary) == 221 )
4632  return 4;
4633  // is the secondary photon from something else
4634  else if ( TMath::Abs(pdgSecondary) != 0 )
4635  return 1;
4636 
4637  }
4638 
4639  return 0;
4640 }
4641 
4642 //________________________________________________________________________
4643 Int_t AliConvEventCuts::SecondaryClassificationPhotonAOD( AliAODMCParticle *particle, TClonesArray *aodmcArray, Bool_t isConversion ){
4644  if (particle != NULL && aodmcArray != NULL){
4645  Int_t pdgSecondary = 0;
4646  if (!isConversion){
4647  //Bool_t hasMother = kFALSE;
4648  //Bool_t hasGrandMother = kFALSE;
4649  Long_t motherID = particle->GetMother();
4650  Long_t grandMotherID = -1;
4651  // is the photon a direct photons, without a mother?
4652  if (motherID > -1){
4653  //hasMother = kTRUE;
4654  grandMotherID = ((AliAODMCParticle*)aodmcArray->At(motherID))->GetMother();
4655  // is the meson a primary?
4656  if (grandMotherID > -1){
4657  //hasGrandMother = kTRUE;
4658  pdgSecondary = ((AliAODMCParticle*)aodmcArray->At(grandMotherID))->GetPdgCode();
4659  }
4660  }
4661  } else {
4662  //Bool_t hasMother = kFALSE;
4663  //Bool_t hasGrandMother = kFALSE;
4664  //Bool_t hasGreatGrandMother = kFALSE;
4665  Long_t motherID = particle->GetMother();
4666  Long_t grandMotherID = -1;
4667  Long_t greatGrandMotherID = -1;
4668  // is the electron a direct electron, without a mother?
4669  if (motherID > -1){
4670  //hasMother = kTRUE;
4671  grandMotherID = ((AliAODMCParticle*)aodmcArray->At(motherID))->GetMother();
4672  // is the photon a direct photons, without a mother?
4673  if (grandMotherID > -1){
4674  //hasGrandMother = kTRUE;
4675  greatGrandMotherID = ((AliAODMCParticle*)aodmcArray->At(grandMotherID))->GetMother();
4676  // is the meson a primary?
4677  if (greatGrandMotherID > -1){
4678  //hasGreatGrandMother = kTRUE;
4679  pdgSecondary = ((AliAODMCParticle*)aodmcArray->At(greatGrandMotherID))->GetPdgCode();
4680  }
4681  }
4682  }
4683  }
4684  // is the secondary photon from a lambda
4685  if (TMath::Abs(pdgSecondary) == 3122 )
4686  return 3;
4687  // is the secondary photon from a K0s
4688  else if ( TMath::Abs(pdgSecondary) == 310 )
4689  return 2;
4690  // is the secondary photon from a K0l
4691  else if ( TMath::Abs(pdgSecondary) == 130 )
4692  return 5;
4693  // is the secondary photon from a eta
4694  else if ( TMath::Abs(pdgSecondary) == 221 )
4695  return 4;
4696  // is the secondary photon from something else
4697  else if ( TMath::Abs(pdgSecondary) != 0 )
4698  return 1;
4699 
4700  }
4701 
4702  return 0;
4703 }
4704 
4706 
4707  if (periodName.CompareTo("") == 0){
4708  periodName = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPeriodName();
4709  }
4710  if (periodName.CompareTo("") == 0) {
4712  fEnergyEnum = kUnset;
4713  AliError("No correct period could be set, periodName string empty");
4714  return;
4715  }
4716 
4717  // Data
4718  if (periodName.CompareTo("LHC10b") == 0 || periodName.CompareTo("LHC10c") == 0 || periodName.CompareTo("LHC10d") == 0 || periodName.CompareTo("LHC10e") == 0 ||
4719  periodName.CompareTo("LHC10f") == 0 || periodName.CompareTo("LHC10g") == 0 || periodName.CompareTo("LHC10bg") == 0
4720  ){
4722  fEnergyEnum = k7TeV;
4723  } else if (periodName.CompareTo("LHC10h") == 0) {
4724  fPeriodEnum = kLHC10h;
4726  } else if (periodName.CompareTo("LHC11a") == 0) {
4727  fPeriodEnum = kLHC11a;
4729  } else if (periodName.CompareTo("LHC11b") == 0) {
4730  fPeriodEnum = kLHC11b;
4731  fEnergyEnum = k7TeV;
4732  } else if (periodName.CompareTo("LHC11c") == 0 || periodName.CompareTo("LHC11d") == 0 || periodName.CompareTo("LHC11e") == 0 || periodName.CompareTo("LHC11f") == 0 ||
4733  periodName.CompareTo("LHC11g") == 0
4734  ) {
4736  fEnergyEnum = k7TeV;
4737  } else if (periodName.CompareTo("LHC11h") == 0) {
4738  fPeriodEnum = kLHC11h;
4740  } else if (periodName.CompareTo("LHC12a") == 0 || periodName.CompareTo("LHC12b") == 0 || periodName.CompareTo("LHC12c") == 0 || periodName.CompareTo("LHC12d") == 0 ||
4741  periodName.CompareTo("LHC12e") == 0 || periodName.CompareTo("LHC12f") == 0 || periodName.CompareTo("LHC12g") == 0 || periodName.CompareTo("LHC12h") == 0 ||
4742  periodName.CompareTo("LHC12i") == 0 || periodName.CompareTo("LHC12ai") == 0
4743  ) {
4744  fPeriodEnum = kLHC12;
4745  fEnergyEnum = k8TeV;
4746  } else if (periodName.CompareTo("LHC13b") == 0 || periodName.CompareTo("LHC13c") == 0 || periodName.CompareTo("LHC13bc") == 0){
4749  } else if (periodName.CompareTo("LHC13d") == 0 || periodName.CompareTo("LHC13e") == 0 || periodName.CompareTo("LHC13de") == 0){
4752  } else if (periodName.CompareTo("LHC13f") == 0 ){
4753  fPeriodEnum = kLHC13f;
4755  } else if (periodName.CompareTo("LHC13g") == 0 ){
4756  fPeriodEnum = kLHC13g;
4758  } else if ( periodName.CompareTo("LHC15f") == 0 || periodName.CompareTo("LHC15g") == 0 || periodName.CompareTo("LHC15h") == 0 || periodName.CompareTo("LHC15i") == 0 ||
4759  periodName.CompareTo("LHC15j") == 0 || periodName.CompareTo("LHC15k") == 0 || periodName.CompareTo("LHC15l") == 0 || periodName.CompareTo("LHC15m") == 0 ||
4760  periodName.CompareTo("LHC15fm") == 0
4761  ) {
4763  fEnergyEnum = k13TeV;
4764  } else if (periodName.CompareTo("LHC15n") == 0 ){
4765  fPeriodEnum = kLHC15n;
4766  fEnergyEnum = k5TeV;
4767  } else if (periodName.CompareTo("LHC15o") == 0 ){
4768  fPeriodEnum = kLHC15o;
4770  } else if ( periodName.CompareTo("LHC16dp") == 0 || periodName.CompareTo("LHC16d") == 0 || periodName.CompareTo("LHC16e") == 0 || periodName.CompareTo("LHC16g") == 0 ||
4771  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 ||
4772  periodName.CompareTo("LHC16p") == 0){
4774  fEnergyEnum = k13TeV;
4775  } else if (periodName.CompareTo("LHC16f") == 0 ){
4778  } else if (periodName.CompareTo("LHC16qt") == 0 || periodName.CompareTo("LHC16q") == 0 || periodName.CompareTo("LHC16t") == 0 ){
4781  } else if (periodName.CompareTo("LHC16r") == 0 ){
4782  fPeriodEnum = kLHC16r;
4784  } else if (periodName.CompareTo("LHC16s") == 0 ){
4785  fPeriodEnum = kLHC16s;
4787  } else if (periodName.CompareTo("LHC17cr") == 0 || periodName.CompareTo("LHC17c") == 0 || periodName.CompareTo("LHC17d") == 0 || periodName.CompareTo("LHC17e") == 0 ||
4788  periodName.CompareTo("LHC17f") == 0 || periodName.CompareTo("LHC17h") == 0 || periodName.CompareTo("LHC17i") == 0 || periodName.CompareTo("LHC17j") == 0 ||
4789  periodName.CompareTo("LHC17k") == 0 || periodName.CompareTo("LHC17l") == 0 || periodName.CompareTo("LHC17m") == 0 || periodName.CompareTo("LHC17o") == 0 ||
4790  periodName.CompareTo("LHC17r") == 0 ){
4792  fEnergyEnum = k13TeV;
4793  } else if ( periodName.CompareTo("LHC17g") == 0 ){
4796  } else if ( periodName.CompareTo("LHC17n") == 0 ){
4797  fPeriodEnum = kLHC17n;
4799  } else if ( periodName.CompareTo("LHC17pq") == 0 || periodName.CompareTo("LHC17p") == 0 || periodName.CompareTo("LHC17q") == 0 ){
4801  fEnergyEnum = k5TeV;
4802 
4803  // LHC10x anchored MCs
4804  } else if (periodName.CompareTo("LHC10d1") == 0){
4806  fEnergyEnum = k7TeV;
4807  } else if (periodName.CompareTo("LHC10d2") == 0){
4809  fEnergyEnum = k7TeV;
4810  } else if (periodName.CompareTo("LHC10d4a") == 0){
4812  fEnergyEnum = k7TeV;
4813  } else if (periodName.CompareTo("LHC10d4") == 0){
4815  fEnergyEnum = k7TeV;
4816  } else if (periodName.CompareTo("LHC10e12") == 0){
4818  fEnergyEnum = k900GeV;
4819  } else if (periodName.CompareTo("LHC10e13") == 0){
4821  fEnergyEnum = k900GeV;
4822  } else if (periodName.CompareTo("LHC10e20") == 0){
4824  fEnergyEnum = k7TeV;
4825  } else if (periodName.CompareTo("LHC10e21") == 0){
4827  fEnergyEnum = k7TeV;
4828  } else if (periodName.CompareTo("LHC10f6a") == 0){
4830  fEnergyEnum = k7TeV;
4831  } else if (periodName.CompareTo("LHC10f6") == 0){
4833  fEnergyEnum = k7TeV;
4834  } else if (periodName.Contains("LHC14j4")){
4836  fEnergyEnum = k7TeV;
4837  } else if (periodName.CompareTo("LHC13d2") == 0){
4840  } else if (periodName.CompareTo("LHC13d2b") == 0){
4843  } else if (periodName.CompareTo("LHC12a11a") == 0){
4846  } else if (periodName.CompareTo("LHC12a11b") == 0){
4849  } else if (periodName.CompareTo("LHC12a11c") == 0){
4852  } else if (periodName.CompareTo("LHC12a11d") == 0){
4855  } else if (periodName.CompareTo("LHC12a11e") == 0){
4858  } else if (periodName.CompareTo("LHC12a11f") == 0){
4861  // LHC11x anchored MCs
4862  } else if (periodName.CompareTo("LHC12a15c") == 0){
4865  } else if (periodName.Contains("LHC12f1a") ){
4868  } else if (periodName.Contains("LHC12f1b") ){
4871  } else if (periodName.Contains("LHC12i3") ){
4874  } else if (periodName.CompareTo("LHC15g1a") == 0){
4877  } else if (periodName.CompareTo("LHC15g1b") == 0){
4880  } else if (periodName.CompareTo("LHC13e4") == 0){
4882  fEnergyEnum = k7TeV;
4883  } else if (periodName.CompareTo("LHC13e5") == 0){
4885  fEnergyEnum = k7TeV;
4886  } else if (periodName.CompareTo("LHC14k1a") == 0){
4888  fEnergyEnum = k7TeV;
4889  } else if (periodName.CompareTo("LHC14k1b") == 0){
4891  fEnergyEnum = k7TeV;
4892  } else if (periodName.CompareTo("LHC12a15f") == 0){
4894  fEnergyEnum = k7TeV;
4895  } else if (periodName.CompareTo("LHC12a15g") == 0){
4897  fEnergyEnum = k7TeV;
4898  } else if (periodName.CompareTo("LHC12f2a") == 0){
4900  fEnergyEnum = k7TeV;
4901  } else if (periodName.CompareTo("LHC14a1a") == 0){
4904  } else if (periodName.CompareTo("LHC14a1b") == 0){
4907  } else if (periodName.CompareTo("LHC14a1c") == 0){
4910  // LHC12x anchored MCs
4911  } else if (periodName.CompareTo("LHC14e2a") == 0){
4913  fEnergyEnum = k8TeV;
4914  } else if (periodName.CompareTo("LHC14e2b") == 0){
4916  fEnergyEnum = k8TeV;
4917  } else if (periodName.CompareTo("LHC14e2c") == 0){
4919  fEnergyEnum = k8TeV;
4920  } else if (periodName.Contains("LHC15h1")){
4922  fEnergyEnum = k8TeV;
4923  } else if (periodName.Contains("LHC15h2")){
4925  fEnergyEnum = k8TeV;
4926  } else if (periodName.CompareTo("LHC16c2") == 0){
4928  fEnergyEnum = k8TeV;
4929  } else if (periodName.CompareTo("LHC16c2_plus") == 0){
4931  fEnergyEnum = k8TeV;
4932  // LHC13x anchored MCs
4933  } else if (periodName.Contains("LHC13b2_efix")){
4936  } else if (periodName.CompareTo("LHC13e7") == 0){
4937  fPeriodEnum =