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