AliPhysics  2853087 (2853087)
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 != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2586  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
2587  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2588  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2589  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2590  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2591  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2592  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2593  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
2594  ){
2595 
2596  weight = 1;
2597  return kTRUE;
2598  }
2599 
2600  if(mcEvent){
2601  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2602  if(cHeader) headerFound = kTRUE;
2603  }else{
2604  //no mcEvent available -> not running on MC
2605  weight = 1;
2606  return kTRUE;
2607  }
2608 
2609  if(headerFound){
2610  TList *genHeaders = 0x0;
2611  if(cHeader) genHeaders = cHeader->GetHeaders();
2612  AliGenEventHeader* gh = 0;
2613  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2614  gh = (AliGenEventHeader*)genHeaders->At(i);
2615  TString GeneratorName = gh->GetName();
2616  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2617  Bool_t eventAccepted = kTRUE;
2618  TParticle * jet = 0;
2619  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(gh)->NTriggerJets();
2620  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
2621  Float_t tmpjet[]={0,0,0,0};
2622  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2623  dynamic_cast<AliGenPythiaEventHeader*>(gh)->TriggerJet(ijet, tmpjet);
2624  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2625  //Compare jet pT and pt Hard
2626  if(jet->Pt() > fMaxFacPtHard * ptHard){
2627  eventAccepted= kFALSE;
2628  }
2629  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2630  }
2631  if (jet) delete jet;
2632  if (mcEvent){
2633  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2634  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2635  if (!particle) continue;
2636  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2637  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2638  eventAccepted= kFALSE;
2639  }
2640  }
2641 
2642  }
2643  }
2644 
2645  if ( fPeriodEnum == kLHC16P1JJLowB) {
2646  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2647  21, 28, 36, 45, 57,
2648  70, 85, 99, 115, 132,
2649  150, 169, 190, 212, 235,
2650  1000000};
2651  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2652  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2653  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2654  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2655  Int_t bin = 0;
2656  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2657  if (bin < 20) weight = weightsBins[bin];
2658 
2659  } else if ( fPeriodEnum == kLHC16P1JJ ){
2660  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2661  21, 28, 36, 45, 57,
2662  70, 85, 99, 115, 132,
2663  150, 169, 190, 212, 235,
2664  1000000};
2665  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2666  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2667  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2668  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2669 
2670  Int_t bin = 0;
2671  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2672  if (bin < 20) weight = weightsBins[bin];
2673 
2674  } else if ( fPeriodEnum == kLHC16h3 ){
2675  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2676  21, 28, 36, 45, 57,
2677  70, 85, 99, 115, 132,
2678  150, 169, 190, 212, 235,
2679  1000000};
2680  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2681  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2682  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2683  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2684  Int_t bin = 0;
2685  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2686  if (bin < 20) weight = weightsBins[bin];
2687 
2688 
2689  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2690  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2691  21, 28, 36, 45, 57,
2692  70, 85, 1000};
2693  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2694  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2695  1.933238e-05, 1.562895e-05};
2696  Int_t bin = 0;
2697  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2698  if (bin < 12) weight = weightsBins[bin];
2699 
2700  } else if ( fPeriodEnum == kLHC15g1a ){
2701  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2702  84, 117, 152, 191, 1000000,
2703  5, 7, 9, 12, 16,
2704  21, 28, 36, 45, 57 };
2705  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2706  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2707  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2708  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2709 
2710  Int_t bin = 0;
2711  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2712  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2713  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2714  if (bin < 19) weight = weightsBins[bin];
2715 
2716  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2717  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2718  84, 117, 152, 191, 1000000,
2719  5, 7, 9, 12, 16,
2720  21, 28, 36, 45, 57 };
2721  // LHC15a3a
2722  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2723  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2724  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2725  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2726  Int_t bin = 0;
2727  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2728  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2729  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2730  if (bin < 19) weight = weightsBins[bin];
2731 
2732  } else if ( fPeriodEnum == kLHC12P2JJ ){
2733  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2734  21, 28, 36, 45, 57,
2735  70, 85, 99, 115, 132,
2736  150, 169, 190, 212, 235,
2737  1000000};
2738  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
2739  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
2740  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
2741  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
2742  Int_t bin = 0;
2743  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2744  if (bin < 20) weight = weightsBins[bin];
2745 
2746  } else if ( fPeriodEnum == kLHC16c3a ){
2747  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
2748  Double_t weightsBins[5] = { 0.00672445, 0.00799158, 0.00678934, 0.00463908, 0.00600068}; //preliminary estimates
2749  Int_t bin = 0;
2750  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2751  if (bin < 5) weight = weightsBins[bin];
2752 
2753  } else if (fPeriodEnum == kLHC16c3b ){
2754  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
2755  Double_t weightsBins[6] = { 0.00608281, 0.00393646, 0.00200138, 0.000986267, 0.000389051, 0.0001863}; //preliminary estimates
2756  Int_t bin = 0;
2757  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2758  if (bin < 6) weight = weightsBins[bin];
2759 
2760  } else if (fPeriodEnum == kLHC16c3c ){
2761  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
2762  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
2763  Int_t bin = 0;
2764  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2765  if (bin < 7) weight = weightsBins[bin];
2766 
2767  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
2768  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
2769  84, 117, 152, 191, 234,
2770  1000};
2771  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
2772  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
2773  Int_t bin = 0;
2774  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2775  if (bin < 10) weight = weightsBins[bin];
2776  } else if ( fPeriodEnum == kLHC17g8a ){ // preliminary weights obtained from local running
2777  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};
2778  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};
2779  Int_t bin = 0;
2780  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2781  if (bin < 20) weight = weightsBins[bin];
2782  } else if ( fPeriodEnum == kLHC16rP1JJ ){ // preliminary weights obtained from local running
2783  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};
2784  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};
2785  Int_t bin = 0;
2786  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2787  if (bin < 20) weight = weightsBins[bin];
2788  } else if ( fPeriodEnum == kLHC16sP1JJ ){ // preliminary weights obtained from local running
2789  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};
2790  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};
2791  Int_t bin = 0;
2792  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2793  if (bin < 20) weight = weightsBins[bin];
2794  } else {
2795  weight = 1;
2796  }
2797 
2798  if (weight == -1) return kFALSE;
2799  else return eventAccepted;
2800 
2801  }
2802  }
2803  } else {
2804  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2805  TString eventHeaderName = eventHeader->ClassName();
2806  Bool_t eventAccepted = kFALSE;
2807  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2808  eventAccepted = kTRUE;
2809  }else { //special case for pythia8jets embedded in EPOSLHC for AODs
2810  if(event->IsA()==AliAODEvent::Class()){
2811  AliAODMCHeader *mch = NULL;
2812  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
2813  if(aod){
2814  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
2815  if ( mch ){
2816  Int_t nGenerators = mch->GetNCocktailHeaders();
2817  if ( nGenerators > 0 ){
2818  for(Int_t igen = 0; igen < nGenerators; igen++)
2819  {
2820  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
2821  TString name = eventHeaderGen->GetName();
2822  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
2823  eventAccepted = kTRUE;
2824  eventHeader = eventHeaderGen;
2825  }
2826  }
2827  }
2828  }
2829  }
2830  }
2831  }
2832  if(eventAccepted){
2833  TParticle * jet = 0;
2834  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->NTriggerJets();
2835  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
2836  Float_t tmpjet[]={0,0,0,0};
2837  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2838  dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->TriggerJet(ijet, tmpjet);
2839  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2840  //Compare jet pT and pt Hard
2841  if(jet->Pt() > fMaxFacPtHard * ptHard){
2842  eventAccepted= kFALSE;
2843  }
2844  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2845  }
2846  if (mcEvent){
2847  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2848  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2849  if (!particle) continue;
2850  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2851  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2852  eventAccepted= kFALSE;
2853  }
2854  }
2855 
2856  }
2857  }
2858 
2859  if ( fPeriodEnum == kLHC16P1JJLowB) {
2860  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2861  21, 28, 36, 45, 57,
2862  70, 85, 99, 115, 132,
2863  150, 169, 190, 212, 235,
2864  1000000};
2865  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2866  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2867  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2868  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2869  Int_t bin = 0;
2870  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2871  if (bin < 20) weight = weightsBins[bin];
2872 
2873  } else if ( fPeriodEnum == kLHC16P1JJ ){
2874  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2875  21, 28, 36, 45, 57,
2876  70, 85, 99, 115, 132,
2877  150, 169, 190, 212, 235,
2878  1000000};
2879  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2880  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2881  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2882  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2883 
2884  Int_t bin = 0;
2885  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2886  if (bin < 20) weight = weightsBins[bin];
2887 
2888  } else if ( fPeriodEnum == kLHC16h3 ){
2889  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2890  21, 28, 36, 45, 57,
2891  70, 85, 99, 115, 132,
2892  150, 169, 190, 212, 235,
2893  1000000};
2894  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2895  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2896  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2897  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2898  Int_t bin = 0;
2899  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2900  if (bin < 20) weight = weightsBins[bin];
2901 
2902 
2903  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2904  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2905  21, 28, 36, 45, 57,
2906  70, 85, 1000};
2907  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2908  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2909  1.933238e-05, 1.562895e-05};
2910  Int_t bin = 0;
2911  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2912  if (bin < 12) weight = weightsBins[bin];
2913 
2914  } else if ( fPeriodEnum == kLHC15g1a ){
2915  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2916  84, 117, 152, 191, 1000000,
2917  5, 7, 9, 12, 16,
2918  21, 28, 36, 45, 57 };
2919  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2920  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2921  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2922  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2923 
2924  Int_t bin = 0;
2925  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2926  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2927  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2928  if (bin < 19) weight = weightsBins[bin];
2929 
2930  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2931  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2932  84, 117, 152, 191, 1000000,
2933  5, 7, 9, 12, 16,
2934  21, 28, 36, 45, 57 };
2935  // LHC15a3a
2936  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2937  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2938  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2939  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2940  Int_t bin = 0;
2941  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2942  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2943  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2944  if (bin < 19) weight = weightsBins[bin];
2945 
2946  } else if ( fPeriodEnum == kLHC12P2JJ ){
2947  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2948  21, 28, 36, 45, 57,
2949  70, 85, 99, 115, 132,
2950  150, 169, 190, 212, 235,
2951  1000000};
2952  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
2953  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
2954  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
2955  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
2956  Int_t bin = 0;
2957  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2958  if (bin < 20) weight = weightsBins[bin];
2959 
2960  } else if ( fPeriodEnum == kLHC16c3a ){
2961  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
2962  Double_t weightsBins[5] = { 0.00672445, 0.00799158, 0.00678934, 0.00463908, 0.00600068}; //preliminary estimates
2963  Int_t bin = 0;
2964  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2965  if (bin < 5) weight = weightsBins[bin];
2966 
2967  } else if (fPeriodEnum == kLHC16c3b ){
2968  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
2969  Double_t weightsBins[6] = { 0.00608281, 0.00393646, 0.00200138, 0.000986267, 0.000389051, 0.0001863}; //preliminary estimates
2970  Int_t bin = 0;
2971  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2972  if (bin < 6) weight = weightsBins[bin];
2973 
2974  } else if (fPeriodEnum == kLHC16c3c ){
2975  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
2976  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
2977  Int_t bin = 0;
2978  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2979  if (bin < 7) weight = weightsBins[bin];
2980 
2981  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
2982  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
2983  84, 117, 152, 191, 234,
2984  1000};
2985  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
2986  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
2987  Int_t bin = 0;
2988  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2989  if (bin < 10) weight = weightsBins[bin];
2990  } else if ( fPeriodEnum == kLHC16rP1JJ ){ // preliminary weights obtained from local running
2991  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};
2992  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};
2993  Int_t bin = 0;
2994  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2995  if (bin < 20) weight = weightsBins[bin];
2996  } else if ( fPeriodEnum == kLHC16sP1JJ ){ // preliminary weights obtained from local running
2997  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};
2998  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};
2999  Int_t bin = 0;
3000  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3001  if (bin < 20) weight = weightsBins[bin];
3002  } else if ( fPeriodEnum == kLHC18b8 ){
3003  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};
3004  Double_t weightsBins[20] = { 16.1083, 4.60917, 2.15196, 0.782021, 0.26541,
3005  0.0978374, 0.0294286, 0.00989457, 0.0040615, 0.00135787,
3006  0.000531766, 0.000188772, 9.23331e-05, 4.30245e-05, 2.10196e-05,
3007  1.06695e-05, 5.78742e-06, 3.02897e-06, 1.62702e-06, 2.12118e-06 };
3008 
3009  Int_t bin = 0;
3010  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
3011  if (bin < 20) weight = weightsBins[bin];
3012  } else {
3013  weight = 1;
3014  }
3015 
3016  if (weight == -1) return kFALSE;
3017  else return eventAccepted;
3018 
3019  } else {
3020  return kFALSE;
3021  }
3022  }
3023 
3024  return kFALSE;
3025 }
3026 
3027 //________________________________________________________________________
3028 // Analysing Jet-Jet MC's
3029 //________________________________________________________________________
3030 void AliConvEventCuts::GetXSectionAndNTrials(AliMCEvent *mcEvent, Float_t &XSection, Float_t &NTrials, AliVEvent* event){
3031 
3032  AliGenCocktailEventHeader *cHeader = 0x0;
3033  Bool_t headerFound = kFALSE;
3034  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
3035  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
3036  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
3037  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
3038  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
3039  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
3040  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
3041  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
3042  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
3043  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
3044  ){
3045  NTrials = -1;
3046  XSection = -1;
3047  return;
3048  }
3049 
3050  if(mcEvent){
3051  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
3052  if(cHeader) headerFound = kTRUE;
3053  }else{
3054  //no mcEvent available -> not running on MC
3055  NTrials = -1;
3056  XSection = -1;
3057  return;
3058  }
3059 
3060  if(headerFound){
3061  TList *genHeaders = 0x0;
3062  if(cHeader) genHeaders = cHeader->GetHeaders();
3063  AliGenEventHeader* gh = 0;
3064  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3065  gh = (AliGenEventHeader*)genHeaders->At(i);
3066  TString GeneratorName = gh->GetName();
3067  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
3068  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(gh);
3069  NTrials = gPythia->Trials();
3070  XSection = gPythia->GetXsection();
3071  return;
3072  }
3073  }
3074  } else {
3075  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
3076  if(eventHeader){
3077  TString eventHeaderName = eventHeader->ClassName();
3078  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
3079  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader);
3080  NTrials = gPythia->Trials();
3081  XSection = gPythia->GetXsection();
3082  return;
3083  }
3084  }
3085  }
3086  // the following part is necessary for pythia8jets embedded in EPOS for AODs
3087  if(event){
3088  if(event->IsA()==AliAODEvent::Class()){
3089  AliAODMCHeader *mch = NULL;
3090  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
3091  if(aod){
3092  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
3093  if ( mch ){
3094  Int_t nGenerators = mch->GetNCocktailHeaders();
3095  if ( nGenerators > 0 ){
3096  for(Int_t igen = 0; igen < nGenerators; igen++)
3097  {
3098  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
3099  TString name = eventHeaderGen->GetName();
3100  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
3101  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeaderGen);
3102  NTrials = gPythia->Trials();
3103  XSection = gPythia->GetXsection();
3104  return;
3105  }
3106  }
3107  }
3108  }
3109  }
3110  }
3111  }
3112 
3113  NTrials = -1;
3114  XSection = -1;
3115  return;
3116 }
3117 
3118 
3119 //________________________________________________________________________
3120 // Analysing Jet-Jet MC's
3121 //________________________________________________________________________
3122 Float_t AliConvEventCuts::GetPtHard(AliMCEvent *mcEvent, AliVEvent* event){
3123  AliGenCocktailEventHeader *cHeader = 0x0;
3124  Bool_t headerFound = kFALSE;
3125 
3126  if ( fPeriodEnum != kLHC18b8 && // LHC17pq pp 5TeV JetJet MC's
3127  fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
3128  fPeriodEnum != kLHC16rP1JJ && fPeriodEnum != kLHC16sP1JJ && // LHC16sr pPb 8TeV JetJet MC's
3129  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
3130  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
3131  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
3132  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
3133  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
3134  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
3135  fPeriodEnum != kLHC12P2JJ // LHC12 JetJet MC
3136  ) return -1;
3137 
3138  if(mcEvent){
3139  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
3140  if(cHeader) headerFound = kTRUE;
3141  }else{
3142  //no mcEvent available -> not running on MC
3143  return -1;
3144  }
3145 
3146  if(headerFound){
3147  TList *genHeaders = 0x0;
3148  if(cHeader) genHeaders = cHeader->GetHeaders();
3149  AliGenEventHeader* gh = 0;
3150  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3151  gh = (AliGenEventHeader*)genHeaders->At(i);
3152  TString GeneratorName = gh->GetName();
3153  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
3154  return dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
3155  }
3156  }
3157  } else {
3158  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
3159  if(eventHeader){
3160  TString eventHeaderName = eventHeader->ClassName();
3161  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
3162  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
3163  }
3164  }
3165 
3166  if(event->IsA()==AliAODEvent::Class()){
3167  AliAODMCHeader *mch = NULL;
3168  AliAODEvent * aod = dynamic_cast<AliAODEvent*> (event);
3169  if(aod){
3170  mch = dynamic_cast<AliAODMCHeader*>(aod->FindListObject("mcHeader"));
3171  if ( mch ){
3172  Int_t nGenerators = mch->GetNCocktailHeaders();
3173  if ( nGenerators > 0 ){
3174  for(Int_t igen = 0; igen < nGenerators; igen++)
3175  {
3176  AliGenEventHeader * eventHeaderGen = mch->GetCocktailHeader(igen) ;
3177  TString name = eventHeaderGen->GetName();
3178  if (name.CompareTo("AliGenPythiaEventHeader") == 0 || name.Contains("Pythia8Jets")){
3179  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeaderGen)->GetPtHard();
3180  }
3181  }
3182  }
3183  }
3184  }
3185  }
3186  }
3187 
3188  return -1;
3189 }
3190 
3191 
3192 //________________________________________________________________________
3194  // abort if mimicing not enabled
3195 
3196  if (!fMimicTrigger) return kTRUE;
3197 
3198  Int_t runRangesEMCalL0 [52] = { 144871, 145288, 146375, 146382, // LHC11a
3199  146502, 148522, // LHC11a
3200  150209, 153056, 153911, 153915, // LHC11b,c,d
3201  158135, 158136, 158178, 158182, 160683,
3202  160764, 161139, 161256, 161379, 161457,
3203  161525, 161556, 161558, 161609, 161630,
3204  161724, // LHC11d,e
3205  173731, 177144, 177147, 177653, 177724, 178327, // LHC12x
3206  195180, // LHC13b-f
3207  197469, 197692, // LHC13g
3208  235195, // LHC15a-h
3209  244285, // LHC15i-LHC15m (235196-244284)
3210  244629, // LHC15n (244340-244628)
3211  245141, 246995, // LHC15o (244824-246994)
3212  255539, // LHC16i-k (255515-258574)
3213  258883, // LHC16l (258883-260187)
3214  260216, // LHC16m-p (260216-p)
3215  265015, 265309, // LHC16q (265015-265525)
3216  265589, 265785, // LHC16r (265589-266318)
3217  266405, // LHC16s (266405-267131)
3218  267161, // LHC16t (267161-267166)
3219  270531, // LHC17c-o (270531-281961)
3220  282008, // LHC17pq (282008-282441)
3221  282504 // 2018
3222  };
3223 
3224  Double_t thresholdEMCalL0[51] = { 2.11, 3.43, 1.71, 2.05, // LHC11a 7 TeV
3225  3.43, // LHC11a 2.76TeV
3226  1.94, 3.39, 4.01, 5.25, 5.5, // LHC11b, LHC11c, LHC11d
3227  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,
3228  2.01, 1.75, 1.52, 2.01, 1.52, 1.85,
3229  3.2,
3230  /*2.01*/1.8, // LHC13g
3231  2000, // LS1
3232  1.8, // LHC15a-h
3233  5.0, // LHC15i-m
3234  5.0, // LHC15n
3235  1.0, 1.0, // LHC15o
3236  2.2, // LHC16i-k (255515-258574)
3237  2.2, // LHC16l (258883-260187)
3238  2.5, // LHC16m-p (260216-p)
3239  2.5, 2.5, // LHC16q (265015-265525)
3240  2.5, 2.5, // LHC16r (265589-266318)
3241  3.5, // LHC16s (266405-267131)
3242  2.5, // LHC16t (267161-267166)
3243  2.5, // LHC17c-o (270531-281961)
3244  2.5 // LHC17pq (282008-282441)
3245 // 2.5 // 2018
3246  };
3247 
3248  Double_t spreadEMCalL0[51] = { 0., 0., 0, 0, // LHC11a 7TeV
3249  /*0.7*/0.65, // LHC11a 2.76TeV
3250  0., 0., 0., 0., 0., // LHC11b, LHC11c, LHC11d
3251  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
3252  0., 0., 0., 0., 0.2, 0.2,/*0.,0.,*/
3253  0.1, // LHC13b-f
3254  /*0.1*/0.12, // LHC13g
3255  0., // LS1
3256  0.1, // LHC15a-h
3257  0.1, // LHC15i-m
3258  0.1, // LHC15n
3259  0.1, 0.1, // LHC15o
3260  0.2, // LHC16i-k (255515-258574)
3261  0.2, // LHC16l (258883-260187)
3262  0.1, // LHC16m-p (260216-p)
3263  0.1, 0.1, // LHC16q (265015-265525)
3264  0.1, 0.1, // LHC16r (265589-266318)
3265  0.1, // LHC16s (266405-267131)
3266  0.1, // LHC16t (267161-267166)
3267  0.1, // LHC17c-o (270531-281961)
3268  0.1 // LHC17pq (282008-282441)
3269 // 0.1 // 2018
3270  };
3271 
3272  Int_t runRangesEMCalL1[21] = { 179796, // LHC12c-i (EGA)
3273  195180, // LHC13b-f
3274  197469, 197692, // LHC13g
3275  235195, // LHC15a-h
3276  244285, // LHC15i-LHC15m (235196-244284)
3277  244629, // LHC15n (244340-244628)
3278  245141, 246995, // LHC15o (244824-246994)
3279  255539, // LHC16i-k (255515-258574)
3280  258883, // LHC16l (258883-260187)
3281  260216, // LHC16m-p (260216-p)
3282  265015, 265309, // LHC16q (265015-265525)
3283  265589, 265785, // LHC16r (265589-266318)
3284  266405, // LHC16s (266405-267131)
3285  267161, // LHC16t (267161-267166)
3286  270531, // LHC17c-o (270531-281961)
3287  282008, // LHC17pq (282008-282441)
3288  282504 // 2018
3289  };
3290 
3291  Double_t thresholdEMCalL1[20] = { 9.5/*8.398*/, // LHC12c-i (EGA)
3292  11.5, /*6.*/ // LHC13b-f
3293  5.5, // LHC13g
3294  2000.0, // LS1
3295  2000.0, // LHC15a-h
3296  5.0, // LHC15i-m
3297  5.0, // LHC15n
3298  2000.0, 10.0, // LHC15o
3299  8.8, // LHC16i-k (255515-258574)
3300  5.5, // LHC16l (258883-260187)
3301  8.8, // LHC16m-p (260216-)
3302  8.8, 10.8, // LHC16q (265015-265525)
3303  10.8, 7.8, // LHC16r (265589-266318)
3304  7.8, // LHC16s (266405-267131)
3305  7.8, // LHC16t (267161-267166)
3306  8.8, // LHC17c-o (270531-281961)
3307  8.8 // LHC17pq (282008-282441)
3308 // 8.8 // 2018
3309  };
3310  Double_t spreadEMCalL1[20] = { 1.0/*0.*/,
3311  0.5,
3312  /*0.4*/ 0.6,
3313  0.0, // LS1
3314  1.2, 0.8, // LHC16r (265589-266318)
3315  0.0, // LHC15a-h
3316  1.0, // LHC15i-m
3317  1.0, // LHC15n
3318  0.0, 1.0, // LHC15o
3319  1.0, // LHC16i-k (255515-258574)
3320  0.8, // LHC16l (258883-260187)
3321  1.0, // LHC16m-p (260216-)
3322  1.0, 1.2, // LHC16q (265015-265525)
3323  0.9, // LHC16s (266405-267131)
3324  0.9, // LHC16t (267161-267166)
3325  1.0, // LHC17c-o (270531-281961)
3326  1.0 // LHC17pq (282008-282441)
3327 // 1.0 // 2018
3328  };
3329 
3330  Int_t runRangesEMCalL1G2[21] = { 195180, // LHC13b-f
3331  197469, 197692, // LHC13g
3332  235195, // LHC15a-h
3333  244285, // LHC15i-LHC15m (235196-244284)
3334  244629, // LHC15n (244340-244628)
3335  245141, 246995, // LHC15o (244824-246994)
3336  255539, // LHC16i-k (255515-258574)
3337  258883, // LHC16l (258883-260187)
3338  260216, // LHC16m-p (260216-)
3339  265015, 265309, // LHC16q (265015-265525)
3340  265589, 265785, // LHC16r (265589-266318)
3341  266405, // LHC16s (266405-267131)
3342  267161, // LHC16t (267161-267166)
3343  270531, // LHC17c-o (270531-281961)
3344  282008, // LHC17pq (282008-282441)
3345  282504 // 2018
3346  };
3347 
3348  Double_t thresholdEMCalL1G2[19] = { 7.2, // LHC13b-f
3349  /*3.9*/3.75, // LHC13g
3350  2000.0, // LS1
3351  1.8, // LHC15a-h
3352  5.0, // LHC15i-m
3353  5.0, // LHC15n
3354  2000.0, 2000.0, // LHC15o
3355  3.9, // LHC16i-k (255515-258574)
3356  3.8, // LHC16l (258883-260187)
3357  3.9, // LHC16m-p (260216-)
3358  3.9, 6.3, // LHC16q (265015-265525)
3359  6.3, 5.3, // LHC16r (265589-266318)
3360  5.3, // LHC16s (266405-267131)
3361  5.3, // LHC16t (267161-267166)
3362  3.9, // LHC17c-o (270531-281961)
3363  3.9 // LHC17pq (282008-282441)
3364 // 3.9 // 2018
3365  };
3366  Double_t spreadEMCalL1G2[19] = { 0.3, // LHC13bf
3367  /*0.2*/0.25, // LHC13g
3368  0., // LS1
3369  0.1, // LHC15a-h
3370  0.1, // LHC15i-m
3371  0.1, // LHC15n
3372  0.1, 1.0, // LHC15o
3373  0.3, // LHC16i-k (255515-258574)
3374  0.3, // LHC16l (258883-260187)
3375  0.3, // LHC16m-p (260216-)
3376  0.3, 0.4, // LHC16q (265015-265525)
3377  0.4, 0.3, // LHC16r (265589-266318)
3378  0.3, // LHC16s (266405-267131)
3379  0.3, // LHC16t (267161-267166)
3380  0.3, // LHC17c-o (270531-281961)
3381  0.3 // LHC17pq (282008-282441)
3382 // 0.3 // 2018
3383  };
3384 
3385  Int_t runnumber = event->GetRunNumber();
3386 
3387  if (fSpecialTrigger == 5 ){
3388  if (runnumber < runRangesEMCalL0[0]) return kTRUE;
3389  Int_t binRun = 0;
3390  while (!(runnumber >= runRangesEMCalL0[binRun] && runnumber < runRangesEMCalL0[binRun+1] ) && binRun < 51 ){
3391 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << ":\t"<< thresholdEMCalL0[binRun] << "\t" << spreadEMCalL0[binRun] << endl;
3392  binRun++;
3393  }
3394  if (binRun==51) return kFALSE;
3395 // cout << runnumber << "\t"<< binRun << "\t"<< thresholdEMCalL0[binRun] << "\t" << spreadEMCalL0[binRun] << endl;
3396  Double_t threshold = thresholdEMCalL0[binRun];
3397 
3398  if (isMC && spreadEMCalL0[binRun] != 0.){
3399  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3400  triggerSmearing->SetParameter(0, 1/(spreadEMCalL0[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3401  triggerSmearing->SetParameter(1, thresholdEMCalL0[binRun]);
3402  triggerSmearing->SetParameter(2, spreadEMCalL0[binRun]);
3403  threshold = triggerSmearing->GetRandom();
3404  delete triggerSmearing;
3405  }
3406 
3407 // cout << "modified" << "\t"<< threshold << endl;
3408  Int_t nclus = 0;
3409  TClonesArray * arrClustersMimic = NULL;
3410  if(!fCorrTaskSetting.CompareTo("")){
3411  nclus = event->GetNumberOfCaloClusters();
3412  } else {
3413  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3414  if(!arrClustersMimic)
3415  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3416  nclus = arrClustersMimic->GetEntries();
3417  }
3418 
3419  if(nclus == 0) return kFALSE;
3420 
3421  // Loop over EMCal clusters
3422  Bool_t eventIsAccepted = kFALSE;
3423  for(Int_t i = 0; i < nclus; i++){
3424  if (eventIsAccepted) continue;
3425  AliVCluster* clus = NULL;
3426  if(event->IsA()==AliESDEvent::Class()){
3427  if(arrClustersMimic)
3428  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3429  else
3430  clus = event->GetCaloCluster(i);
3431  } else if(event->IsA()==AliAODEvent::Class()){
3432  if(arrClustersMimic)
3433  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3434  else
3435  clus = event->GetCaloCluster(i);
3436  }
3437 
3438  if (!clus){
3439  if(arrClustersMimic) delete clus;
3440  continue;
3441  }
3442  if (!clus->IsEMCAL()) {
3443  if(arrClustersMimic) delete clus;
3444  continue;
3445  }
3446  if (clus->GetM02()<0.1) {
3447  if(arrClustersMimic) delete clus;
3448  continue;
3449  }
3450  if (clus->GetNCells()<2) {
3451  if(arrClustersMimic) delete clus;
3452  continue;
3453  }
3454  if (clus->E() > threshold ){
3455 // cout << "found L0" << endl;
3456  eventIsAccepted = kTRUE;
3457  }
3458  if(arrClustersMimic)
3459  delete clus;
3460  }
3461  return eventIsAccepted;
3462 
3463  } else if (fSpecialTrigger == 6 ) {
3464 
3465  return kTRUE;
3466  } else if (fSpecialTrigger == 8 ) {
3467  if (fSpecialSubTriggerName.CompareTo("7EGA")==0 || fSpecialSubTriggerName.CompareTo("8EGA")==0 || fSpecialSubTriggerName.CompareTo("7EG1")==0 ||fSpecialSubTriggerName.CompareTo("8EG1")==0 ){
3468  if (runnumber < runRangesEMCalL1[0]) return kTRUE;
3469  Int_t binRun = 0;
3470  while (!(runnumber >= runRangesEMCalL1[binRun] && runnumber < runRangesEMCalL1[binRun+1] ) && binRun < 20 ){
3471 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL1[binRun] << "\t" << runRangesEMCalL1[binRun+1] << ":\t"<< thresholdEMCalL1[binRun]<<"\t"<< spreadEMCalL1[binRun]<< endl;
3472  binRun++;
3473  }
3474  if (binRun==20) return kFALSE;
3475  Double_t threshold = thresholdEMCalL1[binRun];
3476 
3477  if (isMC && spreadEMCalL1[binRun] != 0.){
3478  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3479  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3480  triggerSmearing->SetParameter(1, thresholdEMCalL1[binRun]);
3481  triggerSmearing->SetParameter(2, spreadEMCalL1[binRun]);
3482  threshold = triggerSmearing->GetRandom();
3483  delete triggerSmearing;
3484  }
3485 
3486 // cout << runnumber << "\t"<< binRun << "\t L1 \t"<< threshold << endl;
3487 
3488  TClonesArray * arrClustersMimic = NULL;
3489  Int_t nclus = 0;
3490  if(!fCorrTaskSetting.CompareTo("")){
3491  nclus = event->GetNumberOfCaloClusters();
3492  } else {
3493  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3494  if(!arrClustersMimic)
3495  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3496  nclus = arrClustersMimic->GetEntries();
3497  }
3498 
3499  if(nclus == 0) return kFALSE;
3500 
3501  // Loop over EMCal clusters
3502  Bool_t eventIsAccepted = kFALSE;
3503  for(Int_t i = 0; i < nclus; i++){
3504  if (eventIsAccepted) continue;
3505  AliVCluster* clus = NULL;
3506  if(event->IsA()==AliESDEvent::Class()){
3507  if(arrClustersMimic)
3508  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3509  else
3510  clus = event->GetCaloCluster(i);
3511  } else if(event->IsA()==AliAODEvent::Class()){
3512  if(arrClustersMimic)
3513  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3514  else
3515  clus = event->GetCaloCluster(i);
3516  }
3517  if (!clus) {
3518  if(arrClustersMimic) delete clus;
3519  continue;
3520  }
3521  if (!clus->IsEMCAL()) {
3522  if(arrClustersMimic) delete clus;
3523  continue;
3524  }
3525  if (clus->GetM02()<0.1) {
3526  if(arrClustersMimic) delete clus;
3527  continue;
3528  }
3529  if (clus->GetNCells()<2) {
3530  if(arrClustersMimic) delete clus;
3531  continue;
3532  }
3533  if (clus->E() > threshold ){
3534 // cout << "found L1G1\t" << clus->E() << endl;
3535  eventIsAccepted = kTRUE;
3536  }
3537  if(arrClustersMimic)
3538  delete clus;
3539  }
3540  return eventIsAccepted;
3541  } else if ( fSpecialSubTriggerName.CompareTo("7EG2")==0 ||fSpecialSubTriggerName.CompareTo("8EG2")==0 ){
3542  if (runnumber < runRangesEMCalL1G2[0]) return kTRUE;
3543  Int_t binRun = 0;
3544  while (!(runnumber >= runRangesEMCalL1G2[binRun] && runnumber < runRangesEMCalL1G2[binRun+1] ) && binRun < 19 ){
3545 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL1G2[binRun] << "\t" << runRangesEMCalL1G2[binRun+1] << ":\t"<< thresholdEMCalL1G2[binRun]<<"\t"<< spreadEMCalL1G2[binRun]<< endl;
3546  binRun++;
3547  }
3548 // cout << runnumber << "\t"<< binRun << "\t L2 \t"<< thresholdEMCalL1G2[binRun]<<"\t"<< spreadEMCalL1G2[binRun]<< endl;
3549  if (binRun==19) return kFALSE;
3550  Double_t threshold = thresholdEMCalL1G2[binRun];
3551  if (isMC && spreadEMCalL1G2[binRun] != 0.){
3552  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3553  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1G2[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3554  triggerSmearing->SetParameter(1, thresholdEMCalL1G2[binRun]);
3555  triggerSmearing->SetParameter(2, spreadEMCalL1G2[binRun]);
3556  threshold = triggerSmearing->GetRandom();
3557  delete triggerSmearing;
3558  }
3559 // cout << "\t L2 mod\t"<< threshold << endl;
3560 
3561  Int_t nclus = 0;
3562  TClonesArray * arrClustersMimic = NULL;
3563  if(!fCorrTaskSetting.CompareTo("")){
3564  nclus = event->GetNumberOfCaloClusters();
3565  } else {
3566  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3567  if(!arrClustersMimic)
3568  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3569  nclus = arrClustersMimic->GetEntries();
3570  }
3571 
3572  if(nclus == 0) return kFALSE;
3573 
3574  // Loop over EMCal clusters
3575  Bool_t eventIsAccepted = kFALSE;
3576  for(Int_t i = 0; i < nclus; i++){
3577  if (eventIsAccepted) continue;
3578  AliVCluster* clus = NULL;
3579  if(event->IsA()==AliESDEvent::Class()){
3580  if(arrClustersMimic)
3581  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3582  else
3583  clus = event->GetCaloCluster(i);
3584  } else if(event->IsA()==AliAODEvent::Class()){
3585  if(arrClustersMimic)
3586  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3587  else
3588  clus = event->GetCaloCluster(i);
3589  }
3590  if (!clus) {
3591  if(arrClustersMimic) delete clus;
3592  continue;
3593  }
3594  if (!clus->IsEMCAL()) {
3595  if(arrClustersMimic) delete clus;
3596  continue;
3597  }
3598  if (clus->GetM02()<0.1) {
3599  if(arrClustersMimic) delete clus;
3600  continue;
3601  }
3602  if (clus->GetNCells()<2) {
3603  if(arrClustersMimic) delete clus;
3604  continue;
3605  }
3606  if (clus->E() > threshold ){
3607 // cout << "found L1G2" << endl;
3608  eventIsAccepted = kTRUE;
3609  }
3610  if(arrClustersMimic)
3611  delete clus;
3612  }
3613  return eventIsAccepted;
3614  }
3615  return kTRUE;
3616  } else if (fSpecialTrigger == 9 ) {
3617  return kTRUE;
3618  } else {
3619  return kTRUE;
3620  }
3621 
3622  return kTRUE;
3623 }
3624 
3625 
3626 //________________________________________________________________________
3628 {
3629 
3630  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
3631 
3632 
3633  UInt_t isSelected = AliVEvent::kAny;
3634 
3635  if (fInputHandler==NULL) return kFALSE;
3636  if( fInputHandler->GetEventSelection() || event->IsA()==AliAODEvent::Class()) {
3637 
3638  TString firedTrigClass = event->GetFiredTriggerClasses();
3639  // if no trigger has been selected manually, select kAny in case of presel (also important for AOD filtering!)
3640  // in other cases select standards depending on system
3642  if (fPreSelCut) fOfflineTriggerMask = AliVEvent::kAny;
3643  else {
3644  if (fIsHeavyIon == 1){
3645  fOfflineTriggerMask = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
3646  } else if (fIsHeavyIon == 2){
3647  fOfflineTriggerMask = AliVEvent::kINT7;
3648  } else {
3649  fOfflineTriggerMask = AliVEvent::kMB;
3650  }
3651  }
3652  }
3653 
3654  // in case of MC switch to kAny if no MB/INT7/INT8 has been selected
3655  if(isMC){
3656  if( fIsHeavyIon == 0){
3657  if( fOfflineTriggerMask != AliVEvent::kMB && fOfflineTriggerMask != AliVEvent::kINT7 && fOfflineTriggerMask != AliVEvent::kINT8 ){
3658  fOfflineTriggerMask = AliVEvent::kAny;
3659  }
3660  }else{
3661  fOfflineTriggerMask = AliVEvent::kAny;
3662  }
3663  }
3664 
3665  if (fOfflineTriggerMask){
3666  isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
3667  if (isSelected && !fPreSelCut){
3668 // cout << firedTrigClass.Data() << endl;
3669 // cout << "Special trigger: "<< fSpecialTrigger << " initialized " << fEMCALTrigInitialized << endl;
3670 // if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3671 // if (!fEMCALTrigInitialized ) InitializeEMCALTrigger(event);
3672 // fTriggersEMCAL= GetTriggerList();
3673 // }
3674  if (fSpecialSubTrigger>0 && !isMC){
3675  if (!firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 0;
3676  if (fRejectTriggerOverlap){
3677  // trigger rejection EMC1,7,8
3678  if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC7") == 0){
3679  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3680  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC1") == 0){
3681  if (fInputHandler->IsEventSelected() & AliVEvent::kMB) isSelected = 0;
3682  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC8") == 0){
3683  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3684  }
3685  // trigger rejection EGA
3686  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EGA") == 0){
3687  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3688  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3689  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EGA") == 0){
3690  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3691  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3692  }
3693  // trigger rejection EG1 & EG2
3694  if (fPeriodEnum == kLHC13g){
3695  // EG1 is the trigger with the highest threshold
3696  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3697 // cout << firedTrigClass.Data() << endl;
3698  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3699 // cout << "INT7? " << isSelected << endl;
3700  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3701 // cout << "CEM7? " << isSelected << endl;
3702  if (firedTrigClass.Contains("7EG2")) isSelected = 0;
3703 // cout << "7EG2? " << isSelected << endl;
3704  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3705  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3706  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3707  if (firedTrigClass.Contains("8EG2")) isSelected = 0;
3708  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3709 // cout << firedTrigClass.Data() << endl;
3710  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3711 // cout << "INT7? " << isSelected << endl;
3712  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3713 // cout << "CEM7? " << isSelected << endl;
3714  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3715  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3716  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3717  }
3718  } else {
3719  // EG2 is the trigger with the highest threshold
3720  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3721  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3722  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3723  if (firedTrigClass.Contains("7EG1")) isSelected = 0;
3724  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3725  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3726  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3727  if (firedTrigClass.Contains("8EG1")) isSelected = 0;
3728  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3729  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3730  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3731  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3732  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3733  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3734  }
3735  }
3736  }
3737  if (isSelected != 0 ){
3738 // cout << "I am here" << " :" << fSpecialSubTriggerName.Data() <<endl;
3739  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9 ){
3741  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassesCorrelated->Fill(0);
3742  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassesCorrelated->Fill(1);
3743  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassesCorrelated->Fill(2);
3744  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassesCorrelated->Fill(3);
3745  if (firedTrigClass.Contains("7EJE") || firedTrigClass.Contains("8EJE")) hTriggerClassesCorrelated->Fill(4);
3746  if (firedTrigClass.Contains("7EJ1") || firedTrigClass.Contains("8EJ1")) hTriggerClassesCorrelated->Fill(5);
3747  if (firedTrigClass.Contains("7EJ2") || firedTrigClass.Contains("8EJ2")) hTriggerClassesCorrelated->Fill(6);
3748  if (firedTrigClass.Contains("7EGA") || firedTrigClass.Contains("8EGA")) hTriggerClassesCorrelated->Fill(7);
3749  if (firedTrigClass.Contains("7EG1") || firedTrigClass.Contains("8EG1")) hTriggerClassesCorrelated->Fill(8);
3750  if (firedTrigClass.Contains("7EG2") || firedTrigClass.Contains("8EG2")) hTriggerClassesCorrelated->Fill(9);
3751  }
3752  }
3753  }
3754 
3755  } else if (isMC){
3756  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3757 // isSelected = 0;
3758 // if (fTriggersEMCAL > 0)cout << "Special Trigger " << fSpecialTrigger << " triggers: " << fTriggersEMCAL << " selected triggers: " << fTriggersEMCALSelected << " run number: " <<event->GetRunNumber()<<endl;
3759 // if (fTriggersEMCAL&fTriggersEMCALSelected){
3760 // cout << "accepted ++++++++++++++++++++" << endl;
3761  isSelected = 1;
3762 // }
3763  }
3764  }
3765  //if for specific centrality trigger selection
3766  if(fSpecialSubTrigger == 1){
3767  if(fSpecialSubTriggerName.Contains("|") && GetCentrality(event) <= 10.){
3768  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("|");
3769  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3770  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3771  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3772  }
3773  } else if(fSpecialSubTriggerName.Contains("%")){
3774  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("%");
3775  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3776  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3777  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3778  }
3779  } else if(fSpecialSubTriggerName.Contains("@")){
3780  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("@");
3781  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3782  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3783  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3784  }
3785  } else if(fSpecialSubTriggerName.Contains("&")){ //logic AND of two classes
3786  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("&");
3787  TString CheckClass = "";
3788  for (Int_t i=0; i<ClassesList->GetEntriesFast(); i++){
3789  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3790  if (firedTrigClass.Contains(NameClass->GetString())) CheckClass+="1";
3791  else CheckClass+="0";
3792  }
3793  if(CheckClass.Contains("0")) isSelected = 0;
3794  }
3795  else if(firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 1;
3796  }
3797  }
3798  }
3799  }
3800  fIsSDDFired = !(fInputHandler->IsEventSelected() & AliVEvent::kFastOnly);
3801 
3802  Bool_t mimickedTrigger = kTRUE;
3803  if (fMimicTrigger) mimickedTrigger = MimicTrigger(event, isMC);
3804 // cout << "mimicked decision \t" << mimickedTrigger << "expect decision? "<< fMimicTrigger<< endl;
3805 
3806  // Fill Histogram
3807  if(hTriggerClass){
3808  if (fIsSDDFired) hTriggerClass->Fill(33);
3809  if (mimickedTrigger){
3810  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
3811  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
3812  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
3813  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClass->Fill(3);
3814  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClass->Fill(4);
3815  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
3816  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
3817  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
3818  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
3819  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
3820  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
3821  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClass->Fill(8);
3822  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClass->Fill(9);
3823  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClass->Fill(9);
3824  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClass->Fill(10);
3825  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClass->Fill(10);
3826  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClass->Fill(11);
3827  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClass->Fill(12);
3828  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClass->Fill(13);
3829  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClass->Fill(13);
3830  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClass->Fill(13);
3831  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClass->Fill(14);
3832  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClass->Fill(15);
3833  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClass->Fill(16);
3834  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClass->Fill(17);
3835  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClass->Fill(18);
3836  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClass->Fill(19);
3837  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClass->Fill(20);
3838  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClass->Fill(20);
3839  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClass->Fill(21);
3840  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClass->Fill(22);
3841  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClass->Fill(23);
3842  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClass->Fill(24);
3843  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClass->Fill(25);
3844  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClass->Fill(26);
3845  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClass->Fill(27);
3846  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClass->Fill(28);
3847  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(29);
3848  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(30);
3849  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(31);
3850  if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(34);
3851  }
3852  if (mimickedTrigger && fMimicTrigger) hTriggerClass->Fill(35);
3853  }
3854 
3855  if(hTriggerClassSelected && isSelected){
3856  if (mimickedTrigger){
3857  if (!fIsSDDFired) hTriggerClassSelected->Fill(33);
3858  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
3859  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
3860  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
3861  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
3862  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
3863  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
3864  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
3865  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
3866  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
3867  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
3868  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
3869  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
3870  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
3871  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
3872  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
3873  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
3874  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
3875  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
3876  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
3877  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
3878  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
3879  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
3880  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
3881  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
3882  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
3883  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
3884  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
3885  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
3886  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
3887  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
3888  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
3889  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
3890  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
3891  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
3892  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
3893  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
3894  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClassSelected->Fill(28);
3895  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(29);
3896  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(30);
3897  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(31);
3898  }
3899  if (mimickedTrigger && fMimicTrigger) hTriggerClassSelected->Fill(34);
3900  }
3901 
3902  if(!isSelected)return kFALSE;
3903  if (fMimicTrigger)
3904  if (!mimickedTrigger ) return kFALSE;
3905  return kTRUE;
3906 
3907 }
3908 
3909 //________________________________________________________________________
3911  // returns TString with current cut number
3912  return fCutStringRead;
3913 }
3914 
3915 //________________________________________________________________________
3916 void AliConvEventCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliVEvent *event){
3917 
3918  if(fNotRejectedStart){
3919  delete[] fNotRejectedStart;
3920  fNotRejectedStart = NULL;
3921  }
3922  if(fNotRejectedEnd){
3923  delete[] fNotRejectedEnd;
3924  fNotRejectedEnd = NULL;
3925  }
3926  if(fGeneratorNames){
3927  delete[] fGeneratorNames;
3928  fGeneratorNames = NULL;
3929  }
3930 
3931  if(rejection == 0) return; // No Rejection
3932 
3933  AliGenCocktailEventHeader *cHeader = 0x0;
3934  AliAODMCHeader *cHeaderAOD = 0x0;
3935  Bool_t headerFound = kFALSE;
3936  AliMCEvent *fMCEvent = 0x0;
3937  TClonesArray *fMCEventAOD = 0x0;
3938  if(event->IsA()==AliMCEvent::Class()){
3939  if(dynamic_cast<AliMCEvent*>(event)){
3940  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(dynamic_cast<AliMCEvent*>(event)->GenEventHeader());
3941  fMCEvent = dynamic_cast<AliMCEvent*>(event);
3942  if(cHeader) headerFound = kTRUE;
3943  }
3944  }
3945  if(event->IsA()==AliAODEvent::Class()){ // event is a AODEvent in case of AOD
3946  cHeaderAOD = dynamic_cast<AliAODMCHeader*>(event->FindListObject(AliAODMCHeader::StdBranchName()));
3947  fMCEventAOD = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
3948  if(cHeaderAOD) headerFound = kTRUE;
3949  }
3950 
3951  if (fDebugLevel > 0 ) cout << "event starts here" << endl;
3952  if(headerFound){
3953  TList *genHeaders = 0x0;
3954  if(cHeader) genHeaders = cHeader->GetHeaders();
3955  if(cHeaderAOD){
3956  genHeaders = cHeaderAOD->GetCocktailHeaders();
3957  if(genHeaders->GetEntries()==1){
3959  return;
3960  }
3961  }
3962  AliGenEventHeader* gh = 0;
3963  fnHeaders = 0;
3964  Int_t firstindexA = 0;
3965  Int_t lastindexA = -1;
3966  if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
3967  if(rejection == 2){ // TList of Headers Names
3968  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3969  gh = (AliGenEventHeader*)genHeaders->At(i);
3970  TString GeneratorName = gh->GetName();
3971  lastindexA = lastindexA + gh->NProduced();
3972  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
3973  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
3974  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
3975  if (fDebugLevel > 0 ) cout << GeneratorInList.Data() << endl;
3976  if(GeneratorInList.Contains(GeneratorName) ){
3977  if (fDebugLevel > 0 ) cout << "accepted" << endl;
3978  if (GeneratorInList.BeginsWith("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
3979  if(fMCEvent){
3980  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
3981  if (fDebugLevel > 2 )cout << "number of produced particle: " << gh->NProduced() << endl;
3982  if (fDebugLevel > 2 )cout << "pdg-code of first particle: " << fMCEvent->Particle(firstindexA)->GetPdgCode() << endl;
3983  if (fMCEvent->Particle(firstindexA)->GetPdgCode() == fAddedSignalPDGCode ) {
3984  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindexA+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
3985  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3986  fnHeaders++;
3987  continue;
3988  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
3989  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
3990  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3991  fnHeaders++;
3992  continue;
3993  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
3994  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
3995  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3996  fnHeaders++;
3997  continue;
3998 
3999  }
4000  continue;
4001  }
4002  } else {
4003  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
4004  fnHeaders++;
4005  continue;
4006  }
4007  }
4008  if ( fMCEventAOD){
4009  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA));
4010  if (aodMCParticle && (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c) ){
4011  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
4012  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0){
4013  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA+10));
4014  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
4015  if (fDebugLevel > 0 ) cout << "cond 1: " << fnHeaders << endl;
4016  fnHeaders++;
4017  continue;
4018  }
4019  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4020  if (fDebugLevel > 2 ) cout << "accepted EMC header "<< endl;
4021  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4022  fnHeaders++;
4023  continue;
4024  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4025  if (fDebugLevel > 2 ) cout << "accepted PHOS header "<< endl;
4026  if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
4027  fnHeaders++;
4028  continue;
4029 
4030  }
4031  continue;
4032  }
4033  } else {
4034  if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
4035  fnHeaders++;
4036  continue;
4037  }
4038  }
4039  continue;
4040  }
4041  if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
4042  if (fDebugLevel > 0 ) cout << "cond 3: "<< fnHeaders << endl;
4043  fnHeaders++;
4044  continue;
4045  }
4046  }
4047  }
4048  firstindexA = firstindexA + gh->NProduced();
4049  }
4050  }
4051  if (fDebugLevel > 0 ) cout << "number of headers: " <<fnHeaders << endl;
4052 
4056 
4057  if(rejection == 1 || rejection == 3){
4058  fNotRejectedStart[0] = 0;
4059  fNotRejectedEnd[0] = ((AliGenEventHeader*)genHeaders->At(0))->NProduced()-1;
4060  fGeneratorNames[0] = ((AliGenEventHeader*)genHeaders->At(0))->GetName();
4061  if (fDebugLevel > 0 ) cout << 0 << "\t" <<fGeneratorNames[0] << "\t" << fNotRejectedStart[0] << "\t" <<fNotRejectedEnd[0] << endl;
4062  return;
4063  }
4064 
4065  Int_t firstindex = 0;
4066  Int_t lastindex = -1;
4067  Int_t number = 0;
4068 
4069  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
4070  gh = (AliGenEventHeader*)genHeaders->At(i);
4071  TString GeneratorName = gh->GetName();
4072  lastindex = lastindex + gh->NProduced();
4073  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
4074  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
4075  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
4076  if(GeneratorInList.Contains(GeneratorName) ){
4077  if (GeneratorInList.Contains("PARAM") || GeneratorInList.CompareTo("BOX") == 0 ){
4078  if(fMCEvent){
4079  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4080  if (fMCEvent->Particle(firstindex)->GetPdgCode() == fAddedSignalPDGCode ) {
4081  if (fDebugLevel > 0 ) cout << "produced " << gh->NProduced() << " with box generator" << endl;
4082  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindex+10)->GetPdgCode() == fAddedSignalPDGCode && GeneratorInList.CompareTo("BOX") == 0){
4083  if (fDebugLevel > 0 ) cout << "one of them was a pi0 or eta" << endl;
4084  fNotRejectedStart[number] = firstindex;
4085  fNotRejectedEnd[number] = lastindex;
4086  fGeneratorNames[number] = GeneratorName;
4087  number++;
4088  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4089  continue;
4090  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4091  fNotRejectedStart[number] = firstindex;
4092  fNotRejectedEnd[number] = lastindex;
4093  fGeneratorNames[number] = GeneratorName;
4094  number++;
4095  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4096  continue;
4097  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
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  }
4105  }
4106  continue;
4107  } else {
4108  fNotRejectedStart[number] = firstindex;
4109  fNotRejectedEnd[number] = lastindex;
4110  fGeneratorNames[number] = GeneratorName;
4111  number++;
4112  continue;
4113  }
4114  }
4115  if ( fMCEventAOD){
4116  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex));
4117  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
4118  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
4119  if (gh->NProduced() > 10 && GeneratorInList.CompareTo("BOX") == 0) {
4120  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex+10));
4121  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
4122  fNotRejectedEnd[number] = lastindex;
4123  fNotRejectedStart[number] = firstindex;
4124  fGeneratorNames[number] = GeneratorName;
4125  number++;
4126  }
4127  continue;
4128  } else if (gh->NProduced() == 3 && GeneratorInList.Contains("PARAM_EMC") && (i == 3 || i == 5) ){
4129  fNotRejectedStart[number] = firstindex;
4130  fNotRejectedEnd[number] = lastindex;
4131  fGeneratorNames[number] = GeneratorName;
4132  number++;
4133  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4134  continue;
4135  } else if (gh->NProduced() > 2 && GeneratorInList.Contains("PARAM_PHOS") && (i == 4 || i == 6) ){
4136  fNotRejectedStart[number] = firstindex;
4137  fNotRejectedEnd[number] = lastindex;
4138  fGeneratorNames[number] = GeneratorName;
4139  number++;
4140  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4141  continue;
4142  }
4143  continue;
4144  }
4145  } else {
4146  fNotRejectedStart[number] = firstindex;
4147  fNotRejectedEnd[number] = lastindex;
4148  fGeneratorNames[number] = GeneratorName;
4149  number++;
4150  continue;
4151  }
4152  }
4153  continue;
4154  } else if(GeneratorName.CompareTo(GeneratorInList) == 0 ){
4155  fNotRejectedStart[number] = firstindex;
4156  fNotRejectedEnd[number] = lastindex;
4157  fGeneratorNames[number] = GeneratorName;
4158  if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
4159  number++;
4160  continue;
4161  }
4162 
4163  }
4164  }
4165  firstindex = firstindex + gh->NProduced();
4166  }
4167  if (fDebugLevel > 0 ) {
4168  for (Int_t i = 0; i < number; i++){
4169  cout << i << "\t" <<fGeneratorNames[i] << "\t" << fNotRejectedStart[i] << "\t" <<fNotRejectedEnd[i] << endl;
4170  }
4171  }
4172  } else { // No Cocktail Header Found
4173  fNotRejectedStart = new Int_t[1];
4174  fNotRejectedEnd = new Int_t[1];
4175 
4176  fnHeaders = 1;
4177  fNotRejectedStart[0] = 0;
4178  fNotRejectedEnd[0] = static_cast<AliMCEvent*>(event)->GetNumberOfPrimaries()-1;
4179  if (rejection > 1){
4180  fNotRejectedStart[0] = -1;
4181  fNotRejectedEnd[0] = -1;
4182  }
4183 
4184  fGeneratorNames = new TString[1];
4185  fGeneratorNames[0] = "NoCocktailGeneratorFound";
4186 // SetRejectExtraSignalsCut(0);
4187  }
4188 
4189 }
4190 
4191 //_________________________________________________________________________
4192 Int_t AliConvEventCuts::IsParticleFromBGEvent(Int_t index, AliMCEvent *mcEvent, AliVEvent *InputEvent, Int_t debug ){
4193 
4194  // if (debug > 2 ) cout << index << endl;
4195  if(index < 0) return 0; // No Particle
4196 
4197  Int_t accepted = 0;
4198  if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
4199  if(!mcEvent) return 0; // no mcEvent available, return 0
4200  if(index >= mcEvent->GetNumberOfPrimaries()){ // initial particle is secondary particle
4201  if( ((TParticle*)mcEvent->Particle(index))->GetMother(0) < 0) return 0; // material particle, return 0
4202  return IsParticleFromBGEvent(((TParticle*)mcEvent->Particle(index))->GetMother(0),mcEvent,InputEvent, debug);
4203  }
4204  for(Int_t i = 0;i<fnHeaders;i++){
4205  // if (debug > 2 ) cout << "header " << fGeneratorNames[i].Data() << ":"<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
4206  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
4207  if (debug > 1 ) cout << "accepted:" << index << "\t header " << fGeneratorNames[i].Data() << ": "<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
4208  accepted = 1;
4209  if(i == 0) accepted = 2; // MB Header
4210  }
4211  }
4212  if (debug > 1 && !accepted) cout << "rejected:" << index << endl;
4213  }
4214  else if(InputEvent->IsA()==AliAODEvent::Class()){
4215  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
4216  if (AODMCTrackArray){
4217  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
4218  if(!aodMCParticle) return 0; // no particle
4219  if(!aodMCParticle->IsPrimary()){
4220  if( aodMCParticle->GetMother() < 0) return 0;// material particle, return 0
4221  return IsParticleFromBGEvent(aodMCParticle->GetMother(),mcEvent,InputEvent, debug);
4222  }
4223  index = TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index))->GetLabel());
4224  for(Int_t i = 0;i<fnHeaders;i++){
4225  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
4226  accepted = 1;
4227  if(i == 0) accepted = 2; // MB Header
4228  }
4229  }
4230  }
4231  }
4232 
4233  return accepted;
4234 }
4235 
4236 //_________________________________________________________________________
4237 Int_t AliConvEventCuts::IsEventAcceptedByCut(AliConvEventCuts *ReaderCuts, AliVEvent *event, AliMCEvent *mcEvent, Int_t isHeavyIon, Bool_t isEMCALAnalysis){
4238 
4239  Bool_t isMC = kFALSE;
4240  if (mcEvent){isMC = kTRUE;}
4241 
4242  if ( !IsTriggerSelected(event, isMC) )
4243  return 3;
4244 
4245  if( !(IsCentralitySelected(event,mcEvent)))
4246  return 1; // Check Centrality --> Not Accepted => eventQuality = 1
4247 
4248  Bool_t hasV0And = ReaderCuts->HasV0AND();
4249  Bool_t isSDDFired = ReaderCuts->IsSDDFired();
4250 
4251  if( ( (IsSpecialTrigger() == 0 && IsSpecialSubTrigger() == 1) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !isSDDFired && !mcEvent)
4252  //if V0OR with SDD requested or V0AND with SDD request but the SDD has not fired
4253  return 7; // V0 with SDD requested but no fired
4254 
4255  if( ( (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 0) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !hasV0And)
4256  //if V0AND (only) or V0AND with SDD requested but V0AND requested but no fired
4257  return 8; // V0AND requested but no fired
4258 
4259 
4260  if( (IsSpecialTrigger() == 2 || IsSpecialTrigger() == 3) && !isSDDFired && !mcEvent)
4261  return 7; // With SDD requested but no fired
4262 
4263  if( (IsSpecialTrigger() == 1 || IsSpecialTrigger() == 3) && !hasV0And)
4264  return 8; // V0AND requested but no fired
4265 
4266  // Special EMCAL checks due to hardware issues in LHC11a
4267  if (isEMCALAnalysis || IsSpecialTrigger() == 5 || IsSpecialTrigger() == 8 || IsSpecialTrigger() == 9 ){
4268  Int_t runnumber = event->GetRunNumber();
4269  if ((runnumber>=144871) && (runnumber<=146860)) {
4270 
4271  AliVCaloCells *cells = event->GetEMCALCells();
4272  const Short_t nCells = cells->GetNumberOfCells();
4273 
4274  if (event->IsA()==AliESDEvent::Class()) AliAnalysisManager::GetAnalysisManager()->LoadBranch("EMCALCells.");
4275 
4276  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
4277  if (!fInputHandler) return 3;
4278 
4279  // count cells above threshold
4280  Int_t nCellCount[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
4281  for(Int_t iCell=0; iCell<nCells; ++iCell) {
4282  Short_t cellId = cells->GetCellNumber(iCell);
4283  Double_t cellE = cells->GetCellAmplitude(cellId);
4284  Int_t sm = cellId / (24*48);
4285  if (cellE>0.1) ++nCellCount[sm];
4286  }
4287 
4288  Bool_t fIsLedEvent = kFALSE;
4289  if (nCellCount[4] > 100) {
4290  fIsLedEvent = kTRUE;
4291  } else {
4292  if ((runnumber>=146858) && (runnumber<=146860)) {
4293  if ((fInputHandler->IsEventSelected() & AliVEvent::kMB) && (nCellCount[3]>=21))
4294  fIsLedEvent = kTRUE;
4295  else if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC1) && (nCellCount[3]>=35))
4296  fIsLedEvent = kTRUE;
4297  }
4298  }
4299  if (fIsLedEvent) {
4300  return 9;
4301  }
4302  }
4303  }
4304 
4305  // SPD clusters vs tracklets to check for pileup/background
4306  Int_t nClustersLayer0 = event->GetNumberOfITSClusters(0);
4307  Int_t nClustersLayer1 = event->GetNumberOfITSClusters(1);
4308  Int_t nTracklets = event->GetMultiplicity()->GetNumberOfTracklets();
4309  if(hSPDClusterTrackletBackgroundBefore) hSPDClusterTrackletBackgroundBefore->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
4310 
4311 
4312  Double_t distZMax = 0;
4313  if(event->IsA()==AliESDEvent::Class()){
4314  Int_t nPileVert = ((AliESDEvent*)event)->GetNumberOfPileupVerticesSPD();
4315  if (hNPileupVertices) hNPileupVertices->Fill(nPileVert);
4316  if (nPileVert > 0){
4317  for(Int_t i=0; i<nPileVert;i++){
4318  const AliESDVertex* pv= ((AliESDEvent*)event)->GetPileupVertexSPD(i);
4319  Int_t nc2 = pv->GetNContributors();
4320  if(nc2>=3){
4321  Double_t z1 = ((AliESDEvent*)event)->GetPrimaryVertexSPD()->GetZ();
4322  Double_t z2 = pv->GetZ();
4323  Double_t distZ = z2-z1;
4324  if (TMath::Abs(distZMax) < TMath::Abs(distZ) ){
4325  distZMax = distZ;
4326  }
4327  }
4328  }
4329  if (hPileupVertexToPrimZ) hPileupVertexToPrimZ->Fill(distZMax);
4330  }
4331  }
4332  if(GetPastFutureLowBC()!=0 && GetPastFutureHighBC()!=0 ){
4333  if(IsOutOfBunchPileupPastFuture(event))
4334  return 12;
4335  }
4336 
4337  if( isHeavyIon != 2 && GetIsFromPileupSPD()){
4338  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.) ){
4340  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
4341  }
4342  if (fUtils->IsSPDClusterVsTrackletBG(event)){
4344  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
4345  }
4346  }
4347  if(isHeavyIon == 2 && GetIsFromPileupSPD()){
4348  if(fUtils->IsPileUpEvent(event) ){
4350  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
4351  }
4352  if (fUtils->IsSPDClusterVsTrackletBG(event)){
4354  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
4355  }
4356  }
4357 
4359  if( IsPileUpV0MTPCout(event) ){
4360  return 13;
4361  }
4362  }
4363 
4364  if(hCentrality)hCentrality->Fill(GetCentrality(event));
4365 
4366  if(hVertexZ)hVertexZ->Fill(event->GetPrimaryVertex()->GetZ());
4367 // if(hCentralityVsNumberOfPrimaryTracks)
4368 // hCentralityVsNumberOfPrimaryTracks->Fill(GetCentrality(event),
4369 // ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
4370 // ->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks());
4371 
4372  if(fIsHeavyIon == 1){
4373  AliEventplane *EventPlane = event->GetEventplane();
4374  fEventPlaneAngle = EventPlane->GetEventplane("V0",event,2);
4375  if(hEventPlaneAngle)hEventPlaneAngle->Fill(TMath::Abs(fEventPlaneAngle));
4376  }
4377  if(hSPDClusterTrackletBackground) hSPDClusterTrackletBackground->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
4378 
4379  return 0;
4380 }
4381 
4382 
4383 //_________________________________________________________________________
4385 
4386  AliInfo("Inside the GetWeightForCentralityFlattening function");
4387  Double_t centrality = 0.;
4388  //obtain centrality for ESD or AOD
4389  if(!event || event->IsA()==AliESDEvent::Class()){
4390  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
4391  if(esdEvent){
4392  AliCentrality *fESDCentrality=(AliCentrality*)esdEvent->GetCentrality();
4393  if(fDetectorCentrality==0 && fIsHeavyIon==1){
4394  centrality = fESDCentrality->GetCentralityPercentile("V0M"); // default for PbPb
4395  }
4396  }
4397  } else if(event->IsA()==AliAODEvent::Class()){
4398  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
4399  if(aodEvent){
4400  if(aodEvent->GetHeader()){
4401  centrality = ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();
4402  }
4403  }
4404  }
4405 
4406  //Get the maximum vlaue from the reference distribution and interpolated value
4407  Float_t GetValueForWeight = 1.;
4408  Float_t maximum = 1.;
4409  Double_t weightCentrality = 1.;
4410  Bool_t CorrCentrLoop = kFALSE;
4411 
4412  //depending on the value of the flag, flattening in different cent. range
4413  if ( fDoCentralityFlat == 1 && (centrality >= 0. && centrality <= 20.) ){
4414  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4415  maximum = hCentralityNotFlat->GetMaximum();
4416  CorrCentrLoop = kTRUE;
4417  } else if ( fDoCentralityFlat == 8 ){
4418  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
4419  maximum = hCentralityNotFlat->GetMaximum();
4420  CorrCentrLoop = kTRUE;
4421  } else {
4422  CorrCentrLoop = kFALSE;
4423  }
4424 
4425  if (CorrCentrLoop && GetValueForWeight != 0. && maximum !=0. && isfinite(GetValueForWeight) && isfinite(maximum) ){
4426  weightCentrality = maximum/GetValueForWeight;
4427  if (!isfinite(GetValueForWeight)) weightCentrality = 1.;
4428  if (!isfinite(weightCentrality)) weightCentrality = 1.;
4429  }
4430 
4431  return weightCentrality;
4432 }
4433 
4434 //_________________________________________________________________________
4436 
4437  Double_t weightMult = 1.;
4438 
4439  Float_t valueMultData = -1.;
4440  Float_t valueMultMC = -1.;
4441 
4442  if (hReweightMultData == NULL || hReweightMultMC == NULL ) return weightMult;
4443 
4444  valueMultData = hReweightMultData->Interpolate(mult);
4445  valueMultMC = hReweightMultMC->Interpolate(mult);
4446 
4447  Float_t relativeErrorMC = hReweightMultMC->GetBinError(hReweightMultMC->FindBin(mult))/hReweightMultMC->GetBinContent(hReweightMultMC->FindBin(mult));
4448  Float_t relativeErrorData = hReweightMultData->GetBinError(hReweightMultData->FindBin(mult))/hReweightMultData->GetBinContent(hReweightMultData->FindBin(mult));
4449 
4450  if (relativeErrorData < 0.2 && relativeErrorMC < 0.2 ){
4451  if (isfinite(valueMultData) && isfinite(valueMultMC) ){
4452  weightMult = valueMultData/valueMultMC;
4453  }
4454  }
4455 
4456  return weightMult;
4457 }
4458 
4459 
4460 
4461 //_________________________________________________________________________
4462 Float_t AliConvEventCuts::GetWeightForMeson(Int_t index, AliMCEvent *mcEvent, AliVEvent *event){
4463  if (!( fPeriodEnum == kLHC13d2 || fPeriodEnum == kLHC13d2b || // LHC10h MCs
4464  fPeriodEnum == kLHC14a1a || fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c || // LHC11h MCs
4465  fPeriodEnum == kLHC13e7 || fPeriodEnum == kLHC13b2_efix || fPeriodEnum == kLHC14b2 || // LHC13bc MCs
4466  fPeriodEnum == kLHC14e2b || // LHC12[a-i] pass 1 MCs
4467  fPeriodEnum == kLHC12f1a || fPeriodEnum == kLHC12f1b || fPeriodEnum == kLHC12i3 // LHC11a MCs
4468  ) ) return 1.;
4469  Int_t kCaseGen = 0;
4470 
4471  if(index < 0) return 0; // No Particle
4472 
4473  if (IsParticleFromBGEvent(index, mcEvent, event)){
4476  kCaseGen = 1;
4477  }
4478  }
4479  if (kCaseGen == 0) return 1;
4480 
4481  Double_t mesonPt = 0;
4482  //Double_t mesonMass = 0;
4483  Int_t PDGCode = 0;
4484  if(!event || event->IsA()==AliESDEvent::Class()){
4485  mesonPt = ((TParticle*)mcEvent->Particle(index))->Pt();
4486  //mesonMass = ((TParticle*)mcEvent->Particle(index))->GetCalcMass();
4487  PDGCode = ((TParticle*)mcEvent->Particle(index))->GetPdgCode();
4488  } else if(event->IsA()==AliAODEvent::Class()){
4489  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4490  if (AODMCTrackArray){
4491  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
4492  mesonPt = aodMCParticle->Pt();
4493  //mesonMass = aodMCParticle->GetCalcMass();
4494  PDGCode = aodMCParticle->GetPdgCode();
4495  } else {
4496  return 1;
4497  }
4498  }
4499 
4500  Float_t functionResultMC = 1.;
4501  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0){
4502  functionResultMC = hReweightMCHistPi0->Interpolate(mesonPt);
4503  }
4504  if ( PDGCode == 221 && fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0){
4505  functionResultMC = hReweightMCHistEta->Interpolate(mesonPt);
4506  }
4507  if ( PDGCode == 310 && fDoReweightHistoMCK0s && hReweightMCHistK0s!= 0x0){
4508  functionResultMC = hReweightMCHistK0s->Interpolate(mesonPt);
4509  }
4510 
4511  Float_t functionResultData = 1;
4512  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && fFitDataPi0!= 0x0){
4513  functionResultData = fFitDataPi0->Eval(mesonPt);
4514  }
4515  if ( PDGCode == 221 && fDoReweightHistoMCEta && fFitDataEta!= 0x0){
4516  functionResultData = fFitDataEta->Eval(mesonPt);
4517  }
4518  if ( PDGCode == 310 && fDoReweightHistoMCK0s && fFitDataK0s!= 0x0){
4519  functionResultData = fFitDataK0s->Eval(mesonPt);
4520  }
4521 
4522  Double_t weight = 1;
4523  if (PDGCode == 111 || PDGCode == 221){
4524  if (functionResultData != 0. && functionResultMC != 0. && isfinite(functionResultData) && isfinite(functionResultMC)){
4525  weight = functionResultData/functionResultMC;
4526  if ( kCaseGen == 3){
4527  if (PDGCode == 111){
4528  if (!(fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0 && PDGCode == 111)){
4529  weight = 1.;
4530  }
4531  }
4532  if (PDGCode == 221){
4533  if (!(fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0 && PDGCode == 221)){
4534  weight = 1.;
4535  }
4536  }
4537  }
4538  if (!isfinite(functionResultData)) weight = 1.;
4539  if (!isfinite(weight)) weight = 1.;
4540  }
4541  } else if (PDGCode == 310 && functionResultMC != 0 && isfinite(functionResultMC)){
4542  weight = functionResultMC;
4543  }
4544  return weight;
4545 }
4546 
4547 
4550 
4551  if( fPeriodEnum == kLHC13bc || // mainly minimum bias
4552  fPeriodEnum == kLHC13de || // mainly triggered
4553  fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus || // MC Pythia 6 (Jet-Jet), anchor LHC13b-e
4554  fPeriodEnum == kLHC13b2_efix || //MC DPMJET, anchr LHC13b+c
4555  fPeriodEnum == kLHC13e7 || //MC HIJING, anchr LHC13b+c
4556  fPeriodEnum == kLHC14b2 //MC HIJING, anchr LHC13b+c
4557  ){
4558  printf(" Gamma Conversion Cuts %s :: pPb Run doing Eta Shift of %f \n\n",(GetCutNumber()).Data(),-0.465);
4559  SetEtaShift(-0.465);
4560  } else if( fPeriodEnum == kLHC13f ) {
4561  printf(" Gamma Conversion Cuts %s :: Pbp Run doing Eta Shift of %f \n\n",(GetCutNumber()).Data(),0.465);
4562  SetEtaShift(+0.465);
4563  }
4564  else printf(" Gamma Conversion Cuts %s :: Automatic Eta Shift requested but Period is not known -> No Shift \n\n",(GetCutNumber()).Data());
4565 }
4566 
4567 //________________________________________________________________________
4568 AliEMCALTriggerPatchInfo* AliConvEventCuts::GetMainTriggerPatch()
4569 {
4570  //get main trigger match; if not known yet, look for it and cache
4571 
4573  return fMainTriggerPatchEMCAL;
4574 
4575  if (!fTriggerPatchInfo) {
4576  AliError(Form("%s: fTriggerPatchInfo not available",GetName()));
4577  return 0;
4578  }
4579 
4580  //number of patches in event
4581  Int_t nPatch = fTriggerPatchInfo->GetEntries();
4582 
4583  //extract main trigger patch
4584  AliEMCALTriggerPatchInfo *patch;
4585  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
4586  patch = (AliEMCALTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
4587  if (patch->IsMainTrigger()) {
4588  fMainTriggerPatchEMCAL = patch;
4589  break;
4590  }
4591  }
4592 
4593  return fMainTriggerPatchEMCAL;
4594 }
4595 
4596 
4597 //________________________________________________________________________
4599 {
4600 // cout << "entered EMCAL trigger initialization" << endl;
4601 
4602  // Init the analysis.
4603  if (fCaloTriggersName.IsNull()){
4604  if (event->IsA()==AliESDEvent::Class()){
4605  fCaloTriggersName = "EMCALTrigger";
4606  } else {
4607  fCaloTriggersName = "emcalTrigger";
4608  }
4609  }
4610 
4611  if (!fCaloTriggersName.IsNull() && !fCaloTriggers) {
4612  fCaloTriggers = dynamic_cast<AliVCaloTrigger*>(event->FindListObject(fCaloTriggersName));
4613  if (!fCaloTriggers) {
4614  AliError(Form("%s: Could not retrieve calo triggers %s!", GetName(), fCaloTriggersName.Data()));
4615  return;
4616  }
4617  }
4618 
4619  if (fCaloTriggerPatchInfoName.IsNull()){
4620  if (event->IsA()==AliESDEvent::Class()){
4621  fCaloTriggerPatchInfoName = "EmcalTriggers";
4622  } else {
4623  fCaloTriggerPatchInfoName = "EmcalTriggers";
4624  }
4625  }
4626 
4627  if (!fCaloTriggerPatchInfoName.IsNull() && !fTriggerPatchInfo) {
4628  fTriggerPatchInfo = GetArrayFromEvent(event, fCaloTriggerPatchInfoName.Data(), "AliEMCALTriggerPatchInfo");
4629  if (!fTriggerPatchInfo) {
4630  AliError(Form("%s: Could not retrieve calo trigger patch info %s!", GetName(), fCaloTriggerPatchInfoName.Data()));
4631  return;
4632  }
4633 
4634  }
4635 
4636  fEMCALTrigInitialized = kTRUE;
4637 }
4638 
4639 //________________________________________________________________________
4641  if (!fTriggerPatchInfo)
4642  return 0;
4643  //number of patches in event
4644  Int_t nPatch = fTriggerPatchInfo->GetEntries();
4645 
4646  //loop over patches to define trigger type of event
4647  Int_t nG1 = 0;
4648  Int_t nG2 = 0;
4649  Int_t nJ1 = 0;
4650  Int_t nJ2 = 0;
4651  Int_t nL0 = 0;
4652  AliEMCALTriggerPatchInfo *patch;
4653 // if (nPatch> 0) {cout << "NEW Triggers in this event*********************************" << endl;}
4654  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
4655  patch = (AliEMCALTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
4656 // cout << "Patch energy: "<<patch->GetPatchE() << "\t ADC counts: " << patch->GetADCAmp() << endl;
4657 // cout << "Phi: " << patch->GetPhiMin() << " - " << patch->GetPhiMax() << " delta phi: " <<TMath::Abs(patch->GetPhiMin()-patch->GetPhiMax())<< endl;
4658 // cout << "Eta: " << patch->GetEtaMin() << " - " << patch->GetEtaMax() << " delta eta: " <<TMath::Abs(patch->GetEtaMin()-patch->GetEtaMax())<< endl;
4659  if (patch->IsGammaHigh()){
4660 // cout << "fired L1GA high" << endl;
4661  nG1++;
4662  }
4663  if (patch->IsGammaLow()){
4664 // cout << "fired L1GA low" << endl;
4665  nG2++;
4666  }
4667  if (patch->IsJetHigh()){
4668 // cout << "fired L1JE high" << endl;
4669  nJ1++;
4670  }
4671  if (patch->IsJetLow()){
4672 // cout << "fired L1JE low" << endl;
4673  nJ2++;
4674  }
4675  if (patch->IsLevel0()){
4676 // cout << "fired L0" << endl;
4677  nL0++;
4678  }
4679 // cout << patch->GetPatchE() << "\t" << patch->GetADCAmp() << "\t" << patch->IsGammaHigh() << "\t" << patch->IsGammaLow()
4680 // << "\t" << patch->IsJetHigh() << "\t" << patch->IsJetLow() << "\t" << patch->IsLevel0()
4681 // << "\t" << patch->GetPhiMin() << "\t" << patch->GetPhiMax() << "\t" << TMath::Abs(patch->GetPhiMin()-patch->GetPhiMax())
4682 // << "\t" << patch->GetEtaMin() << "\t" << patch->GetEtaMax() << "\t" << TMath::Abs(patch->GetEtaMin()-patch->GetEtaMax()) << endl;
4683  }
4684 
4685  if (nPatch > 0){
4686  AliDebug(2, "Patch summary: ");
4687  AliDebug(2, Form("Number of patches: %d", nPatch));
4688  AliDebug(2, Form("Level0: [%d]" ,nL0));
4689  AliDebug(2, Form("Jet: low[%d], high[%d]" ,nJ2, nJ1));
4690  AliDebug(2, Form("Gamma: low[%d], high[%d]" ,nG2, nG1));
4691  }
4692 
4693 // if (nPatch > 0){
4694 // cout << Form("Number of patches: %d", nPatch) << endl;
4695 // cout << Form("Level0: [%d]" ,nL0) << endl;
4696 // cout << Form("Jet: low[%d], high[%d]" ,nJ2, nJ1) << endl;
4697 // cout << Form("Gamma: low[%d], high[%d]" ,nG2, nG1) << endl;
4698 // }
4699 
4700  ULong_t triggers(0);
4701  if (nG1>0)
4702  SETBIT(triggers, kG1);
4703  if (nG2>0)
4704  SETBIT(triggers, kG2);
4705  if (nJ1>0)
4706  SETBIT(triggers, kJ1);
4707  if (nJ2>0)
4708  SETBIT(triggers, kJ2);
4709  if (nL0>0)
4710  SETBIT(triggers, kL0);
4711  return triggers;
4712 }
4713 
4714 //________________________________________________________________________
4716  // Check if event has a given trigger type
4717  if(t == kND){
4718  return fTriggersEMCAL == 0;
4719  }
4720  return TESTBIT(fTriggersEMCAL, int(t));
4721 }
4722 
4723 
4724 //________________________________________________________________________
4725 TClonesArray *AliConvEventCuts::GetArrayFromEvent(AliVEvent* event, const char *name, const char *clname)
4726 {
4727  // Get array from event.
4728 
4729  TClonesArray *arr = 0;
4730  TString sname(name);
4731  if (!sname.IsNull()) {
4732  arr = dynamic_cast<TClonesArray*>(event->FindListObject(sname));
4733  if (!arr) {
4734  AliWarning(Form("%s: Could not retrieve array with name %s!", GetName(), name));
4735  return 0;
4736  }
4737  } else {
4738  return 0;
4739  }
4740 
4741  if (!clname)
4742  return arr;
4743 
4744  TString objname(arr->GetClass()->GetName());
4745  TClass cls(objname);
4746  if (!cls.InheritsFrom(clname)) {
4747  AliWarning(Form("%s: Objects of type %s in %s are not inherited from %s!",
4748  GetName(), cls.GetName(), name, clname));
4749  return 0;
4750  }
4751  return arr;
4752 }
4753 
4754 //_________________________________________________________________________
4755 Bool_t AliConvEventCuts::IsConversionPrimaryESD( AliMCEvent *mcEvent, Long_t eventpos, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ){
4756 
4757  if (eventpos < 0) return kFALSE;
4758  TParticle* particle = (TParticle *)mcEvent->Particle(eventpos);
4759  if (!particle) return kFALSE;
4760  if (TMath::Abs(particle->GetPdgCode()) == 11 ){
4761  if (particle->GetMother(0) != -1){
4762  TParticle* particleMother = (TParticle *)mcEvent->Particle(particle->GetMother(0));
4763  if (particleMother){
4764  if (TMath::Abs(particleMother->GetPdgCode()) == 22)
4765  particle = particleMother;
4766  }
4767  }
4768  }
4769  if (particle->GetMother(0) != -1){
4770  Double_t deltaX = particle->Vx() - prodVtxX;
4771  Double_t deltaY = particle->Vy() - prodVtxY;
4772  Double_t deltaZ = particle->Vz() - prodVtxZ;
4773 
4774  //Double_t realRadius2D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY);
4775  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
4776 
4777 
4778  Bool_t dalitzCand = kFALSE;
4779 
4780  TParticle* firstmother = (TParticle *)mcEvent->Particle(particle->GetMother(0));
4781  if (!firstmother) return kFALSE;
4782  Int_t pdgCodeFirstMother = firstmother->GetPdgCode();
4783  Bool_t intDecay = kFALSE;
4784  if ( pdgCodeFirstMother == 111 || pdgCodeFirstMother == 221 ) intDecay = kTRUE;
4785  if ( intDecay && TMath::Abs(particle->GetPdgCode()) == 11 ){
4786  dalitzCand = kTRUE;
4787 // cout << "dalitz candidate found" << endl;
4788  }
4789 
4790  Long_t source = particle->GetMother(0);
4791  Bool_t foundExcludedPart = kFALSE;
4792  Bool_t foundShower = kFALSE;
4793  Int_t pdgCodeMotherPrev = 0;
4794  Int_t pdgCodeMotherPPrevMother = 0;
4795  Int_t depth = 0;
4796  if (dalitzCand || realRadius3D < fSecProdBoundary ){
4797 // if (particle->GetPdgCode() == 22){
4798 // cout << endl << endl << "new particle: " << eventpos <<endl;
4799 // cout << particle->GetPdgCode() << "\t" << particle->R() << "\t" << realRadius2D << "\t" << realRadius3D << endl;
4800 // }
4801  while (depth < 20){
4802  TParticle* mother = (TParticle *)mcEvent->Particle(source);
4803  source = mother->GetMother(0);
4804 // if (particle->GetPdgCode() == 22)cout << "eventposition: "<< source << endl;
4805  Int_t pdgCodeMother = mother->GetPdgCode();
4806 // if (particle->GetPdgCode() == 22)cout << "Previous mothers: " << pdgCodeMother << "\t"<< pdgCodeMotherPrev<< "\t" << pdgCodeMotherPPrevMother << endl;
4807  if (pdgCodeMother == pdgCodeMotherPrev && pdgCodeMother == pdgCodeMotherPPrevMother) depth = 20;
4808  if (TMath::Abs(pdgCodeMother) == 11 && TMath::Abs(pdgCodeMotherPrev) == 22 && TMath::Abs(pdgCodeMotherPPrevMother) == 11 ){
4809  foundShower = kTRUE;
4810  depth =20;
4811  }
4812  if (TMath::Abs(pdgCodeMother) == 22 && TMath::Abs(pdgCodeMotherPrev) == 11 && TMath::Abs(pdgCodeMotherPPrevMother) == 22 ){
4813  foundShower = kTRUE;
4814  depth =20;
4815  }
4816 
4817  // particles to be excluded:
4818  // K0s - 310
4819  // K0l - 130
4820  // K+/- - 321
4821  // Lambda - 3122
4822  // Sigma0 - 3212
4823  // Sigma+/- - 3222, 3112
4824  // Cascades - 3322, 3312
4825  if (TMath::Abs(pdgCodeMother) == 310 || TMath::Abs(pdgCodeMother) == 130 || TMath::Abs(pdgCodeMother) == 321 ||
4826  TMath::Abs(pdgCodeMother) == 3122 || TMath::Abs(pdgCodeMother) == 3212 || TMath::Abs(pdgCodeMother) == 3222 ||
4827  TMath::Abs(pdgCodeMother) == 3112 || TMath::Abs(pdgCodeMother) == 3322 || TMath::Abs(pdgCodeMother) == 3312
4828  ) {
4829  foundExcludedPart = kTRUE;
4830  }
4831 // if (particle->GetPdgCode() == 22)cout << mother->GetPdgCode() << "\t" << source << "\t" << foundExcludedPart<< endl;
4832  pdgCodeMotherPPrevMother = pdgCodeMotherPrev;
4833  pdgCodeMotherPrev = pdgCodeMother;
4834  if (source == -1) depth = 20;
4835 
4836 // if (particle->GetPdgCode() == 22)cout << depth << endl;
4837  depth++;
4838  }
4839  }
4840  if (foundExcludedPart){
4841 // if (particle->GetPdgCode() == 22)cout << "This is definitely a secondary, manually excluded" << endl;
4842  return kFALSE;
4843  } else if (dalitzCand && realRadius3D < fSecProdBoundary ){
4844 // if (particle->GetPdgCode() == 22)cout << "This was a decay via a virtual photon" << endl;
4845  return kTRUE;
4846  } else if (foundShower){
4847 // if (particle->GetPdgCode() == 22)cout << "This is a shower" << endl;
4848  return kFALSE;
4849  } else if (realRadius3D >= fSecProdBoundary){
4850 // cout << "This is a secondary, to large production radius" << endl;
4851  return kFALSE;
4852  }
4853  }
4854 
4855  return kTRUE;
4856 }
4857 
4858 //_________________________________________________________________________
4859 Bool_t AliConvEventCuts::IsConversionPrimaryAOD(AliVEvent *event, AliAODMCParticle* AODMCParticle, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ){
4860 
4861  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4862  if (AODMCTrackArray == NULL) return kFALSE;
4863  AliAODMCParticle* currentParticle = AODMCParticle;
4864  if (TMath::Abs(currentParticle->GetPdgCode()) == 11 ){
4865  if (currentParticle->GetMother() != -1){
4866  AliAODMCParticle* particleMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(currentParticle->GetMother()));
4867  if (particleMother){
4868  if (TMath::Abs(particleMother->GetPdgCode()) == 22)
4869  currentParticle = particleMother;
4870  }
4871  }
4872  }
4873  if (currentParticle->GetMother() > -1){
4874  Double_t deltaX = currentParticle->Xv() - prodVtxX;
4875  Double_t deltaY = currentParticle->Yv() - prodVtxY;
4876  Double_t deltaZ = currentParticle->Zv() - prodVtxZ;
4877 
4878  //Double_t realRadius2D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY);
4879  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
4880 
4881  Bool_t dalitzCand = kFALSE;
4882 
4883  AliAODMCParticle* firstmother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(currentParticle->GetMother()));
4884  if (!firstmother) return kFALSE;
4885  Int_t pdgCodeFirstMother = firstmother->GetPdgCode();
4886  Bool_t intDecay = kFALSE;
4887  if ( pdgCodeFirstMother == 111 || pdgCodeFirstMother == 221 ) intDecay = kTRUE;
4888  if ( intDecay && TMath::Abs(currentParticle->GetPdgCode()) == 11 ){
4889  dalitzCand = kTRUE;
4890 // cout << "dalitz candidate found" << endl;
4891  }
4892 
4893  Long_t source = currentParticle->GetMother();
4894  Bool_t foundExcludedPart = kFALSE;
4895  Bool_t foundShower = kFALSE;
4896  Int_t pdgCodeMotherPrev = 0;
4897  Int_t pdgCodeMotherPPrevMother = 0;
4898  Int_t depth = 0;
4899  if (dalitzCand || realRadius3D < fSecProdBoundary ){
4900 // if (currentParticle->GetPdgCode() == 22){
4901 // cout << endl << endl << "new particle: " << eventpos <<endl;
4902 // cout << currentParticle->GetPdgCode() << "\t" << currentParticle->R() << "\t" << realRadius2D << "\t" << realRadius3D << endl;
4903 // }
4904  while (depth < 20){
4905  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(source));
4906  source = mother->GetMother();
4907 // if (currentParticle->GetPdgCode() == 22)cout << "eventposition: "<< source << endl;
4908  Int_t pdgCodeMother = mother->GetPdgCode();
4909 // if (currentParticle->GetPdgCode() == 22)cout << "Previous mothers: " << pdgCodeMother << "\t"<< pdgCodeMotherPrev<< "\t" << pdgCodeMotherPPrevMother << endl;
4910  if (pdgCodeMother == pdgCodeMotherPrev && pdgCodeMother == pdgCodeMotherPPrevMother) depth = 20;
4911  if (TMath::Abs(pdgCodeMother) == 11 && TMath::Abs(pdgCodeMotherPrev) == 22 && TMath::Abs(pdgCodeMotherPPrevMother) == 11 ){
4912  foundShower = kTRUE;
4913  depth =20;
4914  }
4915  if (TMath::Abs(pdgCodeMother) == 22 && TMath::Abs(pdgCodeMotherPrev) == 11 && TMath::Abs(pdgCodeMotherPPrevMother) == 22 ){
4916  foundShower = kTRUE;
4917  depth =20;
4918  }
4919 
4920  // particles to be excluded:
4921  // K0s - 310
4922  // K0l - 130
4923  // K+/- - 321
4924  // Lambda - 3122
4925  // Sigma0 - 3212
4926  // Sigma+/- - 3222, 3112
4927  // Cascades - 3322, 3312
4928  if (TMath::Abs(pdgCodeMother) == 310 || TMath::Abs(pdgCodeMother) == 130 || TMath::Abs(pdgCodeMother) == 321 ||
4929  TMath::Abs(pdgCodeMother) == 3122 || TMath::Abs(pdgCodeMother) == 3212 || TMath::Abs(pdgCodeMother) == 3222 ||
4930  TMath::Abs(pdgCodeMother) == 3112 || TMath::Abs(pdgCodeMother) == 3322 || TMath::Abs(pdgCodeMother) == 3312)
4931  {
4932  foundExcludedPart = kTRUE;
4933  }
4934 // if (currentParticle->GetPdgCode() == 22)cout << mother->GetPdgCode() << "\t" << source << "\t" << foundExcludedPart<< endl;
4935  pdgCodeMotherPPrevMother = pdgCodeMotherPrev;
4936  pdgCodeMotherPrev = pdgCodeMother;
4937  if (source == -1) depth = 20;
4938 
4939 // if (currentParticle->GetPdgCode() == 22)cout << depth << endl;
4940  depth++;
4941  }
4942  }
4943  if (foundExcludedPart){
4944 // if (currentParticle->GetPdgCode() == 22)cout << "This is definitely a secondary, manually excluded" << endl;
4945  return kFALSE;
4946  } else if (dalitzCand && realRadius3D < fSecProdBoundary ){
4947 // if (currentParticle->GetPdgCode() == 22)cout << "This was a decay via a virtual photon" << endl;
4948  return kTRUE;
4949  } else if (foundShower){
4950 // if (currentParticle->GetPdgCode() == 22)cout << "This is a shower" << endl;
4951  return kFALSE;
4952  } else if (realRadius3D >= fSecProdBoundary){
4953 // cout << "This is a secondary, too large production radius" << endl;
4954  return kFALSE;
4955  }
4956  }
4957 
4958  return kTRUE;
4959 }
4960 
4961 
4962 //________________________________________________________________________
4963 Int_t AliConvEventCuts::SecondaryClassificationPhoton( TParticle *particle, AliMCEvent* mcEvent, Bool_t isConversion ){
4964  if (particle != NULL && mcEvent != NULL){
4965  Int_t pdgSecondary = 0;
4966  if (!isConversion){
4967  //Bool_t hasMother = kFALSE;
4968  //Bool_t hasGrandMother = kFALSE;
4969  Long_t motherID = particle->GetMother(0);
4970  Long_t grandMotherID = -1;
4971  // is the photon a direct photons, without a mother?
4972  if (motherID > -1){
4973  //hasMother = kTRUE;
4974  grandMotherID = mcEvent->Particle(motherID)->GetMother(0);
4975  // is the meson a primary?
4976  if (grandMotherID > -1){
4977  //hasGrandMother = kTRUE;
4978  pdgSecondary = mcEvent->Particle(grandMotherID)->GetPdgCode();
4979  }
4980  }
4981  } else {
4982  //Bool_t hasMother = kFALSE;
4983  //Bool_t hasGrandMother = kFALSE;
4984  //Bool_t hasGreatGrandMother = kFALSE;
4985  Long_t motherID = particle->GetMother(0);
4986  Long_t grandMotherID = -1;
4987  Long_t greatGrandMotherID = -1;
4988  // is the electron a direct electron, without a mother?
4989  if (motherID > -1){
4990  //hasMother = kTRUE;
4991  grandMotherID = mcEvent->Particle(motherID)->GetMother(0);
4992  // is the photon a direct photons, without a mother?
4993  if (grandMotherID > -1){
4994  //hasGrandMother = kTRUE;
4995  greatGrandMotherID = mcEvent->Particle(grandMotherID)->GetMother(0);
4996  // is the meson a primary?
4997  if (greatGrandMotherID > -1){
4998  //hasGreatGrandMother = kTRUE;
4999  pdgSecondary = mcEvent->Particle(greatGrandMotherID)->GetPdgCode();
5000  }
5001  }
5002  }
5003  }
5004  // is the secondary photon from a lambda
5005  if (TMath::Abs(pdgSecondary) == 3122 )
5006  return 3;
5007  // is the secondary photon from a K0s
5008  else if ( TMath::Abs(pdgSecondary) == 310 )
5009  return 2;
5010  // is the secondary photon from a K0l
5011  else if ( TMath::Abs(pdgSecondary) == 130 )
5012  return 5;
5013  // is the secondary photon from a eta
5014  else if ( TMath::Abs(pdgSecondary) == 221 )
5015  return 4;
5016  // is the secondary photon from something else
5017  else if ( TMath::Abs(pdgSecondary) != 0 )
5018  return 1;
5019 
5020  }
5021 
5022  return 0;
5023 }
5024 
5025 //________________________________________________________________________
5026 Int_t AliConvEventCuts::SecondaryClassificationPhotonAOD( AliAODMCParticle *particle, TClonesArray *aodmcArray, Bool_t isConversion ){
5027  if (particle != NULL && aodmcArray != NULL){
5028  Int_t pdgSecondary = 0;
5029  if (!isConversion){
5030  //Bool_t hasMother = kFALSE;
5031  //Bool_t hasGrandMother = kFALSE;
5032  Long_t motherID = particle->GetMother();
5033  Long_t grandMotherID = -1;
5034  // is the photon a direct photons, without a mother?
5035  if (motherID > -1){
5036  //hasMother = kTRUE;
5037  grandMotherID = ((AliAODMCParticle*)aodmcArray->At(motherID))->GetMother();
5038  // is the meson a primary?
5039  if (grandMotherID > -1){
5040  //hasGrandMother = kTRUE;
5041  pdgSecondary = ((AliAODMCParticle*)aodmcArray->At(grandMotherID))->GetPdgCode();
5042  }
5043  }
5044  } else {
5045  //Bool_t hasMother = kFALSE;
5046  //Bool_t hasGrandMother = kFALSE;
5047  //Bool_t hasGreatGrandMother = kFALSE;
5048  Long_t motherID = particle->GetMother();
5049  Long_t grandMotherID = -1;
5050  Long_t greatGrandMotherID = -1;
5051  // is the electron a direct electron, without a mother?
5052  if (motherID > -1){