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