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