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