AliPhysics  df4bbdf (df4bbdf)
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  } else if (fDetectorCentrality == 2){
1003  printf("\t centrality selection based on ZNA \n");
1004  }
1005  if (fModCentralityClass == 0){
1006  printf("\t %d - %d \n", fCentralityMin*10, fCentralityMax*10);
1007  } else if ( fModCentralityClass == 1){
1008  printf("\t %d - %d \n", fCentralityMin*5, fCentralityMax*5);
1009  } else if ( fModCentralityClass == 2){
1010  printf("\t %d - %d \n", fCentralityMin, fCentralityMax);
1011  } else if (fModCentralityClass == 3){
1012  printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*10, fCentralityMax*10);
1013  } else if ( fModCentralityClass == 4){
1014  printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*5, fCentralityMax*5);
1015  } else if (fModCentralityClass == 5){
1016  printf("\t %d - %d, with overlapping Track mult in MC as data \n", fCentralityMin*10, fCentralityMax*10);
1017  } else if ( fModCentralityClass == 6){
1018  printf("\t %d - %d, with overlapping Track mult in MC as data \n", fCentralityMin*5, fCentralityMax*5);
1019  }
1020  if (fSpecialTrigger == 0){
1021  printf("\t only events triggered by kMB, kCentral, kSemiCentral will be analysed \n");
1022  } else if (fSpecialTrigger > 1){
1023  printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
1024  printf("\n\t SpecialTrigger is: %s\n", fSpecialTriggerName.Data());
1025  printf("\t SpecialSubTrigger is: %s\n", fSpecialSubTriggerName.Data());
1026  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps\n\n");
1027  }
1028  } else if (fIsHeavyIon == 2){
1029  printf("Running in pPb mode \n");
1030  if (fDetectorCentrality == 0){
1031  printf("\t centrality selection based on V0A \n");
1032  } else if (fDetectorCentrality == 1){
1033  printf("\t centrality selection based on Cl1 \n");
1034  } else if (fDetectorCentrality == 2){
1035  printf("\t centrality selection based on ZNA \n");
1036  }
1037  if (fModCentralityClass == 0){
1038  printf("\t %d - %d \n", fCentralityMin*10, fCentralityMax*10);
1039  } else if ( fModCentralityClass == 1){
1040  printf("\t %d - %d \n", fCentralityMin*5, fCentralityMax*5);
1041  } else if ( fModCentralityClass == 2){
1042  printf("\t %d - %d \n", fCentralityMin, fCentralityMax);
1043  }
1044  if (fSpecialTrigger == 0){
1045  printf("\t only events triggered by kINT7 will be analysed \n");
1046  } else if (fSpecialTrigger > 1){
1047  printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
1048  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps\n\n");
1049  }
1050  }
1051  if (fEnableVertexCut) printf("\t Vertex cut with |Z_{vtx}| <%2.2f \n",fMaxVertexZ);
1052  else printf("\t No vertex cut \n");
1053 
1054  if (fRemovePileUp ==1 ) {
1055  printf("\t Doing pile up removal \n");
1056  if (fRemovePileUpSPD ==1 ){
1057  printf("\t Doing pile up removal using SPD \n");
1058  }
1059  if (fDoPileUpRejectV0MTPCout ==1 ){
1060  printf("\t Doing extra pile up removal V0M vs TPCout \n");
1061  }
1063  printf("\t Doing extra past-future pile up removal\n");
1064  }
1065  }
1066 
1067  printf("MC event cuts: \n");
1068  if (fRejectExtraSignals == 0) printf("\t no rejection was applied \n");
1069  else if (fRejectExtraSignals == 1) printf("\t only MB header will be inspected \n");
1070  else if (fRejectExtraSignals == 4) printf("\t special handling for Jets embedded in MB events \n");
1071  else if (fRejectExtraSignals > 1) printf("\t special header have been selected \n");
1072  printf("\t maximum factor between jet and pt hard = %2.2f \n", fMaxFacPtHard);
1073 }
1074 
1077 { // Set Cut
1078  switch(isHeavyIon){
1079  case 0: // pp
1080  fIsHeavyIon=0;
1081  break;
1082  case 1: // V0M PbPb & XeXe
1083  // steps of 10%
1084  fIsHeavyIon=1;
1086  break;
1087  case 2: // CL1 PbPb & XeXe
1088  // steps of 10%
1089  fIsHeavyIon=1;
1091  break;
1092  case 3: // V0M PbPb & XeXe
1093  // steps of 5%
1094  // 0 -0%, 1-5%, 2-10%, 3-15%, 4-20%, 5-25%, 6-30%, 7-35%, 8-40%, 9-45%, a-50%, b-55%, c-60%, d-65%, e-70%, f-75%, g-80%, h-85%, i-90%, j-95%, k-100%
1095  fIsHeavyIon=1;
1098  break;
1099  case 4: // V0M PbPb & XeXe & primary track mult for MC different track array
1100  // steps of 10%
1101  fIsHeavyIon=1;
1104  break;
1105  case 5: // V0M PbPb & XeXe & primary track mult for MC
1106  // steps of 10%
1107  fIsHeavyIon=1;
1110  break;
1111  case 6: // V0M PbPb & XeXe & primary track mult for MC
1112  // steps of 5%
1113  // 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%
1114  fIsHeavyIon=1;
1117  break;
1118  case 7: // V0M PbPb & XeXe & primary track mult for MC different track array
1119  // steps of 5%
1120  // 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%
1121  fIsHeavyIon=1;
1124  break;
1125  case 8: // pPb V0A
1126  // steps of 10%
1127  fIsHeavyIon=2;
1129  break;
1130  case 9: // pPb CL1
1131  // steps of 10%
1132  fIsHeavyIon=2;
1134  break;
1135  case 10: // a: pPb V0A
1136  // steps of 5%
1137  // 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%
1138  fIsHeavyIon=2;
1141  break;
1142  case 11: // b: pPb CL1
1143  // steps of 5%
1144  // 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%
1145  fIsHeavyIon=2;
1148  break;
1149  case 12: // c: pPb V0A
1150  // steps of 1%
1151  // 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%
1152  fIsHeavyIon=2;
1155  break;
1156  case 13: // d: pPb CL1
1157  // steps of 1%
1158  // 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%
1159  fIsHeavyIon=2;
1162  break;
1163  case 14: // e: pPb ZNA
1164  // steps of 10%
1165  fIsHeavyIon=2;
1167  break;
1168  case 15: // f: pPb ZNA
1169  // steps of 5%
1170  // 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%
1171  fIsHeavyIon=2;
1174  break;
1175  case 16: // g: pPb CL1
1176  // steps of 1%
1177  // 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%
1178  fIsHeavyIon=2;
1181  break;
1182 
1183  default:
1184  AliError(Form("SetHeavyIon not defined %d",isHeavyIon));
1185  return kFALSE;
1186  }
1187  return kTRUE;
1188 }
1189 
1190 //___________________________________________________________________
1192 {
1193  // Set Cut
1194  if(minCentrality<0||minCentrality>20){
1195  AliError(Form("minCentrality not defined %d",minCentrality));
1196  return kFALSE;
1197  }
1198 
1199  fCentralityMin=minCentrality;
1200  return kTRUE;
1201 }
1202 
1203 //___________________________________________________________________
1205 {
1206  // Set Cut
1207  if(maxCentrality<0||maxCentrality>20){
1208  AliError(Form("maxCentrality not defined %d",maxCentrality));
1209  return kFALSE;
1210  }
1211  fCentralityMax=maxCentrality;
1212  return kTRUE;
1213 }
1214 
1217 {
1218  // Set Cut
1219  switch(selectSpecialTrigger){
1220  case 0:
1221  fSpecialTrigger=0; // V0OR
1222  break;
1223  case 1:
1224  fSpecialTrigger=1; // V0AND
1225  break;
1226 // case 2:
1227 // fSpecialTrigger=2; //
1228 // break;
1229  case 3:
1230  fSpecialTrigger=3; //specific centrality trigger selection
1231  fSpecialTriggerName="AliVEvent::kCentral/kSemiCentral/kMB";
1232  break;
1233  case 4:
1234  fSpecialTrigger=4; // trigger alias kTRD
1235  fOfflineTriggerMask=AliVEvent::kTRD;
1236  fTriggerSelectedManually = kTRUE;
1237  fSpecialTriggerName="AliVEvent::kTRD";
1238  break;
1239  case 5:
1240  fSpecialTrigger=5; // trigger alias kEMC
1241  fOfflineTriggerMask=AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMC1 ;
1242  fTriggerSelectedManually = kTRUE;
1244  SETBIT(fTriggersEMCALSelected, kL0);
1245  fSpecialTriggerName="AliVEvent::kEMC7/kEMC8/kEMC1";
1246  break;
1247  case 6:
1248  fSpecialTrigger=6; // trigger alias kPHI
1249  fOfflineTriggerMask=AliVEvent::kPHI7 | AliVEvent::kPHI1 | AliVEvent::kPHI8 | AliVEvent::kPHOSPb;
1250  fTriggerSelectedManually = kTRUE;
1251  fSpecialTriggerName="AliVEvent::kPHI7/kPHI1/kPHI8/kPHOSPb";
1252  break;
1253  case 7:
1254  fSpecialTrigger=7; // trigger alias kHighMult
1255  fOfflineTriggerMask=AliVEvent::kHighMult;
1256  fTriggerSelectedManually = kTRUE;
1257  fSpecialTriggerName="AliVEvent::kHighMult";
1258  break;
1259  case 8:
1260  fSpecialTrigger=8; // trigger alias kEMCEGA
1261  fOfflineTriggerMask=AliVEvent::kEMCEGA;
1262  fTriggerSelectedManually = kTRUE;
1264  SETBIT(fTriggersEMCALSelected, kG2);
1265  fSpecialTriggerName="AliVEvent::kEMCEGA";
1266  break;
1267  case 9:
1268  fSpecialTrigger=9; // trigger alias kEMCEJE
1269  fOfflineTriggerMask=AliVEvent::kEMCEJE;
1270  fTriggerSelectedManually = kTRUE;
1272  SETBIT(fTriggersEMCALSelected, kJ2);
1273  fSpecialTriggerName="AliVEvent::kEMCEJE";
1274  break;
1275  default:
1276  AliError("Warning: Special Trigger Not known");
1277  return 0;
1278  }
1279  return 1;
1280 }
1281 
1284 {
1285  // Set Cut
1286  if (fSpecialTrigger == 0){ //OR
1287  switch(selectSpecialSubTriggerClass){
1288  case 0://with VZERO
1289  fSpecialTrigger=0;
1291 // AliInfo("Info: Nothing to be done");
1292  break;
1293  case 3: //V0OR with SDD requested (will only work with LHC11a dataset)
1295 // cout << "V0OR with SDD requested" << endl;
1296  break;
1297  default:
1298  AliError("Warning: Special Subtrigger Class Not known");
1299  return 0;
1300  }
1301  } else if (fSpecialTrigger == 1){ //AND with different detectors
1302  switch(selectSpecialSubTriggerClass){
1303  case 0: //with VZERO general implementation of V0AND (periods LHC11c onwards)
1304  fSpecialTrigger=0;
1306  fOfflineTriggerMask=AliVEvent::kINT7;
1307  fTriggerSelectedManually = kTRUE;
1308  fSpecialTriggerName="AliVEvent::kINT7";
1309  break;
1310  case 1: //with TZERO
1311  fSpecialTrigger=0;
1313  fOfflineTriggerMask=AliVEvent::kINT8;
1314  fTriggerSelectedManually = kTRUE;
1315  fSpecialTriggerName="AliVEvent::kINT8";
1316  break;
1317  case 2: //with VZERO (will only work with LHC11a dataset)
1318  fSpecialTrigger=1;
1320 // AliInfo("Info: Nothing to be done");
1321  break;
1322  case 3: //V0AND with SDD requested (will only work with LHC11a dataset)
1323  fSpecialTrigger=1;
1325  break;
1326  default:
1327  AliError("Warning: Special Subtrigger Class Not known");
1328  return 0;
1329  }
1330  } else if (fSpecialTrigger == 3){ // Selecting kCentral and kSemiCentral from trigger classes, not aliases
1331  switch(selectSpecialSubTriggerClass){
1332  case 0: // all together
1335 // AliInfo("Info: Nothing to be done");
1336  break;
1337  case 1: // kCentral - no vertex restriction
1340  fSpecialSubTriggerName="CVHN";
1341 // cout << "kCentralOpen" << endl;
1342  break;
1343  case 2: // kCentral - T00 +- 10 cm
1346  fSpecialSubTriggerName="CCENT";
1347 // cout << "kCentralVertex" << endl;
1348  break;
1349  case 3: // kCentral - both
1352  fSpecialSubTriggerName="CVHN|CCENT|CSEMI|CVLN";
1353 // cout << "kCentral both" << endl;
1354  break;
1355  case 4: // kSemiCentral - no vertex restriction
1358  fSpecialSubTriggerName="CVLN";
1359 // cout << "kSemiCentralOpen" << endl;
1360  break;
1361  case 5: // kSemiCentral - T00 +- 10 cm
1364  fSpecialSubTriggerName="CSEMI";
1365 // cout << "kSemiCentralVertex" << endl;
1366  break;
1367  case 6: // kSemiCentral - both
1370  fSpecialSubTriggerName="CSEMI%CVLN";
1371 // cout << "kSemiCentral both" << endl;
1372  break;
1373  case 7: // kMB
1376  fSpecialSubTriggerName="CPBI1_|CPBI1-";
1377 // cout << "kMB 1" << endl;
1378  break;
1379  case 8: // kMB
1382  fSpecialSubTriggerName="CPBI2_|CPBI2-";
1383 // cout << "kMB 2" << endl;
1384  break;
1385  case 9: // kMB
1388  fSpecialSubTriggerName="CPBI2_@CPBI2-@CPBI2_@CPBI2-";
1389 // cout << "kMB both" << endl;
1390  break;
1391  case 10: // 0V0M
1392  fOfflineTriggerMask=AliVEvent::kINT7;
1393  fTriggerSelectedManually = kTRUE;
1396  fSpecialSubTriggerName="C0V0M";
1397  break;
1398  case 11: // 0V0L
1399  fOfflineTriggerMask=AliVEvent::kINT7;
1400  fTriggerSelectedManually = kTRUE;
1403  fSpecialSubTriggerName="C0V0L";
1404  break;
1405  case 12: // 0VHM
1406  fOfflineTriggerMask=AliVEvent::kINT7;
1407  fTriggerSelectedManually = kTRUE;
1410  fSpecialSubTriggerName="C0VHM";
1411  break;
1412  case 13: // VOL7
1413  fOfflineTriggerMask=AliVEvent::kINT7;
1414  fTriggerSelectedManually = kTRUE;
1417  fSpecialSubTriggerName="CV0L7";
1418  break;
1419  case 14: // 0STC
1420  fOfflineTriggerMask=AliVEvent::kINT7;
1421  fTriggerSelectedManually = kTRUE;
1424  fSpecialSubTriggerName="C0STC";
1425  break;
1426  default:
1427  AliError("Warning: Special Subtrigger Class Not known");
1428  return 0;
1429  }
1430  } else if (fSpecialTrigger == 4){ // Subdivision of TRD trigger classes
1431  switch(selectSpecialSubTriggerClass){
1432  case 0: // all together
1435 // AliInfo("Info: Nothing to be done");
1436  break;
1437  case 1: // 7WUHSH - V0AND with single electron in TRD & EMCAL
1440  fSpecialSubTriggerName="7WUHEE";
1441  break;
1442  case 2: // 8WUHSH - T0AND with single electron in TRD & EMCAL
1445  fSpecialSubTriggerName="8WUHEE";
1446  break;
1447  case 3: // 7WUHSE - V0AND with single high pt electron in TRD
1450  fSpecialSubTriggerName="7WUHSE";
1451  break;
1452  case 4: // 8WUHSE - T0AND with single high pt electron in TRD
1455  fSpecialSubTriggerName="8WUHSE";
1456  break;
1457  case 5: // 7WUHJE - V0AND with jet in TRD
1460  fSpecialSubTriggerName="7WUHJT";
1461  break;
1462  case 6: // 8WUHJE - T0AND with jet in TRD
1465  fSpecialSubTriggerName="8WUHJT";
1466  break;
1467  case 7: // 7WUHQU - V0AND with dielectron pair in TRD
1470  fSpecialSubTriggerName="7WUHQU";
1471  break;
1472  case 8: // 8WUHQU - T0AND with dielectron pair in TRD
1475  fSpecialSubTriggerName="8WUHQU";
1476  break;
1477  default:
1478  AliError("Warning: Special Subtrigger Class Not known");
1479  return 0;
1480  }
1481  } else if (fSpecialTrigger == 5){ // Subdivision of kEMC trigger classes
1482  switch(selectSpecialSubTriggerClass){
1483  case 0: // all together
1486 // AliInfo("Info: Nothing to be done");
1487  break;
1488  case 1: // CEMC1 - V0OR and EMCAL fired
1489  fOfflineTriggerMask=AliVEvent::kEMC1;
1490  fSpecialTriggerName="AliVEvent::kEMC1";
1493  fSpecialSubTriggerName="CEMC1";
1494  break;
1495  case 2: // CEMC7 - V0AND and EMCAL fired
1497  fOfflineTriggerMask=AliVEvent::kEMC7;
1498  fSpecialTriggerName="AliVEvent::kEMC7";
1500  fSpecialSubTriggerName="CEMC7";
1501  break;
1502  case 3: // CEMC8 - T0OR and EMCAL fired
1503  fOfflineTriggerMask=AliVEvent::kEMC8;
1504  fSpecialTriggerName="AliVEvent::kEMC8";
1507  fSpecialSubTriggerName="CEMC8";
1508  break;
1509  case 4: // CDMC1 - V0OR and DCAL fired
1510  fOfflineTriggerMask=AliVEvent::kEMC1;
1511  fSpecialTriggerName="AliVEvent::kEMC1";
1514  fSpecialSubTriggerName="CDMC1";
1515  break;
1516  case 5: // CDMC7 - V0AND and DCAL fired
1518  fOfflineTriggerMask=AliVEvent::kEMC7;
1519  fSpecialTriggerName="AliVEvent::kEMC7";
1521  fSpecialSubTriggerName="CDMC7";
1522  break;
1523  case 6: // CDMC8 - T0OR and DCAL fired
1524  fOfflineTriggerMask=AliVEvent::kEMC8;
1525  fSpecialTriggerName="AliVEvent::kEMC8";
1528  fSpecialSubTriggerName="CDMC8";
1529  break;
1530  default:
1531  AliError("Warning: Special Subtrigger Class Not known");
1532  return 0;
1533  }
1534  }else if (fSpecialTrigger == 6){ // Subdivision of kPHI trigger classes
1535  switch(selectSpecialSubTriggerClass){
1536  case 0: // all together
1539 // AliInfo("Info: Nothing to be done");
1540  break;
1541  case 1: // CEMC1 - V0OR and EMCAL fired
1542  fOfflineTriggerMask=AliVEvent::kPHI1;
1543  fSpecialTriggerName="AliVEvent::kPHI1";
1546  fSpecialSubTriggerName="CPHI1";
1547  break;
1548  case 2: // CEMC7 - V0AND and EMCAL fired
1550  fOfflineTriggerMask=AliVEvent::kPHI7;
1551  fSpecialTriggerName="AliVEvent::kPHI7";
1553  fSpecialSubTriggerName="CPHI7";
1554  break;
1555  case 3: // CEMC8 - T0OR and EMCAL fired
1556  fOfflineTriggerMask=AliVEvent::kPHI8;
1557  fSpecialTriggerName="AliVEvent::kPHI8";
1560  fSpecialSubTriggerName="CPHI8";
1561  break;
1562  default:
1563  AliError("Warning: Special Subtrigger Class Not known");
1564  return 0;
1565  }
1566  } else if (fSpecialTrigger == 7){ // Subdivision of kHighMult trigger classes
1567  switch(selectSpecialSubTriggerClass){
1568  case 0: // all together
1571 // AliInfo("Info: Nothing to be done");
1572  break;
1573  case 1: // CSHM1 - V0OR and high mult fired
1576  fSpecialSubTriggerName="CSHM1";
1577  break;
1578  case 2: // CSHM7 - V0AND and high mult fired
1581  fSpecialSubTriggerName="CSHM7";
1582  break;
1583  case 3: // CSHM8 - T0OR and high mult fired
1586  fSpecialSubTriggerName="CSHM8";
1587  break;
1588  case 4: // V0 high mult trigger
1590  fOfflineTriggerMask=AliVEvent::kAny;
1591  fSpecialTriggerName="V0Mult";
1593  fSpecialSubTriggerName="CVHMV0M-B-";
1594  break;
1595  case 5: // SPD high mult trigger
1597  fOfflineTriggerMask=AliVEvent::kAny;
1598  fSpecialTriggerName="SPMult";
1600  fSpecialSubTriggerName="CVHMSH2-B-";
1601  break;
1602  case 6: // V0 high mult trigger with pileup condition on
1604  fOfflineTriggerMask=AliVEvent::kAny;
1605  fSpecialTriggerName="V0Mult";
1607  fSpecialSubTriggerName="CVHMV0M-B-SPD2";
1608  break;
1609 
1610  default:
1611  AliError("Warning: Special Subtrigger Class Not known");
1612  return 0;
1613  }
1614  }else if (fSpecialTrigger == 8){ // Subdivision of kEMCEGA trigger classes
1615  switch(selectSpecialSubTriggerClass){
1616  case 0: // all together
1619 // AliInfo("Info: Nothing to be done");
1620  break;
1621  case 1: // 7EGA - CINT7 EGA
1624  fSpecialSubTriggerName="7EGA";
1626  SETBIT(fTriggersEMCALSelected, kG2);
1627  break;
1628  case 2: // 8EGA - CINT8 EGA
1631  fSpecialSubTriggerName="8EGA";
1633  SETBIT(fTriggersEMCALSelected, kG2);
1634  break;
1635  case 3: // 7EG1 - CINT7 EG1
1638  fSpecialSubTriggerName="7EG1";
1640  SETBIT(fTriggersEMCALSelected, kG1);
1641  break;
1642  case 4: // 8EG1 - CINT8 EG1
1645  fSpecialSubTriggerName="8EG1";
1647  SETBIT(fTriggersEMCALSelected, kG1);
1648  break;
1649  case 5: // 7EG2 - CINT7 EG2
1652  fSpecialSubTriggerName="7EG2";
1654  SETBIT(fTriggersEMCALSelected, kG2);
1655  break;
1656  case 6: // 8EG2 - CINT8 EG2
1659  fSpecialSubTriggerName="8EG2";
1661  SETBIT(fTriggersEMCALSelected, kG2);
1662  break;
1663  case 7: // 7DGA - CINT7 DGA
1666  fSpecialSubTriggerName="7DGA";
1668  SETBIT(fTriggersEMCALSelected, kG2);
1669  break;
1670  case 8: // 8DGA - CINT8 DGA
1673  fSpecialSubTriggerName="8DGA";
1675  SETBIT(fTriggersEMCALSelected, kG2);
1676  break;
1677  case 9: // 7DG1 - CINT7 DG1
1680  fSpecialSubTriggerName="7DG1";
1682  SETBIT(fTriggersEMCALSelected, kG1);
1683  break;
1684  case 10: // 8DG1 - CINT8 DG1
1687  fSpecialSubTriggerName="8DG1";
1689  SETBIT(fTriggersEMCALSelected, kG1);
1690  break;
1691  case 11: // 7DG2 - CINT7 DG2
1694  fSpecialSubTriggerName="7DG2";
1696  SETBIT(fTriggersEMCALSelected, kG2);
1697  break;
1698  case 12: // 8DG2 - CINT8 DG2
1701  fSpecialSubTriggerName="8DG2";
1703  SETBIT(fTriggersEMCALSelected, kG2);
1704  break;
1705 
1706  default:
1707  AliError("Warning: Special Subtrigger Class Not known");
1708  return 0;
1709  }
1710  } else if (fSpecialTrigger == 9){ // Subdivision of kEMCEGA trigger classes
1711  switch(selectSpecialSubTriggerClass){
1712  case 0: // all together
1715 // AliInfo("Info: Nothing to be done");
1716  break;
1717  case 1: // 7EJE - CINT7 EJE
1720  fSpecialSubTriggerName="7EJE";
1722  SETBIT(fTriggersEMCALSelected, kJ2);
1723  break;
1724  case 2: // 8EJE - CINT8 EJE
1727  fSpecialSubTriggerName="8EJE";
1729  SETBIT(fTriggersEMCALSelected, kJ2);
1730  break;
1731  case 3: // 7EJ1 - CINT7 EJ1
1734  fSpecialSubTriggerName="7EJ1";
1736  SETBIT(fTriggersEMCALSelected, kJ1);
1737  break;
1738  case 4: // 8EJ1 - CINT8 EJ1
1741  fSpecialSubTriggerName="8EJ1";
1743  SETBIT(fTriggersEMCALSelected, kJ1);
1744  break;
1745  case 5: // 7EJ2 - CINT7 EJ2
1748  fSpecialSubTriggerName="7EJ2";
1750  SETBIT(fTriggersEMCALSelected, kJ2);
1751  break;
1752  case 6: // 8EJ2 - CINT8 EJ2
1755  fSpecialSubTriggerName="8EJ2";
1757  SETBIT(fTriggersEMCALSelected, kJ2);
1758  break;
1759  case 7: // 7DJ1 - CINT7 DJ1
1762  fSpecialSubTriggerName="7DJ1";
1764  SETBIT(fTriggersEMCALSelected, kJ1);
1765  break;
1766  case 8: // 8DJ1 - CINT8 DJ1
1769  fSpecialSubTriggerName="8DJ1";
1771  SETBIT(fTriggersEMCALSelected, kJ1);
1772  break;
1773  case 9: // 7DJ2 - CINT7 DJ2
1776  fSpecialSubTriggerName="7DJ2";
1778  SETBIT(fTriggersEMCALSelected, kJ2);
1779  break;
1780  case 10: // 8DJ2 - CINT8 DJ2
1783  fSpecialSubTriggerName="8DJ2";
1785  SETBIT(fTriggersEMCALSelected, kJ2);
1786  break;
1787 
1788  default:
1789  AliError("Warning: Special Subtrigger Class Not known");
1790  return 0;
1791  }
1792  }
1793  return 1;
1794 }
1795 
1796 //________________________________________________________________________
1798 {
1799  // Set Cut
1800  fMultiplicityMethod=multiplicityMethod;
1801 
1802  // 0 Photon Multiplicity
1803  // 1 TPC Track multiplicity
1804  // 2 V0 Mult
1805  // 3 SPD Mult
1806 
1807  return kTRUE;
1808 }
1809 
1810 //________________________________________________________________________
1812 {// Set Cut
1813  switch(removePileUp){
1814  case 0:
1815  fRemovePileUp = kFALSE;
1816  break;
1817  case 1:
1818  fRemovePileUp = kTRUE;
1819  fRemovePileUpSPD = kTRUE;
1820  break;
1821  case 2:
1822  fRemovePileUp = kTRUE;
1823  fRemovePileUpSPD = kTRUE;
1826  break;
1827  case 3:
1828  fRemovePileUp = kTRUE;
1829  fRemovePileUpSPD = kTRUE;
1832  break;
1833  case 4:
1834  fRemovePileUp = kTRUE;
1835  fRemovePileUpSPD = kTRUE;
1838  break;
1839  case 5:
1840  fRemovePileUp = kTRUE;
1841  fRemovePileUpSPD = kTRUE;
1844  break;
1845  case 6:
1846  fRemovePileUp = kTRUE;
1847  fRemovePileUpSPD = kTRUE;
1848  fDoPileUpRejectV0MTPCout = kTRUE;
1849  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1850  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1851  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1852  if (fIsHeavyIon==1){
1853  if(fPeriodEnum == kLHC15o){
1854  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1855  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1856  break;
1857  }else{
1858  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
1859  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1860  break;
1861  }
1862  } else if(fIsHeavyIon == 2){
1863  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
1864  fFPileUpRejectV0MTPCout->SetParameter(1,2.0);
1865  break;
1866  }else{
1867  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1868  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
1869  break;
1870  }
1871  break;
1872  case 7:
1873  fRemovePileUp = kTRUE;
1874  fRemovePileUpSPD = kTRUE;
1875  fDoPileUpRejectV0MTPCout = kTRUE;
1876  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1877  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1878  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1879  if (fIsHeavyIon==1){
1880  if(fPeriodEnum == kLHC15o){
1881  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1882  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1883  break;
1884  }else{
1885  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1886  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1887  break;
1888  }
1889  } else if(fIsHeavyIon == 2){
1890  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1891  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
1892  break;
1893  }else{
1894  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1895  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1896  break;
1897  }
1898  break;
1899  case 8:
1900  fRemovePileUp = kTRUE;
1901  fRemovePileUpSPD = kTRUE;
1902  fDoPileUpRejectV0MTPCout = kTRUE;
1903  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1904  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1905  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1906  if (fIsHeavyIon==1){
1907  if(fPeriodEnum == kLHC15o){
1908  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1909  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1910  break;
1911  }else{
1912  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
1913  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1914  break;
1915  }
1916  } else if(fIsHeavyIon == 2){
1917  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
1918  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
1919  break;
1920  }else{
1921  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1922  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
1923  break;
1924  }
1925  break;
1926  case 9:
1927  fRemovePileUp = kTRUE;
1928  fRemovePileUpSPD = kTRUE;
1931  fDoPileUpRejectV0MTPCout = kTRUE;
1932  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1933  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1934  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1935  if (fIsHeavyIon==1){
1936  if(fPeriodEnum == kLHC15o){
1937  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1938  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1939  break;
1940  }else{
1941  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
1942  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1943  break;
1944  }
1945  } else if(fIsHeavyIon == 2){
1946  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
1947  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
1948  break;
1949  }else{
1950  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1951  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
1952  break;
1953  }
1954  break;
1955  case 10: // for Pb-Pb
1956  fRemovePileUp = kTRUE;
1957  fRemovePileUpSPD = kTRUE;
1958  fUtils->SetASPDCvsTCut(200.);
1959  fUtils->SetBSPDCvsTCut(7.);
1960  fDoPileUpRejectV0MTPCout = kTRUE;
1961  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1962  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1963  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1964  break;
1965  case 11: // for Pb-Pb
1966  fRemovePileUp = kTRUE;
1967  fRemovePileUpSPD = kFALSE;
1968  fDoPileUpRejectV0MTPCout = kTRUE;
1969  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1970  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1971  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1972  break;
1973  default:
1974  AliError("RemovePileUpCut not defined");
1975  return kFALSE;
1976  }
1977  return kTRUE;
1978 }
1979 
1980 //________________________________________________________________________
1982 
1983  switch(extraSignal){
1984  case 0:
1985  fRejectExtraSignals = 0;
1986  break; // No Rejection
1987  case 1:
1988  fRejectExtraSignals = 1;
1989  break; // MinBias Header
1990  case 2:
1991  fRejectExtraSignals = 2;
1992  break; // User String Array
1993  case 3:
1994  fRejectExtraSignals = 3;
1995  break; // Rejection for Gamma Correction only
1996  case 4:
1997  fRejectExtraSignals = 4;
1998  break; // Special handling of Jet weights for Jets embedded in MB events
1999  default:
2000  AliError(Form("Extra Signal Rejection not defined %d",extraSignal));
2001  return kFALSE;
2002  }
2003  return kTRUE;
2004 }
2005 
2006 //________________________________________________________________________
2008 
2009  switch(vertexCut){
2010  case 0: // no Vertex required // NOT fully working yet
2011  fEnableVertexCut = kFALSE;
2012  fMaxVertexZ = 1000;
2013  break;
2014  case 1: // vertex within +-15 cm
2015  fEnableVertexCut = kTRUE;
2016  fMaxVertexZ = 15;
2017  break;
2018  case 2: // vertex within +-12.5 cm
2019  fEnableVertexCut = kTRUE;
2020  fMaxVertexZ = 12.5;
2021  break;
2022  case 3: // vertex within +-10 cm
2023  fEnableVertexCut = kTRUE;
2024  fMaxVertexZ = 10.0;
2025  break;
2026  case 4: // vertex within +-7.5 cm
2027  fEnableVertexCut = kTRUE;
2028  fMaxVertexZ = 7.5;
2029  break;
2030  case 5: // vertex within +-5 cm
2031  fEnableVertexCut = kTRUE;
2032  fMaxVertexZ = 5.;
2033  break;
2034  default:
2035  AliError(Form("Vertex Cut not defined %d",vertexCut));
2036  return kFALSE;
2037  }
2038  return kTRUE;
2039 }
2040 
2041 //-------------------------------------------------------------
2043  if (fPeriodEnum == kLHC15n || // pp 5TeV
2044  fPeriodEnum == kLHC15o || // PbPb 5TeV
2045  fPeriodEnum == kLHC15k1a1 || fPeriodEnum == kLHC15k1a2 || fPeriodEnum == kLHC15k1a3 || fPeriodEnum == kLHC16j7 || // MC PbPb 5TeV LowIR
2046  fPeriodEnum == kLHC16g1 || fPeriodEnum == kLHC16g1a || fPeriodEnum == kLHC16g1b || fPeriodEnum == kLHC16g1c || // MC PbPb 5TeV general purpose
2047  fPeriodEnum == kLHC16g2 || // MC PbPb 5TeV EPOS-LHC
2048  fPeriodEnum == kLHC16g3 || // MC PbPb 5TeV DPMJET
2049  fPeriodEnum == kLHC16h4 || // MC PbPb 5TeV GA added pi0 and eta
2050  fPeriodEnum == kLHC16i1a || fPeriodEnum == kLHC16i1b || fPeriodEnum == kLHC16i1c || // MC PbPb 5TeV LF added (multi-)strange
2051  fPeriodEnum == kLHC16i2a || fPeriodEnum == kLHC16i2b || fPeriodEnum == kLHC16i2c || // MC PbPb 5TeV HF added hadronic decays
2052  fPeriodEnum == kLHC16i3a || fPeriodEnum == kLHC16i3b || fPeriodEnum == kLHC16i3c || // MC PbPb 5TeV HF added electron decays
2053  fPeriodEnum == kLHC16h2a || fPeriodEnum == kLHC16h2b || fPeriodEnum == kLHC16h2c || // MC PbPb 5TeV jet-jet
2055  fPeriodEnum == kLHC15g3a3 || fPeriodEnum == kLHC15g3c3 || // MC pp 13TeV
2056  fPeriodEnum == kLHC16qt || // pPb 5TeV LHC16qt
2057  fPeriodEnum == kLHC16r || fPeriodEnum == kLHC16s || // pPb 8TeV LHC16rs
2058  fPeriodEnum == kLHC17f2a || fPeriodEnum == kLHC17f2b || fPeriodEnum == kLHC17g8a || // MC pPb 5TeV LHC16qt
2060  fPeriodEnum == kLHC17f3 || fPeriodEnum == kLHC17f4 || // MC pPb 8TeV LHC16sr
2061  fPeriodEnum == kLHC17n || // Xe-Xe LHC17n
2062  fPeriodEnum == kLHC17j7 || // MC Xe-Xe LHC17n
2063  fPeriodEnum == kLHC17pq || // pp 5TeV LHC17pq
2064  fPeriodEnum == kLHC17l3b || // MC pp 5TeV LHC17pq
2065  fPeriodEnum == kLHC17l4b || // MC pp 5TeV LHC17pq
2066  fPeriodEnum == kLHC18b8 // MC Jet Jet pp 5TeV LHC17pq
2067  ){
2068  return kTRUE;
2069  } else {
2070  return kFALSE;
2071  }
2072 }
2073 
2074 //-------------------------------------------------------------
2076 { // Get Event Centrality
2077 
2078  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
2079  if(esdEvent){
2081  AliMultSelection *MultSelection = (AliMultSelection*)event->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");// default
2089  }else if(fDetectorCentrality==1) return MultSelection->GetMultiplicityPercentile("CL1",kTRUE);
2090  else if(fDetectorCentrality==2) return MultSelection->GetMultiplicityPercentile("ZNA",kTRUE);
2091  }
2092  }else{
2093  AliCentrality *fESDCentrality = (AliCentrality*)esdEvent->GetCentrality();
2094  if(fDetectorCentrality==0){
2095  if(fIsHeavyIon==2) return fESDCentrality->GetCentralityPercentile("V0A"); // default for pPb
2096  else return fESDCentrality->GetCentralityPercentile("V0M"); // default
2097  }else if(fDetectorCentrality==1) return fESDCentrality->GetCentralityPercentile("CL1");
2098  else if(fDetectorCentrality==2) return fESDCentrality->GetCentralityPercentile("ZNA");
2099  }
2100  }
2101 
2102  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
2103  if(aodEvent){
2105  AliMultSelection *MultSelection = (AliMultSelection*)aodEvent->FindListObject("MultSelection");
2106  if(!MultSelection){
2107  AliWarning ("AliMultSelection object not found !");
2108  return -1;
2109  } else{
2110  if(fDetectorCentrality==0){
2111  if(fIsHeavyIon==2) return MultSelection->GetMultiplicityPercentile("V0A");// default for pPb
2112  else return MultSelection->GetMultiplicityPercentile("V0M",kTRUE);
2113  }else if(fDetectorCentrality==1) return MultSelection->GetMultiplicityPercentile("CL1",kTRUE);
2114  else if(fDetectorCentrality==2) return MultSelection->GetMultiplicityPercentile("ZNA",kTRUE);
2115  }
2116  }else{
2117  if(aodEvent->GetHeader()){return ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();}
2118  }
2119  }
2120 
2121  return -1;
2122 }
2123 
2124 //_____________________________________________________________________________________
2125 Bool_t AliConvEventCuts::IsCentralitySelected(AliVEvent *event, AliMCEvent *mcEvent)
2126 {
2127  // Centrality Selection
2128  if(!fIsHeavyIon){
2129  if ((fCentralityMin == 0 && fCentralityMax == 0) || (fCentralityMin > fCentralityMax) ){
2130  return kTRUE;
2131  } else {
2132  Int_t primaryTracksPP[9] = { 0, 2, 5, 10, 15,
2133  30, 50, 100, 1000
2134  };
2135  Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
2136  if ( nprimaryTracks >= primaryTracksPP[fCentralityMin] && nprimaryTracks < primaryTracksPP[fCentralityMax]){
2137  return kTRUE;
2138  } else {
2139  return kFALSE;
2140  }
2141  return kFALSE;
2142  }
2143  }
2144  if(fCentralityMin == fCentralityMax ) return kTRUE;//0-100%
2145  else if ( fCentralityMax==0) fCentralityMax=10; //CentralityRange = fCentralityMin-10*multfactor
2147  if(centrality<0 && !mcEvent)return kFALSE;
2148 
2149  Int_t centralityC=0;
2150  if (fModCentralityClass == 0){
2151  centralityC= Int_t(centrality/10);
2152  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2153  return kTRUE;
2154  else return kFALSE;
2155  }
2156  else if (fModCentralityClass == 1){
2157  centralityC= Int_t(centrality);
2158  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2159  return kTRUE;
2160  } else return kFALSE;
2161  }
2162  else if (fModCentralityClass == 2){
2163  centralityC= Int_t(centrality);
2164  if(centralityC >= fCentralityMin && centralityC < fCentralityMax){
2165  return kTRUE;
2166  } else return kFALSE;
2167  }
2168  Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
2169  Int_t PrimaryTracks10[11][2] =
2170  {
2171  {9999,9999}, // 0 //1550 changed to 9999 on 9 Dec
2172  {1210, 928}, // 10
2173  { 817, 658}, // 20
2174  { 536, 435}, // 30
2175  { 337, 276}, // 40
2176  { 197, 162}, // 50
2177  { 106, 100}, // 60
2178  { 51, 44}, // 70
2179  { 21, 18}, // 80
2180  { 0, 0}, // 90
2181  { 0, 0}// 100 // only max accessible
2182  };
2183  Int_t PrimaryTracksLHC11h10[11][2] =
2184  {
2185  {9999,9999}, // 0 //1550 changed to 9999 on 9 Dec
2186  { 985, 928}, // 10
2187  { 661, 658}, // 20
2188  { 434, 435}, // 30
2189  { 275, 276}, // 40
2190  { 173, 162}, // 50
2191  { 100, 100}, // 60
2192  { 42, 44}, // 70
2193  { 19, 18}, // 80
2194  { 0, 0}, // 90
2195  { 0, 0}// 100 // only max accessible
2196  };
2197  Int_t PrimaryTracksLHC15o10[11][2] =
2198  {
2199  {2500, 2700}, // 0-10% cent class max # of tracks: max value of the data distribution
2200  {1498, 1498}, // 0-10% cent class min # of tracks
2201  {1012, 1012}, // 10-20
2202  { 669, 669}, // 20-30
2203  { 423, 423}, // 30-40
2204  { 251, 251}, // 40-50
2205  { 136, 136}, // 50-60
2206  { 67, 67}, // 60-70
2207  { 28, 28}, // 70-80
2208  { 0, 0}, // 80-90% cent class min # of tracks
2209  { 0, 0} // not used
2210  };
2211  Int_t PrimaryTracksLHC10h5[21][2] =
2212  {
2213  {9999,9999}, // 0 ///1550 changed to 9999 on 9 Dec
2214  {1485,1168}, // 5
2215  {1210, 928}, // 10
2216  { 995, 795}, // 15
2217  { 817, 658}, // 20
2218  { 666, 538}, // 25
2219  { 536, 435}, // 30
2220  { 428, 350}, // 35
2221  { 337, 276}, // 40
2222  { 260, 214}, // 45
2223  { 197, 162}, // 50
2224  { 147, 125}, // 55
2225  { 106, 100}, // 60
2226  { 75, 63}, // 65
2227  { 51, 44}, // 70
2228  { 34, 29}, // 75
2229  { 21, 18}, // 80
2230  { 13, 11}, // 85
2231  { 6, 6}, // 90
2232  { 3, 3}, // 95
2233  { 0, 0} // 100 only max accessible
2234  };
2235  Int_t PrimaryTracksLHC11h5[21][2] =
2236  {
2237  {9999,9999}, // 0 ///1550 changed to 9999 on 9 Dec
2238  {1166,1168}, // 5
2239  { 953, 928}, // 10
2240  { 805, 795}, // 15
2241  { 655, 658}, // 20
2242  { 535, 538}, // 25
2243  { 435, 435}, // 30
2244  { 349, 350}, // 35
2245  { 275, 276}, // 40
2246  { 214, 214}, // 45
2247  { 165, 162}, // 50
2248  { 127, 125}, // 55
2249  { 93, 100}, // 60
2250  { 64, 63}, // 65
2251  { 44, 44}, // 70
2252  { 30, 29}, // 75
2253  { 18, 18}, // 80
2254  { 11, 11}, // 85
2255  { 6, 6}, // 90
2256  { 3, 3}, // 95
2257  { 0, 0} // 100 only max accessible
2258  };
2259  Int_t PrimaryTracksLHC15o5[21][2] =
2260  {
2261  { 2500, 2700}, // 0-5% cent class max # of tracks: max value of the data distribution
2262  { 1827, 1827}, // 0-5% cent class min # of tracks
2263  { 1498, 1498}, // 5-10
2264  { 1234, 1234}, // 10-15
2265  { 1012, 1012}, // 15-20
2266  { 827, 827}, // 20-25
2267  { 669, 669}, // 25-30
2268  { 536, 536}, // 30-35
2269  { 423, 423}, // 35-40
2270  { 329, 329}, // 40-45
2271  { 251, 251}, // 45-50
2272  { 188, 188}, // 50-55
2273  { 136, 136}, // 55-60
2274  { 97, 97}, // 60-65
2275  { 67, 67}, // 65-70
2276  { 44, 44}, // 70-75
2277  { 28, 28}, // 75-80
2278  { 17, 17}, // 80-85
2279  { 10, 10}, // 85-90
2280  { 5, 5}, // 90-95 cent class minimum # of tracks
2281  { 0, 0} // 95-100
2282  };
2283  Int_t PrimaryTracksLHC17n10[11][2] =
2284  {
2285  {9999,9999}, // 0 // 1500 max in hist but set to real max
2286  { 800, 800}, // 10 // guess
2287  { 628, 628}, // 20
2288  { 350, 350}, // 30 // guess
2289  { 268, 268}, // 40
2290  { 200, 200}, // 50 // guess
2291  { 100, 100}, // 60 // guess
2292  { 51, 44}, // 70 // guess
2293  { 21, 18}, // 80 // guess
2294  { 0, 0}, // 90 // guess
2295  { 0, 0} // 100 // only max accessible
2296  };
2297 
2298  Int_t column = 0;
2299  if(event->IsA()==AliESDEvent::Class()) column = 0;
2300  if(event->IsA()==AliAODEvent::Class()) column = 1;
2301 
2302  if (fModCentralityClass == 3){
2303  if(mcEvent){
2304  // setting specific arry for LHC11h for MC track mult
2306  if(nprimaryTracks > PrimaryTracksLHC11h10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h10[fCentralityMin][column])
2307  return kTRUE;
2308  else return kFALSE;
2309  // setting specific arry for LHC17n for MC track mult
2310  } else if(fPeriodEnum == kLHC17j7 ){
2311  if(nprimaryTracks > PrimaryTracksLHC17n10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC17n10[fCentralityMin][column])
2312  return kTRUE;
2313  else return kFALSE;
2314  // settings for LHC15o MCs
2316  centralityC= Int_t(centrality/10);
2317  if(centralityC >= fCentralityMin && centralityC < fCentralityMax){
2318  if(fCentralityMin==0 && nprimaryTracks >= PrimaryTracksLHC15o10[0][column]) return kFALSE;
2319  else return kTRUE;
2320  } else return kFALSE;
2321  // setting specific arry for LHC10h for MC track mult
2322  } else {
2323  if(nprimaryTracks > PrimaryTracks10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracks10[fCentralityMin][column])
2324  return kTRUE;
2325  else return kFALSE;
2326  }
2327  }
2328  else{
2329  centralityC= Int_t(centrality/10);
2330  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2331  return kTRUE;
2332  else return kFALSE;
2333  }
2334  }
2335  else if (fModCentralityClass ==4){
2336  if(mcEvent){
2337  // setting specific arry for LHC11h for MC track mult
2339  if(nprimaryTracks > PrimaryTracksLHC11h5[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h5[fCentralityMin][column])
2340  return kTRUE;
2341  else return kFALSE;
2342  // settings for LHC15o MCs
2344  centralityC = Int_t(centrality);
2345  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2346  if(fCentralityMin==0 && nprimaryTracks >= PrimaryTracksLHC15o5[0][column]) return kFALSE;
2347  else return kTRUE;
2348  } else return kFALSE;
2349  // setting specific arry for LHC10h for MC track mult
2350  } else {
2351  if(nprimaryTracks > PrimaryTracksLHC10h5[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC10h5[fCentralityMin][column])
2352  return kTRUE;
2353  else return kFALSE;
2354  }
2355  }
2356  else{
2357  centralityC= Int_t(centrality);
2358  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2359  return kTRUE;
2360  } else return kFALSE;
2361  }
2362  }
2363 
2364  Int_t PrimaryTracksLHC11h10AltMin[11][2] =
2365  {
2366  {1550,1550}, // 0 - 0
2367  { 800, 800}, // 10 - 1
2368  { 600, 600}, // 20 - 2
2369  { 400, 400}, // 30 - 3
2370  { 240, 240}, // 40 - 4
2371  { 130, 130}, // 50 - 5
2372  { 90, 90}, // 60 - 6
2373  { 35, 35}, // 70 - 7
2374  { 15, 15}, // 80 - 8
2375  { 5, 5}, // 90 - 9
2376  { 0, 0} // 100 // only max accessible
2377  };
2378  Int_t PrimaryTracksLHC11h10AltMax[11][2] =
2379  {
2380  {1550,1550}, // 0 //1550 changed to 9999 on 9 Dec
2381  {1000,1000}, // 10
2382  { 700, 700}, // 20
2383  { 480, 480}, // 30
2384  { 300, 300}, // 40
2385  { 200, 200}, // 50
2386  { 120, 120}, // 60
2387  { 50, 50}, // 70
2388  { 22, 22}, // 80
2389  { 10, 10}, // 90
2390  { 0, 0} // 100 // only max accessible
2391  };
2392  Int_t PrimaryTracksLHC11h5AltMin[21][2] =
2393  {
2394  {1550,1550}, // 0
2395  {1000,1000}, // 5
2396  { 800, 800}, // 10
2397  { 700, 700}, // 15
2398  { 600, 600}, // 20
2399  { 500, 500}, // 25
2400  { 400, 400}, // 30
2401  { 300, 300}, // 35
2402  { 240, 240}, // 40
2403  { 180, 180}, // 45
2404  { 130, 130}, // 50
2405  { 127, 125}, // 55
2406  { 90, 90}, // 60
2407  { 55, 55}, // 65
2408  { 35, 35}, // 70
2409  { 25, 25}, // 75
2410  { 15, 15}, // 80
2411  { 11, 11}, // 85
2412  { 5, 5}, // 90
2413  { 0, 0}, // 95
2414  { 0, 0} // 100 only max accessible
2415  };
2416  Int_t PrimaryTracksLHC11h5AltMax[21][2] =
2417  {
2418  {1550,1550}, // 0
2419  {1250,1250}, // 5
2420  {1000,1000}, // 10
2421  { 805, 795}, // 15
2422  { 700, 700}, // 20
2423  { 585, 585}, // 25
2424  { 480, 480}, // 30
2425  { 380, 380}, // 35
2426  { 300, 300}, // 40
2427  { 235, 235}, // 45
2428  { 200, 200}, // 50
2429  { 140, 140}, // 55
2430  { 120, 120}, // 60
2431  { 70, 70}, // 65
2432  { 50, 50}, // 70
2433  { 35, 25}, // 75
2434  { 22, 22}, // 80
2435  { 15, 15}, // 85
2436  { 10, 10}, // 90
2437  { 5, 5}, // 95
2438  { 0, 0} // 100 only max accessible
2439  };
2440 
2441  if (fModCentralityClass == 5){
2442  if(mcEvent){
2443  // setting specific arry for LHC11h for MC track mult
2445  if(nprimaryTracks > PrimaryTracksLHC11h10AltMin[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h10AltMax[fCentralityMin][column])
2446  return kTRUE;
2447  else return kFALSE;
2448  // default return
2449  } else {
2450  return kFALSE;
2451  }
2452  } else {
2453  centralityC= Int_t(centrality/10);
2454  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2455  return kTRUE;
2456  else return kFALSE;
2457  }
2458  }
2459  else if (fModCentralityClass ==6){
2460  if(mcEvent){
2461  // setting specific arry for LHC11h for MC track mult
2463  if(nprimaryTracks > PrimaryTracksLHC11h5AltMin[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h5AltMax[fCentralityMin][column])
2464  return kTRUE;
2465  else return kFALSE;
2466  } else {
2467  return kFALSE;
2468  }
2469  } else{
2470  centralityC= Int_t(centrality);
2471  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2472  return kTRUE;
2473  } else return kFALSE;
2474  }
2475  }
2476 
2477  return kFALSE;
2478 }
2479 
2480 //________________________________________________________________________
2482  // Cut on z position of primary vertex
2483  Double_t fVertexZ=event->GetPrimaryVertex()->GetZ();
2484  Double_t fVertexZSPD = 0;
2485  AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2486  if(fESDEvent){
2487  fVertexZSPD = fESDEvent->GetPrimaryVertexSPD()->GetZ();
2488  }
2489  AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2490  if(fAODEvent){
2491  fVertexZSPD = fAODEvent->GetPrimaryVertexSPD()->GetZ();
2492  }
2493 
2494  if(TMath::Abs(fVertexZ)>fMaxVertexZ)return kFALSE;
2495 
2496 
2497  if (fPeriodEnum == kLHC11h){
2498  if (TMath::Abs(fVertexZ-fVertexZSPD) > 0.1) return kFALSE;
2499  }
2500  if (fIsHeavyIon == 2){
2501  if(!fUtils->IsVertexSelected2013pA(event)) return kFALSE;
2502  }
2503 
2504  return kTRUE;
2505 }
2506 
2507 //________________________________________________________________________
2509 {
2511  return kFALSE;
2512  TBits fIR1 = event->GetHeader()->GetIRInt1InteractionMap(); // IR1 contains V0 information (VIR)
2513  TBits fIR2 = event->GetHeader()->GetIRInt2InteractionMap(); // IR2 contains T0 information
2514  UShort_t bunchCrossings = event->GetBunchCrossNumber();
2516  for(Int_t i = 0; i<180;i++){
2517  if(fIR1.TestBitNumber(i))
2518  fHistoPastFutureBits->Fill((i*25)-90*25);
2519  }
2520  }
2521 
2522  Bool_t isOutOfBunchPileup = 0;
2523  Int_t pf1 = fPastFutureRejectionLow +bunchCrossings%4;
2524  Int_t pf2 = fPastFutureRejectionHigh+bunchCrossings%4;
2525  if(pf1 < -89) pf1 = -89;
2526  if(pf2 > 89) pf2 = 89;
2527  Int_t pf2maxForT0 = pf2;
2528  Int_t ir1skip = 0;
2529  for (Int_t i=pf1;i<=pf2;i++) {
2530  if (i==0) continue;
2531  if (i<=pf2maxForT0) isOutOfBunchPileup|=fIR2.TestBitNumber(90+i); // T0-based clean-up
2532  if (i>0 && i<=ir1skip) continue; // skip next 2 for old IR definitions
2533  isOutOfBunchPileup|=fIR1.TestBitNumber(90+i); // V0-based clean-up
2534  }
2535  return isOutOfBunchPileup;
2536 }
2537 //________________________________________________________________________
2538 
2540 {
2541  Bool_t isPileUpV0MTPCout=0;
2542 
2543  Double_t multV0M;
2544  Double_t valFunc;
2545  if (fIsHeavyIon==2){
2546  multV0M = event->GetVZEROData()->GetMTotV0A();
2547  }else{
2548  multV0M = event->GetVZEROData()->GetMTotV0A() + event->GetVZEROData()->GetMTotV0C() ;
2549  }
2550 
2551  if ( fFPileUpRejectV0MTPCout != 0x0 ){
2552  valFunc= fFPileUpRejectV0MTPCout->Eval(((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfTPCoutTracks());
2553  if (multV0M < valFunc ) isPileUpV0MTPCout=1;
2554  }
2555 
2556  return isPileUpV0MTPCout;
2557 
2558 }
2559 //________________________________________________________________________
2561  // returns number of contributors to the vertex
2562 
2563  AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2564  if(fESDEvent){
2565  if (fESDEvent->GetPrimaryVertex() != NULL){
2566  if(fESDEvent->GetPrimaryVertex()->GetNContributors()>0) {
2567  // cout << "accepted global" << fESDEvent->GetEventNumberInFile() << " with NCont: " << fESDEvent->GetPrimaryVertex()->GetNContributors() << endl;
2568  return fESDEvent->GetPrimaryVertex()->GetNContributors();
2569  }
2570  }
2571 
2572  if(fESDEvent->GetPrimaryVertexSPD() !=NULL){
2573  if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2574  // cout << "accepted SPD" << fESDEvent->GetEventNumberInFile() << " with NCont: " << fESDEvent->GetPrimaryVertexSPD()->GetNContributors() << endl;
2575  return fESDEvent->GetPrimaryVertexSPD()->GetNContributors();
2576  }else {
2577  AliWarning(Form("Number of contributors from bad vertex type:: %s",fESDEvent->GetPrimaryVertex()->GetName()));
2578  // cout << "rejected " << fESDEvent->GetEventNumberInFile() << endl;
2579  return 0;
2580  }
2581  }
2582  }
2583 
2584  AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2585  if(fAODEvent){
2586  if (fAODEvent->GetPrimaryVertex() != NULL){
2587  if(fAODEvent->GetPrimaryVertex()->GetNContributors()>0) {
2588  return fAODEvent->GetPrimaryVertex()->GetNContributors();
2589  }
2590  }
2591  if(fAODEvent->GetPrimaryVertexSPD() !=NULL){
2592  if(fAODEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2593  return fAODEvent->GetPrimaryVertexSPD()->GetNContributors();
2594  } else {
2595  AliWarning(Form("Number of contributors from bad vertex type:: %s",fAODEvent->GetPrimaryVertex()->GetName()));
2596  return 0;
2597  }
2598  }
2599  }
2600  // cout << "rejected " << fESDEvent->GetEventNumberInFile() << endl;
2601  return 0;
2602 }
2603 
2604 //________________________________________________________________________
2605 // Analysing Jet-Jet MC's
2606 //________________________________________________________________________
2607 Bool_t AliConvEventCuts::IsJetJetMCEventAccepted(AliMCEvent *mcEvent, Double_t& weight, AliVEvent* event ){
2608  AliGenCocktailEventHeader *cHeader = 0x0;
2609  Bool_t headerFound = kFALSE;
2610  weight = -1;
2611  fMaxPtJetMC = 0;
2612 
2613  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
2614  fPeriodEnum != kLHC17i3a1 && // LHC16ijklop GammaJet MC EMCal triggered
2615  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2616  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
2617  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2618  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2619  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2620  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2621  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2622  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2623  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
2624  ){
2625 
2626  weight = 1;
2627  return kTRUE;
2628  }
2629 
2630  if(mcEvent){
2631  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2632  if(cHeader) headerFound = kTRUE;
2633  }else{
2634  //no mcEvent available -> not running on MC
2635  weight = 1;
2636  return kTRUE;
2637  }
2638 
2639  if(headerFound){
2640  TList *genHeaders = 0x0;
2641  if(cHeader) genHeaders = cHeader->GetHeaders();
2642  AliGenEventHeader* gh = 0;
2643  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2644  gh = (AliGenEventHeader*)genHeaders->At(i);
2645  TString GeneratorName = gh->GetName();
2646  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2647  Bool_t eventAccepted = kTRUE;
2648  TParticle * jet = 0;
2649  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(gh)->NTriggerJets();
2650  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
2651  Float_t tmpjet[]={0,0,0,0};
2652  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2653  dynamic_cast<AliGenPythiaEventHeader*>(gh)->TriggerJet(ijet, tmpjet);
2654  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2655  //Compare jet pT and pt Hard
2656  if(jet->Pt() > fMaxFacPtHard * ptHard){
2657  eventAccepted= kFALSE;
2658  }
2659  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2660  }
2661  if (jet) delete jet;
2662  if (mcEvent){
2663  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2664  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2665  if (!particle) continue;
2666  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2667  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2668  eventAccepted= kFALSE;
2669  }
2670  }
2671 
2672  }
2673  }
2674 
2675  if ( fPeriodEnum == kLHC16P1JJLowB) {
2676  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2677  21, 28, 36, 45, 57,
2678  70, 85, 99, 115, 132,
2679  150, 169, 190, 212, 235,
2680  1000000};
2681  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2682  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2683  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2684  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2685  Int_t bin = 0;
2686  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2687  if (bin < 20) weight = weightsBins[bin];
2688 
2689  } else if ( fPeriodEnum == kLHC16P1JJ ){
2690  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2691  21, 28, 36, 45, 57,
2692  70, 85, 99, 115, 132,
2693  150, 169, 190, 212, 235,
2694  1000000};
2695  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2696  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2697  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2698  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2699 
2700  Int_t bin = 0;
2701  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2702  if (bin < 20) weight = weightsBins[bin];
2703 
2704  } else if ( fPeriodEnum == kLHC16h3 ){
2705  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2706  21, 28, 36, 45, 57,
2707  70, 85, 99, 115, 132,
2708  150, 169, 190, 212, 235,
2709  1000000};
2710  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2711  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2712  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2713  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2714  Int_t bin = 0;
2715  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2716  if (bin < 20) weight = weightsBins[bin];
2717 
2718 
2719  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2720  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2721  21, 28, 36, 45, 57,
2722  70, 85, 1000};
2723  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2724  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2725  1.933238e-05, 1.562895e-05};
2726  Int_t bin = 0;
2727  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2728  if (bin < 12) weight = weightsBins[bin];
2729 
2730  } else if ( fPeriodEnum == kLHC15g1a ){
2731  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2732  84, 117, 152, 191, 1000000,
2733  5, 7, 9, 12, 16,
2734  21, 28, 36, 45, 57 };
2735  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2736  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2737  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2738  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2739 
2740  Int_t bin = 0;
2741  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2742  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2743  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2744  if (bin < 19) weight = weightsBins[bin];
2745 
2746  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2747  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2748  84, 117, 152, 191, 1000000,
2749  5, 7, 9, 12, 16,
2750  21, 28, 36, 45, 57 };
2751  // LHC15a3a
2752  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2753  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2754  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2755  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2756  Int_t bin = 0;
2757  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2758  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2759  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2760  if (bin < 19) weight = weightsBins[bin];
2761 
2762  } else if ( fPeriodEnum == kLHC12P2JJ ){
2763  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2764  21, 28, 36, 45, 57,
2765  70, 85, 99, 115, 132,
2766  150, 169, 190, 212, 235,
2767  1000000};
2768  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
2769  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
2770  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
2771  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
2772  Int_t bin = 0;
2773  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2774  if (bin < 20) weight = weightsBins[bin];
2775 
2776  } else if ( fPeriodEnum == kLHC16c3a ){
2777  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
2778  Double_t weightsBins[5] = { 0.00672445, 0.00799158, 0.00678934, 0.00463908, 0.00600068}; //preliminary estimates
2779  Int_t bin = 0;
2780  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2781  if (bin < 5) weight = weightsBins[bin];
2782 
2783  } else if (fPeriodEnum == kLHC16c3b ){
2784  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
2785  Double_t weightsBins[6] = { 0.00608281, 0.00393646, 0.00200138, 0.000986267, 0.000389051, 0.0001863}; //preliminary estimates
2786  Int_t bin = 0;
2787  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2788  if (bin < 6) weight = weightsBins[bin];
2789 
2790  } else if (fPeriodEnum == kLHC16c3c ){
2791  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
2792  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
2793  Int_t bin = 0;
2794  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2795  if (bin < 7) weight = weightsBins[bin];
2796 
2797  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
2798  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
2799  84, 117, 152, 191, 234,
2800  1000};
2801  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
2802  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
2803  Int_t bin = 0;
2804  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2805  if (bin < 10) weight = weightsBins[bin];
2806  } else if ( fPeriodEnum == kLHC17g8a ){ // preliminary weights obtained from local running
2807  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};
2808  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};
2809  Int_t bin = 0;
2810  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2811  if (bin < 20) weight = weightsBins[bin];
2812  } else if ( fPeriodEnum == kLHC16rP1JJ ){ // preliminary weights obtained from local running
2813  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};
2814  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};
2815  Int_t bin = 0;
2816  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2817  if (bin < 20) weight = weightsBins[bin];
2818  } else if ( fPeriodEnum == kLHC16sP1JJ ){ // preliminary weights obtained from local running
2819  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};
2820  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};
2821  Int_t bin = 0;
2822  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2823  if (bin < 20) weight = weightsBins[bin];
2824  } else if ( fPeriodEnum == kLHC17i3a1 ){ // weights obtained from ga_pp_mc_aod train 912
2825  Double_t ptHardBinRanges[7] = { 5, 11, 21, 36, 57, 84, 10000};
2826  Double_t weightsBins[6] = { 0.0002181, 3.13684e-05, 5.01515e-06, 9.50662e-07, 2.08186e-07, 7.96555e-08};
2827  Int_t bin = 0;
2828  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2829  if (bin < 6) weight = weightsBins[bin];
2830  } else {
2831  weight = 1;
2832  }
2833 
2834  if (weight == -1) return kFALSE;
2835  else return eventAccepted;
2836 
2837  }
2838  }
2839  } else {
2840  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2841  TString eventHeaderName = eventHeader->ClassName();
2842  Bool_t eventAccepted = kFALSE;
2843  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2844  eventAccepted = kTRUE;
2845  }else { //special case for pythia8jets embedded in EPOSLHC for AODs
2846  if(event->IsA()==AliAODEvent::Class()){
2847  AliAODMCHeader *mch = NULL;
2848  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
2849  if(aod){
2850  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
2851  if ( mch ){
2852  Int_t nGenerators = mch->GetNCocktailHeaders();
2853  if ( nGenerators > 0 ){
2854  for(Int_t igen = 0; igen < nGenerators; igen++)
2855  {
2856  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
2857  TString name = eventHeaderGen->GetName();
2858  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
2859  eventAccepted = kTRUE;
2860  eventHeader = eventHeaderGen;
2861  }
2862  }
2863  }
2864  }
2865  }
2866  }
2867  }
2868  if(eventAccepted){
2869  TParticle * jet = 0;
2870  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->NTriggerJets();
2871  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
2872  Float_t tmpjet[]={0,0,0,0};
2873  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2874  dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->TriggerJet(ijet, tmpjet);
2875  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2876  //Compare jet pT and pt Hard
2877  if(jet->Pt() > fMaxFacPtHard * ptHard){
2878  eventAccepted= kFALSE;
2879  }
2880  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2881  }
2882  if (mcEvent){
2883  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2884  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2885  if (!particle) continue;
2886  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2887  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2888  eventAccepted= kFALSE;
2889  }
2890  }
2891 
2892  }
2893  }
2894 
2895  if ( fPeriodEnum == kLHC16P1JJLowB) {
2896  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2897  21, 28, 36, 45, 57,
2898  70, 85, 99, 115, 132,
2899  150, 169, 190, 212, 235,
2900  1000000};
2901  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2902  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2903  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2904  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2905  Int_t bin = 0;
2906  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2907  if (bin < 20) weight = weightsBins[bin];
2908 
2909  } else if ( fPeriodEnum == kLHC16P1JJ ){
2910  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2911  21, 28, 36, 45, 57,
2912  70, 85, 99, 115, 132,
2913  150, 169, 190, 212, 235,
2914  1000000};
2915  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2916  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2917  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2918  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2919 
2920  Int_t bin = 0;
2921  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2922  if (bin < 20) weight = weightsBins[bin];
2923 
2924  } else if ( fPeriodEnum == kLHC16h3 ){
2925  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2926  21, 28, 36, 45, 57,
2927  70, 85, 99, 115, 132,
2928  150, 169, 190, 212, 235,
2929  1000000};
2930  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2931  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2932  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2933  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2934  Int_t bin = 0;
2935  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2936  if (bin < 20) weight = weightsBins[bin];
2937 
2938 
2939  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2940  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2941  21, 28, 36, 45, 57,
2942  70, 85, 1000};
2943  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2944  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2945  1.933238e-05, 1.562895e-05};
2946  Int_t bin = 0;
2947  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2948  if (bin < 12) weight = weightsBins[bin];
2949 
2950  } else if ( fPeriodEnum == kLHC15g1a ){
2951  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2952  84, 117, 152, 191, 1000000,
2953  5, 7, 9, 12, 16,
2954  21, 28, 36, 45, 57 };
2955  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2956  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2957  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2958  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2959 
2960  Int_t bin = 0;
2961  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2962  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2963  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2964  if (bin < 19) weight = weightsBins[bin];
2965 
2966  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2967  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2968  84, 117, 152, 191, 1000000,
2969  5, 7, 9, 12, 16,
2970  21, 28, 36, 45, 57 };
2971  // LHC15a3a
2972  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2973  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2974  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2975  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2976  Int_t bin = 0;
2977  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2978  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2979  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2980  if (bin < 19) weight = weightsBins[bin];
2981 
2982  } else if ( fPeriodEnum == kLHC12P2JJ ){
2983  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2984  21, 28, 36, 45, 57,
2985  70, 85, 99, 115, 132,
2986  150, 169, 190, 212, 235,
2987  1000000};
2988  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
2989  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
2990  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
2991  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
2992  Int_t bin = 0;
2993  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2994  if (bin < 20) weight = weightsBins[bin];
2995 
2996  } else if ( fPeriodEnum == kLHC16c3a ){
2997  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
2998  Double_t weightsBins[5] = { 0.00672445, 0.00799158, 0.00678934, 0.00463908, 0.00600068}; //preliminary estimates
2999  Int_t bin = 0;
3000  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3001  if (bin < 5) weight = weightsBins[bin];
3002 
3003  } else if (fPeriodEnum == kLHC16c3b ){
3004  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
3005  Double_t weightsBins[6] = { 0.00608281, 0.00393646, 0.00200138, 0.000986267, 0.000389051, 0.0001863}; //preliminary estimates
3006  Int_t bin = 0;
3007  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3008  if (bin < 6) weight = weightsBins[bin];
3009 
3010  } else if (fPeriodEnum == kLHC16c3c ){
3011  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
3012  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
3013  Int_t bin = 0;
3014  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3015  if (bin < 7) weight = weightsBins[bin];
3016 
3017  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
3018  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
3019  84, 117, 152, 191, 234,
3020  1000};
3021  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
3022  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
3023  Int_t bin = 0;
3024  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3025  if (bin < 10) weight = weightsBins[bin];
3026  } else if ( fPeriodEnum == kLHC16rP1JJ ){ // preliminary weights obtained from local running
3027  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};
3028  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};
3029  Int_t bin = 0;
3030  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3031  if (bin < 20) weight = weightsBins[bin];
3032  } else if ( fPeriodEnum == kLHC16sP1JJ ){ // preliminary weights obtained from local running
3033  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};
3034  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};
3035  Int_t bin = 0;
3036  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3037  if (bin < 20) weight = weightsBins[bin];
3038  } else if ( fPeriodEnum == kLHC17i3a1 ){ // weights obtained from ga_pp_mc_aod train 912
3039  Double_t ptHardBinRanges[7] = { 5, 11, 21, 36, 57, 84, 10000};
3040  Double_t weightsBins[6] = { 0.0002181, 3.13684e-05, 5.01515e-06, 9.50662e-07, 2.08186e-07, 7.96555e-08};
3041  Int_t bin = 0;
3042  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3043  if (bin < 6) weight = weightsBins[bin];
3044  } else if ( fPeriodEnum == kLHC18b8 ){
3045  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};
3046  Double_t weightsBins[20] = { 16.1083, 4.60917, 2.15196, 0.782021, 0.26541,
3047  0.0978374, 0.0294286, 0.00989457, 0.0040615, 0.00135787,
3048  0.000531766, 0.000188772, 9.23331e-05, 4.30245e-05, 2.10196e-05,
3049  1.06695e-05, 5.78742e-06, 3.02897e-06, 1.62702e-06, 2.12118e-06 };
3050 
3051  Int_t bin = 0;
3052  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3053  if (bin < 20) weight = weightsBins[bin];
3054  } else {
3055  weight = 1;
3056  }
3057 
3058  if (weight == -1) return kFALSE;
3059  else return eventAccepted;
3060 
3061  } else {
3062  return kFALSE;
3063  }
3064  }
3065 
3066  return kFALSE;
3067 }
3068 
3069 //________________________________________________________________________
3070 // Analysing Jet-Jet MC's
3071 //________________________________________________________________________
3072 void AliConvEventCuts::GetXSectionAndNTrials(AliMCEvent *mcEvent, Float_t &XSection, Float_t &NTrials, AliVEvent* event){
3073 
3074  AliGenCocktailEventHeader *cHeader = 0x0;
3075  Bool_t headerFound = kFALSE;
3076  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
3077  fPeriodEnum != kLHC17i3a1 && // LHC16ijklop GammaJet MC EMCal triggered
3078  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
3079  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
3080  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
3081  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
3082  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
3083  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
3084  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
3085  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
3086  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
3087  ){
3088  NTrials = -1;
3089  XSection = -1;
3090  return;
3091  }
3092 
3093  if(mcEvent){
3094  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
3095  if(cHeader) headerFound = kTRUE;
3096  }else{
3097  //no mcEvent available -> not running on MC
3098  NTrials = -1;
3099  XSection = -1;
3100  return;
3101  }
3102 
3103  if(headerFound){
3104  TList *genHeaders = 0x0;
3105  if(cHeader) genHeaders = cHeader->GetHeaders();
3106  AliGenEventHeader* gh = 0;
3107  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3108  gh = (AliGenEventHeader*)genHeaders->At(i);
3109  TString GeneratorName = gh->GetName();
3110  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
3111  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(gh);
3112  NTrials = gPythia->Trials();
3113  XSection = gPythia->GetXsection();
3114  return;
3115  }
3116  }
3117  } else {
3118  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
3119  if(eventHeader){
3120  TString eventHeaderName = eventHeader->ClassName();
3121  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
3122  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader);
3123  NTrials = gPythia->Trials();
3124  XSection = gPythia->GetXsection();
3125  return;
3126  }
3127  }
3128  }
3129  // the following part is necessary for pythia8jets embedded in EPOS for AODs
3130  if(event){
3131  if(event->IsA()==AliAODEvent::Class()){
3132  AliAODMCHeader *mch = NULL;
3133  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
3134  if(aod){
3135  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
3136  if ( mch ){
3137  Int_t nGenerators = mch->GetNCocktailHeaders();
3138  if ( nGenerators > 0 ){
3139  for(Int_t igen = 0; igen < nGenerators; igen++)
3140  {
3141  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
3142  TString name = eventHeaderGen->GetName();
3143  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
3144  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeaderGen);
3145  NTrials = gPythia->Trials();
3146  XSection = gPythia->GetXsection();
3147  return;
3148  }
3149  }
3150  }
3151  }
3152  }
3153  }
3154  }
3155 
3156  NTrials = -1;
3157  XSection = -1;
3158  return;
3159 }
3160 
3161 
3162 //________________________________________________________________________
3163 // Analysing Jet-Jet MC's
3164 //________________________________________________________________________
3165 Float_t AliConvEventCuts::GetPtHard(AliMCEvent *mcEvent, AliVEvent* event){
3166  AliGenCocktailEventHeader *cHeader = 0x0;
3167  Bool_t headerFound = kFALSE;
3168 
3169  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
3170  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
3171  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
3172  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
3173  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
3174  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
3175  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
3176  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
3177  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
3178  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
3179  ) return -1;
3180 
3181  if(mcEvent){
3182  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
3183  if(cHeader) headerFound = kTRUE;
3184  }else{
3185  //no mcEvent available -> not running on MC
3186  return -1;
3187  }
3188 
3189  if(headerFound){
3190  TList *genHeaders = 0x0;
3191  if(cHeader) genHeaders = cHeader->GetHeaders();
3192  AliGenEventHeader* gh = 0;
3193  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3194  gh = (AliGenEventHeader*)genHeaders->At(i);
3195  TString GeneratorName = gh->GetName();
3196  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
3197  return dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
3198  }
3199  }
3200  } else {
3201  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
3202  if(eventHeader){
3203  TString eventHeaderName = eventHeader->ClassName();
3204  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
3205  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
3206  }
3207  }
3208 
3209  if(event->IsA()==AliAODEvent::Class()){
3210  AliAODMCHeader *mch = NULL;
3211  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
3212  if(aod){
3213  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
3214  if ( mch ){
3215  Int_t nGenerators = mch->GetNCocktailHeaders();
3216  if ( nGenerators > 0 ){
3217  for(Int_t igen = 0; igen < nGenerators; igen++)
3218  {
3219  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
3220  TString name = eventHeaderGen->GetName();
3221  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
3222  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeaderGen)->GetPtHard();
3223  }
3224  }
3225  }
3226  }
3227  }
3228  }
3229  }
3230 
3231  return -1;
3232 }
3233 
3234 
3235 //________________________________________________________________________
3237  // abort if mimicing not enabled
3238 
3239  if (!fMimicTrigger) return kTRUE;
3240 
3241  Int_t runRangesEMCalL0 [52] = { 144871, 145288, 146375, 146382, // LHC11a
3242  146502, 148522, // LHC11a
3243  150209, 153056, 153911, 153915, // LHC11b,c,d
3244  158135, 158136, 158178, 158182, 160683,
3245  160764, 161139, 161256, 161379, 161457,
3246  161525, 161556, 161558, 161609, 161630,
3247  161724, // LHC11d,e
3248  173731, 177144, 177147, 177653, 177724, 178327, // LHC12x
3249  195180, // LHC13b-f
3250  197469, 197692, // LHC13g
3251  235195, // LHC15a-h
3252  244285, // LHC15i-LHC15m (235196-244284)
3253  244629, // LHC15n (244340-244628)
3254  245141, 246995, // LHC15o (244824-246994)
3255  255539, // LHC16i-k (255515-258574)
3256  258883, // LHC16l (258883-260187)
3257  260216, // LHC16m-p (260216-p)
3258  265015, 265309, // LHC16q (265015-265525)
3259  265589, 265785, // LHC16r (265589-266318)
3260  266405, // LHC16s (266405-267131)
3261  267161, // LHC16t (267161-267166)
3262  270531, // LHC17c-o (270531-281961)
3263  282008, // LHC17pq (282008-282441)
3264  282504 // 2018
3265  };
3266 
3267  Double_t thresholdEMCalL0[51] = { 2.11, 3.43, 1.71, 2.05, // LHC11a 7 TeV
3268  3.43, // LHC11a 2.76TeV
3269  1.94, 3.39, 4.01, 5.25, 5.5, // LHC11b, LHC11c, LHC11d
3270  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,
3271  2.01, 1.75, 1.52, 2.01, 1.52, 1.85,
3272  3.2,
3273  /*2.01*/1.8, // LHC13g
3274  2000, // LS1
3275  1.8, // LHC15a-h
3276  5.0, // LHC15i-m
3277  5.0, // LHC15n
3278  1.0, 1.0, // LHC15o
3279  2.2, // LHC16i-k (255515-258574)
3280  2.2, // LHC16l (258883-260187)
3281  2.5, // LHC16m-p (260216-p)
3282  2.5, 2.5, // LHC16q (265015-265525)
3283  2.5, 2.5, // LHC16r (265589-266318)
3284  3.5, // LHC16s (266405-267131)
3285  2.5, // LHC16t (267161-267166)
3286  2.5, // LHC17c-o (270531-281961)
3287  2.5 // LHC17pq (282008-282441)
3288 // 2.5 // 2018
3289  };
3290 
3291  Double_t spreadEMCalL0[51] = { 0., 0., 0, 0, // LHC11a 7TeV
3292  /*0.7*/0.65, // LHC11a 2.76TeV
3293  0., 0., 0., 0., 0., // LHC11b, LHC11c, LHC11d
3294  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
3295  0., 0., 0., 0., 0.2, 0.2,/*0.,0.,*/
3296  0.1, // LHC13b-f
3297  /*0.1*/0.12, // LHC13g
3298  0., // LS1
3299  0.1, // LHC15a-h
3300  0.1, // LHC15i-m
3301  0.1, // LHC15n
3302  0.1, 0.1, // LHC15o
3303  0.2, // LHC16i-k (255515-258574)
3304  0.2, // LHC16l (258883-260187)
3305  0.1, // LHC16m-p (260216-p)
3306  0.1, 0.1, // LHC16q (265015-265525)
3307  0.1, 0.1, // LHC16r (265589-266318)
3308  0.1, // LHC16s (266405-267131)
3309  0.1, // LHC16t (267161-267166)
3310  0.1, // LHC17c-o (270531-281961)
3311  0.1 // LHC17pq (282008-282441)
3312 // 0.1 // 2018
3313  };
3314 
3315  Int_t runRangesEMCalL1[21] = { 179796, // LHC12c-i (EGA)
3316  195180, // LHC13b-f
3317  197469, 197692, // LHC13g
3318  235195, // LHC15a-h
3319  244285, // LHC15i-LHC15m (235196-244284)
3320  244629, // LHC15n (244340-244628)
3321  245141, 246995, // LHC15o (244824-246994)
3322  255539, // LHC16i-k (255515-258574)
3323  258883, // LHC16l (258883-260187)
3324  260216, // LHC16m-p (260216-p)
3325  265015, 265309, // LHC16q (265015-265525)
3326  265589, 265785, // LHC16r (265589-266318)
3327  266405, // LHC16s (266405-267131)
3328  267161, // LHC16t (267161-267166)
3329  270531, // LHC17c-o (270531-281961)
3330  282008, // LHC17pq (282008-282441)
3331  282504 // 2018
3332  };
3333 
3334  Double_t thresholdEMCalL1[20] = { 9.5/*8.398*/, // LHC12c-i (EGA)
3335  11.5, /*6.*/ // LHC13b-f
3336  5.5, // LHC13g
3337  2000.0, // LS1
3338  2000.0, // LHC15a-h
3339  5.0, // LHC15i-m
3340  5.0, // LHC15n
3341  2000.0, 10.0, // LHC15o
3342  8.8, // LHC16i-k (255515-258574)
3343  5.5, // LHC16l (258883-260187)
3344  8.8, // LHC16m-p (260216-)
3345  8.8, 10.8, // LHC16q (265015-265525)
3346  10.8, 7.8, // LHC16r (265589-266318)
3347  7.8, // LHC16s (266405-267131)
3348  7.8, // LHC16t (267161-267166)
3349  8.8, // LHC17c-o (270531-281961)
3350  8.8 // LHC17pq (282008-282441)
3351 // 8.8 // 2018
3352  };
3353  Double_t spreadEMCalL1[20] = { 1.0/*0.*/,
3354  0.5,
3355  /*0.4*/ 0.6,
3356  0.0, // LS1
3357  1.2, 0.8, // LHC16r (265589-266318)
3358  0.0, // LHC15a-h
3359  1.0, // LHC15i-m
3360  1.0, // LHC15n
3361  0.0, 1.0, // LHC15o
3362  1.0, // LHC16i-k (255515-258574)
3363  0.8, // LHC16l (258883-260187)
3364  1.0, // LHC16m-p (260216-)
3365  1.0, 1.2, // LHC16q (265015-265525)
3366  0.9, // LHC16s (266405-267131)
3367  0.9, // LHC16t (267161-267166)
3368  1.0, // LHC17c-o (270531-281961)
3369  1.0 // LHC17pq (282008-282441)
3370 // 1.0 // 2018
3371  };
3372 
3373  Int_t runRangesEMCalL1G2[21] = { 195180, // LHC13b-f
3374  197469, 197692, // LHC13g
3375  235195, // LHC15a-h
3376  244285, // LHC15i-LHC15m (235196-244284)
3377  244629, // LHC15n (244340-244628)
3378  245141, 246995, // LHC15o (244824-246994)
3379  255539, // LHC16i-k (255515-258574)
3380  258883, // LHC16l (258883-260187)
3381  260216, // LHC16m-p (260216-)
3382  265015, 265309, // LHC16q (265015-265525)
3383  265589, 265785, // LHC16r (265589-266318)
3384  266405, // LHC16s (266405-267131)
3385  267161, // LHC16t (267161-267166)
3386  270531, // LHC17c-o (270531-281961)
3387  282008, // LHC17pq (282008-282441)
3388  282504 // 2018
3389  };
3390 
3391  Double_t thresholdEMCalL1G2[19] = { 7.2, // LHC13b-f
3392  /*3.9*/3.75, // LHC13g
3393  2000.0, // LS1
3394  1.8, // LHC15a-h
3395  5.0, // LHC15i-m
3396  5.0, // LHC15n
3397  2000.0, 2000.0, // LHC15o
3398  3.9, // LHC16i-k (255515-258574)
3399  3.8, // LHC16l (258883-260187)
3400  3.9, // LHC16m-p (260216-)
3401  3.9, 6.3, // LHC16q (265015-265525)
3402  6.3, 5.3, // LHC16r (265589-266318)
3403  5.3, // LHC16s (266405-267131)
3404  5.3, // LHC16t (267161-267166)
3405  3.9, // LHC17c-o (270531-281961)
3406  3.9 // LHC17pq (282008-282441)
3407 // 3.9 // 2018
3408  };
3409  Double_t spreadEMCalL1G2[19] = { 0.3, // LHC13bf
3410  /*0.2*/0.25, // LHC13g
3411  0., // LS1
3412  0.1, // LHC15a-h
3413  0.1, // LHC15i-m
3414  0.1, // LHC15n
3415  0.1, 1.0, // LHC15o
3416  0.3, // LHC16i-k (255515-258574)
3417  0.3, // LHC16l (258883-260187)
3418  0.3, // LHC16m-p (260216-)
3419  0.3, 0.4, // LHC16q (265015-265525)
3420  0.4, 0.3, // LHC16r (265589-266318)
3421  0.3, // LHC16s (266405-267131)
3422  0.3, // LHC16t (267161-267166)
3423  0.3, // LHC17c-o (270531-281961)
3424  0.3 // LHC17pq (282008-282441)
3425 // 0.3 // 2018
3426  };
3427 
3428  Int_t runnumber = event->GetRunNumber();
3429 
3430  if (fSpecialTrigger == 5 ){
3431  if (runnumber < runRangesEMCalL0[0]) return kTRUE;
3432  Int_t binRun = 0;
3433  while (!(runnumber >= runRangesEMCalL0[binRun] && runnumber < runRangesEMCalL0[binRun+1] ) && binRun < 51 ){
3434 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << ":\t"<< thresholdEMCalL0[binRun] << "\t" << spreadEMCalL0[binRun] << endl;
3435  binRun++;
3436  }
3437  if (binRun==51) return kFALSE;
3438 // cout << runnumber << "\t"<< binRun << "\t"<< thresholdEMCalL0[binRun] << "\t" << spreadEMCalL0[binRun] << endl;
3439  Double_t threshold = thresholdEMCalL0[binRun];
3440 
3441  if (isMC && spreadEMCalL0[binRun] != 0.){
3442  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3443  triggerSmearing->SetParameter(0, 1/(spreadEMCalL0[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3444  triggerSmearing->SetParameter(1, thresholdEMCalL0[binRun]);
3445  triggerSmearing->SetParameter(2, spreadEMCalL0[binRun]);
3446  threshold = triggerSmearing->GetRandom();
3447  delete triggerSmearing;
3448  }
3449 
3450 // cout << "modified" << "\t"<< threshold << endl;
3451  Int_t nclus = 0;
3452  TClonesArray * arrClustersMimic = NULL;
3453  if(!fCorrTaskSetting.CompareTo("")){
3454  nclus = event->GetNumberOfCaloClusters();
3455  } else {
3456  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3457  if(!arrClustersMimic)
3458  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3459  nclus = arrClustersMimic->GetEntries();
3460  }
3461 
3462  if(nclus == 0) return kFALSE;
3463 
3464  // Loop over EMCal clusters
3465  Bool_t eventIsAccepted = kFALSE;
3466  for(Int_t i = 0; i < nclus; i++){
3467  if (eventIsAccepted) continue;
3468  AliVCluster* clus = NULL;
3469  if(event->IsA()==AliESDEvent::Class()){
3470  if(arrClustersMimic)
3471  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3472  else
3473  clus = event->GetCaloCluster(i);
3474  } else if(event->IsA()==AliAODEvent::Class()){
3475  if(arrClustersMimic)
3476  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3477  else
3478  clus = event->GetCaloCluster(i);
3479  }
3480 
3481  if (!clus){
3482  if(arrClustersMimic) delete clus;
3483  continue;
3484  }
3485  if (!clus->IsEMCAL()) {
3486  if(arrClustersMimic) delete clus;
3487  continue;
3488  }
3489  if (clus->GetM02()<0.1) {
3490  if(arrClustersMimic) delete clus;
3491  continue;
3492  }
3493  if (clus->GetNCells()<2) {
3494  if(arrClustersMimic) delete clus;
3495  continue;
3496  }
3497  if (clus->E() > threshold ){
3498 // cout << "found L0" << endl;
3499  eventIsAccepted = kTRUE;
3500  }
3501  if(arrClustersMimic)
3502  delete clus;
3503  }
3504  return eventIsAccepted;
3505 
3506  } else if (fSpecialTrigger == 6 ) {
3507 
3508  return kTRUE;
3509  } else if (fSpecialTrigger == 8 ) {
3510  if (fSpecialSubTriggerName.CompareTo("7EGA")==0 || fSpecialSubTriggerName.CompareTo("8EGA")==0 || fSpecialSubTriggerName.CompareTo("7EG1")==0 ||fSpecialSubTriggerName.CompareTo("8EG1")==0 ){
3511  if (runnumber < runRangesEMCalL1[0]) return kTRUE;
3512  Int_t binRun = 0;
3513  while (!(runnumber >= runRangesEMCalL1[binRun] && runnumber < runRangesEMCalL1[binRun+1] ) && binRun < 20 ){
3514 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL1[binRun] << "\t" << runRangesEMCalL1[binRun+1] << ":\t"<< thresholdEMCalL1[binRun]<<"\t"<< spreadEMCalL1[binRun]<< endl;
3515  binRun++;
3516  }
3517  if (binRun==20) return kFALSE;
3518  Double_t threshold = thresholdEMCalL1[binRun];
3519 
3520  if (isMC && spreadEMCalL1[binRun] != 0.){
3521  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3522  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3523  triggerSmearing->SetParameter(1, thresholdEMCalL1[binRun]);
3524  triggerSmearing->SetParameter(2, spreadEMCalL1[binRun]);
3525  threshold = triggerSmearing->GetRandom();
3526  delete triggerSmearing;
3527  }
3528 
3529 // cout << runnumber << "\t"<< binRun << "\t L1 \t"<< threshold << endl;
3530 
3531  TClonesArray * arrClustersMimic = NULL;
3532  Int_t nclus = 0;
3533  if(!fCorrTaskSetting.CompareTo("")){
3534  nclus = event->GetNumberOfCaloClusters();
3535  } else {
3536  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3537  if(!arrClustersMimic)
3538  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3539  nclus = arrClustersMimic->GetEntries();
3540  }
3541 
3542  if(nclus == 0) return kFALSE;
3543 
3544  // Loop over EMCal clusters
3545  Bool_t eventIsAccepted = kFALSE;
3546  for(Int_t i = 0; i < nclus; i++){
3547  if (eventIsAccepted) continue;
3548  AliVCluster* clus = NULL;
3549  if(event->IsA()==AliESDEvent::Class()){
3550  if(arrClustersMimic)
3551  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3552  else
3553  clus = event->GetCaloCluster(i);
3554  } else if(event->IsA()==AliAODEvent::Class()){
3555  if(arrClustersMimic)
3556  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3557  else
3558  clus = event->GetCaloCluster(i);
3559  }
3560  if (!clus) {
3561  if(arrClustersMimic) delete clus;
3562  continue;
3563  }
3564  if (!clus->IsEMCAL()) {
3565  if(arrClustersMimic) delete clus;
3566  continue;
3567  }
3568  if (clus->GetM02()<0.1) {
3569  if(arrClustersMimic) delete clus;
3570  continue;
3571  }
3572  if (clus->GetNCells()<2) {
3573  if(arrClustersMimic) delete clus;
3574  continue;
3575  }
3576  if (clus->E() > threshold ){
3577 // cout << "found L1G1\t" << clus->E() << endl;
3578  eventIsAccepted = kTRUE;
3579  }
3580  if(arrClustersMimic)
3581  delete clus;
3582  }
3583  return eventIsAccepted;
3584  } else if ( fSpecialSubTriggerName.CompareTo("7EG2")==0 ||fSpecialSubTriggerName.CompareTo("8EG2")==0 ){
3585  if (runnumber < runRangesEMCalL1G2[0]) return kTRUE;
3586  Int_t binRun = 0;
3587  while (!(runnumber >= runRangesEMCalL1G2[binRun] && runnumber < runRangesEMCalL1G2[binRun+1] ) && binRun < 19 ){
3588 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL1G2[binRun] << "\t" << runRangesEMCalL1G2[binRun+1] << ":\t"<< thresholdEMCalL1G2[binRun]<<"\t"<< spreadEMCalL1G2[binRun]<< endl;
3589  binRun++;
3590  }
3591 // cout << runnumber << "\t"<< binRun << "\t L2 \t"<< thresholdEMCalL1G2[binRun]<<"\t"<< spreadEMCalL1G2[binRun]<< endl;
3592  if (binRun==19) return kFALSE;
3593  Double_t threshold = thresholdEMCalL1G2[binRun];
3594  if (isMC && spreadEMCalL1G2[binRun] != 0.){
3595  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3596  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1G2[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3597  triggerSmearing->SetParameter(1, thresholdEMCalL1G2[binRun]);
3598  triggerSmearing->SetParameter(2, spreadEMCalL1G2[binRun]);
3599  threshold = triggerSmearing->GetRandom();
3600  delete triggerSmearing;
3601  }
3602 // cout << "\t L2 mod\t"<< threshold << endl;
3603 
3604  Int_t nclus = 0;
3605  TClonesArray * arrClustersMimic = NULL;
3606  if(!fCorrTaskSetting.CompareTo("")){
3607  nclus = event->GetNumberOfCaloClusters();
3608  } else {
3609  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3610  if(!arrClustersMimic)
3611  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3612  nclus = arrClustersMimic->GetEntries();
3613  }
3614 
3615  if(nclus == 0) return kFALSE;
3616 
3617  // Loop over EMCal clusters
3618  Bool_t eventIsAccepted = kFALSE;
3619  for(Int_t i = 0; i < nclus; i++){
3620  if (eventIsAccepted) continue;
3621  AliVCluster* clus = NULL;
3622  if(event->IsA()==AliESDEvent::Class()){
3623  if(arrClustersMimic)
3624  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3625  else
3626  clus = event->GetCaloCluster(i);
3627  } else if(event->IsA()==AliAODEvent::Class()){
3628  if(arrClustersMimic)
3629  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3630  else
3631  clus = event->GetCaloCluster(i);
3632  }
3633  if (!clus) {
3634  if(arrClustersMimic) delete clus;
3635  continue;
3636  }
3637  if (!clus->IsEMCAL()) {
3638  if(arrClustersMimic) delete clus;
3639  continue;
3640  }
3641  if (clus->GetM02()<0.1) {
3642  if(arrClustersMimic) delete clus;
3643  continue;
3644  }
3645  if (clus->GetNCells()<2) {
3646  if(arrClustersMimic) delete clus;
3647  continue;
3648  }
3649  if (clus->E() > threshold ){
3650 // cout << "found L1G2" << endl;
3651  eventIsAccepted = kTRUE;
3652  }
3653  if(arrClustersMimic)
3654  delete clus;
3655  }
3656  return eventIsAccepted;
3657  }
3658  return kTRUE;
3659  } else if (fSpecialTrigger == 9 ) {
3660  return kTRUE;
3661  } else {
3662  return kTRUE;
3663  }
3664 
3665  return kTRUE;
3666 }
3667 
3668 
3669 //________________________________________________________________________
3671 {
3672 
3673  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
3674 
3675 
3676  UInt_t isSelected = AliVEvent::kAny;
3677 
3678  if (fInputHandler==NULL) return kFALSE;
3679  if( fInputHandler->GetEventSelection() || event->IsA()==AliAODEvent::Class()) {
3680 
3681  TString firedTrigClass = event->GetFiredTriggerClasses();
3682  // if no trigger has been selected manually, select kAny in case of presel (also important for AOD filtering!)
3683  // in other cases select standards depending on system
3685  if (fPreSelCut) fOfflineTriggerMask = AliVEvent::kAny;
3686  else {
3687  if (fIsHeavyIon == 1){
3688  fOfflineTriggerMask = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
3689  } else if (fIsHeavyIon == 2){
3690  fOfflineTriggerMask = AliVEvent::kINT7;
3691  } else {
3692  fOfflineTriggerMask = AliVEvent::kMB;
3693  }
3694  }
3695  }
3696 
3697  // in case of MC switch to kAny if no MB/INT7/INT8 has been selected
3698  if(isMC){
3699  if( fIsHeavyIon == 0){
3700  if( fOfflineTriggerMask != AliVEvent::kMB && fOfflineTriggerMask != AliVEvent::kINT7 && fOfflineTriggerMask != AliVEvent::kINT8 ){
3701  fOfflineTriggerMask = AliVEvent::kAny;
3702  }
3703  }else{
3704  fOfflineTriggerMask = AliVEvent::kAny;
3705  }
3706  }
3707 
3708  if (fOfflineTriggerMask){
3709  isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
3710  if (isSelected && !fPreSelCut){
3711 // cout << firedTrigClass.Data() << endl;
3712 // cout << "Special trigger: "<< fSpecialTrigger << " initialized " << fEMCALTrigInitialized << endl;
3713 // if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3714 // if (!fEMCALTrigInitialized ) InitializeEMCALTrigger(event);
3715 // fTriggersEMCAL= GetTriggerList();
3716 // }
3717  if (fSpecialSubTrigger>0 && !isMC){
3718  if (!firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 0;
3719  if (fRejectTriggerOverlap){
3720  // trigger rejection EMC1,7,8
3721  if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC7") == 0){
3722  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3723  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC1") == 0){
3724  if (fInputHandler->IsEventSelected() & AliVEvent::kMB) isSelected = 0;
3725  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC8") == 0){
3726  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3727  }
3728  // trigger rejection EGA
3729  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EGA") == 0){
3730  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3731  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3732  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EGA") == 0){
3733  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3734  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3735  }
3736  // trigger rejection EG1 & EG2
3737  if (fPeriodEnum == kLHC13g){
3738  // EG1 is the trigger with the highest threshold
3739  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3740 // cout << firedTrigClass.Data() << endl;
3741  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3742 // cout << "INT7? " << isSelected << endl;
3743  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3744 // cout << "CEM7? " << isSelected << endl;
3745  if (firedTrigClass.Contains("7EG2")) isSelected = 0;
3746 // cout << "7EG2? " << isSelected << endl;
3747  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3748  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3749  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3750  if (firedTrigClass.Contains("8EG2")) isSelected = 0;
3751  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3752 // cout << firedTrigClass.Data() << endl;
3753  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3754 // cout << "INT7? " << isSelected << endl;
3755  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3756 // cout << "CEM7? " << isSelected << endl;
3757  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3758  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3759  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3760  }
3761  } else {
3762  // EG2 is the trigger with the highest threshold
3763  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3764  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3765  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3766  if (firedTrigClass.Contains("7EG1")) isSelected = 0;
3767  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3768  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3769  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3770  if (firedTrigClass.Contains("8EG1")) isSelected = 0;
3771  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3772  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3773  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3774  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3775  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3776  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3777  }
3778  }
3779  }
3780  if (isSelected != 0 ){
3781 // cout << "I am here" << " :" << fSpecialSubTriggerName.Data() <<endl;
3782  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9 ){
3784  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassesCorrelated->Fill(0);
3785  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassesCorrelated->Fill(1);
3786  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassesCorrelated->Fill(2);
3787  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassesCorrelated->Fill(3);
3788  if (firedTrigClass.Contains("7EJE") || firedTrigClass.Contains("8EJE")) hTriggerClassesCorrelated->Fill(4);
3789  if (firedTrigClass.Contains("7EJ1") || firedTrigClass.Contains("8EJ1")) hTriggerClassesCorrelated->Fill(5);
3790  if (firedTrigClass.Contains("7EJ2") || firedTrigClass.Contains("8EJ2")) hTriggerClassesCorrelated->Fill(6);
3791  if (firedTrigClass.Contains("7EGA") || firedTrigClass.Contains("8EGA")) hTriggerClassesCorrelated->Fill(7);
3792  if (firedTrigClass.Contains("7EG1") || firedTrigClass.Contains("8EG1")) hTriggerClassesCorrelated->Fill(8);
3793  if (firedTrigClass.Contains("7EG2") || firedTrigClass.Contains("8EG2")) hTriggerClassesCorrelated->Fill(9);
3794  }
3795  }
3796  }
3797 
3798  } else if (isMC){
3799  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3800 // isSelected = 0;
3801 // if (fTriggersEMCAL > 0)cout << "Special Trigger " << fSpecialTrigger << " triggers: " << fTriggersEMCAL << " selected triggers: " << fTriggersEMCALSelected << " run number: " <<event->GetRunNumber()<<endl;
3802 // if (fTriggersEMCAL&fTriggersEMCALSelected){
3803 // cout << "accepted ++++++++++++++++++++" << endl;
3804  isSelected = 1;
3805 // }
3806  }
3807  }
3808  //if for specific centrality trigger selection
3809  if(fSpecialSubTrigger == 1){
3810  if(fSpecialSubTriggerName.Contains("|") && GetCentrality(event) <= 10.){
3811  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("|");
3812  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3813  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3814  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3815  }
3816  } else if(fSpecialSubTriggerName.Contains("%")){
3817  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("%");
3818  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3819  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3820  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3821  }
3822  } else if(fSpecialSubTriggerName.Contains("@")){
3823  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("@");
3824  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3825  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3826  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3827  }
3828  } else if(fSpecialSubTriggerName.Contains("&")){ //logic AND of two classes
3829  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("&");
3830  TString CheckClass = "";
3831  for (Int_t i=0; i<ClassesList->GetEntriesFast(); i++){
3832  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3833  if (firedTrigClass.Contains(NameClass->GetString())) CheckClass+="1";
3834  else CheckClass+="0";
3835  }
3836  if(CheckClass.Contains("0")) isSelected = 0;
3837  }
3838  else if(firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 1;
3839  }
3840  }
3841  }
3842  }
3843  fIsSDDFired = !(fInputHandler->IsEventSelected() & AliVEvent::kFastOnly);
3844 
3845  Bool_t mimickedTrigger = kTRUE;
3846  if (fMimicTrigger) mimickedTrigger = MimicTrigger(event, isMC);
3847 // cout << "mimicked decision \t" << mimickedTrigger << "expect decision? "<< fMimicTrigger<< endl;
3848 
3849  // Fill Histogram
3850  if(hTriggerClass){
3851  if (fIsSDDFired) hTriggerClass->Fill(33);
3852  if (mimickedTrigger){
3853  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
3854  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
3855  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
3856  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClass->Fill(3);
3857  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClass->Fill(4);
3858  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
3859  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
3860  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
3861  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
3862  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
3863  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
3864  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClass->Fill(8);
3865  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClass->Fill(9);
3866  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClass->Fill(9);
3867  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClass->Fill(10);
3868  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClass->Fill(10);
3869  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClass->Fill(11);
3870  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClass->Fill(12);
3871  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClass->Fill(13);
3872  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClass->Fill(13);
3873  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClass->Fill(13);
3874  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClass->Fill(14);
3875  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClass->Fill(15);
3876  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClass->Fill(16);
3877  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClass->Fill(17);
3878  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClass->Fill(18);
3879  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClass->Fill(19);
3880  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClass->Fill(20);
3881  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClass->Fill(20);
3882  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClass->Fill(21);
3883  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClass->Fill(22);
3884  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClass->Fill(23);
3885  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClass->Fill(24);
3886  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClass->Fill(25);
3887  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClass->Fill(26);
3888  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClass->Fill(27);
3889  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClass->Fill(28);
3890  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(29);
3891  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(30);
3892  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(31);
3893  if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(34);
3894  }
3895  if (mimickedTrigger && fMimicTrigger) hTriggerClass->Fill(35);
3896  }
3897 
3898  if(hTriggerClassSelected && isSelected){
3899  if (mimickedTrigger){
3900  if (!fIsSDDFired) hTriggerClassSelected->Fill(33);
3901  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
3902  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
3903  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
3904  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
3905  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
3906  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
3907  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
3908  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
3909  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
3910  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
3911  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
3912  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
3913  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
3914  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
3915  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
3916  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
3917  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
3918  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
3919  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
3920  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
3921  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
3922  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
3923  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
3924  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
3925  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
3926  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
3927  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
3928  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
3929  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
3930  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
3931  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
3932  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
3933  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
3934  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
3935  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
3936  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
3937  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClassSelected->Fill(28);
3938  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(29);
3939  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(30);
3940  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(31);
3941  }
3942  if (mimickedTrigger && fMimicTrigger) hTriggerClassSelected->Fill(34);
3943  }
3944 
3945  if(!isSelected)return kFALSE;
3946  if (fMimicTrigger)
3947  if (!mimickedTrigger ) return kFALSE;
3948  return kTRUE;
3949 
3950 }
3951 
3952 //________________________________________________________________________
3954  // returns TString with current cut number
3955  return fCutStringRead;
3956 }
3957 
3958 //________________________________________________________________________
3959 void AliConvEventCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliVEvent *event){
3960 
3961  if(fNotRejectedStart){
3962  delete[] fNotRejectedStart;
3963  fNotRejectedStart = NULL;
3964  }
3965  if(fNotRejectedEnd){
3966  delete[] fNotRejectedEnd;
3967  fNotRejectedEnd = NULL;
3968  }
3969  if(fGeneratorNames){
3970  delete[] fGeneratorNames;
3971  fGeneratorNames = NULL;
3972  }
3973 
3974  if(rejection == 0) return; // No Rejection
3975 
3976  AliGenCocktailEventHeader *cHeader = 0x0;
3977  AliAODMCHeader *cHeaderAOD = 0x0;
3978  Bool_t headerFound = kFALSE;
3979  AliMCEvent *fMCEvent = 0x0;
3980  TClonesArray *fMCEventAOD = 0x0;
3981  if(event->IsA()==AliMCEvent::Class()){
3982  if(dynamic_cast<AliMCEvent*>(event)){
3983  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(dynamic_cast<AliMCEvent*>(event)->GenEventHeader());
3984  fMCEvent = dynamic_cast<AliMCEvent*>(event);
3985  if(cHeader) headerFound = kTRUE;
3986  }
3987  }
3988  if(event->IsA()==AliAODEvent::Class()){ // event is a AODEvent in case of AOD
3989  cHeaderAOD = dynamic_cast<AliAODMCHeader*>(event->FindListObject(AliAODMCHeader::StdBranchName()));
3990  fMCEventAOD = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
3991  if(cHeaderAOD) headerFound = kTRUE;
3992  }
3993 
3994  if (fDebugLevel > 0 ) cout << "event starts here" << endl;
3995  if(headerFound){
3996  TList *genHeaders = 0x0;
3997  if(cHeader) genHeaders = cHeader->GetHeaders();
3998  if(cHeaderAOD){
3999  genHeaders = cHeaderAOD->GetCocktailHeaders();
4000  if(genHeaders->GetEntries()==1){
4002  return;
4003  }
4004  }
4005  AliGenEventHeader* gh = 0;
4006  fnHeaders = 0;
4007  Int_t firstindexA = 0;
4008  Int_t lastindexA = -1;
4009  if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
4010  if(rejection == 2 || rejection == 4){ // TList of Headers Names
4011  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
4012  gh = (AliGenEventHeader*)genHeaders->At(i);
4013  TString GeneratorName = gh->GetName();
4014  lastindexA = lastindexA + gh->NProduced();
4015  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
4016  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
4017  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
4018  if (fDebugLevel > 0 ) cout << GeneratorInList.Data() << endl;
4019  if(GeneratorInList.Contains(GeneratorName) ){
4020  if (fDebugLevel > 0 ) cout << "accepted" << endl;
4021  if (GeneratorInList.BeginsWith("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
4022  if(fMCEvent){
4023  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4024  if (fDebugLevel > 2 )cout << "number of produced particle: " << gh->NProduced() << endl;
4025  if (fDebugLevel > 2 )cout << "pdg-code of first particle: " << fMCEvent->Particle(firstindexA)->GetPdgCode() << endl;
4026  if (fMCEvent->Particle(firstindexA)->GetPdgCode() == fAddedSignalPDGCode ) {
4027  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindexA+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
4028  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4029  fnHeaders++;
4030  continue;
4031  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4032  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
4033  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4034  fnHeaders++;
4035  continue;
4036  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4037  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
4038  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4039  fnHeaders++;
4040  continue;
4041 
4042  }
4043  continue;
4044  }
4045  } else {
4046  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
4047  fnHeaders++;
4048  continue;
4049  }
4050  }
4051  if ( fMCEventAOD){
4052  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA));
4053  if (aodMCParticle && (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c) ){
4054  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
4055  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0){
4056  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA+10));
4057  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
4058  if (fDebugLevel > 0 ) cout << "cond 1: " << fnHeaders << endl;
4059  fnHeaders++;
4060  continue;
4061  }
4062  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4063  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
4064  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4065  fnHeaders++;
4066  continue;
4067  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4068  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
4069  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4070  fnHeaders++;
4071  continue;
4072 
4073  }
4074  continue;
4075  }
4076  } else {
4077  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
4078  fnHeaders++;
4079  continue;
4080  }
4081  }
4082  continue;
4083  }
4084  if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
4085  if (fDebugLevel > 0 ) cout << "cond 3: "<< fnHeaders << endl;
4086  fnHeaders++;
4087  continue;
4088  }
4089  }
4090  }
4091  firstindexA = firstindexA + gh->NProduced();
4092  }
4093  }
4094  if (fDebugLevel > 0 ) cout << "number of headers: " <<fnHeaders << endl;
4095 
4099 
4100  if(rejection == 1 || rejection == 3){
4101  fNotRejectedStart[0] = 0;
4102  fNotRejectedEnd[0] = ((AliGenEventHeader*)genHeaders->At(0))->NProduced()-1;
4103  fGeneratorNames[0] = ((AliGenEventHeader*)genHeaders->At(0))->GetName();
4104  if (fDebugLevel > 0 ) cout << 0 << "\t" <<fGeneratorNames[0] << "\t" << fNotRejectedStart[0] << "\t" <<fNotRejectedEnd[0] << endl;
4105  return;
4106  }
4107 
4108  Int_t firstindex = 0;
4109  Int_t lastindex = -1;
4110  Int_t number = 0;
4111 
4112  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
4113  gh = (AliGenEventHeader*)genHeaders->At(i);
4114  TString GeneratorName = gh->GetName();
4115  lastindex = lastindex + gh->NProduced();
4116  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
4117  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
4118  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
4119  if(GeneratorInList.Contains(GeneratorName) ){
4120  if (GeneratorInList.Contains("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
4121  if(fMCEvent){
4122  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4123  if (fMCEvent->Particle(firstindex)->GetPdgCode() == fAddedSignalPDGCode ) {
4124  if (fDebugLevel > 0 ) cout << "produced " << gh->NProduced() << " with box generator" << endl;
4125  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindex+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
4126  if (fDebugLevel > 0 ) cout << "one of them was a pi0 or eta" << endl;
4127  fNotRejectedStart[number] = firstindex;
4128  fNotRejectedEnd[number] = lastindex;
4129  fGeneratorNames[number] = GeneratorName;
4130  number++;
4131  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4132  continue;
4133  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4134  fNotRejectedStart[number] = firstindex;
4135  fNotRejectedEnd[number] = lastindex;
4136  fGeneratorNames[number] = GeneratorName;
4137  number++;
4138  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4139  continue;
4140  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4141  fNotRejectedStart[number] = firstindex;
4142  fNotRejectedEnd[number] = lastindex;
4143  fGeneratorNames[number] = GeneratorName;
4144  number++;
4145  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4146  continue;
4147  }
4148  }
4149  continue;
4150  } else {
4151  fNotRejectedStart[number] = firstindex;
4152  fNotRejectedEnd[number] = lastindex;
4153  fGeneratorNames[number] = GeneratorName;
4154  number++;
4155  continue;
4156  }
4157  }
4158  if ( fMCEventAOD){
4159  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex));
4160  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4161  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
4162  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0) {
4163  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex+10));
4164  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
4165  fNotRejectedEnd[number] = lastindex;
4166  fNotRejectedStart[number] = firstindex;
4167  fGeneratorNames[number] = GeneratorName;
4168  number++;
4169  }
4170  continue;
4171  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4172  fNotRejectedStart[number] = firstindex;
4173  fNotRejectedEnd[number] = lastindex;
4174  fGeneratorNames[number] = GeneratorName;
4175  number++;
4176  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4177  continue;
4178  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4179  fNotRejectedStart[number] = firstindex;
4180  fNotRejectedEnd[number] = lastindex;
4181  fGeneratorNames[number] = GeneratorName;
4182  number++;
4183  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4184  continue;
4185  }
4186  continue;
4187  }
4188  } else {
4189  fNotRejectedStart[number] = firstindex;
4190  fNotRejectedEnd[number] = lastindex;
4191  fGeneratorNames[number] = GeneratorName;
4192  number++;
4193  continue;
4194  }
4195  }
4196  continue;
4197  } else if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
4198  fNotRejectedStart[number] = firstindex;
4199  fNotRejectedEnd[number] = lastindex;
4200  fGeneratorNames[number] = GeneratorName;
4201  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4202  number++;
4203  continue;
4204  }
4205 
4206  }
4207  }
4208  firstindex = firstindex + gh->NProduced();
4209  }
4210  if (fDebugLevel > 0 ) {
4211  for (Int_t i = 0; i < number; i++){
4212  cout << i << "\t" <<fGeneratorNames[i] << "\t" << fNotRejectedStart[i] << "\t" <<fNotRejectedEnd[i] << endl;
4213  }
4214  }
4215  } else { // No Cocktail Header Found
4216  fNotRejectedStart = new Int_t[1];
4217  fNotRejectedEnd = new Int_t[1];
4218 
4219  fnHeaders = 1;
4220  fNotRejectedStart[0] = 0;
4221  fNotRejectedEnd[0] = static_cast<AliMCEvent*>(event)->GetNumberOfPrimaries()-1;
4222  if (rejection > 1){
4223  fNotRejectedStart[0] = -1;
4224  fNotRejectedEnd[0] = -1;
4225  }
4226 
4227  fGeneratorNames = new TString[1];
4228  fGeneratorNames[0] = "NoCocktailGeneratorFound";
4229 // SetRejectExtraSignalsCut(0);
4230  }
4231 
4232 }
4233 
4234 //_________________________________________________________________________
4235 Int_t AliConvEventCuts::IsParticleFromBGEvent(Int_t index, AliMCEvent *mcEvent, AliVEvent *InputEvent, Int_t debug ){
4236 
4237  // if (debug > 2 ) cout << index << endl;
4238  if(index < 0) return 0; // No Particle
4239 
4240  Int_t accepted = 0;
4241  if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
4242  if(!mcEvent) return 0; // no mcEvent available, return 0
4243  if(index >= mcEvent->GetNumberOfPrimaries()){ // initial particle is secondary particle
4244  if( ((TParticle*)mcEvent->Particle(index))->GetMother(0) < 0) return 0; // material particle, return 0
4245  return IsParticleFromBGEvent(((TParticle*)mcEvent->Particle(index))->GetMother(0),mcEvent,InputEvent, debug);
4246  }
4247  for(Int_t i = 0;i<fnHeaders;i++){
4248  // if (debug > 2 ) cout << "header " << fGeneratorNames[i].Data() << ":"<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
4249  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
4250  if (debug > 1 ) cout << "accepted:" << index << "\t header " << fGeneratorNames[i].Data() << ": "<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
4251  accepted = 1;
4252  if(i == 0) accepted = 2; // MB Header
4253  }
4254  }
4255  if (debug > 1 && !accepted) cout << "rejected:" << index << endl;
4256  }
4257  else if(InputEvent->IsA()==AliAODEvent::Class()){
4258  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
4259  if (AODMCTrackArray){
4260  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
4261  if(!aodMCParticle) return 0; // no particle
4262  if(!aodMCParticle->IsPrimary()){
4263  if( aodMCParticle->GetMother() < 0) return 0;// material particle, return 0
4264  return IsParticleFromBGEvent(aodMCParticle->GetMother(),mcEvent,InputEvent, debug);
4265  }
4266  index = TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index))->GetLabel());
4267  for(Int_t i = 0;i<fnHeaders;i++){
4268  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
4269  accepted = 1;
4270  if(i == 0) accepted = 2; // MB Header
4271  }
4272  }
4273  }
4274  }
4275 
4276  return accepted;
4277 }
4278 
4279 //_________________________________________________________________________
4280 Int_t AliConvEventCuts::IsEventAcceptedByCut(AliConvEventCuts *ReaderCuts, AliVEvent *event, AliMCEvent *mcEvent, Int_t isHeavyIon, Bool_t isEMCALAnalysis){
4281 
4282  Bool_t isMC = kFALSE;
4283  if (mcEvent){isMC = kTRUE;}
4284 
4285  if ( !IsTriggerSelected(event, isMC) )
4286  return 3;
4287 
4288  if( !(IsCentralitySelected(event,mcEvent)))
4289  return 1; // Check Centrality --> Not Accepted => eventQuality = 1
4290 
4291  Bool_t hasV0And = ReaderCuts->HasV0AND();
4292  Bool_t isSDDFired = ReaderCuts->IsSDDFired();
4293 
4294  if( ( (IsSpecialTrigger() == 0 && IsSpecialSubTrigger() == 1) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !isSDDFired && !mcEvent)
4295  //if V0OR with SDD requested or V0AND with SDD request but the SDD has not fired
4296  return 7; // V0 with SDD requested but no fired
4297 
4298  if( ( (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 0) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !hasV0And)
4299  //if V0AND (only) or V0AND with SDD requested but V0AND requested but no fired
4300  return 8; // V0AND requested but no fired
4301 
4302 
4303  if( (IsSpecialTrigger() == 2 || IsSpecialTrigger() == 3) && !isSDDFired && !mcEvent)
4304  return 7; // With SDD requested but no fired
4305 
4306  if( (IsSpecialTrigger() == 1 || IsSpecialTrigger() == 3) && !hasV0And)
4307  return 8; // V0AND requested but no fired
4308 
4309  // Special EMCAL checks due to hardware issues in LHC11a
4310  if (isEMCALAnalysis || IsSpecialTrigger() == 5 || IsSpecialTrigger() == 8 || IsSpecialTrigger() == 9 ){
4311  Int_t runnumber = event->GetRunNumber();
4312  if ((runnumber>=144871) && (runnumber<=146860)) {
4313 
4314  AliVCaloCells *cells = event->GetEMCALCells();
4315  const Short_t nCells = cells->GetNumberOfCells();
4316 
4317  if (event->IsA()==AliESDEvent::Class()) AliAnalysisManager::GetAnalysisManager()->LoadBranch("EMCALCells.");
4318 
4319  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
4320  if (!fInputHandler) return 3;
4321 
4322  // count cells above threshold
4323  Int_t nCellCount[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
4324  for(Int_t iCell=0; iCell<nCells; ++iCell) {
4325  Short_t cellId = cells->GetCellNumber(iCell);
4326  Double_t cellE = cells->GetCellAmplitude(cellId);
4327  Int_t sm = cellId / (24*48);
4328  if (cellE>0.1) ++nCellCount[sm];
4329  }
4330 
4331  Bool_t fIsLedEvent = kFALSE;
4332  if (nCellCount[4] > 100) {
4333  fIsLedEvent = kTRUE;
4334  } else {
4335  if ((runnumber>=146858) && (runnumber<=146860)) {
4336  if ((fInputHandler->IsEventSelected() & AliVEvent::kMB) && (nCellCount[3]>=21))
4337  fIsLedEvent = kTRUE;
4338  else if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC1) && (nCellCount[3]>=35))
4339  fIsLedEvent = kTRUE;
4340  }
4341  }
4342  if (fIsLedEvent) {
4343  return 9;
4344  }
4345  }
4346  }
4347 
4348  // SPD clusters vs tracklets to check for pileup/background
4349  Int_t nClustersLayer0 = event->GetNumberOfITSClusters(0);
4350  Int_t nClustersLayer1 = event->GetNumberOfITSClusters(1);
4351  Int_t nTracklets = event->GetMultiplicity()->GetNumberOfTracklets();
4352  if(hSPDClusterTrackletBackgroundBefore) hSPDClusterTrackletBackgroundBefore->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
4353 
4354 
4355  Double_t distZMax = 0;
4356  if(event->IsA()==AliESDEvent::Class()){
4357  Int_t nPileVert = ((AliESDEvent*)event)->GetNumberOfPileupVerticesSPD();
4358  if (hNPileupVertices) hNPileupVertices->Fill(nPileVert);
4359  if (nPileVert > 0){
4360  for(Int_t i=0; i<nPileVert;i++){
4361  const AliESDVertex* pv= ((AliESDEvent*)event)->GetPileupVertexSPD(i);
4362  Int_t nc2 = pv->GetNContributors();
4363  if(nc2>=3){
4364  Double_t z1 = ((AliESDEvent*)event)->GetPrimaryVertexSPD()->GetZ();
4365  Double_t z2 = pv->GetZ();
4366  Double_t distZ = z2-z1;
4367  if (TMath::Abs(distZMax) < TMath::Abs(distZ) ){
4368  distZMax = distZ;
4369  }
4370  }
4371  }
4372  if (hPileupVertexToPrimZ) hPileupVertexToPrimZ->Fill(distZMax);
4373  }
4374  }
4375  if(GetPastFutureLowBC()!=0 && GetPastFutureHighBC()!=0 ){
4376  if(IsOutOfBunchPileupPastFuture(event))
4377  return 12;
4378  }
4379 
4380  if( isHeavyIon != 2 && GetIsFromPileupSPD()){
4381  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.) ){
4383  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
4384  }
4385  if (fUtils->IsSPDClusterVsTrackletBG(event)){
4387  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
4388  }
4389  }
4390  if(isHeavyIon == 2 && GetIsFromPileupSPD()){
4391  if(fUtils->IsPileUpEvent(event) ){
4393  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
4394  }
4395  if (fUtils->IsSPDClusterVsTrackletBG(event)){
4397  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
4398  }
4399  }
4400 
4402  if( IsPileUpV0MTPCout(event) ){
4403  return 13;
4404  }
4405  }
4406 
4407  if(hCentrality)hCentrality->Fill(GetCentrality(event));
4408 
4409  if(hVertexZ)hVertexZ->Fill(event->GetPrimaryVertex()->GetZ());
4410 // if(hCentralityVsNumberOfPrimaryTracks)
4411 // hCentralityVsNumberOfPrimaryTracks->Fill(GetCentrality(event),
4412 // ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
4413 // ->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks());
4414 
4415  if(fIsHeavyIon == 1){
4416  AliEventplane *EventPlane = event->GetEventplane();
4417  fEventPlaneAngle = EventPlane->GetEventplane("V0",event,2);
4418  if(hEventPlaneAngle)hEventPlaneAngle->Fill(TMath::Abs(fEventPlaneAngle));
4419  }
4420  if(hSPDClusterTrackletBackground) hSPDClusterTrackletBackground->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
4421 
4422  return 0;
4423 }
4424 
4425 
4426 //_________________________________________________________________________
4428 
4429  AliInfo("Inside the GetWeightForCentralityFlattening function");
4430  Double_t centrality = 0.;
4431  //obtain centrality for ESD or AOD
4432  if(!event || event->IsA()==AliESDEvent::Class()){
4433  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
4434  if(esdEvent){
4435  AliCentrality *fESDCentrality=(AliCentrality*)esdEvent->GetCentrality();
4436  if(fDetectorCentrality==0 && fIsHeavyIon==1){
4437  centrality = fESDCentrality->GetCentralityPercentile("V0M"); // default for PbPb
4438  }
4439  }
4440  } else if(event->IsA()==AliAODEvent::Class()){
4441  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
4442  if(aodEvent){
4443  if(aodEvent->GetHeader()){
4444  centrality = ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();
4445  }
4446  }
4447  }
4448 
4449  //Get the maximum vlaue from the reference distribution and interpolated value
4450  Float_t GetValueForWeight = 1.;
4451  Float_t maximum = 1.;
4452  Double_t weightCentrality = 1.;
4453  Bool_t CorrCentrLoop = kFALSE;
4454 
4455  //depending on the value of the flag, flattening in different cent. range
4456  if ( fDoCentralityFlat == 1 && (centrality >= 0. && centrality <= 20.) ){
4457  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4458  maximum = hCentralityNotFlat->GetMaximum();
4459  CorrCentrLoop = kTRUE;
4460  } else if ( fDoCentralityFlat == 8 ){
4461  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4462  maximum = hCentralityNotFlat->GetMaximum();
4463  CorrCentrLoop = kTRUE;
4464  } else {
4465  CorrCentrLoop = kFALSE;
4466  }
4467 
4468  if (CorrCentrLoop && GetValueForWeight != 0. && maximum !=0. && isfinite(GetValueForWeight) && isfinite(maximum) ){
4469  weightCentrality = maximum/GetValueForWeight;
4470  if (!isfinite(GetValueForWeight)) weightCentrality = 1.;
4471  if (!isfinite(weightCentrality)) weightCentrality = 1.;
4472  }
4473 
4474  return weightCentrality;
4475 }
4476 
4477 //_________________________________________________________________________
4479 
4480  Double_t weightMult = 1.;
4481 
4482  Float_t valueMultData = -1.;
4483  Float_t valueMultMC = -1.;
4484 
4485  if (hReweightMultData == NULL || hReweightMultMC == NULL ) return weightMult;
4486 
4487  valueMultData = hReweightMultData->Interpolate(mult);
4488  valueMultMC = hReweightMultMC->Interpolate(mult);
4489 
4490  Float_t relativeErrorMC = hReweightMultMC->GetBinError(hReweightMultMC->FindBin(mult))/hReweightMultMC->GetBinContent(hReweightMultMC->FindBin(mult));
4491  Float_t relativeErrorData = hReweightMultData->GetBinError(hReweightMultData->FindBin(mult))/hReweightMultData->GetBinContent(hReweightMultData->FindBin(mult));
4492 
4493  if (relativeErrorData < 0.2 && relativeErrorMC < 0.2 ){
4494  if (isfinite(valueMultData) && isfinite(valueMultMC) ){
4495  weightMult = valueMultData/valueMultMC;
4496  }
4497  }
4498 
4499  return weightMult;
4500 }
4501 
4502 
4503 
4504 //_________________________________________________________________________
4505 Float_t AliConvEventCuts::GetWeightForMeson(Int_t index, AliMCEvent *mcEvent, AliVEvent *event){
4506  if (!( fPeriodEnum == kLHC13d2 || fPeriodEnum == kLHC13d2b || // LHC10h MCs
4507  fPeriodEnum == kLHC14a1a || fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c || // LHC11h MCs
4508  fPeriodEnum == kLHC13e7 || fPeriodEnum == kLHC13b2_efix || fPeriodEnum == kLHC14b2 || // LHC13bc MCs
4509  fPeriodEnum == kLHC14e2b || // LHC12[a-i] pass 1 MCs
4510  fPeriodEnum == kLHC12f1a || fPeriodEnum == kLHC12f1b || fPeriodEnum == kLHC12i3 // LHC11a MCs
4511  ) ) return 1.;
4512  Int_t kCaseGen = 0;
4513 
4514  if(index < 0) return 0; // No Particle
4515 
4516  if (IsParticleFromBGEvent(index, mcEvent, event)){
4519  kCaseGen = 1;
4520  }
4521  }
4522  if (kCaseGen == 0) return 1;
4523 
4524  Double_t mesonPt = 0;
4525  //Double_t mesonMass = 0;
4526  Int_t PDGCode = 0;
4527  if(!event || event->IsA()==AliESDEvent::Class()){
4528  mesonPt = ((TParticle*)mcEvent->Particle(index))->Pt();
4529  //mesonMass = ((TParticle*)mcEvent->Particle(index))->GetCalcMass();
4530  PDGCode = ((TParticle*)mcEvent->Particle(index))->GetPdgCode();
4531  } else if(event->IsA()==AliAODEvent::Class()){
4532  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4533  if (AODMCTrackArray){
4534  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
4535  mesonPt = aodMCParticle->Pt();
4536  //mesonMass = aodMCParticle->GetCalcMass();
4537  PDGCode = aodMCParticle->GetPdgCode();
4538  } else {
4539  return 1;
4540  }
4541  }
4542 
4543  Float_t functionResultMC = 1.;
4544  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0){
4545  functionResultMC = hReweightMCHistPi0->Interpolate(mesonPt);
4546  }
4547  if ( PDGCode == 221 && fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0){
4548  functionResultMC = hReweightMCHistEta->Interpolate(mesonPt);
4549  }
4550  if ( PDGCode == 310 && fDoReweightHistoMCK0s && hReweightMCHistK0s!= 0x0){
4551  functionResultMC = hReweightMCHistK0s->Interpolate(mesonPt);
4552  }
4553 
4554  Float_t functionResultData = 1;
4555  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && fFitDataPi0!= 0x0){
4556  functionResultData = fFitDataPi0->Eval(mesonPt);
4557  }
4558  if ( PDGCode == 221 && fDoReweightHistoMCEta && fFitDataEta!= 0x0){
4559  functionResultData = fFitDataEta->Eval(mesonPt);
4560  }
4561  if ( PDGCode == 310 && fDoReweightHistoMCK0s && fFitDataK0s!= 0x0){
4562  functionResultData = fFitDataK0s->Eval(mesonPt);
4563  }
4564 
4565  Double_t weight = 1;
4566  if (PDGCode == 111 || PDGCode == 221){
4567  if (functionResultData != 0. && functionResultMC != 0. && isfinite(functionResultData) && isfinite(functionResultMC)){
4568  weight = functionResultData/functionResultMC;
4569  if ( kCaseGen == 3){
4570  if (PDGCode == 111){
4571  if (!(fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0 && PDGCode == 111)){
4572  weight = 1.;
4573  }
4574  }
4575  if (PDGCode == 221){
4576  if (!(fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0 && PDGCode == 221)){
4577  weight = 1.;
4578  }
4579  }
4580  }
4581  if (!isfinite(functionResultData)) weight = 1.;
4582  if (!isfinite(weight)) weight = 1.;
4583  }
4584  } else if (PDGCode == 310 && functionResultMC != 0 && isfinite(functionResultMC)){
4585  weight = functionResultMC;
4586  }
4587  return weight;
4588 }
4589 
4590 
4593 
4594  if( fPeriodEnum == kLHC13bc || // mainly minimum bias
4595  fPeriodEnum == kLHC13de || // mainly triggered
4596  fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus || // MC Pythia 6 (Jet-Jet), anchor LHC13b-e
4597  fPeriodEnum == kLHC13b2_efix || //MC DPMJET, anchr LHC13b+c
4598  fPeriodEnum == kLHC13e7 || //MC HIJING, anchr LHC13b+c
4599  fPeriodEnum == kLHC14b2 //MC HIJING, anchr LHC13b+c
4600  ){
4601  printf(" Gamma Conversion Cuts %s :: pPb Run doing Eta Shift of %f \n\n",(GetCutNumber()).Data(),-0.465);
4602  SetEtaShift(-0.465);
4603  } else if( fPeriodEnum == kLHC13f ) {
4604  printf(" Gamma Conversion Cuts %s :: Pbp Run doing Eta Shift of %f \n\n",(GetCutNumber()).Data(),0.465);
4605  SetEtaShift(+0.465);
4606  }
4607  else printf(" Gamma Conversion Cuts %s :: Automatic Eta Shift requested but Period is not known -> No Shift \n\n",(GetCutNumber()).Data());
4608 }
4609 
4610 //________________________________________________________________________
4611 AliEMCALTriggerPatchInfo* AliConvEventCuts::GetMainTriggerPatch()
4612 {
4613  //get main trigger match; if not known yet, look for it and cache
4614 
4616  return fMainTriggerPatchEMCAL;
4617 
4618  if (!fTriggerPatchInfo) {
4619  AliError(Form("%s: fTriggerPatchInfo not available",GetName()));
4620  return 0;
4621  }
4622 
4623  //number of patches in event
4624  Int_t nPatch = fTriggerPatchInfo->GetEntries();
4625 
4626  //extract main trigger patch
4627  AliEMCALTriggerPatchInfo *patch;
4628  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
4629  patch = (AliEMCALTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
4630  if (patch->IsMainTrigger()) {
4631  fMainTriggerPatchEMCAL = patch;
4632  break;
4633  }
4634  }
4635 
4636  return fMainTriggerPatchEMCAL;
4637 }
4638 
4639 
4640 //________________________________________________________________________
4642 {
4643 // cout << "entered EMCAL trigger initialization" << endl;
4644 
4645  // Init the analysis.
4646  if (fCaloTriggersName.IsNull()){
4647  if (event->IsA()==AliESDEvent::Class()){
4648  fCaloTriggersName = "EMCALTrigger";
4649  } else {
4650  fCaloTriggersName = "emcalTrigger";
4651  }
4652  }
4653 
4654  if (!fCaloTriggersName.IsNull() && !fCaloTriggers) {
4655  fCaloTriggers = dynamic_cast<AliVCaloTrigger*>(event->FindListObject(fCaloTriggersName));
4656  if (!fCaloTriggers) {
4657  AliError(Form("%s: Could not retrieve calo triggers %s!", GetName(), fCaloTriggersName.Data()));
4658  return;
4659  }
4660  }
4661 
4662  if (fCaloTriggerPatchInfoName.IsNull()){
4663  if (event->IsA()==AliESDEvent::Class()){
4664  fCaloTriggerPatchInfoName = "EmcalTriggers";
4665  } else {
4666  fCaloTriggerPatchInfoName = "EmcalTriggers";
4667  }
4668  }
4669 
4670  if (!fCaloTriggerPatchInfoName.IsNull() && !fTriggerPatchInfo) {
4671  fTriggerPatchInfo = GetArrayFromEvent(event, fCaloTriggerPatchInfoName.Data(), "AliEMCALTriggerPatchInfo");
4672  if (!fTriggerPatchInfo) {
4673  AliError(Form("%s: Could not retrieve calo trigger patch info %s!", GetName(), fCaloTriggerPatchInfoName.Data()));
4674  return;
4675  }
4676 
4677  }
4678 
4679  fEMCALTrigInitialized = kTRUE;
4680 }
4681 
4682 //________________________________________________________________________
4684  if (!fTriggerPatchInfo)
4685  return 0;
4686  //number of patches in event
4687  Int_t nPatch = fTriggerPatchInfo->GetEntries();
4688 
4689  //loop over patches to define trigger type of event
4690  Int_t nG1 = 0;
4691  Int_t nG2 = 0;
4692  Int_t nJ1 = 0;
4693  Int_t nJ2 = 0;
4694  Int_t nL0 = 0;
4695  AliEMCALTriggerPatchInfo *patch;
4696 // if (nPatch> 0) {cout << "NEW Triggers in this event*********************************" << endl;}
4697  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
4698  patch = (AliEMCALTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
4699 // cout << "Patch energy: "<<patch->GetPatchE() << "\t ADC counts: " << patch->GetADCAmp() << endl;
4700 // cout << "Phi: " << patch->GetPhiMin() << " - " << patch->GetPhiMax() << " delta phi: " <<TMath::Abs(patch->GetPhiMin()-patch->GetPhiMax())<< endl;
4701 // cout << "Eta: " << patch->GetEtaMin() << " - " << patch->GetEtaMax() << " delta eta: " <<TMath::Abs(patch->GetEtaMin()-patch->GetEtaMax())<< endl;
4702  if (patch->IsGammaHigh()){
4703 // cout << "fired L1GA high" << endl;
4704  nG1++;
4705  }
4706  if (patch->IsGammaLow()){
4707 // cout << "fired L1GA low" << endl;
4708  nG2++;
4709  }
4710  if (patch->IsJetHigh()){
4711 // cout << "fired L1JE high" << endl;
4712  nJ1++;
4713  }
4714  if (patch->IsJetLow()){
4715 // cout << "fired L1JE low" << endl;
4716  nJ2++;
4717  }
4718  if (patch->IsLevel0()){
4719 // cout << "fired L0" << endl;
4720  nL0++;
4721  }
4722 // cout << patch->GetPatchE() << "\t" << patch->GetADCAmp() << "\t" << patch->IsGammaHigh() << "\t" << patch->IsGammaLow()
4723 // << "\t" << patch->IsJetHigh() << "\t" << patch->IsJetLow() << "\t" << patch->IsLevel0()
4724 // << "\t" << patch->GetPhiMin() << "\t" << patch->GetPhiMax() << "\t" << TMath::Abs(patch->GetPhiMin()-patch->GetPhiMax())
4725 // << "\t" << patch->GetEtaMin() << "\t" << patch->GetEtaMax() << "\t" << TMath::Abs(patch->GetEtaMin()-patch->GetEtaMax()) << endl;
4726  }
4727 
4728  if (nPatch > 0){
4729  AliDebug(2, "Patch summary: ");
4730  AliDebug(2, Form("Number of patches: %d", nPatch));
4731  AliDebug(2, Form("Level0: [%d]" ,nL0));
4732  AliDebug(2, Form("Jet: low[%d], high[%d]" ,nJ2, nJ1));
4733  AliDebug(2, Form("Gamma: low[%d], high[%d]" ,nG2, nG1));
4734  }
4735 
4736 // if (nPatch > 0){
4737 // cout << Form("Number of patches: %d", nPatch) << endl;
4738 // cout << Form("Level0: [%d]" ,nL0) << endl;
4739 // cout << Form("Jet: low[%d], high[%d]" ,nJ2, nJ1) << endl;
4740 // cout << Form("Gamma: low[%d], high[%d]" ,nG2, nG1) << endl;
4741 // }
4742 
4743  ULong_t triggers(0);
4744  if (nG1>0)
4745  SETBIT(triggers, kG1);
4746  if (nG2>0)
4747  SETBIT(triggers, kG2);
4748  if (nJ1>0)
4749  SETBIT(triggers, kJ1);
4750  if (nJ2>0)
4751  SETBIT(triggers, kJ2);
4752  if (nL0>0)
4753  SETBIT(triggers, kL0);
4754  return triggers;
4755 }
4756 
4757 //________________________________________________________________________
4759  // Check if event has a given trigger type
4760  if(t == kND){
4761  return fTriggersEMCAL == 0;
4762  }
4763  return TESTBIT(fTriggersEMCAL, int(t));
4764 }
4765 
4766 
4767 //________________________________________________________________________
4768 TClonesArray *AliConvEventCuts::GetArrayFromEvent(AliVEvent* event, const char *name, const char *clname)
4769 {
4770  // Get array from event.
4771 
4772  TClonesArray *arr = 0;
4773  TString sname(name);
4774  if (!sname.IsNull()) {
4775  arr = dynamic_cast<TClonesArray*>(event->FindListObject(sname));
4776  if (!arr) {
4777  AliWarning(Form("%s: Could not retrieve array with name %s!", GetName(), name));
4778  return 0;
4779  }
4780  } else {
4781  return 0;
4782  }
4783 
4784  if (!clname)
4785  return arr;
4786 
4787  TString objname(arr->GetClass()->GetName());
4788  TClass cls(objname);
4789  if (!cls.InheritsFrom(clname)) {
4790  AliWarning(Form("%s: Objects of type %s in %s are not inherited from %s!",
4791  GetName(), cls.GetName(), name, clname));
4792  return 0;
4793  }
4794  return arr;
4795 }
4796 
4797 //_________________________________________________________________________
4798 Bool_t AliConvEventCuts::IsConversionPrimaryESD( AliMCEvent *mcEvent, Long_t eventpos, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ){
4799 
4800  if (eventpos < 0) return kFALSE;
4801  TParticle* particle = (TParticle *)mcEvent->Particle(eventpos);
4802  if (!particle) return kFALSE;
4803  if (TMath::Abs(particle->GetPdgCode()) == 11 ){
4804  if (particle->GetMother(0) != -1){
4805  TParticle* particleMother = (TParticle *)mcEvent->Particle(particle->GetMother(0));
4806  if (particleMother){
4807  if (TMath::Abs(particleMother->GetPdgCode()) == 22)
4808  particle = particleMother;
4809  }
4810  }
4811  }
4812  if (particle->GetMother(0) != -1){
4813  Double_t deltaX = particle->Vx() - prodVtxX;
4814  Double_t deltaY = particle->Vy() - prodVtxY;
4815  Double_t deltaZ = particle->Vz() - prodVtxZ;
4816 
4817  //Double_t realRadius2D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY);
4818  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
4819 
4820 
4821  Bool_t dalitzCand = kFALSE;
4822 
4823  TParticle* firstmother = (TParticle *)mcEvent->Particle(particle->GetMother(0));
4824  if (!firstmother) return kFALSE;
4825  Int_t pdgCodeFirstMother = firstmother->GetPdgCode();
4826  Bool_t intDecay = kFALSE;
4827  if ( pdgCodeFirstMother == 111 || pdgCodeFirstMother == 221 ) intDecay = kTRUE;
4828  if ( intDecay && TMath::Abs(particle->GetPdgCode()) == 11 ){
4829  dalitzCand = kTRUE;
4830 // cout << "dalitz candidate found" << endl;
4831  }
4832 
4833  Long_t source = particle->GetMother(0);
4834  Bool_t foundExcludedPart = kFALSE;
4835  Bool_t foundShower = kFALSE;
4836  Int_t pdgCodeMotherPrev = 0;
4837  Int_t pdgCodeMotherPPrevMother = 0;
4838  Int_t depth = 0;
4839  if (dalitzCand || realRadius3D < fSecProdBoundary ){
4840 // if (particle->GetPdgCode() == 22){
4841 // cout << endl << endl << "new particle: " << eventpos <<endl;
4842 // cout << particle->GetPdgCode() << "\t" << particle->R() << "\t" << realRadius2D << "\t" << realRadius3D << endl;
4843 // }
4844  while (depth < 20){
4845  TParticle* mother = (TParticle *)mcEvent->Particle(source);
4846  source = mother->GetMother(0);
4847 // if (particle->GetPdgCode() == 22)cout << "eventposition: "<< source << endl;
4848  Int_t pdgCodeMother = mother->GetPdgCode();
4849 // if (particle->GetPdgCode() == 22)cout << "Previous mothers: " << pdgCodeMother << "\t"<< pdgCodeMotherPrev<< "\t" << pdgCodeMotherPPrevMother << endl;
4850  if (pdgCodeMother == pdgCodeMotherPrev && pdgCodeMother == pdgCodeMotherPPrevMother) depth = 20;
4851  if (TMath::Abs(pdgCodeMother) == 11 && TMath::Abs(pdgCodeMotherPrev) == 22 && TMath::Abs(pdgCodeMotherPPrevMother) == 11 ){
4852  foundShower = kTRUE;
4853  depth =20;
4854  }
4855  if (TMath::Abs(pdgCodeMother) == 22 && TMath::Abs(pdgCodeMotherPrev) == 11 && TMath::Abs(pdgCodeMotherPPrevMother) == 22 ){
4856  foundShower = kTRUE;
4857  depth =20;
4858  }
4859 
4860  // particles to be excluded:
4861  // K0s - 310
4862  // K0l - 130
4863  // K+/- - 321
4864  // Lambda - 3122
4865  // Sigma0 - 3212
4866  // Sigma+/- - 3222, 3112
4867  // Cascades - 3322, 3312
4868  if (TMath::Abs(pdgCodeMother) == 310 || TMath::Abs(pdgCodeMother) == 130 || TMath::Abs(pdgCodeMother) == 321 ||
4869  TMath::Abs(pdgCodeMother) == 3122 || TMath::Abs(pdgCodeMother) == 3212 || TMath::Abs(pdgCodeMother) == 3222 ||
4870  TMath::Abs(pdgCodeMother) == 3112 || TMath::Abs(pdgCodeMother) == 3322 || TMath::Abs(pdgCodeMother) == 3312
4871  ) {
4872  foundExcludedPart = kTRUE;
4873  }
4874 // if (particle->GetPdgCode() == 22)cout << mother->GetPdgCode() << "\t" << source << "\t" << foundExcludedPart<< endl;
4875  pdgCodeMotherPPrevMother = pdgCodeMotherPrev;
4876  pdgCodeMotherPrev = pdgCodeMother;
4877  if (source == -1) depth = 20;
4878 
4879 // if (particle->GetPdgCode() == 22)cout << depth << endl;
4880  depth++;
4881  }
4882  }
4883  if (foundExcludedPart){
4884 // if (particle->GetPdgCode() == 22)cout << "This is definitely a secondary, manually excluded" << endl;
4885  return kFALSE;
4886  } else if (dalitzCand && realRadius3D < fSecProdBoundary ){
4887 // if (particle->GetPdgCode() == 22)cout << "This was a decay via a virtual photon" << endl;
4888  return kTRUE;
4889  } else if (foundShower){
4890 // if (particle->GetPdgCode() == 22)cout << "This is a shower" << endl;
4891  return kFALSE;
4892  } else if (realRadius3D >= fSecProdBoundary){
4893 // cout << "This is a secondary, to large production radius" << endl;
4894  return kFALSE;
4895  }
4896  }
4897 
4898  return kTRUE;
4899 }
4900 
4901 //_________________________________________________________________________
4902 Bool_t AliConvEventCuts::IsConversionPrimaryAOD(AliVEvent *event, AliAODMCParticle* AODMCParticle, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ){
4903 
4904  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4905  if (AODMCTrackArray == NULL) return kFALSE;
4906  AliAODMCParticle* currentParticle = AODMCParticle;
4907  if (TMath::Abs(currentParticle->GetPdgCode()) == 11 ){
4908  if (currentParticle->GetMother() != -1){
4909  AliAODMCParticle* particleMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(currentParticle->GetMother()));
4910  if (particleMother){
4911  if (TMath::Abs(particleMother->GetPdgCode()) == 22)
4912  currentParticle = particleMother;
4913  }
4914  }
4915  }
4916  if (currentParticle->GetMother() > -1){
4917  Double_t deltaX = currentParticle->Xv() - prodVtxX;
4918  Double_t deltaY = currentParticle->Yv() - prodVtxY;
4919  Double_t deltaZ = currentParticle->Zv() - prodVtxZ;
4920 
4921  //Double_t realRadius2D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY);
4922  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
4923 
4924  Bool_t dalitzCand = kFALSE;
4925 
4926  AliAODMCParticle* firstmother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(currentParticle->GetMother()));
4927  if (!firstmother) return kFALSE;
4928  Int_t pdgCodeFirstMother = firstmother->GetPdgCode();
4929  Bool_t intDecay = kFALSE;
4930  if ( pdgCodeFirstMother == 111 || pdgCodeFirstMother == 221 ) intDecay = kTRUE;
4931  if ( intDecay && TMath::Abs(currentParticle->GetPdgCode()) == 11 ){
4932  dalitzCand = kTRUE;
4933 // cout << "dalitz candidate found" << endl;
4934  }
4935 
4936  Long_t source = currentParticle->GetMother();
4937  Bool_t foundExcludedPart = kFALSE;
4938  Bool_t foundShower = kFALSE;
4939  Int_t pdgCodeMotherPrev = 0;
4940  Int_t pdgCodeMotherPPrevMother = 0;
4941  Int_t depth = 0;
4942  if (dalitzCand || realRadius3D < fSecProdBoundary ){
4943 // if (currentParticle->GetPdgCode() == 22){
4944 // cout << endl << endl << "new particle: " << eventpos <<endl;
4945 // cout << currentParticle->GetPdgCode() << "\t" << currentParticle->R() << "\t" << realRadius2D << "\t" << realRadius3D << endl;
4946 // }
4947  while (depth < 20){
4948  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(source));
4949  source = mother->GetMother();
4950 // if (currentParticle->GetPdgCode() == 22)cout << "eventposition: "<< source << endl;
4951  Int_t pdgCodeMother = mother->GetPdgCode();
4952 // if (currentParticle->GetPdgCode() == 22)cout << "Previous mothers: " << pdgCodeMother << "\t"<< pdgCodeMotherPrev<< "\t" << pdgCodeMotherPPrevMother << endl;
4953  if (pdgCodeMother == pdgCodeMotherPrev && pdgCodeMother == pdgCodeMotherPPrevMother) depth = 20;
4954  if (TMath::Abs(pdgCodeMother) == 11 && TMath::Abs(pdgCodeMotherPrev) == 22 && TMath::Abs(pdgCodeMotherPPrevMother) == 11 ){
4955  foundShower = kTRUE;
4956  depth =20;
4957  }
4958  if (TMath::Abs(pdgCodeMother) == 22 && TMath::Abs(pdgCodeMotherPrev) == 11 && TMath::Abs(pdgCodeMotherPPrevMother) == 22 ){
4959  foundShower = kTRUE;
4960  depth =20;
4961  }
4962 
4963  // particles to be excluded:
4964  // K0s - 310
4965  // K0l - 130
4966  // K+/- - 321
4967  // Lambda - 3122
4968  // Sigma0 - 3212
4969  // Sigma+/- - 3222, 3112
4970  // Cascades - 3322, 3312
4971  if (TMath::Abs(pdgCodeMother) == 310 || TMath::Abs(pdgCodeMother) == 130 || TMath::Abs(pdgCodeMother) == 321 ||
4972  TMath::Abs(pdgCodeMother) == 3122 || TMath::Abs(pdgCodeMother) == 3212 || TMath::Abs(pdgCodeMother) == 3222 ||
4973  TMath::Abs(pdgCodeMother) == 3112 || TMath::Abs(pdgCodeMother) == 3322 || TMath::Abs(pdgCodeMother) == 3312)
4974  {
4975  foundExcludedPart = kTRUE;
4976  }
4977 // if (currentParticle->GetPdgCode() == 22)cout << mother->GetPdgCode() << "\t" << source << "\t" << foundExcludedPart<< endl;
4978  pdgCodeMotherPPrevMother = pdgCodeMotherPrev;
4979  pdgCodeMotherPrev = pdgCodeMother;
4980  if (source == -1) depth = 20;
4981 
4982 // if (currentParticle->GetPdgCode() == 22)cout << depth << endl;
4983  depth++;
4984  }
4985  }
4986  if (foundExcludedPart){
4987 // if (currentParticle->GetPdgCode() == 22)cout << "This is definitely a secondary, manually excluded" << endl;
4988  return kFALSE;
4989  } else if (dalitzCand && realRadius3D < fSecProdBoundary ){
4990 // if (currentParticle->GetPdgCode() == 22)cout << "This was a decay via a virtual photon" << endl;
4991  return kTRUE;
4992  } else if (foundShower){
4993 // if (currentParticle->GetPdgCode() == 22)cout << "This is a shower" << endl;
4994  return kFALSE;
4995  } else if (realRadius3D >= fSecProdBoundary){
4996 // cout << "This is a secondary, too large production radius" << endl;
4997  return kFALSE;
4998  }
4999  }
5000 
5001  return kTRUE;
5002 }
5003 
5004 
5005 //________________________________________________________________________
5006 Int_t AliConvEventCuts::SecondaryClassificationPhoton( TParticle *particle, AliMCEvent* mcEvent, Bool_t isConversion ){
5007  if (particle != NULL && mcEvent != NULL){
5008  Int_t pdgSecondary = 0;
5009  if (!isConversion){
5010  //Bool_t hasMother = kFALSE;
5011  //Bool_t hasGrandMother = kFALSE;
5012  Long_t motherID = particle->GetMother(0);
5013  Long_t grandMotherID = -1;
5014  // is the photon a direct photons, without a mother?
5015  if (motherID > -1){
5016  //hasMother = kTRUE;
5017  grandMotherID = mcEvent->Particle(motherID)->GetMother(0);
5018  // is the meson a primary?
5019  if (grandMotherID > -1){
5020  //hasGrandMother = kTRUE;
5021  pdgSecondary = mcEvent->Particle(grandMotherID)->GetPdgCode();
5022  }
5023  }
5024  } else {
5025  //Bool_t hasMother = kFALSE;
5026  //Bool_t hasGrandMother = kFALSE;
5027  //Bool_t hasGreatGrandMother = kFALSE;