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