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