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