AliPhysics  3aa38c9 (3aa38c9)
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  }
1026  if (fSpecialTrigger == 0){
1027  printf("\t only events triggered by kINT7 will be analysed \n");
1028  } else if (fSpecialTrigger > 1){
1029  printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
1030  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps\n\n");
1031  }
1032  }
1033  if (fEnableVertexCut) printf("\t Vertex cut with |Z_{vtx}| <%2.2f \n",fMaxVertexZ);
1034  else printf("\t No vertex cut \n");
1035 
1036  if (fRemovePileUp ==1 ) {
1037  printf("\t Doing pile up removal \n");
1038  if (fDoPileUpRejectV0MTPCout ==1 ){
1039  printf("\t Doing extra pile up removal V0M vs TPCout \n");
1040  }
1041  }
1042 
1043  printf("MC event cuts: \n");
1044  if (fRejectExtraSignals == 0) printf("\t no rejection was applied \n");
1045  else if (fRejectExtraSignals == 1) printf("\t only MB header will be inspected \n");
1046  else if (fRejectExtraSignals > 1) printf("\t special header have been selected \n");
1047  printf("\t maximum factor between jet and pt hard = %2.2f \n", fMaxFacPtHard);
1048 }
1049 
1052 { // Set Cut
1053  switch(isHeavyIon){
1054  case 0: // pp
1055  fIsHeavyIon=0;
1056  break;
1057  case 1: // V0M PbPb & XeXe
1058  // steps of 10%
1059  fIsHeavyIon=1;
1061  break;
1062  case 2: // CL1 PbPb & XeXe
1063  // steps of 10%
1064  fIsHeavyIon=1;
1066  break;
1067  case 3: // V0M PbPb & XeXe
1068  // steps of 5%
1069  // 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%
1070  fIsHeavyIon=1;
1073  break;
1074  case 4: // V0M PbPb & XeXe & primary track mult for MC different track array
1075  // steps of 10%
1076  fIsHeavyIon=1;
1079  break;
1080  case 5: // V0M PbPb & XeXe & primary track mult for MC
1081  // steps of 10%
1082  fIsHeavyIon=1;
1085  break;
1086  case 6: // V0M PbPb & XeXe & primary track mult for MC
1087  // steps of 5%
1088  // 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%
1089  fIsHeavyIon=1;
1092  break;
1093  case 7: // V0M PbPb & XeXe & primary track mult for MC different track array
1094  // steps of 5%
1095  // 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%
1096  fIsHeavyIon=1;
1099  break;
1100  case 8: // pPb V0A
1101  // steps of 10%
1102  fIsHeavyIon=2;
1104  break;
1105  case 9: // pPb CL1
1106  // steps of 10%
1107  fIsHeavyIon=2;
1109  break;
1110 
1111  default:
1112  AliError(Form("SetHeavyIon not defined %d",isHeavyIon));
1113  return kFALSE;
1114  }
1115  return kTRUE;
1116 }
1117 
1118 //___________________________________________________________________
1120 {
1121  // Set Cut
1122  if(minCentrality<0||minCentrality>20){
1123  AliError(Form("minCentrality not defined %d",minCentrality));
1124  return kFALSE;
1125  }
1126 
1127  fCentralityMin=minCentrality;
1128  return kTRUE;
1129 }
1130 
1131 //___________________________________________________________________
1133 {
1134  // Set Cut
1135  if(maxCentrality<0||maxCentrality>20){
1136  AliError(Form("maxCentrality not defined %d",maxCentrality));
1137  return kFALSE;
1138  }
1139  fCentralityMax=maxCentrality;
1140  return kTRUE;
1141 }
1142 
1145 {
1146  // Set Cut
1147  switch(selectSpecialTrigger){
1148  case 0:
1149  fSpecialTrigger=0; // V0OR
1150  break;
1151  case 1:
1152  fSpecialTrigger=1; // V0AND
1153  break;
1154 // case 2:
1155 // fSpecialTrigger=2; //
1156 // break;
1157  case 3:
1158  fSpecialTrigger=3; //specific centrality trigger selection
1159  fSpecialTriggerName="AliVEvent::kCentral/kSemiCentral/kMB";
1160  break;
1161  case 4:
1162  fSpecialTrigger=4; // trigger alias kTRD
1163  fOfflineTriggerMask=AliVEvent::kTRD;
1164  fTriggerSelectedManually = kTRUE;
1165  fSpecialTriggerName="AliVEvent::kTRD";
1166  break;
1167  case 5:
1168  fSpecialTrigger=5; // trigger alias kEMC
1169  fOfflineTriggerMask=AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMC1 ;
1170  fTriggerSelectedManually = kTRUE;
1172  SETBIT(fTriggersEMCALSelected, kL0);
1173  fSpecialTriggerName="AliVEvent::kEMC7/kEMC8/kEMC1";
1174  break;
1175  case 6:
1176  fSpecialTrigger=6; // trigger alias kPHI
1177  fOfflineTriggerMask=AliVEvent::kPHI7 | AliVEvent::kPHI1 | AliVEvent::kPHI8 | AliVEvent::kPHOSPb;
1178  fTriggerSelectedManually = kTRUE;
1179  fSpecialTriggerName="AliVEvent::kPHI7/kPHI1/kPHI8/kPHOSPb";
1180  break;
1181  case 7:
1182  fSpecialTrigger=7; // trigger alias kHighMult
1183  fOfflineTriggerMask=AliVEvent::kHighMult;
1184  fTriggerSelectedManually = kTRUE;
1185  fSpecialTriggerName="AliVEvent::kHighMult";
1186  break;
1187  case 8:
1188  fSpecialTrigger=8; // trigger alias kEMCEGA
1189  fOfflineTriggerMask=AliVEvent::kEMCEGA;
1190  fTriggerSelectedManually = kTRUE;
1192  SETBIT(fTriggersEMCALSelected, kG2);
1193  fSpecialTriggerName="AliVEvent::kEMCEGA";
1194  break;
1195  case 9:
1196  fSpecialTrigger=9; // trigger alias kEMCEJE
1197  fOfflineTriggerMask=AliVEvent::kEMCEJE;
1198  fTriggerSelectedManually = kTRUE;
1200  SETBIT(fTriggersEMCALSelected, kJ2);
1201  fSpecialTriggerName="AliVEvent::kEMCEJE";
1202  break;
1203  default:
1204  AliError("Warning: Special Trigger Not known");
1205  return 0;
1206  }
1207  return 1;
1208 }
1209 
1212 {
1213  // Set Cut
1214  if (fSpecialTrigger == 0){ //OR
1215  switch(selectSpecialSubTriggerClass){
1216  case 0://with VZERO
1217  fSpecialTrigger=0;
1219 // AliInfo("Info: Nothing to be done");
1220  break;
1221  case 3: //V0OR with SDD requested (will only work with LHC11a dataset)
1223 // cout << "V0OR with SDD requested" << endl;
1224  break;
1225  default:
1226  AliError("Warning: Special Subtrigger Class Not known");
1227  return 0;
1228  }
1229  } else if (fSpecialTrigger == 1){ //AND with different detectors
1230  switch(selectSpecialSubTriggerClass){
1231  case 0: //with VZERO general implementation of V0AND (periods LHC11c onwards)
1232  fSpecialTrigger=0;
1234  fOfflineTriggerMask=AliVEvent::kINT7;
1235  fTriggerSelectedManually = kTRUE;
1236  fSpecialTriggerName="AliVEvent::kINT7";
1237  break;
1238  case 1: //with TZERO
1239  fSpecialTrigger=0;
1241  fOfflineTriggerMask=AliVEvent::kINT8;
1242  fTriggerSelectedManually = kTRUE;
1243  fSpecialTriggerName="AliVEvent::kINT8";
1244  break;
1245  case 2: //with VZERO (will only work with LHC11a dataset)
1246  fSpecialTrigger=1;
1248 // AliInfo("Info: Nothing to be done");
1249  break;
1250  case 3: //V0AND with SDD requested (will only work with LHC11a dataset)
1251  fSpecialTrigger=1;
1253  break;
1254  default:
1255  AliError("Warning: Special Subtrigger Class Not known");
1256  return 0;
1257  }
1258  } else if (fSpecialTrigger == 3){ // Selecting kCentral and kSemiCentral from trigger classes, not aliases
1259  switch(selectSpecialSubTriggerClass){
1260  case 0: // all together
1263 // AliInfo("Info: Nothing to be done");
1264  break;
1265  case 1: // kCentral - no vertex restriction
1268  fSpecialSubTriggerName="CVHN";
1269 // cout << "kCentralOpen" << endl;
1270  break;
1271  case 2: // kCentral - T00 +- 10 cm
1274  fSpecialSubTriggerName="CCENT";
1275 // cout << "kCentralVertex" << endl;
1276  break;
1277  case 3: // kCentral - both
1280  fSpecialSubTriggerName="CVHN|CCENT|CSEMI|CVLN";
1281 // cout << "kCentral both" << endl;
1282  break;
1283  case 4: // kSemiCentral - no vertex restriction
1286  fSpecialSubTriggerName="CVLN";
1287 // cout << "kSemiCentralOpen" << endl;
1288  break;
1289  case 5: // kSemiCentral - T00 +- 10 cm
1292  fSpecialSubTriggerName="CSEMI";
1293 // cout << "kSemiCentralVertex" << endl;
1294  break;
1295  case 6: // kSemiCentral - both
1298  fSpecialSubTriggerName="CSEMI%CVLN";
1299 // cout << "kSemiCentral both" << endl;
1300  break;
1301  case 7: // kMB
1304  fSpecialSubTriggerName="CPBI1_|CPBI1-";
1305 // cout << "kMB 1" << endl;
1306  break;
1307  case 8: // kMB
1310  fSpecialSubTriggerName="CPBI2_|CPBI2-";
1311 // cout << "kMB 2" << endl;
1312  break;
1313  case 9: // kMB
1316  fSpecialSubTriggerName="CPBI2_@CPBI2-@CPBI2_@CPBI2-";
1317 // cout << "kMB both" << endl;
1318  break;
1319  default:
1320  AliError("Warning: Special Subtrigger Class Not known");
1321  return 0;
1322  }
1323  } else if (fSpecialTrigger == 4){ // Subdivision of TRD trigger classes
1324  switch(selectSpecialSubTriggerClass){
1325  case 0: // all together
1328 // AliInfo("Info: Nothing to be done");
1329  break;
1330  case 1: // 7WUHSH - V0AND with single electron in TRD & EMCAL
1333  fSpecialSubTriggerName="7WUHEE";
1334  break;
1335  case 2: // 8WUHSH - T0AND with single electron in TRD & EMCAL
1338  fSpecialSubTriggerName="8WUHEE";
1339  break;
1340  case 3: // 7WUHSE - V0AND with single high pt electron in TRD
1343  fSpecialSubTriggerName="7WUHSE";
1344  break;
1345  case 4: // 8WUHSE - T0AND with single high pt electron in TRD
1348  fSpecialSubTriggerName="8WUHSE";
1349  break;
1350  case 5: // 7WUHJE - V0AND with jet in TRD
1353  fSpecialSubTriggerName="7WUHJT";
1354  break;
1355  case 6: // 8WUHJE - T0AND with jet in TRD
1358  fSpecialSubTriggerName="8WUHJT";
1359  break;
1360  case 7: // 7WUHQU - V0AND with dielectron pair in TRD
1363  fSpecialSubTriggerName="7WUHQU";
1364  break;
1365  case 8: // 8WUHQU - T0AND with dielectron pair in TRD
1368  fSpecialSubTriggerName="8WUHQU";
1369  break;
1370  default:
1371  AliError("Warning: Special Subtrigger Class Not known");
1372  return 0;
1373  }
1374  } else if (fSpecialTrigger == 5){ // Subdivision of kEMC trigger classes
1375  switch(selectSpecialSubTriggerClass){
1376  case 0: // all together
1379 // AliInfo("Info: Nothing to be done");
1380  break;
1381  case 1: // CEMC1 - V0OR and EMCAL fired
1382  fOfflineTriggerMask=AliVEvent::kEMC1;
1383  fSpecialTriggerName="AliVEvent::kEMC1";
1386  fSpecialSubTriggerName="CEMC1";
1387  break;
1388  case 2: // CEMC7 - V0AND and EMCAL fired
1390  fOfflineTriggerMask=AliVEvent::kEMC7;
1391  fSpecialTriggerName="AliVEvent::kEMC7";
1393  fSpecialSubTriggerName="CEMC7";
1394  break;
1395  case 3: // CEMC8 - T0OR and EMCAL fired
1396  fOfflineTriggerMask=AliVEvent::kEMC8;
1397  fSpecialTriggerName="AliVEvent::kEMC8";
1400  fSpecialSubTriggerName="CEMC8";
1401  break;
1402  case 4: // CDMC1 - V0OR and DCAL fired
1403  fOfflineTriggerMask=AliVEvent::kEMC1;
1404  fSpecialTriggerName="AliVEvent::kEMC1";
1407  fSpecialSubTriggerName="CDMC1";
1408  break;
1409  case 5: // CDMC7 - V0AND and DCAL fired
1411  fOfflineTriggerMask=AliVEvent::kEMC7;
1412  fSpecialTriggerName="AliVEvent::kEMC7";
1414  fSpecialSubTriggerName="CDMC7";
1415  break;
1416  case 6: // CDMC8 - T0OR and DCAL fired
1417  fOfflineTriggerMask=AliVEvent::kEMC8;
1418  fSpecialTriggerName="AliVEvent::kEMC8";
1421  fSpecialSubTriggerName="CDMC8";
1422  break;
1423  default:
1424  AliError("Warning: Special Subtrigger Class Not known");
1425  return 0;
1426  }
1427  }else if (fSpecialTrigger == 6){ // Subdivision of kPHI trigger classes
1428  switch(selectSpecialSubTriggerClass){
1429  case 0: // all together
1432 // AliInfo("Info: Nothing to be done");
1433  break;
1434  case 1: // CEMC1 - V0OR and EMCAL fired
1435  fOfflineTriggerMask=AliVEvent::kPHI1;
1436  fSpecialTriggerName="AliVEvent::kPHI1";
1439  fSpecialSubTriggerName="CPHI1";
1440  break;
1441  case 2: // CEMC7 - V0AND and EMCAL fired
1443  fOfflineTriggerMask=AliVEvent::kPHI7;
1444  fSpecialTriggerName="AliVEvent::kPHI7";
1446  fSpecialSubTriggerName="CPHI7";
1447  break;
1448  case 3: // CEMC8 - T0OR and EMCAL fired
1449  fOfflineTriggerMask=AliVEvent::kPHI8;
1450  fSpecialTriggerName="AliVEvent::kPHI8";
1453  fSpecialSubTriggerName="CPHI8";
1454  break;
1455  default:
1456  AliError("Warning: Special Subtrigger Class Not known");
1457  return 0;
1458  }
1459  } else if (fSpecialTrigger == 7){ // Subdivision of kHighMult trigger classes
1460  switch(selectSpecialSubTriggerClass){
1461  case 0: // all together
1464 // AliInfo("Info: Nothing to be done");
1465  break;
1466  case 1: // CSHM1 - V0OR and high mult fired
1469  fSpecialSubTriggerName="CSHM1";
1470  break;
1471  case 2: // CSHM7 - V0AND and high mult fired
1474  fSpecialSubTriggerName="CSHM7";
1475  break;
1476  case 3: // CSHM8 - T0OR and high mult fired
1479  fSpecialSubTriggerName="CSHM8";
1480  break;
1481  case 4: // V0 high mult trigger
1483  fOfflineTriggerMask=AliVEvent::kAny;
1484  fSpecialTriggerName="V0Mult";
1486  fSpecialSubTriggerName="CVHMV0M-B-";
1487  break;
1488  case 5: // SPD high mult trigger
1490  fOfflineTriggerMask=AliVEvent::kAny;
1491  fSpecialTriggerName="SPMult";
1493  fSpecialSubTriggerName="CVHMSH2-B-";
1494  break;
1495  case 6: // V0 high mult trigger with pileup condition on
1497  fOfflineTriggerMask=AliVEvent::kAny;
1498  fSpecialTriggerName="V0Mult";
1500  fSpecialSubTriggerName="CVHMV0M-B-SPD2";
1501  break;
1502 
1503  default:
1504  AliError("Warning: Special Subtrigger Class Not known");
1505  return 0;
1506  }
1507  }else if (fSpecialTrigger == 8){ // Subdivision of kEMCEGA trigger classes
1508  switch(selectSpecialSubTriggerClass){
1509  case 0: // all together
1512 // AliInfo("Info: Nothing to be done");
1513  break;
1514  case 1: // 7EGA - CINT7 EGA
1517  fSpecialSubTriggerName="7EGA";
1519  SETBIT(fTriggersEMCALSelected, kG2);
1520  break;
1521  case 2: // 8EGA - CINT8 EGA
1524  fSpecialSubTriggerName="8EGA";
1526  SETBIT(fTriggersEMCALSelected, kG2);
1527  break;
1528  case 3: // 7EG1 - CINT7 EG1
1531  fSpecialSubTriggerName="7EG1";
1533  SETBIT(fTriggersEMCALSelected, kG1);
1534  break;
1535  case 4: // 8EG1 - CINT8 EG1
1538  fSpecialSubTriggerName="8EG1";
1540  SETBIT(fTriggersEMCALSelected, kG1);
1541  break;
1542  case 5: // 7EG2 - CINT7 EG2
1545  fSpecialSubTriggerName="7EG2";
1547  SETBIT(fTriggersEMCALSelected, kG2);
1548  break;
1549  case 6: // 8EG2 - CINT8 EG2
1552  fSpecialSubTriggerName="8EG2";
1554  SETBIT(fTriggersEMCALSelected, kG2);
1555  break;
1556  case 7: // 7DGA - CINT7 DGA
1559  fSpecialSubTriggerName="7DGA";
1561  SETBIT(fTriggersEMCALSelected, kG2);
1562  break;
1563  case 8: // 8DGA - CINT8 DGA
1566  fSpecialSubTriggerName="8DGA";
1568  SETBIT(fTriggersEMCALSelected, kG2);
1569  break;
1570  case 9: // 7DG1 - CINT7 DG1
1573  fSpecialSubTriggerName="7DG1";
1575  SETBIT(fTriggersEMCALSelected, kG1);
1576  break;
1577  case 10: // 8DG1 - CINT8 DG1
1580  fSpecialSubTriggerName="8DG1";
1582  SETBIT(fTriggersEMCALSelected, kG1);
1583  break;
1584  case 11: // 7DG2 - CINT7 DG2
1587  fSpecialSubTriggerName="7DG2";
1589  SETBIT(fTriggersEMCALSelected, kG2);
1590  break;
1591  case 12: // 8DG2 - CINT8 DG2
1594  fSpecialSubTriggerName="8DG2";
1596  SETBIT(fTriggersEMCALSelected, kG2);
1597  break;
1598 
1599  default:
1600  AliError("Warning: Special Subtrigger Class Not known");
1601  return 0;
1602  }
1603  } else if (fSpecialTrigger == 9){ // Subdivision of kEMCEGA trigger classes
1604  switch(selectSpecialSubTriggerClass){
1605  case 0: // all together
1608 // AliInfo("Info: Nothing to be done");
1609  break;
1610  case 1: // 7EJE - CINT7 EJE
1613  fSpecialSubTriggerName="7EJE";
1615  SETBIT(fTriggersEMCALSelected, kJ2);
1616  break;
1617  case 2: // 8EJE - CINT8 EJE
1620  fSpecialSubTriggerName="8EJE";
1622  SETBIT(fTriggersEMCALSelected, kJ2);
1623  break;
1624  case 3: // 7EJ1 - CINT7 EJ1
1627  fSpecialSubTriggerName="7EJ1";
1629  SETBIT(fTriggersEMCALSelected, kJ1);
1630  break;
1631  case 4: // 8EJ1 - CINT8 EJ1
1634  fSpecialSubTriggerName="8EJ1";
1636  SETBIT(fTriggersEMCALSelected, kJ1);
1637  break;
1638  case 5: // 7EJ2 - CINT7 EJ2
1641  fSpecialSubTriggerName="7EJ2";
1643  SETBIT(fTriggersEMCALSelected, kJ2);
1644  break;
1645  case 6: // 8EJ2 - CINT8 EJ2
1648  fSpecialSubTriggerName="8EJ2";
1650  SETBIT(fTriggersEMCALSelected, kJ2);
1651  break;
1652  case 7: // 7DJ1 - CINT7 DJ1
1655  fSpecialSubTriggerName="7DJ1";
1657  SETBIT(fTriggersEMCALSelected, kJ1);
1658  break;
1659  case 8: // 8DJ1 - CINT8 DJ1
1662  fSpecialSubTriggerName="8DJ1";
1664  SETBIT(fTriggersEMCALSelected, kJ1);
1665  break;
1666  case 9: // 7DJ2 - CINT7 DJ2
1669  fSpecialSubTriggerName="7DJ2";
1671  SETBIT(fTriggersEMCALSelected, kJ2);
1672  break;
1673  case 10: // 8DJ2 - CINT8 DJ2
1676  fSpecialSubTriggerName="8DJ2";
1678  SETBIT(fTriggersEMCALSelected, kJ2);
1679  break;
1680 
1681  default:
1682  AliError("Warning: Special Subtrigger Class Not known");
1683  return 0;
1684  }
1685  }
1686  return 1;
1687 }
1688 
1689 //________________________________________________________________________
1691 {
1692  // Set Cut
1693  fMultiplicityMethod=multiplicityMethod;
1694 
1695  // 0 Photon Multiplicity
1696  // 1 TPC Track multiplicity
1697  // 2 V0 Mult
1698  // 3 SPD Mult
1699 
1700  return kTRUE;
1701 }
1702 
1703 //________________________________________________________________________
1705 {// Set Cut
1706  switch(removePileUp){
1707  case 0:
1708  fRemovePileUp = kFALSE;
1709  break;
1710  case 1:
1711  fRemovePileUp = kTRUE;
1712  break;
1713  case 2:
1714  fRemovePileUp = kTRUE;
1717  break;
1718  case 3:
1719  fRemovePileUp = kTRUE;
1722  break;
1723  case 4:
1724  fRemovePileUp = kTRUE;
1727  break;
1728  case 5:
1729  fRemovePileUp = kTRUE;
1732  break;
1733  case 6:
1734  fRemovePileUp = kTRUE;
1735  fDoPileUpRejectV0MTPCout = kTRUE;
1736  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1737  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1738  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1739  if (fIsHeavyIon==1){
1740  if(fPeriodEnum == kLHC15o){
1741  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1742  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1743  break;
1744  }else{
1745  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
1746  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1747  break;
1748  }
1749  } else if(fIsHeavyIon == 2){
1750  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
1751  fFPileUpRejectV0MTPCout->SetParameter(1,2.0);
1752  break;
1753  }else{
1754  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1755  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
1756  break;
1757  }
1758  break;
1759  case 7:
1760  fRemovePileUp = kTRUE;
1761  fDoPileUpRejectV0MTPCout = kTRUE;
1762  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1763  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1764  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1765  if (fIsHeavyIon==1){
1766  if(fPeriodEnum == kLHC15o){
1767  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1768  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1769  break;
1770  }else{
1771  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1772  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1773  break;
1774  }
1775  } else if(fIsHeavyIon == 2){
1776  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1777  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
1778  break;
1779  }else{
1780  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1781  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1782  break;
1783  }
1784  break;
1785  case 8:
1786  fRemovePileUp = kTRUE;
1787  fDoPileUpRejectV0MTPCout = kTRUE;
1788  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1789  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1790  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1791  if (fIsHeavyIon==1){
1792  if(fPeriodEnum == kLHC15o){
1793  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1794  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1795  break;
1796  }else{
1797  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
1798  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1799  break;
1800  }
1801  } else if(fIsHeavyIon == 2){
1802  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
1803  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
1804  break;
1805  }else{
1806  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1807  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
1808  break;
1809  }
1810  break;
1811  case 9:
1812  fRemovePileUp = kTRUE;
1815  fDoPileUpRejectV0MTPCout = kTRUE;
1816  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1817  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1818  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1819  if (fIsHeavyIon==1){
1820  if(fPeriodEnum == kLHC15o){
1821  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1822  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1823  break;
1824  }else{
1825  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
1826  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1827  break;
1828  }
1829  } else if(fIsHeavyIon == 2){
1830  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
1831  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
1832  break;
1833  }else{
1834  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1835  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
1836  break;
1837  }
1838  break;
1839  default:
1840  AliError("RemovePileUpCut not defined");
1841  return kFALSE;
1842  }
1843  return kTRUE;
1844 }
1845 
1846 //________________________________________________________________________
1848 
1849  switch(extraSignal){
1850  case 0:
1851  fRejectExtraSignals = 0;
1852  break; // No Rejection
1853  case 1:
1854  fRejectExtraSignals = 1;
1855  break; // MinBias Header
1856  case 2:
1857  fRejectExtraSignals = 2;
1858  break; // User String Array
1859  case 3:
1860  fRejectExtraSignals = 3;
1861  break; // Rejection for Gamma Correction only
1862  default:
1863  AliError(Form("Extra Signal Rejection not defined %d",extraSignal));
1864  return kFALSE;
1865  }
1866  return kTRUE;
1867 }
1868 
1869 //________________________________________________________________________
1871 
1872  switch(vertexCut){
1873  case 0: // no Vertex required // NOT fully working yet
1874  fEnableVertexCut = kFALSE;
1875  fMaxVertexZ = 1000;
1876  break;
1877  case 1: // vertex within +-15 cm
1878  fEnableVertexCut = kTRUE;
1879  fMaxVertexZ = 15;
1880  break;
1881  case 2: // vertex within +-12.5 cm
1882  fEnableVertexCut = kTRUE;
1883  fMaxVertexZ = 12.5;
1884  break;
1885  case 3: // vertex within +-10 cm
1886  fEnableVertexCut = kTRUE;
1887  fMaxVertexZ = 10.0;
1888  break;
1889  case 4: // vertex within +-7.5 cm
1890  fEnableVertexCut = kTRUE;
1891  fMaxVertexZ = 7.5;
1892  break;
1893  case 5: // vertex within +-5 cm
1894  fEnableVertexCut = kTRUE;
1895  fMaxVertexZ = 5.;
1896  break;
1897  default:
1898  AliError(Form("Vertex Cut not defined %d",vertexCut));
1899  return kFALSE;
1900  }
1901  return kTRUE;
1902 }
1903 
1904 //-------------------------------------------------------------
1906  if (fPeriodEnum == kLHC15n || // pp 5TeV
1907  fPeriodEnum == kLHC15o || // PbPb 5TeV
1908  fPeriodEnum == kLHC15k1a1 || fPeriodEnum == kLHC15k1a2 || fPeriodEnum == kLHC15k1a3 || fPeriodEnum == kLHC16j7 || // MC PbPb 5TeV LowIR
1909  fPeriodEnum == kLHC16g1 || fPeriodEnum == kLHC16g1a || fPeriodEnum == kLHC16g1b || fPeriodEnum == kLHC16g1c || // MC PbPb 5TeV general purpose
1910  fPeriodEnum == kLHC16g2 || // MC PbPb 5TeV EPOS-LHC
1911  fPeriodEnum == kLHC16g3 || // MC PbPb 5TeV DPMJET
1912  fPeriodEnum == kLHC16h4 || // MC PbPb 5TeV GA added pi0 and eta
1913  fPeriodEnum == kLHC16i1a || fPeriodEnum == kLHC16i1b || fPeriodEnum == kLHC16i1c || // MC PbPb 5TeV LF added (multi-)strange
1914  fPeriodEnum == kLHC16i2a || fPeriodEnum == kLHC16i2b || fPeriodEnum == kLHC16i2c || // MC PbPb 5TeV HF added hadronic decays
1915  fPeriodEnum == kLHC16i3a || fPeriodEnum == kLHC16i3b || fPeriodEnum == kLHC16i3c || // MC PbPb 5TeV HF added electron decays
1916  fPeriodEnum == kLHC16h2a || fPeriodEnum == kLHC16h2b || fPeriodEnum == kLHC16h2c || // MC PbPb 5TeV jet-jet
1918  fPeriodEnum == kLHC15g3a3 || fPeriodEnum == kLHC15g3c3 || // MC pp 13TeV
1919  fPeriodEnum == kLHC16q || fPeriodEnum == kLHC16t || // pPb 5TeV LHC16qt
1920  fPeriodEnum == kLHC16r || fPeriodEnum == kLHC16s || // pPb 8TeV LHC16rs
1921  fPeriodEnum == kLHC17f2a || fPeriodEnum == kLHC17f2b || fPeriodEnum == kLHC17g8a || // MC pPb 5TeV LHC16qt
1924  fPeriodEnum == kLHC17f4a || fPeriodEnum == kLHC17f4b || // MC pPb 8TeV LHC16sr
1925  fPeriodEnum == kLHC17n || // Xe-Xe LHC17n
1926  fPeriodEnum == kLHC17j7 || // MC Xe-Xe LHC17n
1927  fPeriodEnum == kLHC17p || fPeriodEnum == kLHC17q || // pp 5TeV LHC17pq
1930  ){
1931  return kTRUE;
1932  } else {
1933  return kFALSE;
1934  }
1935 }
1936 
1937 //-------------------------------------------------------------
1939 { // Get Event Centrality
1940 
1941  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
1942  if(esdEvent){
1944  AliMultSelection *MultSelection = (AliMultSelection*)event->FindListObject("MultSelection");
1945  if(!MultSelection){
1946  AliWarning ("AliMultSelection object not found !");
1947  return -1;
1948  }else{
1949  if(fDetectorCentrality==0){
1950  if(fIsHeavyIon==2) return MultSelection->GetMultiplicityPercentile("V0A");// default for pPb
1951  else return MultSelection->GetMultiplicityPercentile("V0M");// default
1952  }else if(fDetectorCentrality==1) return MultSelection->GetMultiplicityPercentile("CL1",kTRUE);
1953  }
1954  }else{
1955  AliCentrality *fESDCentrality = (AliCentrality*)esdEvent->GetCentrality();
1956  if(fDetectorCentrality==0){
1957  if(fIsHeavyIon==2) return fESDCentrality->GetCentralityPercentile("V0A"); // default for pPb
1958  else return fESDCentrality->GetCentralityPercentile("V0M"); // default
1959  }else if(fDetectorCentrality==1) return fESDCentrality->GetCentralityPercentile("CL1");
1960  }
1961  }
1962 
1963  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
1964  if(aodEvent){
1966  AliMultSelection *MultSelection = (AliMultSelection*)aodEvent->FindListObject("MultSelection");
1967  if(!MultSelection){
1968  AliWarning ("AliMultSelection object not found !");
1969  return -1;
1970  } else{
1971  if(fDetectorCentrality==0){
1972  if(fIsHeavyIon==2) return MultSelection->GetMultiplicityPercentile("V0A");// default for pPb
1973  else return MultSelection->GetMultiplicityPercentile("V0M",kTRUE);
1974  }else if(fDetectorCentrality==1) return MultSelection->GetMultiplicityPercentile("CL1",kTRUE);
1975  }
1976  }else{
1977  if(aodEvent->GetHeader()){return ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();}
1978  }
1979  }
1980 
1981  return -1;
1982 }
1983 
1984 //_____________________________________________________________________________________
1985 Bool_t AliConvEventCuts::IsCentralitySelected(AliVEvent *event, AliMCEvent *mcEvent)
1986 {
1987  // Centrality Selection
1988  if(!fIsHeavyIon){
1989  if ((fCentralityMin == 0 && fCentralityMax == 0) || (fCentralityMin > fCentralityMax) ){
1990  return kTRUE;
1991  } else {
1992  Int_t primaryTracksPP[9] = { 0, 2, 5, 10, 15,
1993  30, 50, 100, 1000
1994  };
1995  Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
1996  if ( nprimaryTracks >= primaryTracksPP[fCentralityMin] && nprimaryTracks < primaryTracksPP[fCentralityMax]){
1997  return kTRUE;
1998  } else {
1999  return kFALSE;
2000  }
2001  return kFALSE;
2002  }
2003  }
2004  if(fCentralityMin == fCentralityMax ) return kTRUE;//0-100%
2005  else if ( fCentralityMax==0) fCentralityMax=10; //CentralityRange = fCentralityMin-10*multfactor
2007  if(centrality<0 && !mcEvent)return kFALSE;
2008 
2009  Int_t centralityC=0;
2010  if (fModCentralityClass == 0){
2011  centralityC= Int_t(centrality/10);
2012  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2013  return kTRUE;
2014  else return kFALSE;
2015  }
2016  else if (fModCentralityClass ==1){
2017  centralityC= Int_t(centrality);
2018  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2019  return kTRUE;
2020  } else return kFALSE;
2021  }
2022 
2023  Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
2024  Int_t PrimaryTracks10[11][2] =
2025  {
2026  {9999,9999}, // 0 //1550 changed to 9999 on 9 Dec
2027  {1210, 928}, // 10
2028  { 817, 658}, // 20
2029  { 536, 435}, // 30
2030  { 337, 276}, // 40
2031  { 197, 162}, // 50
2032  { 106, 100}, // 60
2033  { 51, 44}, // 70
2034  { 21, 18}, // 80
2035  { 0, 0}, // 90
2036  { 0, 0}// 100 // only max accessible
2037  };
2038  Int_t PrimaryTracksLHC11h10[11][2] =
2039  {
2040  {9999,9999}, // 0 //1550 changed to 9999 on 9 Dec
2041  { 985, 928}, // 10
2042  { 661, 658}, // 20
2043  { 434, 435}, // 30
2044  { 275, 276}, // 40
2045  { 173, 162}, // 50
2046  { 100, 100}, // 60
2047  { 42, 44}, // 70
2048  { 19, 18}, // 80
2049  { 0, 0}, // 90
2050  { 0, 0}// 100 // only max accessible
2051  };
2052  Int_t PrimaryTracksLHC15o10[11][2] =
2053  { // values calculated from ESD analysis so far
2054  {2700, 2700}, // 0-10% cent class max # of tracks: max value of the data distribution
2055  {1498, 1498}, // 0-10% cent class min # of tracks
2056  {1012, 1012}, // 10-20
2057  { 669, 669}, // 20-30
2058  { 423, 423}, // 30-40
2059  { 251, 251}, // 40-50
2060  { 136, 136}, // 50-60
2061  { 67, 67}, // 60-70
2062  { 28, 28}, // 70-80
2063  { 0, 0}, // 80-90% cent class min # of tracks
2064  { 0, 0} // not used
2065  };
2066  Int_t PrimaryTracksLHC10h5[21][2] =
2067  {
2068  {9999,9999}, // 0 ///1550 changed to 9999 on 9 Dec
2069  {1485,1168}, // 5
2070  {1210, 928}, // 10
2071  { 995, 795}, // 15
2072  { 817, 658}, // 20
2073  { 666, 538}, // 25
2074  { 536, 435}, // 30
2075  { 428, 350}, // 35
2076  { 337, 276}, // 40
2077  { 260, 214}, // 45
2078  { 197, 162}, // 50
2079  { 147, 125}, // 55
2080  { 106, 100}, // 60
2081  { 75, 63}, // 65
2082  { 51, 44}, // 70
2083  { 34, 29}, // 75
2084  { 21, 18}, // 80
2085  { 13, 11}, // 85
2086  { 6, 6}, // 90
2087  { 3, 3}, // 95
2088  { 0, 0} // 100 only max accessible
2089  };
2090  Int_t PrimaryTracksLHC11h5[21][2] =
2091  {
2092  {9999,9999}, // 0 ///1550 changed to 9999 on 9 Dec
2093  {1166,1168}, // 5
2094  { 953, 928}, // 10
2095  { 805, 795}, // 15
2096  { 655, 658}, // 20
2097  { 535, 538}, // 25
2098  { 435, 435}, // 30
2099  { 349, 350}, // 35
2100  { 275, 276}, // 40
2101  { 214, 214}, // 45
2102  { 165, 162}, // 50
2103  { 127, 125}, // 55
2104  { 93, 100}, // 60
2105  { 64, 63}, // 65
2106  { 44, 44}, // 70
2107  { 30, 29}, // 75
2108  { 18, 18}, // 80
2109  { 11, 11}, // 85
2110  { 6, 6}, // 90
2111  { 3, 3}, // 95
2112  { 0, 0} // 100 only max accessible
2113  };
2114  Int_t PrimaryTracksLHC15o5[21][2] =
2115  {
2116  { 2700, 2700}, // 0-5% cent class max # of tracks: max value of the data distribution
2117  { 1827, 1827}, // 0-5% cent class min # of tracks
2118  { 1498, 1498}, // 5-10
2119  { 1234, 1234}, // 10-15
2120  { 1012, 1012}, // 15-20
2121  { 827, 827}, // 20-25
2122  { 669, 669}, // 25-30
2123  { 536, 536}, // 30-35
2124  { 423, 423}, // 35-40
2125  { 329, 329}, // 40-45 cent class min # of tracks (cut digit 9)
2126  { 251, 251}, // 45-50% cent class min # of tracks
2127  { 188, 188}, // 50-55
2128  { 136, 136}, // 55-60
2129  { 97, 97}, // 60-65
2130  { 67, 67}, // 65-70
2131  { 44, 44}, // 70-75
2132  { 28, 28}, // 75-80
2133  { 17, 17}, // 80-85
2134  { 10, 10}, // 85-90
2135  { 5, 5}, // 90-95 cent class minimum # of tracks
2136  { 0, 0} // 95-100
2137  };
2138  Int_t PrimaryTracksLHC17n10[11][2] =
2139  {
2140  {9999,9999}, // 0 // 1500 max in hist but set to real max
2141  { 800, 800}, // 10 // guess
2142  { 628, 628}, // 20
2143  { 350, 350}, // 30 // guess
2144  { 268, 268}, // 40
2145  { 200, 200}, // 50 // guess
2146  { 100, 100}, // 60 // guess
2147  { 51, 44}, // 70 // guess
2148  { 21, 18}, // 80 // guess
2149  { 0, 0}, // 90 // guess
2150  { 0, 0} // 100 // only max accessible
2151  };
2152 
2153  Int_t column = 0;
2154  if(event->IsA()==AliESDEvent::Class()) column = 0;
2155  if(event->IsA()==AliAODEvent::Class()) column = 1;
2156 
2157  if (fModCentralityClass == 3){
2158  if(mcEvent){
2159  // setting specific arry for LHC11h for MC track mult
2161  if(nprimaryTracks > PrimaryTracksLHC11h10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h10[fCentralityMin][column])
2162  return kTRUE;
2163  else return kFALSE;
2164  // setting specific arry for LHC17n for MC track mult
2165  } else if(fPeriodEnum == kLHC17j7 ){
2166  if(nprimaryTracks > PrimaryTracksLHC17n10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC17n10[fCentralityMin][column])
2167  return kTRUE;
2168  else return kFALSE;
2169  // setting specific arry for LHC15o for MC track mult
2171  if(nprimaryTracks > PrimaryTracksLHC15o10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC15o10[fCentralityMin][column])
2172  return kTRUE;
2173  else return kFALSE;
2174  // setting specific arry for LHC10h for MC track mult
2175  } else {
2176  if(nprimaryTracks > PrimaryTracks10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracks10[fCentralityMin][column])
2177  return kTRUE;
2178  else return kFALSE;
2179  }
2180  }
2181  else{
2182  centralityC= Int_t(centrality/10);
2183  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2184  return kTRUE;
2185  else return kFALSE;
2186  }
2187  }
2188  else if (fModCentralityClass ==4){
2189  if(mcEvent){
2190  // setting specific arry for LHC11h for MC track mult
2192  if(nprimaryTracks > PrimaryTracksLHC11h5[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h5[fCentralityMin][column])
2193  return kTRUE;
2194  else return kFALSE;
2195  // setting specific arry for LHC15o for MC track mult
2197  if(nprimaryTracks > PrimaryTracksLHC15o5[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC15o5[fCentralityMin][column])
2198  return kTRUE;
2199  else return kFALSE;
2200  // setting specific arry for LHC10h for MC track mult
2201  } else {
2202  if(nprimaryTracks > PrimaryTracksLHC10h5[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC10h5[fCentralityMin][column])
2203  return kTRUE;
2204  else return kFALSE;
2205  }
2206  }
2207  else{
2208  centralityC= Int_t(centrality);
2209  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2210  return kTRUE;
2211  } else return kFALSE;
2212  }
2213  }
2214 
2215  Int_t PrimaryTracksLHC11h10AltMin[11][2] =
2216  {
2217  {1550,1550}, // 0 - 0
2218  { 800, 800}, // 10 - 1
2219  { 600, 600}, // 20 - 2
2220  { 400, 400}, // 30 - 3
2221  { 240, 240}, // 40 - 4
2222  { 130, 130}, // 50 - 5
2223  { 90, 90}, // 60 - 6
2224  { 35, 35}, // 70 - 7
2225  { 15, 15}, // 80 - 8
2226  { 5, 5}, // 90 - 9
2227  { 0, 0} // 100 // only max accessible
2228  };
2229  Int_t PrimaryTracksLHC11h10AltMax[11][2] =
2230  {
2231  {1550,1550}, // 0 //1550 changed to 9999 on 9 Dec
2232  {1000,1000}, // 10
2233  { 700, 700}, // 20
2234  { 480, 480}, // 30
2235  { 300, 300}, // 40
2236  { 200, 200}, // 50
2237  { 120, 120}, // 60
2238  { 50, 50}, // 70
2239  { 22, 22}, // 80
2240  { 10, 10}, // 90
2241  { 0, 0} // 100 // only max accessible
2242  };
2243  Int_t PrimaryTracksLHC11h5AltMin[21][2] =
2244  {
2245  {1550,1550}, // 0
2246  {1000,1000}, // 5
2247  { 800, 800}, // 10
2248  { 700, 700}, // 15
2249  { 600, 600}, // 20
2250  { 500, 500}, // 25
2251  { 400, 400}, // 30
2252  { 300, 300}, // 35
2253  { 240, 240}, // 40
2254  { 180, 180}, // 45
2255  { 130, 130}, // 50
2256  { 127, 125}, // 55
2257  { 90, 90}, // 60
2258  { 55, 55}, // 65
2259  { 35, 35}, // 70
2260  { 25, 25}, // 75
2261  { 15, 15}, // 80
2262  { 11, 11}, // 85
2263  { 5, 5}, // 90
2264  { 0, 0}, // 95
2265  { 0, 0} // 100 only max accessible
2266  };
2267  Int_t PrimaryTracksLHC11h5AltMax[21][2] =
2268  {
2269  {1550,1550}, // 0
2270  {1250,1250}, // 5
2271  {1000,1000}, // 10
2272  { 805, 795}, // 15
2273  { 700, 700}, // 20
2274  { 585, 585}, // 25
2275  { 480, 480}, // 30
2276  { 380, 380}, // 35
2277  { 300, 300}, // 40
2278  { 235, 235}, // 45
2279  { 200, 200}, // 50
2280  { 140, 140}, // 55
2281  { 120, 120}, // 60
2282  { 70, 70}, // 65
2283  { 50, 50}, // 70
2284  { 35, 25}, // 75
2285  { 22, 22}, // 80
2286  { 15, 15}, // 85
2287  { 10, 10}, // 90
2288  { 5, 5}, // 95
2289  { 0, 0} // 100 only max accessible
2290  };
2291 
2292  if (fModCentralityClass == 5){
2293  if(mcEvent){
2294  // setting specific arry for LHC11h for MC track mult
2296  if(nprimaryTracks > PrimaryTracksLHC11h10AltMin[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h10AltMax[fCentralityMin][column])
2297  return kTRUE;
2298  else return kFALSE;
2299  // default return
2300  } else {
2301  return kFALSE;
2302  }
2303  } else {
2304  centralityC= Int_t(centrality/10);
2305  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2306  return kTRUE;
2307  else return kFALSE;
2308  }
2309  }
2310  else if (fModCentralityClass ==6){
2311  if(mcEvent){
2312  // setting specific arry for LHC11h for MC track mult
2314  if(nprimaryTracks > PrimaryTracksLHC11h5AltMin[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h5AltMax[fCentralityMin][column])
2315  return kTRUE;
2316  else return kFALSE;
2317  // setting specific arry for LHC15o for MC track mult
2318  } else {
2319  return kFALSE;
2320  }
2321  } else{
2322  centralityC= Int_t(centrality);
2323  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2324  return kTRUE;
2325  } else return kFALSE;
2326  }
2327  }
2328 
2329  return kFALSE;
2330 }
2331 
2332 //________________________________________________________________________
2334  // Cut on z position of primary vertex
2335  Double_t fVertexZ=event->GetPrimaryVertex()->GetZ();
2336  Double_t fVertexZSPD = 0;
2337  AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2338  if(fESDEvent){
2339  fVertexZSPD = fESDEvent->GetPrimaryVertexSPD()->GetZ();
2340  }
2341  AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2342  if(fAODEvent){
2343  fVertexZSPD = fAODEvent->GetPrimaryVertexSPD()->GetZ();
2344  }
2345 
2346  if(TMath::Abs(fVertexZ)>fMaxVertexZ)return kFALSE;
2347 
2348 
2349  if (fPeriodEnum == kLHC11h){
2350  if (TMath::Abs(fVertexZ-fVertexZSPD) > 0.1) return kFALSE;
2351  }
2352  if (fIsHeavyIon == 2){
2353  if(!fUtils->IsVertexSelected2013pA(event)) return kFALSE;
2354  }
2355 
2356  return kTRUE;
2357 }
2358 
2359 //________________________________________________________________________
2361 {
2363  return kFALSE;
2364  TBits fIR1 = event->GetHeader()->GetIRInt1InteractionMap(); // IR1 contains V0 information (VIR)
2365  TBits fIR2 = event->GetHeader()->GetIRInt2InteractionMap(); // IR2 contains T0 information
2366  UShort_t bunchCrossings = event->GetBunchCrossNumber();
2368  for(Int_t i = 0; i<180;i++){
2369  if(fIR1.TestBitNumber(i))
2370  fHistoPastFutureBits->Fill((i*25)-90*25);
2371  }
2372  }
2373 
2374  Bool_t isOutOfBunchPileup = 0;
2375  Int_t pf1 = fPastFutureRejectionLow +bunchCrossings%4;
2376  Int_t pf2 = fPastFutureRejectionHigh+bunchCrossings%4;
2377  if(pf1 < -89) pf1 = -89;
2378  if(pf2 > 89) pf2 = 89;
2379  Int_t pf2maxForT0 = pf2;
2380  Int_t ir1skip = 0;
2381  for (Int_t i=pf1;i<=pf2;i++) {
2382  if (i==0) continue;
2383  if (i<=pf2maxForT0) isOutOfBunchPileup|=fIR2.TestBitNumber(90+i); // T0-based clean-up
2384  if (i>0 && i<=ir1skip) continue; // skip next 2 for old IR definitions
2385  isOutOfBunchPileup|=fIR1.TestBitNumber(90+i); // V0-based clean-up
2386  }
2387  return isOutOfBunchPileup;
2388 }
2389 //________________________________________________________________________
2390 
2392 {
2393  Bool_t isPileUpV0MTPCout=0;
2394 
2395  Double_t multV0M;
2396  Double_t valFunc;
2397  if (fIsHeavyIon==2){
2398  multV0M = event->GetVZEROData()->GetMTotV0A();
2399  }else{
2400  multV0M = event->GetVZEROData()->GetMTotV0A() + event->GetVZEROData()->GetMTotV0C() ;
2401  }
2402 
2403  if ( fFPileUpRejectV0MTPCout != 0x0 ){
2404  valFunc= fFPileUpRejectV0MTPCout->Eval(((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfTPCoutTracks());
2405  if (multV0M < valFunc ) isPileUpV0MTPCout=1;
2406  }
2407 
2408  return isPileUpV0MTPCout;
2409 
2410 }
2411 //________________________________________________________________________
2413  // returns number of contributors to the vertex
2414 
2415  AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2416  if(fESDEvent){
2417  if (fESDEvent->GetPrimaryVertex() != NULL){
2418  if(fESDEvent->GetPrimaryVertex()->GetNContributors()>0) {
2419  // cout << "accepted global" << fESDEvent->GetEventNumberInFile() << " with NCont: " << fESDEvent->GetPrimaryVertex()->GetNContributors() << endl;
2420  return fESDEvent->GetPrimaryVertex()->GetNContributors();
2421  }
2422  }
2423 
2424  if(fESDEvent->GetPrimaryVertexSPD() !=NULL){
2425  if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2426  // cout << "accepted SPD" << fESDEvent->GetEventNumberInFile() << " with NCont: " << fESDEvent->GetPrimaryVertexSPD()->GetNContributors() << endl;
2427  return fESDEvent->GetPrimaryVertexSPD()->GetNContributors();
2428  }else {
2429  AliWarning(Form("Number of contributors from bad vertex type:: %s",fESDEvent->GetPrimaryVertex()->GetName()));
2430  // cout << "rejected " << fESDEvent->GetEventNumberInFile() << endl;
2431  return 0;
2432  }
2433  }
2434  }
2435 
2436  AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2437  if(fAODEvent){
2438  if (fAODEvent->GetPrimaryVertex() != NULL){
2439  if(fAODEvent->GetPrimaryVertex()->GetNContributors()>0) {
2440  return fAODEvent->GetPrimaryVertex()->GetNContributors();
2441  }
2442  }
2443  if(fAODEvent->GetPrimaryVertexSPD() !=NULL){
2444  if(fAODEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2445  return fAODEvent->GetPrimaryVertexSPD()->GetNContributors();
2446  } else {
2447  AliWarning(Form("Number of contributors from bad vertex type:: %s",fAODEvent->GetPrimaryVertex()->GetName()));
2448  return 0;
2449  }
2450  }
2451  }
2452  // cout << "rejected " << fESDEvent->GetEventNumberInFile() << endl;
2453  return 0;
2454 }
2455 
2456 //________________________________________________________________________
2457 // Analysing Jet-Jet MC's
2458 //________________________________________________________________________
2460  AliGenCocktailEventHeader *cHeader = 0x0;
2461  Bool_t headerFound = kFALSE;
2462  weight = -1;
2463  fMaxPtJetMC = 0;
2464 
2465  if ( fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2466  fPeriodEnum != kLHC17g8b && fPeriodEnum != kLHC17g8c && // LHC16sr pPb 8TeV JetJet MC's
2467  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2468  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2469  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2470  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2471  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2472  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2473  fPeriodEnum != kLHC16c2 && fPeriodEnum != kLHC16c2_plus // LHC12 JetJet MC
2474  ){
2475 
2476  weight = 1;
2477  return kTRUE;
2478  }
2479 
2480  if(mcEvent){
2481  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2482  if(cHeader) headerFound = kTRUE;
2483  }else{
2484  //no mcEvent available -> not running on MC
2485  weight = 1;
2486  return kTRUE;
2487  }
2488 
2489  if(headerFound){
2490  TList *genHeaders = 0x0;
2491  if(cHeader) genHeaders = cHeader->GetHeaders();
2492  AliGenEventHeader* gh = 0;
2493  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2494  gh = (AliGenEventHeader*)genHeaders->At(i);
2495  TString GeneratorName = gh->GetName();
2496  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2497  Bool_t eventAccepted = kTRUE;
2498  TParticle * jet = 0;
2499  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(gh)->NTriggerJets();
2500  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
2501  Float_t tmpjet[]={0,0,0,0};
2502  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2503  dynamic_cast<AliGenPythiaEventHeader*>(gh)->TriggerJet(ijet, tmpjet);
2504  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2505  //Compare jet pT and pt Hard
2506  if(jet->Pt() > fMaxFacPtHard * ptHard){
2507  eventAccepted= kFALSE;
2508  }
2509  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2510  }
2511  if (jet) delete jet;
2512  if (mcEvent){
2513  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2514  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2515  if (!particle) continue;
2516  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2517  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2518  eventAccepted= kFALSE;
2519  }
2520  }
2521 
2522  }
2523  }
2524 
2525  if ( fPeriodEnum == kLHC16P1JJLowB) {
2526  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2527  21, 28, 36, 45, 57,
2528  70, 85, 99, 115, 132,
2529  150, 169, 190, 212, 235,
2530  1000000};
2531  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2532  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2533  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2534  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2535  Int_t bin = 0;
2536  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2537  if (bin < 20) weight = weightsBins[bin];
2538 
2539  } else if ( fPeriodEnum == kLHC16P1JJ ){
2540  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2541  21, 28, 36, 45, 57,
2542  70, 85, 99, 115, 132,
2543  150, 169, 190, 212, 235,
2544  1000000};
2545  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2546  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2547  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2548  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2549 
2550  Int_t bin = 0;
2551  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2552  if (bin < 20) weight = weightsBins[bin];
2553 
2554  } else if ( fPeriodEnum == kLHC16h3 ){
2555  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2556  21, 28, 36, 45, 57,
2557  70, 85, 99, 115, 132,
2558  150, 169, 190, 212, 235,
2559  1000000};
2560  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2561  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2562  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2563  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2564  Int_t bin = 0;
2565  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2566  if (bin < 20) weight = weightsBins[bin];
2567 
2568 
2569  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2570  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2571  21, 28, 36, 45, 57,
2572  70, 85, 1000};
2573  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2574  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2575  1.933238e-05, 1.562895e-05};
2576  Int_t bin = 0;
2577  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2578  if (bin < 12) weight = weightsBins[bin];
2579 
2580  } else if ( fPeriodEnum == kLHC15g1a ){
2581  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2582  84, 117, 152, 191, 1000000,
2583  5, 7, 9, 12, 16,
2584  21, 28, 36, 45, 57 };
2585  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2586  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2587  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2588  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2589 
2590  Int_t bin = 0;
2591  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2592  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2593  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2594  if (bin < 19) weight = weightsBins[bin];
2595 
2596  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2597  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2598  84, 117, 152, 191, 1000000,
2599  5, 7, 9, 12, 16,
2600  21, 28, 36, 45, 57 };
2601  // LHC15a3a
2602  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2603  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2604  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2605  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2606  Int_t bin = 0;
2607  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2608  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2609  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2610  if (bin < 19) weight = weightsBins[bin];
2611 
2612  } else if ( fPeriodEnum == kLHC16c2 || fPeriodEnum == kLHC16c2_plus ){
2613  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2614  21, 28, 36, 45, 57,
2615  70, 85, 99, 115, 132,
2616  150, 169, 190, 212, 235,
2617  1000000};
2618  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
2619  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
2620  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
2621  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
2622  Int_t bin = 0;
2623  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2624  if (bin < 20) weight = weightsBins[bin];
2625 
2626  } else if ( fPeriodEnum == kLHC16c3a ){
2627  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
2628  Double_t weightsBins[5] = { 0.00672445, 0.00799158, 0.00678934, 0.00463908, 0.00600068}; //preliminary estimates
2629  Int_t bin = 0;
2630  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2631  if (bin < 5) weight = weightsBins[bin];
2632 
2633  } else if (fPeriodEnum == kLHC16c3b ){
2634  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
2635  Double_t weightsBins[6] = { 0.00608281, 0.00393646, 0.00200138, 0.000986267, 0.000389051, 0.0001863}; //preliminary estimates
2636  Int_t bin = 0;
2637  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2638  if (bin < 6) weight = weightsBins[bin];
2639 
2640  } else if (fPeriodEnum == kLHC16c3c ){
2641  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
2642  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
2643  Int_t bin = 0;
2644  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2645  if (bin < 7) weight = weightsBins[bin];
2646 
2647  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
2648  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
2649  84, 117, 152, 191, 234,
2650  1000};
2651  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
2652  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
2653  Int_t bin = 0;
2654  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2655  if (bin < 10) weight = weightsBins[bin];
2656 
2657  } else if ( fPeriodEnum == kLHC17g8a ){ // preliminary weights obtained from local running
2658  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};
2659  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};
2660  Int_t bin = 0;
2661  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2662  if (bin < 20) weight = weightsBins[bin];
2663  } else if ( fPeriodEnum == kLHC17g8b ){ // preliminary weights obtained from local running
2664  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};
2665  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};
2666  Int_t bin = 0;
2667  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2668  if (bin < 20) weight = weightsBins[bin];
2669  } else if ( fPeriodEnum == kLHC17g8c ){ // preliminary weights obtained from local running
2670  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};
2671  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};
2672  Int_t bin = 0;
2673  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2674  if (bin < 20) weight = weightsBins[bin];
2675 
2676  } else {
2677  weight = 1;
2678  }
2679 
2680  if (weight == -1) return kFALSE;
2681  else return eventAccepted;
2682 
2683  }
2684  }
2685  } else {
2686  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2687  TString eventHeaderName = eventHeader->ClassName();
2688  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2689  Bool_t eventAccepted = kTRUE;
2690  TParticle * jet = 0;
2691  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->NTriggerJets();
2692  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
2693  Float_t tmpjet[]={0,0,0,0};
2694  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2695  dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->TriggerJet(ijet, tmpjet);
2696  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2697  //Compare jet pT and pt Hard
2698  if(jet->Pt() > fMaxFacPtHard * ptHard){
2699  eventAccepted= kFALSE;
2700  }
2701  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2702  }
2703  if (mcEvent){
2704  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2705  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2706  if (!particle) continue;
2707  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2708  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2709  eventAccepted= kFALSE;
2710  }
2711  }
2712 
2713  }
2714  }
2715 
2716  if ( fPeriodEnum == kLHC16P1JJLowB) {
2717  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2718  21, 28, 36, 45, 57,
2719  70, 85, 99, 115, 132,
2720  150, 169, 190, 212, 235,
2721  1000000};
2722  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2723  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2724  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2725  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2726  Int_t bin = 0;
2727  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2728  if (bin < 20) weight = weightsBins[bin];
2729 
2730  } else if ( fPeriodEnum == kLHC16P1JJ ){
2731  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2732  21, 28, 36, 45, 57,
2733  70, 85, 99, 115, 132,
2734  150, 169, 190, 212, 235,
2735  1000000};
2736  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2737  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2738  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2739  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2740 
2741  Int_t bin = 0;
2742  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2743  if (bin < 20) weight = weightsBins[bin];
2744 
2745  } else if ( fPeriodEnum == kLHC16h3 ){
2746  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2747  21, 28, 36, 45, 57,
2748  70, 85, 99, 115, 132,
2749  150, 169, 190, 212, 235,
2750  1000000};
2751  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2752  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2753  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2754  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2755  Int_t bin = 0;
2756  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2757  if (bin < 20) weight = weightsBins[bin];
2758 
2759 
2760  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2761  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2762  21, 28, 36, 45, 57,
2763  70, 85, 1000};
2764  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2765  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2766  1.933238e-05, 1.562895e-05};
2767  Int_t bin = 0;
2768  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2769  if (bin < 12) weight = weightsBins[bin];
2770 
2771  } else if ( fPeriodEnum == kLHC15g1a ){
2772  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2773  84, 117, 152, 191, 1000000,
2774  5, 7, 9, 12, 16,
2775  21, 28, 36, 45, 57 };
2776  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2777  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2778  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2779  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2780 
2781  Int_t bin = 0;
2782  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2783  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2784  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2785  if (bin < 19) weight = weightsBins[bin];
2786 
2787  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2788  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2789  84, 117, 152, 191, 1000000,
2790  5, 7, 9, 12, 16,
2791  21, 28, 36, 45, 57 };
2792  // LHC15a3a
2793  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2794  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2795  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2796  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2797  Int_t bin = 0;
2798  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2799  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2800  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2801  if (bin < 19) weight = weightsBins[bin];
2802 
2803  } else if ( fPeriodEnum == kLHC16c2 || fPeriodEnum == kLHC16c2_plus ){
2804  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2805  21, 28, 36, 45, 57,
2806  70, 85, 99, 115, 132,
2807  150, 169, 190, 212, 235,
2808  1000000};
2809  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
2810  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
2811  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
2812  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
2813  Int_t bin = 0;
2814  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2815  if (bin < 20) weight = weightsBins[bin];
2816 
2817  } else if ( fPeriodEnum == kLHC16c3a ){
2818  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
2819  Double_t weightsBins[5] = { 0.00672445, 0.00799158, 0.00678934, 0.00463908, 0.00600068}; //preliminary estimates
2820  Int_t bin = 0;
2821  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2822  if (bin < 5) weight = weightsBins[bin];
2823 
2824  } else if (fPeriodEnum == kLHC16c3b ){
2825  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
2826  Double_t weightsBins[6] = { 0.00608281, 0.00393646, 0.00200138, 0.000986267, 0.000389051, 0.0001863}; //preliminary estimates
2827  Int_t bin = 0;
2828  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2829  if (bin < 6) weight = weightsBins[bin];
2830 
2831  } else if (fPeriodEnum == kLHC16c3c ){
2832  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
2833  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
2834  Int_t bin = 0;
2835  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2836  if (bin < 7) weight = weightsBins[bin];
2837 
2838  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
2839  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
2840  84, 117, 152, 191, 234,
2841  1000};
2842  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
2843  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
2844  Int_t bin = 0;
2845  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2846  if (bin < 10) weight = weightsBins[bin];
2847  } else {
2848  weight = 1;
2849  }
2850 
2851  if (weight == -1) return kFALSE;
2852  else return eventAccepted;
2853 
2854  } else {
2855  return kFALSE;
2856  }
2857  }
2858 
2859  return kFALSE;
2860 }
2861 
2862 //________________________________________________________________________
2863 // Analysing Jet-Jet MC's
2864 //________________________________________________________________________
2865 void AliConvEventCuts::GetXSectionAndNTrials(AliMCEvent *mcEvent, Float_t &XSection, Float_t &NTrials){
2866 
2867  AliGenCocktailEventHeader *cHeader = 0x0;
2868  Bool_t headerFound = kFALSE;
2869 
2870  if ( fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2871  fPeriodEnum != kLHC17g8b && fPeriodEnum != kLHC17g8c && // LHC16sr pPb 8TeV JetJet MC's
2872  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2873  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2874  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2875  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2876  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2877  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2878  fPeriodEnum != kLHC16c2 && fPeriodEnum != kLHC16c2_plus // LHC12 JetJet MC
2879  ){
2880  NTrials = -1;
2881  XSection = -1;
2882  return;
2883  }
2884 
2885  if(mcEvent){
2886  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2887  if(cHeader) headerFound = kTRUE;
2888  }else{
2889  //no mcEvent available -> not running on MC
2890  NTrials = -1;
2891  XSection = -1;
2892  return;
2893  }
2894 
2895  if(headerFound){
2896  TList *genHeaders = 0x0;
2897  if(cHeader) genHeaders = cHeader->GetHeaders();
2898  AliGenEventHeader* gh = 0;
2899  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2900  gh = (AliGenEventHeader*)genHeaders->At(i);
2901  TString GeneratorName = gh->GetName();
2902  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2903  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(gh);
2904  NTrials = gPythia->Trials();
2905  XSection = gPythia->GetXsection();
2906  return;
2907  }
2908  }
2909  } else {
2910  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2911  if(eventHeader){
2912  TString eventHeaderName = eventHeader->ClassName();
2913  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2914  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader);
2915  NTrials = gPythia->Trials();
2916  XSection = gPythia->GetXsection();
2917  return;
2918  }
2919  }
2920  }
2921 
2922  NTrials = -1;
2923  XSection = -1;
2924  return;
2925 }
2926 
2927 
2928 //________________________________________________________________________
2929 // Analysing Jet-Jet MC's
2930 //________________________________________________________________________
2932  AliGenCocktailEventHeader *cHeader = 0x0;
2933  Bool_t headerFound = kFALSE;
2934 
2935  if ( fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2936  fPeriodEnum != kLHC17g8b && fPeriodEnum != kLHC17g8c && // LHC16sr pPb 8TeV JetJet MC's
2937  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2938  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2939  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2940  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2941  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2942  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2943  fPeriodEnum != kLHC16c2 && fPeriodEnum != kLHC16c2_plus // LHC12 JetJet MC
2944  ) return -1;
2945 
2946  if(mcEvent){
2947  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2948  if(cHeader) headerFound = kTRUE;
2949  }else{
2950  //no mcEvent available -> not running on MC
2951  return -1;
2952  }
2953 
2954  if(headerFound){
2955  TList *genHeaders = 0x0;
2956  if(cHeader) genHeaders = cHeader->GetHeaders();
2957  AliGenEventHeader* gh = 0;
2958  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2959  gh = (AliGenEventHeader*)genHeaders->At(i);
2960  TString GeneratorName = gh->GetName();
2961  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2962  return dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
2963  }
2964  }
2965  } else {
2966  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2967  if(eventHeader){
2968  TString eventHeaderName = eventHeader->ClassName();
2969  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2970  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
2971  }
2972  }
2973  }
2974 
2975  return -1;
2976 }
2977 
2978 
2979 //________________________________________________________________________
2981  // abort if mimicing not enabled
2982 
2983  if (!fMimicTrigger) return kTRUE;
2984 
2985  Int_t runRangesEMCalL0 [35] = { 144871, 145288, 146375, 146382, // LHC11a
2986  146502, 148522, // LHC11a
2987  150209, 153056, 153911, 153915, // LHC11b,c,d
2988  158135, 158136, 158178, 158182, 160683,
2989  160764, 161139, 161256, 161379, 161457,
2990  161525, 161556, 161558, 161609, 161630,
2991  161724, // LHC11d,e
2992  173731, 177144, 177147, 177653, 177724, 178327,
2993  195180, // LHC13b-f
2994  197469, 197692 // LHC13g
2995  };
2996 
2997  Double_t thresholdEMCalL0[34] = { 2.11, 3.43, 1.71, 2.05, // LHC11a 7 TeV
2998  3.43, // LHC11a 2.76TeV
2999  1.94, 3.39, 4.01, 5.25, 5.5, // LHC11b, LHC11c, LHC11d
3000  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,
3001  2.01, 1.75, 1.52, 2.01, 1.52, 1.85,
3002  3.2,
3003  /*2.01*/1.8
3004  };
3005  Double_t spreadEMCalL0[34] = { 0., 0., 0, 0, // LHC11a 7TeV
3006  /*0.7*/0.65, // LHC11a 2.76TeV
3007  0., 0., 0., 0., 0., // LHC11b, LHC11c, LHC11d
3008  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
3009  0., 0., 0., 0., 0.2, 0.2,/*0.,0.,*/
3010  0.1,
3011  /*0.1*/0.12
3012  };
3013 
3014  Int_t runRangesEMCalL1[4] = { 179796, // LHC12c-i
3015  195180, // LHC13b-f
3016  197469, 197692 // LHC13g
3017  };
3018 
3019  Double_t thresholdEMCalL1[3] = { 9.5/*8.398*/, 11.5, /*6.*/5.5};
3020  Double_t spreadEMCalL1[3] = { 1.0/*0.*/, 0.5, /*0.4*/0.6};
3021 
3022  Int_t runRangesEMCalL1G2[3] = { 195180, // LHC13b-f
3023  197469, 197692 // LHC13g
3024  };
3025 
3026  Double_t thresholdEMCalL1G2[2] = { 7.2, /*3.9*/3.75};
3027  Double_t spreadEMCalL1G2[2] = { 0.3, /*0.2*/0.25};
3028 
3029  Int_t runnumber = event->GetRunNumber();
3030 
3031  if (fSpecialTrigger == 5 ){
3032  if (runnumber < runRangesEMCalL0[0]) return kTRUE;
3033  Int_t binRun = 0;
3034  while (!(runnumber >= runRangesEMCalL0[binRun] && runnumber < runRangesEMCalL0[binRun+1] ) && binRun < 34 ){
3035 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << endl;
3036  binRun++;
3037  }
3038  if (binRun==34) return kFALSE;
3039  Double_t threshold = thresholdEMCalL0[binRun];
3040 
3041  if (isMC && spreadEMCalL0[binRun] != 0.){
3042  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3043  triggerSmearing->SetParameter(0, 1/(spreadEMCalL0[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3044  triggerSmearing->SetParameter(1, thresholdEMCalL0[binRun]);
3045  triggerSmearing->SetParameter(2, spreadEMCalL0[binRun]);
3046  threshold = triggerSmearing->GetRandom();
3047  delete triggerSmearing;
3048  }
3049 
3050 // cout << runnumber << "\t"<< binRun << "\t"<< threshold << endl;
3051  Int_t nclus = 0;
3052  TClonesArray * arrClustersMimic = NULL;
3053  if(!fCorrTaskSetting.CompareTo("")){
3054  nclus = event->GetNumberOfCaloClusters();
3055  } else {
3056  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3057  if(!arrClustersMimic)
3058  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3059  nclus = arrClustersMimic->GetEntries();
3060  }
3061 
3062  if(nclus == 0) return kFALSE;
3063 
3064  // Loop over EMCal clusters
3065  Bool_t eventIsAccepted = kFALSE;
3066  for(Int_t i = 0; i < nclus; i++){
3067  AliVCluster* clus = NULL;
3068  if(event->IsA()==AliESDEvent::Class()){
3069  if(arrClustersMimic)
3070  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3071  else
3072  clus = event->GetCaloCluster(i);
3073  } else if(event->IsA()==AliAODEvent::Class()){
3074  if(arrClustersMimic)
3075  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3076  else
3077  clus = event->GetCaloCluster(i);
3078  }
3079 
3080  if (!clus) continue;
3081  if (!clus->IsEMCAL()) continue;
3082  if (clus->GetM02()<0.1) continue;
3083  if (clus->GetNCells()<2) continue;
3084  if (clus->E() > threshold ){
3085 // cout << "found L0" << endl;
3086  eventIsAccepted = kTRUE;
3087  }
3088  }
3089  return eventIsAccepted;
3090 
3091  } else if (fSpecialTrigger == 6 ) {
3092 
3093  return kTRUE;
3094  } else if (fSpecialTrigger == 8 ) {
3095  if (fSpecialSubTriggerName.CompareTo("7EGA")==0 || fSpecialSubTriggerName.CompareTo("8EGA")==0 || fSpecialSubTriggerName.CompareTo("7EG1")==0 ||fSpecialSubTriggerName.CompareTo("8EG1")==0 ){
3096  if (runnumber < runRangesEMCalL1[0]) return kTRUE;
3097  Int_t binRun = 0;
3098  while (!(runnumber >= runRangesEMCalL1[binRun] && runnumber < runRangesEMCalL1[binRun+1] ) && binRun < 3 ){
3099  // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << endl;
3100  binRun++;
3101  }
3102  if (binRun==3) return kFALSE;
3103  Double_t threshold = thresholdEMCalL1[binRun];
3104 
3105  if (isMC && spreadEMCalL1[binRun] != 0.){
3106  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3107  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3108  triggerSmearing->SetParameter(1, thresholdEMCalL1[binRun]);
3109  triggerSmearing->SetParameter(2, spreadEMCalL1[binRun]);
3110  threshold = triggerSmearing->GetRandom();
3111  delete triggerSmearing;
3112  }
3113 
3114 // cout << runnumber << "\t"<< binRun << "\t L1 \t"<< threshold << endl;
3115 
3116  TClonesArray * arrClustersMimic = NULL;
3117  Int_t nclus = 0;
3118  if(!fCorrTaskSetting.CompareTo("")){
3119  nclus = event->GetNumberOfCaloClusters();
3120  } else {
3121  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3122  if(!arrClustersMimic)
3123  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3124  nclus = arrClustersMimic->GetEntries();
3125  }
3126 
3127  if(nclus == 0) return kFALSE;
3128 
3129  // Loop over EMCal clusters
3130  Bool_t eventIsAccepted = kFALSE;
3131  for(Int_t i = 0; i < nclus; i++){
3132  AliVCluster* clus = NULL;
3133  if(event->IsA()==AliESDEvent::Class()){
3134  if(arrClustersMimic)
3135  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3136  else
3137  clus = event->GetCaloCluster(i);
3138  } else if(event->IsA()==AliAODEvent::Class()){
3139  if(arrClustersMimic)
3140  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3141  else
3142  clus = event->GetCaloCluster(i);
3143  }
3144  if (!clus) continue;
3145  if (!clus->IsEMCAL()) continue;
3146  if (clus->GetM02()<0.1) continue;
3147  if (clus->GetNCells()<2) continue;
3148  if (clus->E() > threshold ){
3149 // cout << "found L1G1" << endl;
3150  eventIsAccepted = kTRUE;
3151  }
3152  }
3153  return eventIsAccepted;
3154  } else if ( fSpecialSubTriggerName.CompareTo("7EG2")==0 ||fSpecialSubTriggerName.CompareTo("8EG2")==0 ){
3155  if (runnumber < runRangesEMCalL1G2[0]) return kTRUE;
3156  Int_t binRun = 0;
3157  while (!(runnumber >= runRangesEMCalL1G2[binRun] && runnumber < runRangesEMCalL1G2[binRun+1] ) && binRun < 2 ){
3158  // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << endl;
3159  binRun++;
3160  }
3161  if (binRun==2) return kFALSE;
3162  Double_t threshold = thresholdEMCalL1G2[binRun];
3163  if (isMC && spreadEMCalL1G2[binRun] != 0.){
3164  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3165  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1G2[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3166  triggerSmearing->SetParameter(1, thresholdEMCalL1G2[binRun]);
3167  triggerSmearing->SetParameter(2, spreadEMCalL1G2[binRun]);
3168  threshold = triggerSmearing->GetRandom();
3169  delete triggerSmearing;
3170  }
3171 // cout << runnumber << "\t"<< binRun << "\t L2 \t"<< threshold << endl;
3172 
3173  Int_t nclus = 0;
3174  TClonesArray * arrClustersMimic = NULL;
3175  if(!fCorrTaskSetting.CompareTo("")){
3176  nclus = event->GetNumberOfCaloClusters();
3177  } else {
3178  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3179  if(!arrClustersMimic)
3180  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3181  nclus = arrClustersMimic->GetEntries();
3182  }
3183 
3184  if(nclus == 0) return kFALSE;
3185 
3186  // Loop over EMCal clusters
3187  Bool_t eventIsAccepted = kFALSE;
3188  for(Int_t i = 0; i < nclus; i++){
3189  AliVCluster* clus = NULL;
3190  if(event->IsA()==AliESDEvent::Class()){
3191  if(arrClustersMimic)
3192  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3193  else
3194  clus = event->GetCaloCluster(i);
3195  } else if(event->IsA()==AliAODEvent::Class()){
3196  if(arrClustersMimic)
3197  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3198  else
3199  clus = event->GetCaloCluster(i);
3200  }
3201  if (!clus) continue;
3202  if (!clus->IsEMCAL()) continue;
3203  if (clus->GetM02()<0.1) continue;
3204  if (clus->GetNCells()<2) continue;
3205  if (clus->E() > threshold ){
3206 // cout << "found L1G2" << endl;
3207  eventIsAccepted = kTRUE;
3208  }
3209  }
3210  return eventIsAccepted;
3211  }
3212  return kTRUE;
3213  } else if (fSpecialTrigger == 9 ) {
3214  return kTRUE;
3215  } else {
3216  return kTRUE;
3217  }
3218 
3219  return kTRUE;
3220 }
3221 
3222 
3223 //________________________________________________________________________
3225 {
3226 
3227  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
3228 
3229 
3230  UInt_t isSelected = AliVEvent::kAny;
3231 
3232  if (fInputHandler==NULL) return kFALSE;
3233  if( fInputHandler->GetEventSelection() || event->IsA()==AliAODEvent::Class()) {
3234 
3235  TString firedTrigClass = event->GetFiredTriggerClasses();
3236  // if no trigger has been selected manually, select kAny in case of presel (also important for AOD filtering!)
3237  // in other cases select standards depending on system
3239  if (fPreSelCut) fOfflineTriggerMask = AliVEvent::kAny;
3240  else {
3241  if (fIsHeavyIon == 1){
3242  fOfflineTriggerMask = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
3243  } else if (fIsHeavyIon == 2){
3244  fOfflineTriggerMask = AliVEvent::kINT7;
3245  } else {
3246  fOfflineTriggerMask = AliVEvent::kMB;
3247  }
3248  }
3249  }
3250 
3251  // in case of MC switch to kAny if no MB/INT7/INT8 has been selected
3252  if(isMC){
3253  if( fIsHeavyIon == 0){
3254  if( fOfflineTriggerMask != AliVEvent::kMB && fOfflineTriggerMask != AliVEvent::kINT7 && fOfflineTriggerMask != AliVEvent::kINT8 ){
3255  fOfflineTriggerMask = AliVEvent::kAny;
3256  }
3257  }else{
3258  fOfflineTriggerMask = AliVEvent::kAny;
3259  }
3260  }
3261 
3262  if (fOfflineTriggerMask){
3263  isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
3264  if (isSelected && !fPreSelCut){
3265 // cout << firedTrigClass.Data() << endl;
3266 // cout << "Special trigger: "<< fSpecialTrigger << " initialized " << fEMCALTrigInitialized << endl;
3267 // if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3268 // if (!fEMCALTrigInitialized ) InitializeEMCALTrigger(event);
3269 // fTriggersEMCAL= GetTriggerList();
3270 // }
3271  if (fSpecialSubTrigger>0 && !isMC){
3272  if (!firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 0;
3273  if (fRejectTriggerOverlap){
3274  // trigger rejection EMC1,7,8
3275  if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC7") == 0){
3276  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3277  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC1") == 0){
3278  if (fInputHandler->IsEventSelected() & AliVEvent::kMB) isSelected = 0;
3279  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC8") == 0){
3280  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3281  }
3282  // trigger rejection EGA
3283  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EGA") == 0){
3284  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3285  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3286  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EGA") == 0){
3287  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3288  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3289  }
3290  // trigger rejection EG1 & EG2
3291  if (fPeriodEnum == kLHC13g){
3292  // EG1 is the trigger with the highest threshold
3293  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3294 // cout << firedTrigClass.Data() << endl;
3295  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3296 // cout << "INT7? " << isSelected << endl;
3297  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3298 // cout << "CEM7? " << isSelected << endl;
3299  if (firedTrigClass.Contains("7EG2")) isSelected = 0;
3300 // cout << "7EG2? " << isSelected << endl;
3301  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3302  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3303  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3304  if (firedTrigClass.Contains("8EG2")) isSelected = 0;
3305  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3306 // cout << firedTrigClass.Data() << endl;
3307  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3308 // cout << "INT7? " << isSelected << endl;
3309  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3310 // cout << "CEM7? " << isSelected << endl;
3311  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3312  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3313  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3314  }
3315  } else {
3316  // EG2 is the trigger with the highest threshold
3317  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3318  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3319  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3320  if (firedTrigClass.Contains("7EG1")) isSelected = 0;
3321  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3322  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3323  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3324  if (firedTrigClass.Contains("8EG1")) isSelected = 0;
3325  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3326  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3327  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3328  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3329  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3330  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3331  }
3332  }
3333  }
3334  if (isSelected != 0 ){
3335 // cout << "I am here" << " :" << fSpecialSubTriggerName.Data() <<endl;
3336  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9 ){
3338  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassesCorrelated->Fill(0);
3339  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassesCorrelated->Fill(1);
3340  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassesCorrelated->Fill(2);
3341  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassesCorrelated->Fill(3);
3342  if (firedTrigClass.Contains("7EJE") || firedTrigClass.Contains("8EJE")) hTriggerClassesCorrelated->Fill(4);
3343  if (firedTrigClass.Contains("7EJ1") || firedTrigClass.Contains("8EJ1")) hTriggerClassesCorrelated->Fill(5);
3344  if (firedTrigClass.Contains("7EJ2") || firedTrigClass.Contains("8EJ2")) hTriggerClassesCorrelated->Fill(6);
3345  if (firedTrigClass.Contains("7EGA") || firedTrigClass.Contains("8EGA")) hTriggerClassesCorrelated->Fill(7);
3346  if (firedTrigClass.Contains("7EG1") || firedTrigClass.Contains("8EG1")) hTriggerClassesCorrelated->Fill(8);
3347  if (firedTrigClass.Contains("7EG2") || firedTrigClass.Contains("8EG2")) hTriggerClassesCorrelated->Fill(9);
3348  }
3349  }
3350  }
3351 
3352  } else if (isMC){
3353  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3354 // isSelected = 0;
3355 // if (fTriggersEMCAL > 0)cout << "Special Trigger " << fSpecialTrigger << " triggers: " << fTriggersEMCAL << " selected triggers: " << fTriggersEMCALSelected << " run number: " <<event->GetRunNumber()<<endl;
3356 // if (fTriggersEMCAL&fTriggersEMCALSelected){
3357 // cout << "accepted ++++++++++++++++++++" << endl;
3358  isSelected = 1;
3359 // }
3360  }
3361  }
3362  //if for specific centrality trigger selection
3363  if(fSpecialSubTrigger == 1){
3364  if(fSpecialSubTriggerName.Contains("|") && GetCentrality(event) <= 10.){
3365  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("|");
3366  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3367  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3368  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3369  }
3370  } else if(fSpecialSubTriggerName.Contains("%")){
3371  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("%");
3372  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3373  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3374  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3375  }
3376  } else if(fSpecialSubTriggerName.Contains("@")){
3377  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("@");
3378  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3379  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3380  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3381  }
3382  } else if(fSpecialSubTriggerName.Contains("&")){ //logic AND of two classes
3383  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("&");
3384  TString CheckClass = "";
3385  for (Int_t i=0; i<ClassesList->GetEntriesFast(); i++){
3386  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3387  if (firedTrigClass.Contains(NameClass->GetString())) CheckClass+="1";
3388  else CheckClass+="0";
3389  }
3390  if(CheckClass.Contains("0")) isSelected = 0;
3391  }
3392  else if(firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 1;
3393  }
3394  }
3395  }
3396  }
3397  fIsSDDFired = !(fInputHandler->IsEventSelected() & AliVEvent::kFastOnly);
3398 
3399  Bool_t mimickedTrigger = kTRUE;
3400  if (fMimicTrigger) mimickedTrigger = MimicTrigger(event, isMC);
3401 // cout << "mimicked decision \t" << mimickedTrigger << "expect decision? "<< fMimicTrigger<< endl;
3402 
3403  // Fill Histogram
3404  if(hTriggerClass){
3405  if (fIsSDDFired) hTriggerClass->Fill(33);
3406  if (mimickedTrigger){
3407  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
3408  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
3409  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
3410  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClass->Fill(3);
3411  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClass->Fill(4);
3412  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
3413  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
3414  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
3415  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
3416  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
3417  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
3418  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClass->Fill(8);
3419  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClass->Fill(9);
3420  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClass->Fill(9);
3421  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClass->Fill(10);
3422  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClass->Fill(10);
3423  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClass->Fill(11);
3424  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClass->Fill(12);
3425  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClass->Fill(13);
3426  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClass->Fill(13);
3427  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClass->Fill(13);
3428  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClass->Fill(14);
3429  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClass->Fill(15);
3430  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClass->Fill(16);
3431  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClass->Fill(17);
3432  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClass->Fill(18);
3433  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClass->Fill(19);
3434  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClass->Fill(20);
3435  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClass->Fill(20);
3436  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClass->Fill(21);
3437  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClass->Fill(22);
3438  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClass->Fill(23);
3439  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClass->Fill(24);
3440  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClass->Fill(25);
3441  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClass->Fill(26);
3442  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClass->Fill(27);
3443  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClass->Fill(28);
3444  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(29);
3445  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(30);
3446  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(31);
3447  if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(34);
3448  }
3449  if (mimickedTrigger && fMimicTrigger) hTriggerClass->Fill(35);
3450  }
3451 
3452  if(hTriggerClassSelected && isSelected){
3453  if (mimickedTrigger){
3454  if (!fIsSDDFired) hTriggerClassSelected->Fill(33);
3455  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
3456  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
3457  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
3458  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
3459  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
3460  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
3461  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
3462  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
3463  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
3464  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
3465  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
3466  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
3467  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
3468  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
3469  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
3470  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
3471  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
3472  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
3473  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
3474  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
3475  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
3476  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
3477  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
3478  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
3479  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
3480  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
3481  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
3482  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
3483  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
3484  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
3485  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
3486  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
3487  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
3488  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
3489  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
3490  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
3491  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClassSelected->Fill(28);
3492  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(29);
3493  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(30);
3494  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(31);
3495  }
3496  if (mimickedTrigger && fMimicTrigger) hTriggerClassSelected->Fill(34);
3497  }
3498 
3499  if(!isSelected)return kFALSE;
3500  if (fMimicTrigger)
3501  if (!mimickedTrigger ) return kFALSE;
3502  return kTRUE;
3503 
3504 }
3505 
3506 //________________________________________________________________________
3508  // returns TString with current cut number
3509  return fCutStringRead;
3510 }
3511 
3512 //________________________________________________________________________
3513 void AliConvEventCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliVEvent *event){
3514 
3515  if(fNotRejectedStart){
3516  delete[] fNotRejectedStart;
3517  fNotRejectedStart = NULL;
3518  }
3519  if(fNotRejectedEnd){
3520  delete[] fNotRejectedEnd;
3521  fNotRejectedEnd = NULL;
3522  }
3523  if(fGeneratorNames){
3524  delete[] fGeneratorNames;
3525  fGeneratorNames = NULL;
3526  }
3527 
3528  if(rejection == 0) return; // No Rejection
3529 
3530  AliGenCocktailEventHeader *cHeader = 0x0;
3531  AliAODMCHeader *cHeaderAOD = 0x0;
3532  Bool_t headerFound = kFALSE;
3533  AliMCEvent *fMCEvent = 0x0;
3534  TClonesArray *fMCEventAOD = 0x0;
3535  if(event->IsA()==AliMCEvent::Class()){
3536  if(dynamic_cast<AliMCEvent*>(event)){
3537  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(dynamic_cast<AliMCEvent*>(event)->GenEventHeader());
3538  fMCEvent = dynamic_cast<AliMCEvent*>(event);
3539  if(cHeader) headerFound = kTRUE;
3540  }
3541  }
3542  if(event->IsA()==AliAODEvent::Class()){ // event is a AODEvent in case of AOD
3543  cHeaderAOD = dynamic_cast<AliAODMCHeader*>(event->FindListObject(AliAODMCHeader::StdBranchName()));
3544  fMCEventAOD = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
3545  if(cHeaderAOD) headerFound = kTRUE;
3546  }
3547 
3548  if (fDebugLevel > 0 ) cout << "event starts here" << endl;
3549  if(headerFound){
3550  TList *genHeaders = 0x0;
3551  if(cHeader) genHeaders = cHeader->GetHeaders();
3552  if(cHeaderAOD){
3553  genHeaders = cHeaderAOD->GetCocktailHeaders();
3554  if(genHeaders->GetEntries()==1){
3556  return;
3557  }
3558  }
3559  AliGenEventHeader* gh = 0;
3560  fnHeaders = 0;
3561  Int_t firstindexA = 0;
3562  Int_t lastindexA = -1;
3563  if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
3564  if(rejection == 2){ // TList of Headers Names
3565  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3566  gh = (AliGenEventHeader*)genHeaders->At(i);
3567  TString GeneratorName = gh->GetName();
3568  lastindexA = lastindexA + gh->NProduced();
3569  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
3570  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
3571  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
3572  if (fDebugLevel > 0 ) cout << GeneratorInList.Data() << endl;
3573  if(GeneratorInList.Contains(GeneratorName) ){
3574  if (fDebugLevel > 0 ) cout << "accepted" << endl;
3575  if (GeneratorInList.BeginsWith("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
3576  if(fMCEvent){
3577  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
3578  if (fDebugLevel > 2 )cout << "number of produced particle: " << gh->NProduced() << endl;
3579  if (fDebugLevel > 2 )cout << "pdg-code of first particle: " << fMCEvent->Particle(firstindexA)->GetPdgCode() << endl;
3580  if (fMCEvent->Particle(firstindexA)->GetPdgCode() == fAddedSignalPDGCode ) {
3581  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindexA+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
3582  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3583  fnHeaders++;
3584  continue;
3585  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
3586  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
3587  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3588  fnHeaders++;
3589  continue;
3590  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
3591  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
3592  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3593  fnHeaders++;
3594  continue;
3595 
3596  }
3597  continue;
3598  }
3599  } else {
3600  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
3601  fnHeaders++;
3602  continue;
3603  }
3604  }
3605  if ( fMCEventAOD){
3606  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA));
3607  if (aodMCParticle && (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c) ){
3608  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
3609  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0){
3610  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA+10));
3611  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
3612  if (fDebugLevel > 0 ) cout << "cond 1: " << fnHeaders << endl;
3613  fnHeaders++;
3614  continue;
3615  }
3616  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
3617  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
3618  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3619  fnHeaders++;
3620  continue;
3621  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
3622  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
3623  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3624  fnHeaders++;
3625  continue;
3626 
3627  }
3628  continue;
3629  }
3630  } else {
3631  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
3632  fnHeaders++;
3633  continue;
3634  }
3635  }
3636  continue;
3637  }
3638  if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
3639  if (fDebugLevel > 0 ) cout << "cond 3: "<< fnHeaders << endl;
3640  fnHeaders++;
3641  continue;
3642  }
3643  }
3644  }
3645  firstindexA = firstindexA + gh->NProduced();
3646  }
3647  }
3648  if (fDebugLevel > 0 ) cout << "number of headers: " <<fnHeaders << endl;
3649 
3653 
3654  if(rejection == 1 || rejection == 3){
3655  fNotRejectedStart[0] = 0;
3656  fNotRejectedEnd[0] = ((AliGenEventHeader*)genHeaders->At(0))->NProduced()-1;
3657  fGeneratorNames[0] = ((AliGenEventHeader*)genHeaders->At(0))->GetName();
3658  if (fDebugLevel > 0 ) cout << 0 << "\t" <<fGeneratorNames[0] << "\t" << fNotRejectedStart[0] << "\t" <<fNotRejectedEnd[0] << endl;
3659  return;
3660  }
3661 
3662  Int_t firstindex = 0;
3663  Int_t lastindex = -1;
3664  Int_t number = 0;
3665 
3666  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3667  gh = (AliGenEventHeader*)genHeaders->At(i);
3668  TString GeneratorName = gh->GetName();
3669  lastindex = lastindex + gh->NProduced();
3670  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
3671  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
3672  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
3673  if(GeneratorInList.Contains(GeneratorName) ){
3674  if (GeneratorInList.Contains("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
3675  if(fMCEvent){
3676  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
3677  if (fMCEvent->Particle(firstindex)->GetPdgCode() == fAddedSignalPDGCode ) {
3678  if (fDebugLevel > 0 ) cout << "produced " << gh->NProduced() << " with box generator" << endl;
3679  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindex+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
3680  if (fDebugLevel > 0 ) cout << "one of them was a pi0 or eta" << endl;
3681  fNotRejectedStart[number] = firstindex;
3682  fNotRejectedEnd[number] = lastindex;
3683  fGeneratorNames[number] = GeneratorName;
3684  number++;
3685  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3686  continue;
3687  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
3688  fNotRejectedStart[number] = firstindex;
3689  fNotRejectedEnd[number] = lastindex;
3690  fGeneratorNames[number] = GeneratorName;
3691  number++;
3692  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3693  continue;
3694  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
3695  fNotRejectedStart[number] = firstindex;
3696  fNotRejectedEnd[number] = lastindex;
3697  fGeneratorNames[number] = GeneratorName;
3698  number++;
3699  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3700  continue;
3701  }
3702  }
3703  continue;
3704  } else {
3705  fNotRejectedStart[number] = firstindex;
3706  fNotRejectedEnd[number] = lastindex;
3707  fGeneratorNames[number] = GeneratorName;
3708  number++;
3709  continue;
3710  }
3711  }
3712  if ( fMCEventAOD){
3713  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex));
3714  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
3715  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
3716  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0) {
3717  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex+10));
3718  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
3719  fNotRejectedEnd[number] = lastindex;
3720  fNotRejectedStart[number] = firstindex;
3721  fGeneratorNames[number] = GeneratorName;
3722  number++;
3723  }
3724  continue;
3725  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
3726  fNotRejectedStart[number] = firstindex;
3727  fNotRejectedEnd[number] = lastindex;
3728  fGeneratorNames[number] = GeneratorName;
3729  number++;
3730  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3731  continue;
3732  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
3733  fNotRejectedStart[number] = firstindex;
3734  fNotRejectedEnd[number] = lastindex;
3735  fGeneratorNames[number] = GeneratorName;
3736  number++;
3737  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3738  continue;
3739  }
3740  continue;
3741  }
3742  } else {
3743  fNotRejectedStart[number] = firstindex;
3744  fNotRejectedEnd[number] = lastindex;
3745  fGeneratorNames[number] = GeneratorName;
3746  number++;
3747  continue;
3748  }
3749  }
3750  continue;
3751  } else if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
3752  fNotRejectedStart[number] = firstindex;
3753  fNotRejectedEnd[number] = lastindex;
3754  fGeneratorNames[number] = GeneratorName;
3755  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3756  number++;
3757  continue;
3758  }
3759 
3760  }
3761  }
3762  firstindex = firstindex + gh->NProduced();
3763  }
3764  if (fDebugLevel > 0 ) {
3765  for (Int_t i = 0; i < number; i++){
3766  cout << i << "\t" <<fGeneratorNames[i] << "\t" << fNotRejectedStart[i] << "\t" <<fNotRejectedEnd[i] << endl;
3767  }
3768  }
3769  } else { // No Cocktail Header Found
3770  fNotRejectedStart = new Int_t[1];
3771  fNotRejectedEnd = new Int_t[1];
3772 
3773  fnHeaders = 1;
3774  fNotRejectedStart[0] = 0;
3775  fNotRejectedEnd[0] = static_cast<AliMCEvent*>(event)->GetNumberOfPrimaries()-1;
3776  if (rejection > 1){
3777  fNotRejectedStart[0] = -1;
3778  fNotRejectedEnd[0] = -1;
3779  }
3780 
3781  fGeneratorNames = new TString[1];
3782  fGeneratorNames[0] = "NoCocktailGeneratorFound";
3783 // SetRejectExtraSignalsCut(0);
3784  }
3785 
3786 }
3787 
3788 //_________________________________________________________________________
3789 Int_t AliConvEventCuts::IsParticleFromBGEvent(Int_t index, AliMCEvent *mcEvent, AliVEvent *InputEvent, Int_t debug ){
3790 
3791  // if (debug > 2 ) cout << index << endl;
3792  if(index < 0) return 0; // No Particle
3793 
3794  Int_t accepted = 0;
3795  if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
3796  if(!mcEvent) return 0; // no mcEvent available, return 0
3797  if(index >= mcEvent->GetNumberOfPrimaries()){ // initial particle is secondary particle
3798  if( ((TParticle*)mcEvent->Particle(index))->GetMother(0) < 0) return 0; // material particle, return 0
3799  return IsParticleFromBGEvent(((TParticle*)mcEvent->Particle(index))->GetMother(0),mcEvent,InputEvent, debug);
3800  }
3801  for(Int_t i = 0;i<fnHeaders;i++){
3802  // if (debug > 2 ) cout << "header " << fGeneratorNames[i].Data() << ":"<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
3803  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
3804  if (debug > 1 ) cout << "accepted:" << index << "\t header " << fGeneratorNames[i].Data() << ": "<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
3805  accepted = 1;
3806  if(i == 0) accepted = 2; // MB Header
3807  }
3808  }
3809  if (debug > 1 && !accepted) cout << "rejected:" << index << endl;
3810  }
3811  else if(InputEvent->IsA()==AliAODEvent::Class()){
3812  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3813  if (AODMCTrackArray){
3814  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
3815  if(!aodMCParticle) return 0; // no particle
3816  if(!aodMCParticle->IsPrimary()){
3817  if( aodMCParticle->GetMother() < 0) return 0;// material particle, return 0
3818  return IsParticleFromBGEvent(aodMCParticle->GetMother(),mcEvent,InputEvent, debug);
3819  }
3820  index = TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index))->GetLabel());
3821  for(Int_t i = 0;i<fnHeaders;i++){
3822  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
3823  accepted = 1;
3824  if(i == 0) accepted = 2; // MB Header
3825  }
3826  }
3827  }
3828  }
3829 
3830  return accepted;
3831 }
3832 
3833 //_________________________________________________________________________
3834 Int_t AliConvEventCuts::IsEventAcceptedByCut(AliConvEventCuts *ReaderCuts, AliVEvent *event, AliMCEvent *mcEvent, Int_t isHeavyIon, Bool_t isEMCALAnalysis){
3835 
3836  Bool_t isMC = kFALSE;
3837  if (mcEvent){isMC = kTRUE;}
3838 
3839  if ( !IsTriggerSelected(event, isMC) )
3840  return 3;
3841 
3842  if( !(IsCentralitySelected(event,mcEvent)))
3843  return 1; // Check Centrality --> Not Accepted => eventQuality = 1
3844 
3845  Bool_t hasV0And = ReaderCuts->HasV0AND();
3846  Bool_t isSDDFired = ReaderCuts->IsSDDFired();
3847 
3848  if( ( (IsSpecialTrigger() == 0 && IsSpecialSubTrigger() == 1) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !isSDDFired && !mcEvent)
3849  //if V0OR with SDD requested or V0AND with SDD request but the SDD has not fired
3850  return 7; // V0 with SDD requested but no fired
3851 
3852  if( ( (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 0) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !hasV0And)
3853  //if V0AND (only) or V0AND with SDD requested but V0AND requested but no fired
3854  return 8; // V0AND requested but no fired
3855 
3856 
3857  if( (IsSpecialTrigger() == 2 || IsSpecialTrigger() == 3) && !isSDDFired && !mcEvent)
3858  return 7; // With SDD requested but no fired
3859 
3860  if( (IsSpecialTrigger() == 1 || IsSpecialTrigger() == 3) && !hasV0And)
3861  return 8; // V0AND requested but no fired
3862 
3863  // Special EMCAL checks due to hardware issues in LHC11a
3864  if (isEMCALAnalysis || IsSpecialTrigger() == 5 || IsSpecialTrigger() == 8 || IsSpecialTrigger() == 9 ){
3865  Int_t runnumber = event->GetRunNumber();
3866  if ((runnumber>=144871) && (runnumber<=146860)) {
3867 
3868  AliVCaloCells *cells = event->GetEMCALCells();
3869  const Short_t nCells = cells->GetNumberOfCells();
3870 
3871  if (event->IsA()==AliESDEvent::Class()) AliAnalysisManager::GetAnalysisManager()->LoadBranch("EMCALCells.");
3872 
3873  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
3874  if (!fInputHandler) return 3;
3875 
3876  // count cells above threshold
3877  Int_t nCellCount[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
3878  for(Int_t iCell=0; iCell<nCells; ++iCell) {
3879  Short_t cellId = cells->GetCellNumber(iCell);
3880  Double_t cellE = cells->GetCellAmplitude(cellId);
3881  Int_t sm = cellId / (24*48);
3882  if (cellE>0.1) ++nCellCount[sm];
3883  }
3884 
3885  Bool_t fIsLedEvent = kFALSE;
3886  if (nCellCount[4] > 100) {
3887  fIsLedEvent = kTRUE;
3888  } else {
3889  if ((runnumber>=146858) && (runnumber<=146860)) {
3890  if ((fInputHandler->IsEventSelected() & AliVEvent::kMB) && (nCellCount[3]>=21))
3891  fIsLedEvent = kTRUE;
3892  else if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC1) && (nCellCount[3]>=35))
3893  fIsLedEvent = kTRUE;
3894  }
3895  }
3896  if (fIsLedEvent) {
3897  return 9;
3898  }
3899  }
3900  }
3901 
3902  // SPD clusters vs tracklets to check for pileup/background
3903  Int_t nClustersLayer0 = event->GetNumberOfITSClusters(0);
3904  Int_t nClustersLayer1 = event->GetNumberOfITSClusters(1);
3905  Int_t nTracklets = event->GetMultiplicity()->GetNumberOfTracklets();
3906  if(hSPDClusterTrackletBackgroundBefore) hSPDClusterTrackletBackgroundBefore->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
3907 
3908 
3909  Double_t distZMax = 0;
3910  if(event->IsA()==AliESDEvent::Class()){
3911  Int_t nPileVert = ((AliESDEvent*)event)->GetNumberOfPileupVerticesSPD();
3912  if (hNPileupVertices) hNPileupVertices->Fill(nPileVert);
3913  if (nPileVert > 0){
3914  for(Int_t i=0; i<nPileVert;i++){
3915  const AliESDVertex* pv= ((AliESDEvent*)event)->GetPileupVertexSPD(i);
3916  Int_t nc2 = pv->GetNContributors();
3917  if(nc2>=3){
3918  Double_t z1 = ((AliESDEvent*)event)->GetPrimaryVertexSPD()->GetZ();
3919  Double_t z2 = pv->GetZ();
3920  Double_t distZ = z2-z1;
3921  if (TMath::Abs(distZMax) < TMath::Abs(distZ) ){
3922  distZMax = distZ;
3923  }
3924  }
3925  }
3926  if (hPileupVertexToPrimZ) hPileupVertexToPrimZ->Fill(distZMax);
3927  }
3928  }
3929  if(GetPastFutureLowBC()!=0 && GetPastFutureHighBC()!=0 ){
3930  if(IsOutOfBunchPileupPastFuture(event))
3931  return 12;
3932  }
3933 
3934  if( isHeavyIon != 2 && GetIsFromPileup()){
3935  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.) ){
3937  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
3938  }
3939  if (fUtils->IsSPDClusterVsTrackletBG(event)){
3941  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
3942  }
3943  }
3944  if(isHeavyIon == 2 && GetIsFromPileup()){
3945  if(fUtils->IsPileUpEvent(event) ){
3947  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
3948  }
3949  if (fUtils->IsSPDClusterVsTrackletBG(event)){
3951  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
3952  }
3953  }
3954 
3956  if( IsPileUpV0MTPCout(event) ){
3957  return 13;
3958  }
3959  }
3960 
3961  if(hCentrality)hCentrality->Fill(GetCentrality(event));
3962 
3963  if(hVertexZ)hVertexZ->Fill(event->GetPrimaryVertex()->GetZ());
3964 // if(hCentralityVsNumberOfPrimaryTracks)
3965 // hCentralityVsNumberOfPrimaryTracks->Fill(GetCentrality(event),
3966 // ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
3967 // ->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks());
3968 
3969  if(fIsHeavyIon == 1){
3970  AliEventplane *EventPlane = event->GetEventplane();
3971  fEventPlaneAngle = EventPlane->GetEventplane("V0",event,2);
3972  if(hEventPlaneAngle)hEventPlaneAngle->Fill(TMath::Abs(fEventPlaneAngle));
3973  }
3974  if(hSPDClusterTrackletBackground) hSPDClusterTrackletBackground->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
3975 
3976  return 0;
3977 }
3978 
3979 
3980 //_________________________________________________________________________
3982 
3983  AliInfo("Inside the GetWeightForCentralityFlattening function");
3984  Double_t centrality = 0.;
3985  //obtain centrality for ESD or AOD
3986  if(!event || event->IsA()==AliESDEvent::Class()){
3987  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
3988  if(esdEvent){
3989  AliCentrality *fESDCentrality=(AliCentrality*)esdEvent->GetCentrality();
3990  if(fDetectorCentrality==0 && fIsHeavyIon==1){
3991  centrality = fESDCentrality->GetCentralityPercentile("V0M"); // default for PbPb
3992  }
3993  }
3994  } else if(event->IsA()==AliAODEvent::Class()){
3995  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
3996  if(aodEvent){
3997  if(aodEvent->GetHeader()){
3998  centrality = ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();
3999  }
4000  }
4001  }
4002 
4003  //Get the maximum vlaue from the reference distribution and interpolated value
4004  Float_t GetValueForWeight = 1.;
4005  Float_t maximum = 1.;
4006  Double_t weightCentrality = 1.;
4007  Bool_t CorrCentrLoop = kFALSE;
4008 
4009  //depending on the value of the flag, flattening in different cent. range
4010  if ( fDoCentralityFlat == 1 && (centrality >= 0. && centrality <= 20.) ){
4011  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4012  maximum = hCentralityNotFlat->GetMaximum();
4013  CorrCentrLoop = kTRUE;
4014  } else if ( fDoCentralityFlat == 8 ){
4015  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4016  maximum = hCentralityNotFlat->GetMaximum();
4017  CorrCentrLoop = kTRUE;
4018  } else {
4019  CorrCentrLoop = kFALSE;
4020  }
4021 
4022  if (CorrCentrLoop && GetValueForWeight != 0. && maximum !=0. && isfinite(GetValueForWeight) && isfinite(maximum) ){
4023  weightCentrality = maximum/GetValueForWeight;
4024  if (!isfinite(GetValueForWeight)) weightCentrality = 1.;
4025  if (!isfinite(weightCentrality)) weightCentrality = 1.;
4026  }
4027 
4028  return weightCentrality;
4029 }
4030 
4031 //_________________________________________________________________________
4033 
4034  Double_t weightMult = 1.;
4035 
4036  Float_t valueMultData = -1.;
4037  Float_t valueMultMC = -1.;
4038 
4039  if (hReweightMultData == NULL || hReweightMultMC == NULL ) return weightMult;
4040 
4041  valueMultData = hReweightMultData->Interpolate(mult);
4042  valueMultMC = hReweightMultMC->Interpolate(mult);
4043 
4044  Float_t relativeErrorMC = hReweightMultMC->GetBinError(hReweightMultMC->FindBin(mult))/hReweightMultMC->GetBinContent(hReweightMultMC->FindBin(mult));
4045  Float_t relativeErrorData = hReweightMultData->GetBinError(hReweightMultData->FindBin(mult))/hReweightMultData->GetBinContent(hReweightMultData->FindBin(mult));
4046 
4047  if (relativeErrorData < 0.2 && relativeErrorMC < 0.2 ){
4048  if (isfinite(valueMultData) && isfinite(valueMultMC) ){
4049  weightMult = valueMultData/valueMultMC;
4050  }
4051  }
4052 
4053  return weightMult;
4054 }
4055 
4056 
4057 
4058 //_________________________________________________________________________
4059 Float_t AliConvEventCuts::GetWeightForMeson(Int_t index, AliMCEvent *mcEvent, AliVEvent *event){
4060  if (!( fPeriodEnum == kLHC13d2 || fPeriodEnum == kLHC13d2b || // LHC10h MCs
4061  fPeriodEnum == kLHC14a1a || fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c || // LHC11h MCs
4062  fPeriodEnum == kLHC13e7 || fPeriodEnum == kLHC13b2_efix || fPeriodEnum == kLHC14b2 || // LHC13bc MCs
4063  fPeriodEnum == kLHC14e2a || fPeriodEnum == kLHC14e2b || fPeriodEnum == kLHC14e2c || // LHC12[a-i] pass 1 MCs
4064  fPeriodEnum == kLHC12f1a || fPeriodEnum == kLHC12f1b || fPeriodEnum == kLHC12i3 // LHC11a MCs
4065  ) ) return 1.;
4066  Int_t kCaseGen = 0;
4067 
4068  if(index < 0) return 0; // No Particle
4069 
4070  if (IsParticleFromBGEvent(index, mcEvent, event)){
4073  kCaseGen = 1;
4074  }
4075  }
4076  if (kCaseGen == 0) return 1;
4077 
4078  Double_t mesonPt = 0;
4079  //Double_t mesonMass = 0;
4080  Int_t PDGCode = 0;
4081  if(!event || event->IsA()==AliESDEvent::Class()){
4082  mesonPt = ((TParticle*)mcEvent->Particle(index))->Pt();
4083  //mesonMass = ((TParticle*)mcEvent->Particle(index))->GetCalcMass();
4084  PDGCode = ((TParticle*)mcEvent->Particle(index))->GetPdgCode();
4085  } else if(event->IsA()==AliAODEvent::Class()){
4086  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4087  if (AODMCTrackArray){
4088  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
4089  mesonPt = aodMCParticle->Pt();
4090  //mesonMass = aodMCParticle->GetCalcMass();
4091  PDGCode = aodMCParticle->GetPdgCode();
4092  } else {
4093  return 1;
4094  }
4095  }
4096 
4097  Float_t functionResultMC = 1.;
4098  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0){
4099  functionResultMC = hReweightMCHistPi0->Interpolate(mesonPt);
4100  }
4101  if ( PDGCode == 221 && fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0){
4102  functionResultMC = hReweightMCHistEta->Interpolate(mesonPt);
4103  }
4104  if ( PDGCode == 310 && fDoReweightHistoMCK0s && hReweightMCHistK0s!= 0x0){
4105  functionResultMC = hReweightMCHistK0s->Interpolate(mesonPt);
4106  }
4107 
4108  Float_t functionResultData = 1;
4109  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && fFitDataPi0!= 0x0){
4110  functionResultData = fFitDataPi0->Eval(mesonPt);
4111  }
4112  if ( PDGCode == 221 && fDoReweightHistoMCEta && fFitDataEta!= 0x0){
4113  functionResultData = fFitDataEta->Eval(mesonPt);
4114  }
4115  if ( PDGCode == 310 && fDoReweightHistoMCK0s && fFitDataK0s!= 0x0){
4116  functionResultData = fFitDataK0s->Eval(mesonPt);
4117  }
4118 
4119  Double_t weight = 1;
4120  if (PDGCode == 111 || PDGCode == 221){
4121  if (functionResultData != 0. && functionResultMC != 0. && isfinite(functionResultData) && isfinite(functionResultMC)){
4122  weight = functionResultData/functionResultMC;
4123  if ( kCaseGen == 3){
4124  if (PDGCode == 111){
4125  if (!(fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0 && PDGCode == 111)){
4126  weight = 1.;
4127  }
4128  }
4129  if (PDGCode == 221){
4130  if (!(fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0 && PDGCode == 221)){
4131  weight = 1.;
4132  }
4133  }
4134  }
4135  if (!isfinite(functionResultData)) weight = 1.;
4136  if (!isfinite(weight)) weight = 1.;
4137  }
4138  } else if (PDGCode == 310 && functionResultMC != 0 && isfinite(functionResultMC)){
4139  weight = functionResultMC;
4140  }
4141  return weight;
4142 }
4143 
4144 
4147 
4148  if( fPeriodEnum == kLHC13bc || // mainly minimum bias
4149  fPeriodEnum == kLHC13de || // mainly triggered
4150  fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus || // MC Pythia 6 (Jet-Jet), anchor LHC13b-e
4151  fPeriodEnum == kLHC13b2_efix || //MC DPMJET, anchr LHC13b+c
4152  fPeriodEnum == kLHC13e7 || //MC HIJING, anchr LHC13b+c
4153  fPeriodEnum == kLHC14b2 //MC HIJING, anchr LHC13b+c
4154  ){
4155  printf(" Gamma Conversion Cuts %s :: pPb Run doing Eta Shift of %f \n\n",(GetCutNumber()).Data(),-0.465);
4156  SetEtaShift(-0.465);
4157  } else if( fPeriodEnum == kLHC13f ) {
4158  printf(" Gamma Conversion Cuts %s :: Pbp Run doing Eta Shift of %f \n\n",(GetCutNumber()).Data(),0.465);
4159  SetEtaShift(+0.465);
4160  }
4161  else printf(" Gamma Conversion Cuts %s :: Automatic Eta Shift requested but Period is not known -> No Shift \n\n",(GetCutNumber()).Data());
4162 }
4163 
4164 //________________________________________________________________________
4165 AliEMCALTriggerPatchInfo* AliConvEventCuts::GetMainTriggerPatch()
4166 {
4167  //get main trigger match; if not known yet, look for it and cache
4168 
4170  return fMainTriggerPatchEMCAL;
4171 
4172  if (!fTriggerPatchInfo) {
4173  AliError(Form("%s: fTriggerPatchInfo not available",GetName()));
4174  return 0;
4175  }
4176 
4177  //number of patches in event
4178  Int_t nPatch = fTriggerPatchInfo->GetEntries();
4179 
4180  //extract main trigger patch
4181  AliEMCALTriggerPatchInfo *patch;
4182  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
4183  patch = (AliEMCALTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
4184  if (patch->IsMainTrigger()) {
4185  fMainTriggerPatchEMCAL = patch;
4186  break;
4187  }
4188  }
4189 
4190  return fMainTriggerPatchEMCAL;
4191 }
4192 
4193 
4194 //________________________________________________________________________
4196 {
4197 // cout << "entered EMCAL trigger initialization" << endl;
4198 
4199  // Init the analysis.
4200  if (fCaloTriggersName.IsNull()){
4201  if (event->IsA()==AliESDEvent::Class()){
4202  fCaloTriggersName = "EMCALTrigger";
4203  } else {
4204  fCaloTriggersName = "emcalTrigger";
4205  }
4206  }
4207 
4208  if (!fCaloTriggersName.IsNull() && !fCaloTriggers) {
4209  fCaloTriggers = dynamic_cast<AliVCaloTrigger*>(event->FindListObject(fCaloTriggersName));
4210  if (!fCaloTriggers) {
4211  AliError(Form("%s: Could not retrieve calo triggers %s!", GetName(), fCaloTriggersName.Data()));
4212  return;
4213  }
4214  }
4215 
4216  if (fCaloTriggerPatchInfoName.IsNull()){
4217  if (event->IsA()==AliESDEvent::Class()){
4218  fCaloTriggerPatchInfoName = "EmcalTriggers";
4219  } else {
4220  fCaloTriggerPatchInfoName = "EmcalTriggers";
4221  }
4222  }
4223 
4224  if (!fCaloTriggerPatchInfoName.IsNull() && !fTriggerPatchInfo) {
4225  fTriggerPatchInfo = GetArrayFromEvent(event, fCaloTriggerPatchInfoName.Data(), "AliEMCALTriggerPatchInfo");
4226  if (!fTriggerPatchInfo) {
4227  AliError(Form("%s: Could not retrieve calo trigger patch info %s!", GetName(), fCaloTriggerPatchInfoName.Data()));
4228  return;
4229  }
4230 
4231  }
4232 
4233  fEMCALTrigInitialized = kTRUE;
4234 }
4235 
4236 //________________________________________________________________________
4238  if (!fTriggerPatchInfo)
4239  return 0;
4240  //number of patches in event
4241  Int_t nPatch = fTriggerPatchInfo->GetEntries();
4242 
4243  //loop over patches to define trigger type of event
4244  Int_t nG1 = 0;
4245  Int_t nG2 = 0;
4246  Int_t nJ1 = 0;
4247  Int_t nJ2 = 0;
4248  Int_t nL0 = 0;
4249  AliEMCALTriggerPatchInfo *patch;
4250 // if (nPatch> 0) {cout << "NEW Triggers in this event*********************************" << endl;}
4251  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
4252  patch = (AliEMCALTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
4253 // cout << "Patch energy: "<<patch->GetPatchE() << "\t ADC counts: " << patch->GetADCAmp() << endl;
4254 // cout << "Phi: " << patch->GetPhiMin() << " - " << patch->GetPhiMax() << " delta phi: " <<TMath::Abs(patch->GetPhiMin()-patch->GetPhiMax())<< endl;
4255 // cout << "Eta: " << patch->GetEtaMin() << " - " << patch->GetEtaMax() << " delta eta: " <<TMath::Abs(patch->GetEtaMin()-patch->GetEtaMax())<< endl;
4256  if (patch->IsGammaHigh()){
4257 // cout << "fired L1GA high" << endl;
4258  nG1++;
4259  }
4260  if (patch->IsGammaLow()){
4261 // cout << "fired L1GA low" << endl;
4262  nG2++;
4263  }
4264  if (patch->IsJetHigh()){
4265 // cout << "fired L1JE high" << endl;
4266  nJ1++;
4267  }
4268  if (patch->IsJetLow()){
4269 // cout << "fired L1JE low" << endl;
4270  nJ2++;
4271  }
4272  if (patch->IsLevel0()){
4273 // cout << "fired L0" << endl;
4274  nL0++;
4275  }
4276 // cout << patch->GetPatchE() << "\t" << patch->GetADCAmp() << "\t" << patch->IsGammaHigh() << "\t" << patch->IsGammaLow()
4277 // << "\t" << patch->IsJetHigh() << "\t" << patch->IsJetLow() << "\t" << patch->IsLevel0()
4278 // << "\t" << patch->GetPhiMin() << "\t" << patch->GetPhiMax() << "\t" << TMath::Abs(patch->GetPhiMin()-patch->GetPhiMax())
4279 // << "\t" << patch->GetEtaMin() << "\t" << patch->GetEtaMax() << "\t" << TMath::Abs(patch->GetEtaMin()-patch->GetEtaMax()) << endl;
4280  }
4281 
4282  if (nPatch > 0){
4283  AliDebug(2, "Patch summary: ");
4284  AliDebug(2, Form("Number of patches: %d", nPatch));
4285  AliDebug(2, Form("Level0: [%d]" ,nL0));
4286  AliDebug(2, Form("Jet: low[%d], high[%d]" ,nJ2, nJ1));
4287  AliDebug(2, Form("Gamma: low[%d], high[%d]" ,nG2, nG1));
4288  }
4289 
4290 // if (nPatch > 0){
4291 // cout << Form("Number of patches: %d", nPatch) << endl;
4292 // cout << Form("Level0: [%d]" ,nL0) << endl;
4293 // cout << Form("Jet: low[%d], high[%d]" ,nJ2, nJ1) << endl;
4294 // cout << Form("Gamma: low[%d], high[%d]" ,nG2, nG1) << endl;
4295 // }
4296 
4297  ULong_t triggers(0);
4298  if (nG1>0)
4299  SETBIT(triggers, kG1);
4300  if (nG2>0)
4301  SETBIT(triggers, kG2);
4302  if (nJ1>0)
4303  SETBIT(triggers, kJ1);
4304  if (nJ2>0)
4305  SETBIT(triggers, kJ2);
4306  if (nL0>0)
4307  SETBIT(triggers, kL0);
4308  return triggers;
4309 }
4310 
4311 //________________________________________________________________________
4313  // Check if event has a given trigger type
4314  if(t == kND){
4315  return fTriggersEMCAL == 0;
4316  }
4317  return TESTBIT(fTriggersEMCAL, int(t));
4318 }
4319 
4320 
4321 //________________________________________________________________________
4322 TClonesArray *AliConvEventCuts::GetArrayFromEvent(AliVEvent* event, const char *name, const char *clname)
4323 {
4324  // Get array from event.
4325 
4326  TClonesArray *arr = 0;
4327  TString sname(name);
4328  if (!sname.IsNull()) {
4329  arr = dynamic_cast<TClonesArray*>(event->FindListObject(sname));
4330  if (!arr) {
4331  AliWarning(Form("%s: Could not retrieve array with name %s!", GetName(), name));
4332  return 0;
4333  }
4334  } else {
4335  return 0;
4336  }
4337 
4338  if (!clname)
4339  return arr;
4340 
4341  TString objname(arr->GetClass()->GetName());
4342  TClass cls(objname);
4343  if (!cls.InheritsFrom(clname)) {
4344  AliWarning(Form("%s: Objects of type %s in %s are not inherited from %s!",
4345  GetName(), cls.GetName(), name, clname));
4346  return 0;
4347  }
4348  return arr;
4349 }
4350 
4351 //_________________________________________________________________________
4352 Bool_t AliConvEventCuts::IsConversionPrimaryESD( AliMCEvent *mcEvent, Long_t eventpos, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ){
4353 
4354  if (eventpos < 0) return kFALSE;
4355  TParticle* particle = (TParticle *)mcEvent->Particle(eventpos);
4356  if (!particle) return kFALSE;
4357  if (TMath::Abs(particle->GetPdgCode()) == 11 ){
4358  if (particle->GetMother(0) != -1){
4359  TParticle* particleMother = (TParticle *)mcEvent->Particle(particle->GetMother(0));
4360  if (particleMother){
4361  if (TMath::Abs(particleMother->GetPdgCode()) == 22)
4362  particle = particleMother;
4363  }
4364  }
4365  }
4366  if (particle->GetMother(0) != -1){
4367  Double_t deltaX = particle->Vx() - prodVtxX;
4368  Double_t deltaY = particle->Vy() - prodVtxY;
4369  Double_t deltaZ = particle->Vz() - prodVtxZ;
4370 
4371  //Double_t realRadius2D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY);
4372  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
4373 
4374 
4375  Bool_t dalitzCand = kFALSE;
4376 
4377  TParticle* firstmother = (TParticle *)mcEvent->Particle(particle->GetMother(0));
4378  if (!firstmother) return kFALSE;
4379  Int_t pdgCodeFirstMother = firstmother->GetPdgCode();
4380  Bool_t intDecay = kFALSE;
4381  if ( pdgCodeFirstMother == 111 || pdgCodeFirstMother == 221 ) intDecay = kTRUE;
4382  if ( intDecay && TMath::Abs(particle->GetPdgCode()) == 11 ){
4383  dalitzCand = kTRUE;
4384 // cout << "dalitz candidate found" << endl;
4385  }
4386 
4387  Long_t source = particle->GetMother(0);
4388  Bool_t foundExcludedPart = kFALSE;
4389  Bool_t foundShower = kFALSE;
4390  Int_t pdgCodeMotherPrev = 0;
4391  Int_t pdgCodeMotherPPrevMother = 0;
4392  Int_t depth = 0;
4393  if (dalitzCand || realRadius3D < fSecProdBoundary ){
4394 // if (particle->GetPdgCode() == 22){
4395 // cout << endl << endl << "new particle: " << eventpos <<endl;
4396 // cout << particle->GetPdgCode() << "\t" << particle->R() << "\t" << realRadius2D << "\t" << realRadius3D << endl;
4397 // }
4398  while (depth < 20){
4399  TParticle* mother = (TParticle *)mcEvent->Particle(source);
4400  source = mother->GetMother(0);
4401 // if (particle->GetPdgCode() == 22)cout << "eventposition: "<< source << endl;
4402  Int_t pdgCodeMother = mother->GetPdgCode();
4403 // if (particle->GetPdgCode() == 22)cout << "Previous mothers: " << pdgCodeMother << "\t"<< pdgCodeMotherPrev<< "\t" << pdgCodeMotherPPrevMother << endl;
4404  if (pdgCodeMother == pdgCodeMotherPrev && pdgCodeMother == pdgCodeMotherPPrevMother) depth = 20;
4405  if (TMath::Abs(pdgCodeMother) == 11 && TMath::Abs(pdgCodeMotherPrev) == 22 && TMath::Abs(pdgCodeMotherPPrevMother) == 11 ){
4406  foundShower = kTRUE;
4407  depth =20;
4408  }
4409  if (TMath::Abs(pdgCodeMother) == 22 && TMath::Abs(pdgCodeMotherPrev) == 11 && TMath::Abs(pdgCodeMotherPPrevMother) == 22 ){
4410  foundShower = kTRUE;
4411  depth =20;
4412  }
4413 
4414  // particles to be excluded:
4415  // K0s - 310
4416  // K0l - 130
4417  // K+/- - 321
4418  // Lambda - 3122
4419  // Sigma0 - 3212
4420  // Sigma+/- - 3222, 3112
4421  // Cascades - 3322, 3312
4422  if (TMath::Abs(pdgCodeMother) == 310 || TMath::Abs(pdgCodeMother) == 130 || TMath::Abs(pdgCodeMother) == 321 ||
4423  TMath::Abs(pdgCodeMother) == 3122 || TMath::Abs(pdgCodeMother) == 3212 || TMath::Abs(pdgCodeMother) == 3222 ||
4424  TMath::Abs(pdgCodeMother) == 3112 || TMath::Abs(pdgCodeMother) == 3322 || TMath::Abs(pdgCodeMother) == 3312
4425  ) {
4426  foundExcludedPart = kTRUE;
4427  }
4428 // if (particle->GetPdgCode() == 22)cout << mother->GetPdgCode() << "\t" << source << "\t" << foundExcludedPart<< endl;
4429  pdgCodeMotherPPrevMother = pdgCodeMotherPrev;
4430  pdgCodeMotherPrev = pdgCodeMother;
4431  if (source == -1) depth = 20;
4432 
4433 // if (particle->GetPdgCode() == 22)cout << depth << endl;
4434  depth++;
4435  }
4436  }
4437  if (foundExcludedPart){
4438 // if (particle->GetPdgCode() == 22)cout << "This is definitely a secondary, manually excluded" << endl;
4439  return kFALSE;
4440  } else if (dalitzCand && realRadius3D < fSecProdBoundary ){
4441 // if (particle->GetPdgCode() == 22)cout << "This was a decay via a virtual photon" << endl;
4442  return kTRUE;
4443  } else if (foundShower){
4444 // if (particle->GetPdgCode() == 22)cout << "This is a shower" << endl;
4445  return kFALSE;
4446  } else if (realRadius3D >= fSecProdBoundary){
4447 // cout << "This is a secondary, to large production radius" << endl;
4448  return kFALSE;
4449  }
4450  }
4451 
4452  return kTRUE;
4453 }
4454 
4455 //_________________________________________________________________________
4456 Bool_t AliConvEventCuts::IsConversionPrimaryAOD(AliVEvent *event, AliAODMCParticle* AODMCParticle, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ){
4457 
4458  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4459  if (AODMCTrackArray == NULL) return kFALSE;
4460  AliAODMCParticle* currentParticle = AODMCParticle;
4461  if (TMath::Abs(currentParticle->GetPdgCode()) == 11 ){
4462  if (currentParticle->GetMother() != -1){
4463  AliAODMCParticle* particleMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(currentParticle->GetMother()));
4464  if (particleMother){
4465  if (TMath::Abs(particleMother->GetPdgCode()) == 22)
4466  currentParticle = particleMother;
4467  }
4468  }
4469  }
4470  if (currentParticle->GetMother() > -1){
4471  Double_t deltaX = currentParticle->Xv() - prodVtxX;
4472  Double_t deltaY = currentParticle->Yv() - prodVtxY;
4473  Double_t deltaZ = currentParticle->Zv() - prodVtxZ;
4474 
4475  //Double_t realRadius2D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY);
4476  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
4477 
4478  Bool_t dalitzCand = kFALSE;
4479 
4480  AliAODMCParticle* firstmother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(currentParticle->GetMother()));
4481  if (!firstmother) return kFALSE;
4482  Int_t pdgCodeFirstMother = firstmother->GetPdgCode();
4483  Bool_t intDecay = kFALSE;
4484  if ( pdgCodeFirstMother == 111 || pdgCodeFirstMother == 221 ) intDecay = kTRUE;
4485  if ( intDecay && TMath::Abs(currentParticle->GetPdgCode()) == 11 ){
4486  dalitzCand = kTRUE;
4487 // cout << "dalitz candidate found" << endl;
4488  }
4489 
4490  Long_t source = currentParticle->GetMother();
4491  Bool_t foundExcludedPart = kFALSE;
4492  Bool_t foundShower = kFALSE;
4493  Int_t pdgCodeMotherPrev = 0;
4494  Int_t pdgCodeMotherPPrevMother = 0;
4495  Int_t depth = 0;
4496  if (dalitzCand || realRadius3D < fSecProdBoundary ){
4497 // if (currentParticle->GetPdgCode() == 22){
4498 // cout << endl << endl << "new particle: " << eventpos <<endl;
4499 // cout << currentParticle->GetPdgCode() << "\t" << currentParticle->R() << "\t" << realRadius2D << "\t" << realRadius3D << endl;
4500 // }
4501  while (depth < 20){
4502  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(source));
4503  source = mother->GetMother();
4504 // if (currentParticle->GetPdgCode() == 22)cout << "eventposition: "<< source << endl;
4505  Int_t pdgCodeMother = mother->GetPdgCode();
4506 // if (currentParticle->GetPdgCode() == 22)cout << "Previous mothers: " << pdgCodeMother << "\t"<< pdgCodeMotherPrev<< "\t" << pdgCodeMotherPPrevMother << endl;
4507  if (pdgCodeMother == pdgCodeMotherPrev && pdgCodeMother == pdgCodeMotherPPrevMother) depth = 20;
4508  if (TMath::Abs(pdgCodeMother) == 11 && TMath::Abs(pdgCodeMotherPrev) == 22 && TMath::Abs(pdgCodeMotherPPrevMother) == 11 ){
4509  foundShower = kTRUE;
4510  depth =20;
4511  }
4512  if (TMath::Abs(pdgCodeMother) == 22 && TMath::Abs(pdgCodeMotherPrev) == 11 && TMath::Abs(pdgCodeMotherPPrevMother) == 22 ){
4513  foundShower = kTRUE;
4514  depth =20;
4515  }
4516 
4517  // particles to be excluded:
4518  // K0s - 310
4519  // K0l - 130
4520  // K+/- - 321
4521  // Lambda - 3122
4522  // Sigma0 - 3212
4523  // Sigma+/- - 3222, 3112
4524  // Cascades - 3322, 3312
4525  if (TMath::Abs(pdgCodeMother) == 310 || TMath::Abs(pdgCodeMother) == 130 || TMath::Abs(pdgCodeMother) == 321 ||
4526  TMath::Abs(pdgCodeMother) == 3122 || TMath::Abs(pdgCodeMother) == 3212 || TMath::Abs(pdgCodeMother) == 3222 ||
4527  TMath::Abs(pdgCodeMother) == 3112 || TMath::Abs(pdgCodeMother) == 3322 || TMath::Abs(pdgCodeMother) == 3312)
4528  {
4529  foundExcludedPart = kTRUE;
4530  }
4531 // if (currentParticle->GetPdgCode() == 22)cout << mother->GetPdgCode() << "\t" << source << "\t" << foundExcludedPart<< endl;
4532  pdgCodeMotherPPrevMother = pdgCodeMotherPrev;
4533  pdgCodeMotherPrev = pdgCodeMother;
4534  if (source == -1) depth = 20;
4535 
4536 // if (currentParticle->GetPdgCode() == 22)cout << depth << endl;
4537  depth++;
4538  }
4539  }
4540  if (foundExcludedPart){
4541 // if (currentParticle->GetPdgCode() == 22)cout << "This is definitely a secondary, manually excluded" << endl;
4542  return kFALSE;
4543  } else if (dalitzCand && realRadius3D < fSecProdBoundary ){
4544 // if (currentParticle->GetPdgCode() == 22)cout << "This was a decay via a virtual photon" << endl;
4545  return kTRUE;
4546  } else if (foundShower){
4547 // if (currentParticle->GetPdgCode() == 22)cout << "This is a shower" << endl;
4548  return kFALSE;
4549  } else if (realRadius3D >= fSecProdBoundary){
4550 // cout << "This is a secondary, too large production radius" << endl;
4551  return kFALSE;
4552  }
4553  }
4554 
4555  return kTRUE;
4556 }
4557 
4558 
4559 //________________________________________________________________________
4560 Int_t AliConvEventCuts::SecondaryClassificationPhoton( TParticle *particle, AliMCEvent* mcEvent, Bool_t isConversion ){
4561  if (particle != NULL && mcEvent != NULL){
4562  Int_t pdgSecondary = 0;
4563  if (!isConversion){
4564  //Bool_t hasMother = kFALSE;
4565  //Bool_t hasGrandMother = kFALSE;
4566  Long_t motherID = particle->GetMother(0);
4567  Long_t grandMotherID = -1;
4568  // is the photon a direct photons, without a mother?
4569  if (motherID > -1){
4570  //hasMother = kTRUE;
4571  grandMotherID = mcEvent->Particle(motherID)->GetMother(0);
4572  // is the meson a primary?
4573  if (grandMotherID > -1){
4574  //hasGrandMother = kTRUE;
4575  pdgSecondary = mcEvent->Particle(grandMotherID)->GetPdgCode();
4576  }
4577  }
4578  } else {
4579  //Bool_t hasMother = kFALSE;
4580  //Bool_t hasGrandMother = kFALSE;
4581  //Bool_t hasGreatGrandMother = kFALSE;
4582  Long_t motherID = particle->GetMother(0);
4583  Long_t grandMotherID = -1;
4584  Long_t greatGrandMotherID = -1;
4585  // is the electron a direct electron, without a mother?
4586  if (motherID > -1){
4587  //hasMother = kTRUE;
4588  grandMotherID = mcEvent->Particle(motherID)->GetMother(0);
4589  // is the photon a direct photons, without a mother?
4590  if (grandMotherID > -1){
4591  //hasGrandMother = kTRUE;
4592  greatGrandMotherID = mcEvent->Particle(grandMotherID)->GetMother(0);
4593  // is the meson a primary?
4594  if (greatGrandMotherID > -1){
4595  //hasGreatGrandMother = kTRUE;
4596  pdgSecondary = mcEvent->Particle(greatGrandMotherID)->GetPdgCode();
4597  }
4598  }
4599  }
4600  }
4601  // is the secondary photon from a lambda
4602  if (TMath::Abs(pdgSecondary) == 3122 )
4603  return 3;
4604  // is the secondary photon from a K0s
4605  else if ( TMath::Abs(pdgSecondary) == 310 )
4606  return 2;
4607  // is the secondary photon from a K0l
4608  else if ( TMath::Abs(pdgSecondary) == 130 )
4609  return 5;
4610  // is the secondary photon from a eta
4611  else if ( TMath::Abs(pdgSecondary) == 221 )
4612  return 4;
4613  // is the secondary photon from something else
4614  else if ( TMath::Abs(pdgSecondary) != 0 )
4615  return 1;
4616 
4617  }
4618 
4619  return 0;
4620 }
4621 
4622 //________________________________________________________________________
4623 Int_t AliConvEventCuts::SecondaryClassificationPhotonAOD( AliAODMCParticle *particle, TClonesArray *aodmcArray, Bool_t isConversion ){
4624  if (particle != NULL && aodmcArray != NULL){
4625  Int_t pdgSecondary = 0;
4626  if (!isConversion){
4627  //Bool_t hasMother = kFALSE;
4628  //Bool_t hasGrandMother = kFALSE;
4629  Long_t motherID = particle->GetMother();
4630  Long_t grandMotherID = -1;
4631  // is the photon a direct photons, without a mother?
4632  if (motherID > -1){
4633  //hasMother = kTRUE;
4634  grandMotherID = ((AliAODMCParticle*)aodmcArray->At(motherID))->GetMother();
4635  // is the meson a primary?
4636  if (grandMotherID > -1){
4637  //hasGrandMother = kTRUE;
4638  pdgSecondary = ((AliAODMCParticle*)aodmcArray->At(grandMotherID))->GetPdgCode();
4639  }
4640  }
4641  } else {
4642  //Bool_t hasMother = kFALSE;
4643  //Bool_t hasGrandMother = kFALSE;
4644  //Bool_t hasGreatGrandMother = kFALSE;
4645  Long_t motherID = particle->GetMother();
4646  Long_t grandMotherID = -1;
4647  Long_t greatGrandMotherID = -1;
4648  // is the electron a direct electron, without a mother?
4649  if (motherID > -1){
4650  //hasMother = kTRUE;
4651  grandMotherID = ((AliAODMCParticle*)aodmcArray->At(motherID))->GetMother();
4652  // is the photon a direct photons, without a mother?
4653  if (grandMotherID > -1){
4654  //hasGrandMother = kTRUE;
4655  greatGrandMotherID = ((AliAODMCParticle*)aodmcArray->At(grandMotherID))->GetMother();
4656  // is the meson a primary?
4657  if (greatGrandMotherID > -1){
4658  //hasGreatGrandMother = kTRUE;
4659  pdgSecondary = ((AliAODMCParticle*)aodmcArray->At(greatGrandMotherID))->GetPdgCode();
4660  }
4661  }
4662  }
4663  }
4664  // is the secondary photon from a lambda
4665  if (TMath::Abs(pdgSecondary) == 3122 )
4666  return 3;
4667  // is the secondary photon from a K0s
4668  else if ( TMath::Abs(pdgSecondary) == 310 )
4669  return 2;
4670  // is the secondary photon from a K0l
4671  else if ( TMath::Abs(pdgSecondary) == 130 )
4672  return 5;
4673  // is the secondary photon from a eta
4674  else if ( TMath::Abs(pdgSecondary) == 221 )
4675  return 4;
4676  // is the secondary photon from something else
4677  else if ( TMath::Abs(pdgSecondary) != 0 )
4678  return 1;
4679 
4680  }
4681 
4682  return 0;
4683 }
4684 
4686 
4687  if (periodName.CompareTo("") == 0){
4688  periodName = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPeriodName();
4689  }
4690  if (periodName.CompareTo("") == 0) {
4692  fEnergyEnum = kUnset;
4693  AliError("No correct period could be set, periodName string empty");
4694  return;
4695  }
4696 
4697  // Data
4698  if (periodName.CompareTo("LHC10b") == 0 || periodName.CompareTo("LHC10c") == 0 || periodName.CompareTo("LHC10d") == 0 || periodName.CompareTo("LHC10e") == 0 ||
4699  periodName.CompareTo("LHC10f") == 0 || periodName.CompareTo("LHC10g") == 0 || periodName.CompareTo("LHC10bg") == 0
4700  ){
4702  fEnergyEnum = k7TeV;
4703  } else if (periodName.CompareTo("LHC10h") == 0) {
4704  fPeriodEnum = kLHC10h;
4706  } else if (periodName.CompareTo("LHC11a") == 0) {
4707  fPeriodEnum = kLHC11a;
4709  } else if (periodName.CompareTo("LHC11b") == 0) {
4710  fPeriodEnum = kLHC11b;
4711  fEnergyEnum = k7TeV;
4712  } else if (periodName.CompareTo("LHC11c") == 0 || periodName.CompareTo("LHC11d") == 0 || periodName.CompareTo("LHC11e") == 0 || periodName.CompareTo("LHC11f") == 0 ||
4713  periodName.CompareTo("LHC11g") == 0
4714  ) {
4716  fEnergyEnum = k7TeV;
4717  } else if (periodName.CompareTo("LHC11h") == 0) {
4718  fPeriodEnum = kLHC11h;
4720  } else if (periodName.CompareTo("LHC12a") == 0 || periodName.CompareTo("LHC12b") == 0 || periodName.CompareTo("LHC12c") == 0 || periodName.CompareTo("LHC12d") == 0 ||
4721  periodName.CompareTo("LHC12e") == 0 || periodName.CompareTo("LHC12f") == 0 || periodName.CompareTo("LHC12g") == 0 || periodName.CompareTo("LHC12h") == 0 ||
4722  periodName.CompareTo("LHC12i") == 0 || periodName.CompareTo("LHC12ai") == 0
4723  ) {
4724  fPeriodEnum = kLHC12;
4725  fEnergyEnum = k8TeV;
4726  } else if (periodName.CompareTo("LHC13b") == 0 || periodName.CompareTo("LHC13c") == 0 || periodName.CompareTo("LHC13bc") == 0){
4729  } else if (periodName.CompareTo("LHC13d") == 0 || periodName.CompareTo("LHC13e") == 0 || periodName.CompareTo("LHC13de") == 0){
4732  } else if (periodName.CompareTo("LHC13f") == 0 ){
4733  fPeriodEnum = kLHC13f;
4735  } else if (periodName.CompareTo("LHC13g") == 0 ){
4736  fPeriodEnum = kLHC13g;
4738  } else if ( periodName.CompareTo("LHC15f") == 0 || periodName.CompareTo("LHC15g") == 0 || periodName.CompareTo("LHC15h") == 0 || periodName.CompareTo("LHC15i") == 0 ||
4739  periodName.CompareTo("LHC15j") == 0 || periodName.CompareTo("LHC15k") == 0 || periodName.CompareTo("LHC15l") == 0 || periodName.CompareTo("LHC15m") == 0 ||
4740  periodName.CompareTo("LHC15fm") == 0
4741  ) {
4743  fEnergyEnum = k13TeV;
4744  } else if (periodName.CompareTo("LHC15n") == 0 ){
4745  fPeriodEnum = kLHC15n;
4746  fEnergyEnum = k5TeV;
4747  } else if (periodName.CompareTo("LHC15o") == 0 ){
4748  fPeriodEnum = kLHC15o;
4750  } else if ( periodName.CompareTo("LHC16d") == 0 || periodName.CompareTo("LHC16e") == 0 || periodName.CompareTo("LHC16g") == 0 || periodName.CompareTo("LHC16h") == 0 ||
4751  periodName.CompareTo("LHC16i") == 0 || periodName.CompareTo("LHC16j") == 0 || periodName.CompareTo("LHC16k") == 0 || periodName.CompareTo("LHC16l") == 0 ||
4752  periodName.CompareTo("LHC16m") == 0 || periodName.CompareTo("LHC16n") == 0 || periodName.CompareTo("LHC16o") == 0 || periodName.CompareTo("LHC16p") == 0){
4754  fEnergyEnum = k13TeV;
4755  } else if (periodName.CompareTo("LHC16f") == 0 ){
4758  } else if (periodName.CompareTo("LHC16q") == 0 ){
4759  fPeriodEnum = kLHC16q;
4761  } else if (periodName.CompareTo("LHC16r") == 0 ){
4762  fPeriodEnum = kLHC16r;
4764  } else if (periodName.CompareTo("LHC16s") == 0 ){
4765  fPeriodEnum = kLHC16s;
4767  } else if (periodName.CompareTo("LHC16t") == 0 ){
4768  fPeriodEnum = kLHC16t;
4770  } else if ( periodName.CompareTo("LHC17c") == 0 || periodName.CompareTo("LHC17d") == 0 || periodName.CompareTo("LHC17e") == 0 || periodName.CompareTo("LHC17f") == 0 ||
4771  periodName.CompareTo("LHC17h") == 0 || periodName.CompareTo("LHC17i") == 0 || periodName.CompareTo("LHC17j") == 0 || periodName.CompareTo("LHC17k") == 0 ||
4772  periodName.CompareTo("LHC17l") == 0 || periodName.CompareTo("LHC17m") == 0 || periodName.CompareTo("LHC17o") == 0 ){
4774  fEnergyEnum = k13TeV;
4775  } else if ( periodName.CompareTo("LHC17g") == 0 ){
4778  } else if ( periodName.CompareTo("LHC17n") == 0 ){
4779  fPeriodEnum = kLHC17n;
4781  } else if ( periodName.CompareTo("LHC17p") == 0 ){
4782  fPeriodEnum = kLHC17p;
4783  fEnergyEnum = k5TeV;
4784  } else if ( periodName.CompareTo("LHC17q") == 0 ){
4785  fPeriodEnum = kLHC17q;
4786  fEnergyEnum = k5TeV;
4787 
4788  // LHC10x anchored MCs
4789  } else if (periodName.CompareTo("LHC10d1") == 0){
4791  fEnergyEnum = k7TeV;
4792  } else if (periodName.CompareTo("LHC10d2") == 0){
4794  fEnergyEnum = k7TeV;
4795  } else if (periodName.CompareTo("LHC10d4a") == 0){
4797  fEnergyEnum = k7TeV;
4798  } else if (periodName.CompareTo("LHC10d4") == 0){
4800  fEnergyEnum = k7TeV;
4801  } else if (periodName.CompareTo("LHC10e12") == 0){
4803  fEnergyEnum = k900GeV;
4804  } else if (periodName.CompareTo("LHC10e13") == 0){
4806  fEnergyEnum = k900GeV;
4807  } else if (periodName.CompareTo("LHC10e20") == 0){
4809  fEnergyEnum = k7TeV;
4810  } else if (periodName.CompareTo("LHC10e21") == 0){
4812  fEnergyEnum = k7TeV;
4813  } else if (periodName.CompareTo("LHC10f6a") == 0){
4815  fEnergyEnum = k7TeV;
4816  } else if (periodName.CompareTo("LHC10f6") == 0){
4818  fEnergyEnum = k7TeV;
4819  } else if (periodName.Contains("LHC14j4")){
4821  fEnergyEnum = k7TeV;
4822  } else if (periodName.CompareTo("LHC13d2") == 0){
4825  } else if (periodName.CompareTo("LHC13d2b") == 0){
4828  } else if (periodName.CompareTo("LHC12a11a") == 0){
4831  } else if (periodName.CompareTo("LHC12a11b") == 0){
4834  } else if (periodName.CompareTo("LHC12a11c") == 0){
4837  } else if (periodName.CompareTo("LHC12a11d") == 0){
4840  } else if (periodName.CompareTo("LHC12a11e") == 0){
4843  } else if (periodName.CompareTo("LHC12a11f") == 0){
4846  // LHC11x anchored MCs
4847  } else if (periodName.CompareTo("LHC12a15c") == 0){
4850  } else if (periodName.Contains("LHC12f1a") ){
4853  } else if (periodName.Contains("LHC12f1b") ){
4856  } else if (periodName.Contains("LHC12i3") ){
4859  } else if (periodName.CompareTo("LHC15g1a") == 0){
4862  } else if (periodName.CompareTo("LHC15g1b") == 0){
4865  } else if (periodName.CompareTo("LHC13e4") == 0){
4867  fEnergyEnum = k7TeV;
4868  } else if (periodName.CompareTo("LHC13e5") == 0){
4870  fEnergyEnum = k7TeV;
4871  } else if (periodName.CompareTo("LHC14k1a") == 0){
4873  fEnergyEnum = k7TeV;
4874  } else if (periodName.CompareTo("LHC14k1b") == 0){
4876  fEnergyEnum = k7TeV;
4877  } else if (periodName.CompareTo("LHC12a15f") == 0){
4879  fEnergyEnum = k7TeV;
4880  } else if (periodName.CompareTo("LHC12a15g") == 0){
4882  fEnergyEnum = k7TeV;
4883  } else if (periodName.CompareTo("LHC12f2a") == 0){
4885  fEnergyEnum = k7TeV;
4886  } else if (periodName.CompareTo("LHC14a1a") == 0){
4889  } else if (periodName.CompareTo("LHC14a1b") == 0){
4892  } else if (periodName.CompareTo("LHC14a1c") == 0){
4895  // LHC12x anchored MCs
4896  } else if (periodName.CompareTo("LHC14e2a") == 0){
4898  fEnergyEnum = k8TeV;
4899  } else if (periodName.CompareTo("LHC14e2b") == 0){
4901  fEnergyEnum = k8TeV;
4902  } else if (periodName.CompareTo("LHC14e2c") == 0){
4904  fEnergyEnum = k8TeV;
4905  } else if (periodName.Contains("LHC15h1")){
4907  fEnergyEnum = k8TeV;
4908  } else if (periodName.Contains("LHC15h2")){
4910  fEnergyEnum = k8TeV;
4911  } else if (periodName.CompareTo("LHC16c2") == 0){
4913  fEnergyEnum = k8TeV;
4914  } else if (periodName.CompareTo("LHC16c2_plus") == 0){
4916  fEnergyEnum = k8TeV;
4917  // LHC13x anchored MCs
4918  } else if (periodName.Contains("LHC13b2_efix")){
4921  } else if (periodName.CompareTo("LHC13e7") == 0){
4924  } else if (periodName.CompareTo("LHC14b2") == 0){
4927  } else if (periodName.CompareTo("LHC13b4_fix") == 0){
4930  } else if (periodName.CompareTo("LHC13b4_plus") == 0){
4933  } else if (periodName.CompareTo("LHC16c3a") == 0){
4936  } else if (periodName.CompareTo("LHC16c3b") == 0){
4939  } else if (periodName.CompareTo("LHC16c3c") == 0){