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