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