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