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