AliPhysics  b555aef (b555aef)
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  if (!mcHandler->TreeTR() ) {
543  fEventQuality = 2;
544  return kFALSE;
545  }
546  isMC = kTRUE;
547  }
548 
549 
550 
551  // Event Trigger
552  // cout << "before event trigger" << endl;
553  if(!IsTriggerSelected(event, isMC )){
554  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
555  fEventQuality = 3;
556  return kFALSE;
557  }
558  cutindex++;
559 
560  if(event->IsA()==AliESDEvent::Class()){
561  AliTriggerAnalysis fTriggerAnalysis;// = new AliTriggerAnalysis;
562  fHasV0AND = fTriggerAnalysis.IsOfflineTriggerFired((AliESDEvent*)event, AliTriggerAnalysis::kV0AND);
563  if(fHasV0AND&&hTriggerClass)hTriggerClass->Fill(32);
564  }
565  // cout << "event number " << ((AliESDEvent*)event)->GetEventNumberInFile() << " entered"<< endl;
566 
567 
568  // Number of Contributors Cut
569  if (fEnableVertexCut){
570  if(GetNumberOfContributorsVtx(event)<=0) {
571  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
572  fEventQuality = 5;
573  return kFALSE;
574  }
575  }
576  cutindex++;
577 
578  // Z Vertex Position Cut
579  if (fEnableVertexCut){
580  if(!VertexZCut(event)){
581  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
582  fEventQuality = 4;
583  return kFALSE;
584  }
585  }
586  cutindex++;
587 
588  // SPD clusters vs tracklets to check for pileup/background
589  Int_t nClustersLayer0 = event->GetNumberOfITSClusters(0);
590  Int_t nClustersLayer1 = event->GetNumberOfITSClusters(1);
591  Int_t nTracklets = event->GetMultiplicity()->GetNumberOfTracklets();
592  if(hSPDClusterTrackletBackgroundBefore) hSPDClusterTrackletBackgroundBefore->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
593 
594 
595  Double_t distZMax = 0;
596  if(event->IsA()==AliESDEvent::Class()){
597  Int_t nPileVert = ((AliESDEvent*)event)->GetNumberOfPileupVerticesSPD();
598  if (hNPileupVertices) hNPileupVertices->Fill(nPileVert);
599  if (nPileVert > 0){
600  for(Int_t i=0; i<nPileVert;i++){
601  const AliESDVertex* pv = ((AliESDEvent*)event)->GetPileupVertexSPD(i);
602  Int_t nc2 = pv->GetNContributors();
603  if(nc2>=3){
604  Double_t z1 = ((AliESDEvent*)event)->GetPrimaryVertexSPD()->GetZ();
605  Double_t z2 = pv->GetZ();
606  Double_t distZ = z2-z1;
607  if (TMath::Abs(distZMax) < TMath::Abs(distZ) ){
608  distZMax = distZ;
609  }
610  }
611  }
612  if (hPileupVertexToPrimZ) hPileupVertexToPrimZ->Fill(distZMax);
613  }
614  }
615 
616  // Pile Up Rejection
617  if (fIsHeavyIon == 2){
618  if(GetUseNewMultiplicityFramework()){// for Run2 pPb
619  if(fUtils->IsPileUpMV(event)){
620  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
621  fEventQuality = 6;
622  return kFALSE;
623  }
624  } else{
625  if(fUtils->IsFirstEventInChunk(event)){
626  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
627  fEventQuality = 6;
628  return kFALSE;
629  }
630  if(fRemovePileUp){
631  if(fUtils->IsPileUpEvent(event)){
632  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
634  fEventQuality = 6;
635  return kFALSE;
636  }
637  if (fUtils->IsSPDClusterVsTrackletBG(event)){
638  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
640  fEventQuality = 11;
641  return kFALSE;
642  }
643  }
644  }
645  } else if(fRemovePileUp){
646  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.) ){
647  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
649  fEventQuality = 6;
650  return kFALSE;
651  }
652  if (fUtils->IsSPDClusterVsTrackletBG(event)){
653  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
655  fEventQuality = 11;
656  return kFALSE;
657  }
658  }
659  cutindex++;
660 
661  // Centrality Selection
662  if(!IsCentralitySelected(event,mcEvent)){
663  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
664  fEventQuality = 1;
665  return kFALSE;
666  }
667  cutindex++;
668 
670  if(fHistoEventCuts) fHistoEventCuts->Fill(cutindex);
671  fEventQuality = 12;
672  return kFALSE;
673  }
674  cutindex++;
675  // Fill Event Histograms
676  if(fHistoEventCuts)fHistoEventCuts->Fill(cutindex);
677  if(hCentrality)hCentrality->Fill(GetCentrality(event));
678  if(hVertexZ)hVertexZ->Fill(event->GetPrimaryVertex()->GetZ());
679  // if(hCentralityVsNumberOfPrimaryTracks)
680  // hCentralityVsNumberOfPrimaryTracks->Fill(GetCentrality(event),
681  // ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
682  // ->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks());
683 
684  if(fIsHeavyIon == 1){
685  AliEventplane *EventPlane = event->GetEventplane();
686  fEventPlaneAngle = EventPlane->GetEventplane("V0",event,2);
687  if(hEventPlaneAngle)hEventPlaneAngle->Fill(TMath::Abs(fEventPlaneAngle));
688  }
689  if(hSPDClusterTrackletBackground) hSPDClusterTrackletBackground->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
690 
691  fEventQuality = 0;
692  return kTRUE;
693 }
694 
698 
699  if(fCutString && fCutString->GetString().Length() == kNCuts) {
700  fCutString->SetString(GetCutNumber());
701  } else {
702  return kFALSE;
703  }
704  return kTRUE;
705 }
706 
709 
710  AliInfo("Entering loading of weights for centrality flattening");
711  TFile *w = TFile::Open(fPathWeightsFlatCent.Data());
712  if(!w){
713  AliError(Form("file for centrality flattening %s not found",fPathWeightsFlatCent.Data()));
714  return;
715  }
716 
717  if (fNameHistoNotFlatCentrality.CompareTo("") != 0 && (fDoCentralityFlat > 0)){
718  cout << "I have to find: " << fNameHistoNotFlatCentrality.Data() << endl;
719  TH1D *hCentralityNotFlattemp = (TH1D*)w->Get(fNameHistoNotFlatCentrality.Data());
720  hCentralityNotFlat = new TH1D(*hCentralityNotFlattemp);
721  if (hCentralityNotFlat) AliInfo(Form("%s has been loaded from %s", fNameHistoNotFlatCentrality.Data(),fPathWeightsFlatCent.Data() ));
722  else AliWarning(Form("%s not found in %s", fNameHistoNotFlatCentrality.Data() ,fPathWeightsFlatCent.Data()));
723  hCentralityNotFlat->SetDirectory(0);
724  }
725 
726  w->Close();
727  delete w;
728 }
729 
732 
733  AliInfo("Entering loading of weights for multiplicity weighting");
734  TFile *w = TFile::Open(fPathReweightingMult.Data());
735  if(!w){
736  AliError(Form("file for multiplicity reweighting %s not found",fPathReweightingMult.Data()));
737  return;
738  }
739 
740  if (fNameHistoReweightingMultData.CompareTo("") != 0 && (fDoMultiplicityWeighting > 0)){
741  cout << "I have to find: " << fNameHistoReweightingMultData.Data() << endl;
742  TH1D *hReweightMultDatatemp = (TH1D*)w->Get(fNameHistoReweightingMultData.Data());
743  if (hReweightMultDatatemp == NULL) AliError(Form("%s was not contained in %s", fNameHistoReweightingMultData.Data(),fPathReweightingMult.Data() ));
744  hReweightMultData = new TH1D(*hReweightMultDatatemp);
745  if (hReweightMultData) AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingMultData.Data(),fPathReweightingMult.Data() ));
746  else AliWarning(Form("%s not found in %s", fNameHistoReweightingMultData.Data() ,fPathReweightingMult.Data()));
747  hReweightMultData->SetDirectory(0);
748  }
749  if (fNameHistoReweightingMultMC.CompareTo("") != 0 && (fDoMultiplicityWeighting > 0)){
750  cout << "I have to find: " << fNameHistoReweightingMultMC.Data() << endl;
751  TH1D *hReweightMultMCtemp = (TH1D*)w->Get(fNameHistoReweightingMultMC.Data());
752  if (hReweightMultMCtemp == NULL) AliError(Form("%s was not contained in %s", fNameHistoReweightingMultMC.Data(),fPathReweightingMult.Data() ));
753  hReweightMultMC = new TH1D(*hReweightMultMCtemp);
754  if (hReweightMultData) AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingMultMC.Data(),fPathReweightingMult.Data() ));
755  else AliWarning(Form("%s not found in %s", fNameHistoReweightingMultMC.Data() ,fPathReweightingMult.Data()));
756  hReweightMultMC->SetDirectory(0);
757  }
758 
759  w->Close();
760  delete w;
761 }
762 
763 
766 
767  AliInfo("Entering loading of histograms for weighting");
768  TFile *f = TFile::Open(fPathTrFReweighting.Data());
769  if(!f){
770  AliError(Form("file for weighting %s not found",fPathTrFReweighting.Data()));
771  return;
772  }
773  if (fNameHistoReweightingPi0.CompareTo("") != 0 && fDoReweightHistoMCPi0 ){
774  cout << "I have to find: " << fNameHistoReweightingPi0.Data() << endl;
775  TH1D *hReweightMCHistPi0temp = (TH1D*)f->Get(fNameHistoReweightingPi0.Data());
776  hReweightMCHistPi0 = new TH1D(*hReweightMCHistPi0temp);
777  if (hReweightMCHistPi0) AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingPi0.Data(),fPathTrFReweighting.Data() ));
778  else AliWarning(Form("%s not found in %s", fNameHistoReweightingPi0.Data() ,fPathTrFReweighting.Data()));
779  hReweightMCHistPi0->SetDirectory(0);
780  }
781  if (fNameFitDataPi0.CompareTo("") != 0 && fDoReweightHistoMCPi0 ){
782  cout << "I have to find: " << fNameFitDataPi0.Data() << endl;
783  TF1 *fFitDataPi0temp = (TF1*)f->Get(fNameFitDataPi0.Data());
784  fFitDataPi0 = new TF1(*fFitDataPi0temp);
785  if (fFitDataPi0) AliInfo(Form("%s has been loaded from %s", fNameFitDataPi0.Data(),fPathTrFReweighting.Data() ));
786  else AliWarning(Form("%s not found in %s",fPathTrFReweighting.Data(), fNameFitDataPi0.Data() ));
787  }
788 
789  if (fNameHistoReweightingEta.CompareTo("") != 0 && fDoReweightHistoMCEta){
790  cout << "I have to find: " << fNameHistoReweightingEta.Data() << endl;
791  TH1D *hReweightMCHistEtatemp = (TH1D*)f->Get(fNameHistoReweightingEta.Data());
792  hReweightMCHistEta = new TH1D(*hReweightMCHistEtatemp);
793  if (hReweightMCHistEta) AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingEta.Data(),fPathTrFReweighting.Data() ));
794  else AliWarning(Form("%s not found in %s", fNameHistoReweightingEta.Data(),fPathTrFReweighting.Data() ));
795  hReweightMCHistEta->SetDirectory(0);
796  }
797 
798  if (fNameFitDataEta.CompareTo("") != 0 && fDoReweightHistoMCEta){
799  cout << "I have to find: " << fNameFitDataEta.Data() << endl;
800  TF1 *fFitDataEtatemp = (TF1*)f->Get(fNameFitDataEta.Data());
801  fFitDataEta = new TF1(*fFitDataEtatemp);
802  if (fFitDataEta) AliInfo(Form("%s has been loaded from %s", fNameFitDataEta.Data(),fPathTrFReweighting.Data() ));
803  else AliWarning(Form("%s not found in %s", fNameFitDataEta.Data(),fPathTrFReweighting.Data() ));
804 
805  }
806  if (fNameHistoReweightingK0s.CompareTo("") != 0 && fDoReweightHistoMCK0s){
807  cout << "I have to find: " << fNameHistoReweightingK0s.Data() << endl;
808  TH1D *hReweightMCHistK0stemp = (TH1D*)f->Get(fNameHistoReweightingK0s.Data());
809  hReweightMCHistK0s = new TH1D(*hReweightMCHistK0stemp);
810  if (hReweightMCHistK0s) AliInfo(Form("%s has been loaded from %s", fNameHistoReweightingK0s.Data(),fPathTrFReweighting.Data() ));
811  else AliWarning(Form("%s not found in %s", fNameHistoReweightingK0s.Data(),fPathTrFReweighting.Data() ));
812  hReweightMCHistK0s->SetDirectory(0);
813  }
814 
815  if (fNameFitDataK0s.CompareTo("") != 0 && fDoReweightHistoMCK0s){
816  cout << "I have to find: " << fNameFitDataK0s.Data() << endl;
817  TF1 *fFitDataK0stemp = (TF1*)f->Get(fNameFitDataK0s.Data());
818  fFitDataK0s = new TF1(*fFitDataK0stemp);
819  if (fFitDataK0s) AliInfo(Form("%s has been loaded from %s", fNameFitDataK0s.Data(),fPathTrFReweighting.Data() ));
820  else AliWarning(Form("%s not found in %s", fNameFitDataK0s.Data(),fPathTrFReweighting.Data() ));
821  }
822  f->Close();
823  delete f;
824 }
825 
826 
829  fCutStringRead = Form("%s",analysisCutSelection.Data());
830 
831  // Initialize Cuts from a given Cut string
832  if(fDoCentralityFlat > 0){
833  AliInfo("Centrality flattening was enabled");
835  }
836 
838  AliInfo("Multiplicity weighting was enabled");
840  }
842  AliInfo("Particle Weighting was enabled");
844  }
845 
846 
847  AliInfo(Form("Set Event Cut Number: %s",analysisCutSelection.Data()));
848  if(analysisCutSelection.Length()!=kNCuts) {
849  AliError(Form("Cut selection has the wrong length! size is %d, number of cuts is %d", analysisCutSelection.Length(), kNCuts));
850  return kFALSE;
851  }
852  if(!analysisCutSelection.IsAlnum()){
853  AliError("Cut selection is not alphanumeric");
854  return kFALSE;
855  }
856 
857  if (fV0ReaderName.CompareTo("") == 0){
858  fV0ReaderName = "V0ReaderV1";
859  }
860  TString analysisCutSelectionLowerCase = Form("%s",analysisCutSelection.Data());
861  analysisCutSelectionLowerCase.ToLower();
862  const char *cutSelection = analysisCutSelectionLowerCase.Data();
863  #define ASSIGNARRAY(i) fCuts[i] = ((int)cutSelection[i]>=(int)'a') ? cutSelection[i]-'a'+10 : cutSelection[i]-'0'
864  for(Int_t ii=0;ii<kNCuts;ii++){
865  ASSIGNARRAY(ii);
866  }
867 
868  // Set Individual Cuts
869  for(Int_t ii=0;ii<kNCuts;ii++){
870  if(!SetCut(cutIds(ii),fCuts[ii]))return kFALSE;
871  }
872 
874 
875  return kTRUE;
876 }
877 
881 // "HeavyIon", //0
882 // "CentralityMin", //1
883 // "CentralityMax", //2
884 // "SelectSpecialTrigger", //3
885 // "SelectSpecialSubTriggerClass", //4
886 // "RemovePileUp", //5
887 // "RejectExtraSignals", //6
888 // "VertexCut", //7
889 
890  switch (cutID) {
891  case kisHeavyIon:
892  if( SetIsHeavyIon(value)) {
893  fCuts[kisHeavyIon] = value;
894  UpdateCutString();
895  return kTRUE;
896  } else return kFALSE;
897  case kCentralityMin:
898  if( SetCentralityMin(value)) {
899  fCuts[kCentralityMin] = value;
900  UpdateCutString();
901  return kTRUE;
902  } else return kFALSE;
903  case kCentralityMax:
904  if( SetCentralityMax(value)) {
905  fCuts[kCentralityMax] = value;
906  UpdateCutString();
907  return kTRUE;
908  } else return kFALSE;
910  if( SetSelectSpecialTrigger(value)) {
912  UpdateCutString();
913  return kTRUE;
914  } else return kFALSE;
916  if( SetSelectSubTriggerClass(value)) {
917  fCuts[kSelectSubTriggerClass] = value;
918  UpdateCutString();
919  return kTRUE;
920  } else return kFALSE;
921  case kremovePileUp:
922  if( SetRemovePileUp(value)) {
923  fCuts[kremovePileUp] = value;
924  UpdateCutString();
925  return kTRUE;
926  } else return kFALSE;
927  case kExtraSignals:
928  if( SetRejectExtraSignalsCut(value)) {
929  fCuts[kExtraSignals] = value;
930  UpdateCutString();
931  return kTRUE;
932  } else return kFALSE;
933  case kVertex:
934  if( SetVertexCut(value)) {
935  fCuts[kVertex] = value;
936  UpdateCutString();
937  return kTRUE;
938  } else return kFALSE;
939 
940  case kNCuts:
941  AliError("Cut id out of range");
942  return kFALSE;
943  }
944 
945  AliError("Cut id %d not recognized");
946  return kFALSE;
947 }
948 
951  // Print out current Cut Selection
952  for(Int_t ic = 0; ic < kNCuts; ic++) {
953  printf("%-30s : %d \n", fgkCutNames[ic], fCuts[ic]);
954  }
955 }
956 
958  // Print out current Cut Selection with value
959  printf("\nEvent cutnumber \n");
960  for(Int_t ic = 0; ic < kNCuts; ic++) {
961  printf("%d",fCuts[ic]);
962  }
963  printf("\n\n");
964  if (fIsHeavyIon == 0) {
965  printf("Running in pp mode \n");
966  if (fSpecialTrigger == 0){
967  if (fSpecialSubTrigger == 0){
968  printf("\t only events triggered by V0OR will be analysed \n");
969  } else if (fSpecialSubTrigger == 1){
970  printf("\t only events where SDD was present will be analysed \n");
971  }
972  } else if (fSpecialTrigger == 1){
973  if (fSpecialSubTrigger == 0){
974  printf("\t only events triggered by V0AND will be analysed \n");
975  } else if(fSpecialSubTrigger == 1){
976  printf("\t only events where SDD was present will be analysed and triggered by VOAND\n");
977  }
978  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps");
979  } else if (fSpecialTrigger > 1){
980  printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
981  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps\n\n");
982  }
983  if ( !(fCentralityMin == 0 && fCentralityMax == 0) && !(fCentralityMax < fCentralityMin) ){
984  printf("\t Multiplicity cut %d - %d \n", fCentralityMin, fCentralityMax);
985  }
986  } else if (fIsHeavyIon == 1){
987  printf("Running in PbPb mode \n");
988  if (fDetectorCentrality == 0){
989  printf("\t centrality selection based on V0M \n");
990  } else if (fDetectorCentrality == 1){
991  printf("\t centrality selection based on Cl1 \n");
992  }
993  if (fModCentralityClass == 0){
994  printf("\t %d - %d \n", fCentralityMin*10, fCentralityMax*10);
995  } else if ( fModCentralityClass == 1){
996  printf("\t %d - %d \n", fCentralityMin*5, fCentralityMax*5);
997  } else if ( fModCentralityClass == 2){
998  printf("\t %d - %d \n", fCentralityMin*5+45, fCentralityMax*5+45);
999  } else if (fModCentralityClass == 3){
1000  printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*10, fCentralityMax*10);
1001  } else if ( fModCentralityClass == 4){
1002  printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*5, fCentralityMax*5);
1003  } else if ( fModCentralityClass == 5){
1004  printf("\t %d - %d, with Track mult in MC as data \n", fCentralityMin*5+45, fCentralityMax*5+45);
1005  }
1006  if (fSpecialTrigger == 0){
1007  printf("\t only events triggered by kMB, kCentral, kSemiCentral will be analysed \n");
1008  } else if (fSpecialTrigger > 1){
1009  printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
1010  printf("\n\t SpecialTrigger is: %s\n", fSpecialTriggerName.Data());
1011  printf("\t SpecialSubTrigger is: %s\n", fSpecialSubTriggerName.Data());
1012  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps\n\n");
1013  }
1014  } else if (fIsHeavyIon == 2){
1015  printf("Running in pPb mode \n");
1016  if (fDetectorCentrality == 0){
1017  printf("\t centrality selection based on V0A \n");
1018  } else if (fDetectorCentrality == 1){
1019  printf("\t centrality selection based on Cl1 \n");
1020  }
1021  if (fModCentralityClass == 0){
1022  printf("\t %d - %d \n", fCentralityMin*10, fCentralityMax*10);
1023  }
1024  if (fSpecialTrigger == 0){
1025  printf("\t only events triggered by kINT7 will be analysed \n");
1026  } else if (fSpecialTrigger > 1){
1027  printf("\t only events triggered by %s %s\n", fSpecialTriggerName.Data(), fSpecialSubTriggerName.Data());
1028  if (fRejectTriggerOverlap) printf("\t reject trigger overlaps\n\n");
1029  }
1030  }
1031  if (fEnableVertexCut) printf("\t Vertex cut with |Z_{vtx}| <%2.2f \n",fMaxVertexZ);
1032  else printf("\t No vertex cut \n");
1033 
1034  if (fRemovePileUp ==1 ) {
1035  printf("\t Doing pile up removal \n");
1036  if (fDoPileUpRejectV0MTPCout ==1 ){
1037  printf("\t Doing extra pile up removal V0M vs TPCout \n");
1038  }
1039  }
1040 
1041  printf("MC event cuts: \n");
1042  if (fRejectExtraSignals == 0) printf("\t no rejection was applied \n");
1043  else if (fRejectExtraSignals == 1) printf("\t only MB header will be inspected \n");
1044  else if (fRejectExtraSignals > 1) printf("\t special header have been selected \n");
1045  printf("\t maximum factor between jet and pt hard = %2.2f \n", fMaxFacPtHard);
1046 }
1047 
1050 { // Set Cut
1051  switch(isHeavyIon){
1052  case 0:
1053  fIsHeavyIon=0;
1054  break;
1055  case 1:
1056  fIsHeavyIon=1;
1058  break;
1059  case 2:
1060  fIsHeavyIon=1;
1062  break;
1063  case 3: //allows to select centrality 0-45% in steps of 5% for V0 Multiplicity
1064  fIsHeavyIon=1;
1067  break;
1068  case 4: //allows to select centrality 45-90% in steps of 5% for V0 Multiplicity
1069  fIsHeavyIon=1;
1072  break;
1073  case 5: //strict cut on v0 tracks for MC
1074  fIsHeavyIon=1;
1077  break;
1078  case 6: //allows to select centrality 0-45% in steps of 5% for track mult
1079  //strict cut on v0 tracks for MC
1080  fIsHeavyIon=1;
1083  break;
1084  case 7: //allows to select centrality 45-90% in steps of 5% for V0 Multiplicity
1085  //strict cut on v0 tracks for MC
1086  fIsHeavyIon=1;
1089  break;
1090  case 8:
1091  fIsHeavyIon=2;
1093  break;
1094  case 9:
1095  fIsHeavyIon=2;
1097  break;
1098  default:
1099  AliError(Form("SetHeavyIon not defined %d",isHeavyIon));
1100  return kFALSE;
1101  }
1102  return kTRUE;
1103 }
1104 
1105 //___________________________________________________________________
1107 {
1108  // Set Cut
1109  if(minCentrality<0||minCentrality>9){
1110  AliError(Form("minCentrality not defined %d",minCentrality));
1111  return kFALSE;
1112  }
1113 
1114  fCentralityMin=minCentrality;
1115  return kTRUE;
1116 }
1117 
1118 //___________________________________________________________________
1120 {
1121  // Set Cut
1122  if(maxCentrality<0||maxCentrality>9){
1123  AliError(Form("maxCentrality not defined %d",maxCentrality));
1124  return kFALSE;
1125  }
1126  fCentralityMax=maxCentrality;
1127  return kTRUE;
1128 }
1129 
1132 {
1133  // Set Cut
1134  switch(selectSpecialTrigger){
1135  case 0:
1136  fSpecialTrigger=0; // V0OR
1137  break;
1138  case 1:
1139  fSpecialTrigger=1; // V0AND
1140  break;
1141 // case 2:
1142 // fSpecialTrigger=2; //
1143 // break;
1144  case 3:
1145  fSpecialTrigger=3; //specific centrality trigger selection
1146  fSpecialTriggerName="AliVEvent::kCentral/kSemiCentral/kMB";
1147  break;
1148  case 4:
1149  fSpecialTrigger=4; // trigger alias kTRD
1150  fOfflineTriggerMask=AliVEvent::kTRD;
1151  fTriggerSelectedManually = kTRUE;
1152  fSpecialTriggerName="AliVEvent::kTRD";
1153  break;
1154  case 5:
1155  fSpecialTrigger=5; // trigger alias kEMC
1156  fOfflineTriggerMask=AliVEvent::kEMC7 | AliVEvent::kEMC8 | AliVEvent::kEMC1 ;
1157  fTriggerSelectedManually = kTRUE;
1159  SETBIT(fTriggersEMCALSelected, kL0);
1160  fSpecialTriggerName="AliVEvent::kEMC7/kEMC8/kEMC1";
1161  break;
1162  case 6:
1163  fSpecialTrigger=6; // trigger alias kPHI
1164  fOfflineTriggerMask=AliVEvent::kPHI7 | AliVEvent::kPHI1 | AliVEvent::kPHI8 | AliVEvent::kPHOSPb;
1165  fTriggerSelectedManually = kTRUE;
1166  fSpecialTriggerName="AliVEvent::kPHI7/kPHI1/kPHI8/kPHOSPb";
1167  break;
1168  case 7:
1169  fSpecialTrigger=7; // trigger alias kHighMult
1170  fOfflineTriggerMask=AliVEvent::kHighMult;
1171  fTriggerSelectedManually = kTRUE;
1172  fSpecialTriggerName="AliVEvent::kHighMult";
1173  break;
1174  case 8:
1175  fSpecialTrigger=8; // trigger alias kEMCEGA
1176  fOfflineTriggerMask=AliVEvent::kEMCEGA;
1177  fTriggerSelectedManually = kTRUE;
1179  SETBIT(fTriggersEMCALSelected, kG2);
1180  fSpecialTriggerName="AliVEvent::kEMCEGA";
1181  break;
1182  case 9:
1183  fSpecialTrigger=9; // trigger alias kEMCEJE
1184  fOfflineTriggerMask=AliVEvent::kEMCEJE;
1185  fTriggerSelectedManually = kTRUE;
1187  SETBIT(fTriggersEMCALSelected, kJ2);
1188  fSpecialTriggerName="AliVEvent::kEMCEJE";
1189  break;
1190  default:
1191  AliError("Warning: Special Trigger Not known");
1192  return 0;
1193  }
1194  return 1;
1195 }
1196 
1199 {
1200  // Set Cut
1201  if (fSpecialTrigger == 0){ //OR
1202  switch(selectSpecialSubTriggerClass){
1203  case 0://with VZERO
1204  fSpecialTrigger=0;
1206 // AliInfo("Info: Nothing to be done");
1207  break;
1208  case 3: //V0OR with SDD requested (will only work with LHC11a dataset)
1210 // cout << "V0OR with SDD requested" << endl;
1211  break;
1212  default:
1213  AliError("Warning: Special Subtrigger Class Not known");
1214  return 0;
1215  }
1216  } else if (fSpecialTrigger == 1){ //AND with different detectors
1217  switch(selectSpecialSubTriggerClass){
1218  case 0: //with VZERO general implementation of V0AND (periods LHC11c onwards)
1219  fSpecialTrigger=0;
1221  fOfflineTriggerMask=AliVEvent::kINT7;
1222  fTriggerSelectedManually = kTRUE;
1223  fSpecialTriggerName="AliVEvent::kINT7";
1224  break;
1225  case 1: //with TZERO
1226  fSpecialTrigger=0;
1228  fOfflineTriggerMask=AliVEvent::kINT8;
1229  fTriggerSelectedManually = kTRUE;
1230  fSpecialTriggerName="AliVEvent::kINT8";
1231  break;
1232  case 2: //with VZERO (will only work with LHC11a dataset)
1233  fSpecialTrigger=1;
1235 // AliInfo("Info: Nothing to be done");
1236  break;
1237  case 3: //V0AND with SDD requested (will only work with LHC11a dataset)
1238  fSpecialTrigger=1;
1240  break;
1241  default:
1242  AliError("Warning: Special Subtrigger Class Not known");
1243  return 0;
1244  }
1245  } else if (fSpecialTrigger == 3){ // Selecting kCentral and kSemiCentral from trigger classes, not aliases
1246  switch(selectSpecialSubTriggerClass){
1247  case 0: // all together
1250 // AliInfo("Info: Nothing to be done");
1251  break;
1252  case 1: // kCentral - no vertex restriction
1255  fSpecialSubTriggerName="CVHN";
1256 // cout << "kCentralOpen" << endl;
1257  break;
1258  case 2: // kCentral - T00 +- 10 cm
1261  fSpecialSubTriggerName="CCENT";
1262 // cout << "kCentralVertex" << endl;
1263  break;
1264  case 3: // kCentral - both
1267  fSpecialSubTriggerName="CVHN|CCENT|CSEMI|CVLN";
1268 // cout << "kCentral both" << endl;
1269  break;
1270  case 4: // kSemiCentral - no vertex restriction
1273  fSpecialSubTriggerName="CVLN";
1274 // cout << "kSemiCentralOpen" << endl;
1275  break;
1276  case 5: // kSemiCentral - T00 +- 10 cm
1279  fSpecialSubTriggerName="CSEMI";
1280 // cout << "kSemiCentralVertex" << endl;
1281  break;
1282  case 6: // kSemiCentral - both
1285  fSpecialSubTriggerName="CSEMI%CVLN";
1286 // cout << "kSemiCentral both" << endl;
1287  break;
1288  case 7: // kMB
1291  fSpecialSubTriggerName="CPBI1_|CPBI1-";
1292 // cout << "kMB 1" << endl;
1293  break;
1294  case 8: // kMB
1297  fSpecialSubTriggerName="CPBI2_|CPBI2-";
1298 // cout << "kMB 2" << endl;
1299  break;
1300  case 9: // kMB
1303  fSpecialSubTriggerName="CPBI2_@CPBI2-@CPBI2_@CPBI2-";
1304 // cout << "kMB both" << endl;
1305  break;
1306  default:
1307  AliError("Warning: Special Subtrigger Class Not known");
1308  return 0;
1309  }
1310  } else if (fSpecialTrigger == 4){ // Subdivision of TRD trigger classes
1311  switch(selectSpecialSubTriggerClass){
1312  case 0: // all together
1315 // AliInfo("Info: Nothing to be done");
1316  break;
1317  case 1: // 7WUHSH - V0AND with single electron in TRD & EMCAL
1320  fSpecialSubTriggerName="7WUHEE";
1321  break;
1322  case 2: // 8WUHSH - T0AND with single electron in TRD & EMCAL
1325  fSpecialSubTriggerName="8WUHEE";
1326  break;
1327  case 3: // 7WUHSE - V0AND with single high pt electron in TRD
1330  fSpecialSubTriggerName="7WUHSE";
1331  break;
1332  case 4: // 8WUHSE - T0AND with single high pt electron in TRD
1335  fSpecialSubTriggerName="8WUHSE";
1336  break;
1337  case 5: // 7WUHJE - V0AND with jet in TRD
1340  fSpecialSubTriggerName="7WUHJT";
1341  break;
1342  case 6: // 8WUHJE - T0AND with jet in TRD
1345  fSpecialSubTriggerName="8WUHJT";
1346  break;
1347  case 7: // 7WUHQU - V0AND with dielectron pair in TRD
1350  fSpecialSubTriggerName="7WUHQU";
1351  break;
1352  case 8: // 8WUHQU - T0AND with dielectron pair in TRD
1355  fSpecialSubTriggerName="8WUHQU";
1356  break;
1357  default:
1358  AliError("Warning: Special Subtrigger Class Not known");
1359  return 0;
1360  }
1361  } else if (fSpecialTrigger == 5){ // Subdivision of kEMC trigger classes
1362  switch(selectSpecialSubTriggerClass){
1363  case 0: // all together
1366 // AliInfo("Info: Nothing to be done");
1367  break;
1368  case 1: // CEMC1 - V0OR and EMCAL fired
1369  fOfflineTriggerMask=AliVEvent::kEMC1;
1370  fSpecialTriggerName="AliVEvent::kEMC1";
1373  fSpecialSubTriggerName="CEMC1";
1374  break;
1375  case 2: // CEMC7 - V0AND and EMCAL fired
1377  fOfflineTriggerMask=AliVEvent::kEMC7;
1378  fSpecialTriggerName="AliVEvent::kEMC7";
1380  fSpecialSubTriggerName="CEMC7";
1381  break;
1382  case 3: // CEMC8 - T0OR and EMCAL fired
1383  fOfflineTriggerMask=AliVEvent::kEMC8;
1384  fSpecialTriggerName="AliVEvent::kEMC8";
1387  fSpecialSubTriggerName="CEMC8";
1388  break;
1389  case 4: // CDMC1 - V0OR and DCAL fired
1390  fOfflineTriggerMask=AliVEvent::kEMC1;
1391  fSpecialTriggerName="AliVEvent::kEMC1";
1394  fSpecialSubTriggerName="CDMC1";
1395  break;
1396  case 5: // CDMC7 - V0AND and DCAL fired
1398  fOfflineTriggerMask=AliVEvent::kEMC7;
1399  fSpecialTriggerName="AliVEvent::kEMC7";
1401  fSpecialSubTriggerName="CDMC7";
1402  break;
1403  case 6: // CDMC8 - T0OR and DCAL fired
1404  fOfflineTriggerMask=AliVEvent::kEMC8;
1405  fSpecialTriggerName="AliVEvent::kEMC8";
1408  fSpecialSubTriggerName="CDMC8";
1409  break;
1410  default:
1411  AliError("Warning: Special Subtrigger Class Not known");
1412  return 0;
1413  }
1414  }else if (fSpecialTrigger == 6){ // Subdivision of kPHI trigger classes
1415  switch(selectSpecialSubTriggerClass){
1416  case 0: // all together
1419 // AliInfo("Info: Nothing to be done");
1420  break;
1421  case 1: // CEMC1 - V0OR and EMCAL fired
1422  fOfflineTriggerMask=AliVEvent::kPHI1;
1423  fSpecialTriggerName="AliVEvent::kPHI1";
1426  fSpecialSubTriggerName="CPHI1";
1427  break;
1428  case 2: // CEMC7 - V0AND and EMCAL fired
1430  fOfflineTriggerMask=AliVEvent::kPHI7;
1431  fSpecialTriggerName="AliVEvent::kPHI7";
1433  fSpecialSubTriggerName="CPHI7";
1434  break;
1435  case 3: // CEMC8 - T0OR and EMCAL fired
1436  fOfflineTriggerMask=AliVEvent::kPHI8;
1437  fSpecialTriggerName="AliVEvent::kPHI8";
1440  fSpecialSubTriggerName="CPHI8";
1441  break;
1442  default:
1443  AliError("Warning: Special Subtrigger Class Not known");
1444  return 0;
1445  }
1446  } else if (fSpecialTrigger == 7){ // Subdivision of kHighMult trigger classes
1447  switch(selectSpecialSubTriggerClass){
1448  case 0: // all together
1451 // AliInfo("Info: Nothing to be done");
1452  break;
1453  case 1: // CSHM1 - V0OR and high mult fired
1456  fSpecialSubTriggerName="CSHM1";
1457  break;
1458  case 2: // CSHM7 - V0AND and high mult fired
1461  fSpecialSubTriggerName="CSHM7";
1462  break;
1463  case 3: // CSHM8 - T0OR and high mult fired
1466  fSpecialSubTriggerName="CSHM8";
1467  break;
1468  case 4: // V0 high mult trigger
1470  fOfflineTriggerMask=AliVEvent::kAny;
1471  fSpecialTriggerName="V0Mult";
1473  fSpecialSubTriggerName="CVHMV0M-B-";
1474  break;
1475  case 5: // SPD high mult trigger
1477  fOfflineTriggerMask=AliVEvent::kAny;
1478  fSpecialTriggerName="SPMult";
1480  fSpecialSubTriggerName="CVHMSH2-B-";
1481  break;
1482  case 6: // V0 high mult trigger with pileup condition on
1484  fOfflineTriggerMask=AliVEvent::kAny;
1485  fSpecialTriggerName="V0Mult";
1487  fSpecialSubTriggerName="CVHMV0M-B-SPD2";
1488  break;
1489 
1490  default:
1491  AliError("Warning: Special Subtrigger Class Not known");
1492  return 0;
1493  }
1494  }else if (fSpecialTrigger == 8){ // Subdivision of kEMCEGA trigger classes
1495  switch(selectSpecialSubTriggerClass){
1496  case 0: // all together
1499 // AliInfo("Info: Nothing to be done");
1500  break;
1501  case 1: // 7EGA - CINT7 EGA
1504  fSpecialSubTriggerName="7EGA";
1506  SETBIT(fTriggersEMCALSelected, kG2);
1507  break;
1508  case 2: // 8EGA - CINT8 EGA
1511  fSpecialSubTriggerName="8EGA";
1513  SETBIT(fTriggersEMCALSelected, kG2);
1514  break;
1515  case 3: // 7EG1 - CINT7 EG1
1518  fSpecialSubTriggerName="7EG1";
1520  SETBIT(fTriggersEMCALSelected, kG1);
1521  break;
1522  case 4: // 8EG1 - CINT8 EG1
1525  fSpecialSubTriggerName="8EG1";
1527  SETBIT(fTriggersEMCALSelected, kG1);
1528  break;
1529  case 5: // 7EG2 - CINT7 EG2
1532  fSpecialSubTriggerName="7EG2";
1534  SETBIT(fTriggersEMCALSelected, kG2);
1535  break;
1536  case 6: // 8EG2 - CINT8 EG2
1539  fSpecialSubTriggerName="8EG2";
1541  SETBIT(fTriggersEMCALSelected, kG2);
1542  break;
1543  case 7: // 7DGA - CINT7 DGA
1546  fSpecialSubTriggerName="7DGA";
1548  SETBIT(fTriggersEMCALSelected, kG2);
1549  break;
1550  case 8: // 8DGA - CINT8 DGA
1553  fSpecialSubTriggerName="8DGA";
1555  SETBIT(fTriggersEMCALSelected, kG2);
1556  break;
1557  case 9: // 7DG1 - CINT7 DG1
1560  fSpecialSubTriggerName="7DG1";
1562  SETBIT(fTriggersEMCALSelected, kG1);
1563  break;
1564  case 10: // 8DG1 - CINT8 DG1
1567  fSpecialSubTriggerName="8DG1";
1569  SETBIT(fTriggersEMCALSelected, kG1);
1570  break;
1571  case 11: // 7DG2 - CINT7 DG2
1574  fSpecialSubTriggerName="7DG2";
1576  SETBIT(fTriggersEMCALSelected, kG2);
1577  break;
1578  case 12: // 8DG2 - CINT8 DG2
1581  fSpecialSubTriggerName="8DG2";
1583  SETBIT(fTriggersEMCALSelected, kG2);
1584  break;
1585 
1586  default:
1587  AliError("Warning: Special Subtrigger Class Not known");
1588  return 0;
1589  }
1590  } else if (fSpecialTrigger == 9){ // Subdivision of kEMCEGA trigger classes
1591  switch(selectSpecialSubTriggerClass){
1592  case 0: // all together
1595 // AliInfo("Info: Nothing to be done");
1596  break;
1597  case 1: // 7EJE - CINT7 EJE
1600  fSpecialSubTriggerName="7EJE";
1602  SETBIT(fTriggersEMCALSelected, kJ2);
1603  break;
1604  case 2: // 8EJE - CINT8 EJE
1607  fSpecialSubTriggerName="8EJE";
1609  SETBIT(fTriggersEMCALSelected, kJ2);
1610  break;
1611  case 3: // 7EJ1 - CINT7 EJ1
1614  fSpecialSubTriggerName="7EJ1";
1616  SETBIT(fTriggersEMCALSelected, kJ1);
1617  break;
1618  case 4: // 8EJ1 - CINT8 EJ1
1621  fSpecialSubTriggerName="8EJ1";
1623  SETBIT(fTriggersEMCALSelected, kJ1);
1624  break;
1625  case 5: // 7EJ2 - CINT7 EJ2
1628  fSpecialSubTriggerName="7EJ2";
1630  SETBIT(fTriggersEMCALSelected, kJ2);
1631  break;
1632  case 6: // 8EJ2 - CINT8 EJ2
1635  fSpecialSubTriggerName="8EJ2";
1637  SETBIT(fTriggersEMCALSelected, kJ2);
1638  break;
1639  case 7: // 7DJ1 - CINT7 DJ1
1642  fSpecialSubTriggerName="7DJ1";
1644  SETBIT(fTriggersEMCALSelected, kJ1);
1645  break;
1646  case 8: // 8DJ1 - CINT8 DJ1
1649  fSpecialSubTriggerName="8DJ1";
1651  SETBIT(fTriggersEMCALSelected, kJ1);
1652  break;
1653  case 9: // 7DJ2 - CINT7 DJ2
1656  fSpecialSubTriggerName="7DJ2";
1658  SETBIT(fTriggersEMCALSelected, kJ2);
1659  break;
1660  case 10: // 8DJ2 - CINT8 DJ2
1663  fSpecialSubTriggerName="8DJ2";
1665  SETBIT(fTriggersEMCALSelected, kJ2);
1666  break;
1667 
1668  default:
1669  AliError("Warning: Special Subtrigger Class Not known");
1670  return 0;
1671  }
1672  }
1673  return 1;
1674 }
1675 
1676 //________________________________________________________________________
1678 {
1679  // Set Cut
1680  fMultiplicityMethod=multiplicityMethod;
1681 
1682  // 0 Photon Multiplicity
1683  // 1 TPC Track multiplicity
1684  // 2 V0 Mult
1685  // 3 SPD Mult
1686 
1687  return kTRUE;
1688 }
1689 
1690 //________________________________________________________________________
1692 {// Set Cut
1693  switch(removePileUp){
1694  case 0:
1695  fRemovePileUp = kFALSE;
1696  break;
1697  case 1:
1698  fRemovePileUp = kTRUE;
1699  break;
1700  case 2:
1701  fRemovePileUp = kTRUE;
1704  break;
1705  case 3:
1706  fRemovePileUp = kTRUE;
1709  break;
1710  case 4:
1711  fRemovePileUp = kTRUE;
1714  break;
1715  case 5:
1716  fRemovePileUp = kTRUE;
1719  break;
1720  case 6:
1721  fRemovePileUp = kTRUE;
1722  fDoPileUpRejectV0MTPCout = kTRUE;
1723  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1724  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1725  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1726  if (fIsHeavyIon==1){
1727  if(fPeriodEnum == kLHC15o){
1728  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1729  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1730  break;
1731  }else{
1732  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
1733  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1734  break;
1735  }
1736  } else if(fIsHeavyIon == 2){
1737  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
1738  fFPileUpRejectV0MTPCout->SetParameter(1,2.0);
1739  break;
1740  }else{
1741  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1742  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
1743  break;
1744  }
1745  break;
1746  case 7:
1747  fRemovePileUp = kTRUE;
1748  fDoPileUpRejectV0MTPCout = kTRUE;
1749  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1750  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1751  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1752  if (fIsHeavyIon==1){
1753  if(fPeriodEnum == kLHC15o){
1754  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1755  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1756  break;
1757  }else{
1758  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1759  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1760  break;
1761  }
1762  } else if(fIsHeavyIon == 2){
1763  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1764  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
1765  break;
1766  }else{
1767  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1768  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1769  break;
1770  }
1771  break;
1772  case 8:
1773  fRemovePileUp = kTRUE;
1774  fDoPileUpRejectV0MTPCout = kTRUE;
1775  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1776  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1777  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1778  if (fIsHeavyIon==1){
1779  if(fPeriodEnum == kLHC15o){
1780  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1781  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1782  break;
1783  }else{
1784  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
1785  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1786  break;
1787  }
1788  } else if(fIsHeavyIon == 2){
1789  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
1790  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
1791  break;
1792  }else{
1793  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1794  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
1795  break;
1796  }
1797  break;
1798  case 9:
1799  fRemovePileUp = kTRUE;
1802  fDoPileUpRejectV0MTPCout = kTRUE;
1803  fFPileUpRejectV0MTPCout = new TF1("fFPileUpRejectV0MTPCout","[0] + [1]*x",0.,10000.);
1804  fFPileUpRejectV0MTPCout->SetParameter(0,0.);
1805  fFPileUpRejectV0MTPCout->SetParameter(1,0.);
1806  if (fIsHeavyIon==1){
1807  if(fPeriodEnum == kLHC15o){
1808  fFPileUpRejectV0MTPCout->SetParameter(0,-2500.);
1809  fFPileUpRejectV0MTPCout->SetParameter(1,5.0);
1810  break;
1811  }else{
1812  fFPileUpRejectV0MTPCout->SetParameter(0,-1500.);
1813  fFPileUpRejectV0MTPCout->SetParameter(1,3.0);
1814  break;
1815  }
1816  } else if(fIsHeavyIon == 2){
1817  fFPileUpRejectV0MTPCout->SetParameter(0,-200.);
1818  fFPileUpRejectV0MTPCout->SetParameter(1,1.5);
1819  break;
1820  }else{
1821  fFPileUpRejectV0MTPCout->SetParameter(0,-300.);
1822  fFPileUpRejectV0MTPCout->SetParameter(1,4.0);
1823  break;
1824  }
1825  break;
1826  default:
1827  AliError("RemovePileUpCut not defined");
1828  return kFALSE;
1829  }
1830  return kTRUE;
1831 }
1832 
1833 //________________________________________________________________________
1835 
1836  switch(extraSignal){
1837  case 0:
1838  fRejectExtraSignals = 0;
1839  break; // No Rejection
1840  case 1:
1841  fRejectExtraSignals = 1;
1842  break; // MinBias Header
1843  case 2:
1844  fRejectExtraSignals = 2;
1845  break; // User String Array
1846  case 3:
1847  fRejectExtraSignals = 3;
1848  break; // Rejection for Gamma Correction only
1849  default:
1850  AliError(Form("Extra Signal Rejection not defined %d",extraSignal));
1851  return kFALSE;
1852  }
1853  return kTRUE;
1854 }
1855 
1856 //________________________________________________________________________
1858 
1859  switch(vertexCut){
1860  case 0: // no Vertex required // NOT fully working yet
1861  fEnableVertexCut = kFALSE;
1862  fMaxVertexZ = 1000;
1863  break;
1864  case 1: // vertex within +-15 cm
1865  fEnableVertexCut = kTRUE;
1866  fMaxVertexZ = 15;
1867  break;
1868  case 2: // vertex within +-12.5 cm
1869  fEnableVertexCut = kTRUE;
1870  fMaxVertexZ = 12.5;
1871  break;
1872  case 3: // vertex within +-10 cm
1873  fEnableVertexCut = kTRUE;
1874  fMaxVertexZ = 10.0;
1875  break;
1876  case 4: // vertex within +-7.5 cm
1877  fEnableVertexCut = kTRUE;
1878  fMaxVertexZ = 7.5;
1879  break;
1880  case 5: // vertex within +-5 cm
1881  fEnableVertexCut = kTRUE;
1882  fMaxVertexZ = 5.;
1883  break;
1884  default:
1885  AliError(Form("Vertex Cut not defined %d",vertexCut));
1886  return kFALSE;
1887  }
1888  return kTRUE;
1889 }
1890 
1891 //-------------------------------------------------------------
1893  if (fPeriodEnum == kLHC15n || // pp 5TeV
1894  fPeriodEnum == kLHC15o || // PbPb 5TeV
1895  fPeriodEnum == kLHC15k1a1 || fPeriodEnum == kLHC15k1a2 || fPeriodEnum == kLHC15k1a3 || fPeriodEnum == kLHC16j7 || // MC PbPb 5TeV LowIR
1896  fPeriodEnum == kLHC16g1 || fPeriodEnum == kLHC16g1a || fPeriodEnum == kLHC16g1b || fPeriodEnum == kLHC16g1c || // MC PbPb 5TeV general purpose
1897  fPeriodEnum == kLHC16g2 || // MC PbPb 5TeV EPOS-LHC
1898  fPeriodEnum == kLHC16g3 || // MC PbPb 5TeV DPMJET
1899  fPeriodEnum == kLHC16h4 || // MC PbPb 5TeV GA added pi0 and eta
1900  fPeriodEnum == kLHC16i1a || fPeriodEnum == kLHC16i1b || fPeriodEnum == kLHC16i1c || // MC PbPb 5TeV LF added (multi-)strange
1901  fPeriodEnum == kLHC16i2a || fPeriodEnum == kLHC16i2b || fPeriodEnum == kLHC16i2c || // MC PbPb 5TeV HF added hadronic decays
1902  fPeriodEnum == kLHC16i3a || fPeriodEnum == kLHC16i3b || fPeriodEnum == kLHC16i3c || // MC PbPb 5TeV HF added electron decays
1903  fPeriodEnum == kLHC16h2a || fPeriodEnum == kLHC16h2b || fPeriodEnum == kLHC16h2c || // MC PbPb 5TeV jet-jet
1905  fPeriodEnum == kLHC15g3a3 || fPeriodEnum == kLHC15g3c3 || // MC pp 13TeV
1906  fPeriodEnum == kLHC16q || fPeriodEnum == kLHC16t || // pPb 5TeV LHC16qt
1907  fPeriodEnum == kLHC16r || fPeriodEnum == kLHC16s || // pPb 8TeV LHC16rs
1908  fPeriodEnum == kLHC17f2a || fPeriodEnum == kLHC17f2b || fPeriodEnum == kLHC17g8a || // MC pPb 5TeV LHC16qt
1911  fPeriodEnum == kLHC17f4a || fPeriodEnum == kLHC17f4b || // MC pPb 8TeV LHC16sr
1912  fPeriodEnum == kLHC17n || // Xe-Xe LHC17n
1913  fPeriodEnum == kLHC17j7 || // MC Xe-Xe LHC17n
1914  fPeriodEnum == kLHC17p || fPeriodEnum == kLHC17q || // pp 5TeV LHC17pq
1917  ){
1918  return kTRUE;
1919  } else {
1920  return kFALSE;
1921  }
1922 }
1923 
1924 //-------------------------------------------------------------
1926 { // Get Event Centrality
1927 
1928  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
1929  if(esdEvent){
1931  AliMultSelection *MultSelection = (AliMultSelection*)event->FindListObject("MultSelection");
1932  if(!MultSelection){
1933  AliWarning ("AliMultSelection object not found !");
1934  return -1;
1935  }else{
1936  if(fDetectorCentrality==0){
1937  if(fIsHeavyIon==2) return MultSelection->GetMultiplicityPercentile("V0A");// default for pPb
1938  else return MultSelection->GetMultiplicityPercentile("V0M");// default
1939  }else if(fDetectorCentrality==1) return MultSelection->GetMultiplicityPercentile("CL1",kTRUE);
1940  }
1941  }else{
1942  AliCentrality *fESDCentrality = (AliCentrality*)esdEvent->GetCentrality();
1943  if(fDetectorCentrality==0){
1944  if(fIsHeavyIon==2) return fESDCentrality->GetCentralityPercentile("V0A"); // default for pPb
1945  else return fESDCentrality->GetCentralityPercentile("V0M"); // default
1946  }else if(fDetectorCentrality==1) return fESDCentrality->GetCentralityPercentile("CL1");
1947  }
1948  }
1949 
1950  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
1951  if(aodEvent){
1953  AliMultSelection *MultSelection = (AliMultSelection*)aodEvent->FindListObject("MultSelection");
1954  if(!MultSelection){
1955  AliWarning ("AliMultSelection object not found !");
1956  return -1;
1957  } else{
1958  if(fDetectorCentrality==0){
1959  if(fIsHeavyIon==2) return MultSelection->GetMultiplicityPercentile("V0A");// default for pPb
1960  else return MultSelection->GetMultiplicityPercentile("V0M",kTRUE);
1961  }else if(fDetectorCentrality==1) return MultSelection->GetMultiplicityPercentile("CL1",kTRUE);
1962  }
1963  }else{
1964  if(aodEvent->GetHeader()){return ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();}
1965  }
1966  }
1967 
1968  return -1;
1969 }
1970 
1971 //_____________________________________________________________________________________
1972 Bool_t AliConvEventCuts::IsCentralitySelected(AliVEvent *event, AliMCEvent *mcEvent)
1973 {
1974  // Centrality Selection
1975  if(!fIsHeavyIon){
1976  if ((fCentralityMin == 0 && fCentralityMax == 0) || (fCentralityMin > fCentralityMax) ){
1977  return kTRUE;
1978  } else {
1979  Int_t primaryTracksPP[9] = { 0, 2, 5, 10, 15,
1980  30, 50, 100, 1000
1981  };
1982  Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
1983  if ( nprimaryTracks >= primaryTracksPP[fCentralityMin] && nprimaryTracks < primaryTracksPP[fCentralityMax]){
1984  return kTRUE;
1985  } else {
1986  return kFALSE;
1987  }
1988  return kFALSE;
1989  }
1990  }
1991  if(fCentralityMin == fCentralityMax ) return kTRUE;//0-100%
1992  else if ( fCentralityMax==0) fCentralityMax=10; //CentralityRange = fCentralityMin-10*multfactor
1994  if(centrality<0 && !mcEvent)return kFALSE;
1995 
1996  Int_t centralityC=0;
1997  if (fModCentralityClass == 0){
1998  centralityC= Int_t(centrality/10);
1999  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2000  return kTRUE;
2001  else return kFALSE;
2002  }
2003  else if (fModCentralityClass ==1){
2004  centralityC= Int_t(centrality);
2005  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2006  return kTRUE;
2007  } else return kFALSE;
2008  }
2009  else if (fModCentralityClass ==2){
2010  centralityC= Int_t(centrality);
2011  if(centralityC >= ((fCentralityMin*5)+45) && centralityC < ((fCentralityMax*5)+45))
2012  return kTRUE;
2013  else return kFALSE;
2014  }
2015 
2016  Int_t nprimaryTracks = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks();
2017  Int_t PrimaryTracks10[11][2] =
2018  {
2019  {9999,9999}, // 0 //1550 changed to 9999 on 9 Dec
2020  {1210, 928}, // 10
2021  { 817, 658}, // 20
2022  { 536, 435}, // 30
2023  { 337, 276}, // 40
2024  { 197, 162}, // 50
2025  { 106, 100}, // 60
2026  { 51, 44}, // 70
2027  { 21, 18}, // 80
2028  { 0, 0}, // 90
2029  { 0, 0}// 100 // only max accessible
2030  };
2031  Int_t PrimaryTracksLHC11h10[11][2] =
2032  {
2033  {9999,9999}, // 0 //1550 changed to 9999 on 9 Dec
2034  { 985, 928}, // 10
2035  { 661, 658}, // 20
2036  { 434, 435}, // 30
2037  { 275, 276}, // 40
2038  { 173, 162}, // 50
2039  { 100, 100}, // 60
2040  { 42, 44}, // 70
2041  { 19, 18}, // 80
2042  { 0, 0}, // 90
2043  { 0, 0}// 100 // only max accessible
2044  };
2045  Int_t PrimaryTracksLHC15o10[11][2] =
2046  { // values calculated from ESD analysis so far
2047  {2700, 2700}, // 0-10% cent class max # of tracks: max value of the data distribution
2048  {1498, 1498}, // 0-10% cent class min # of tracks
2049  {1012, 1012}, // 10-20
2050  { 669, 669}, // 20-30
2051  { 423, 423}, // 30-40
2052  { 251, 251}, // 40-50
2053  { 136, 136}, // 50-60
2054  { 67, 67}, // 60-70
2055  { 28, 28}, // 70-80
2056  { 0, 0}, // 80-90% cent class min # of tracks
2057  { 0, 0} // not used
2058  };
2059  Int_t PrimaryTracks5a[11][2] =
2060  {
2061  {9999,9999}, // 0 ///1550 changed to 9999 on 9 Dec
2062  {1485,1168}, // 5
2063  {1210, 928}, // 10
2064  { 995, 795}, // 15
2065  { 817, 658}, // 20
2066  { 666, 538}, // 25
2067  { 536, 435}, // 30
2068  { 428, 350}, // 35
2069  { 337, 276}, // 40
2070  { 260, 214}, // 45
2071  { 0, 162}// 50 only max accessible
2072  };
2073  Int_t PrimaryTracksLHC11h5a[11][2] =
2074  {
2075  {9999,9999}, // 0 ///1550 changed to 9999 on 9 Dec
2076  {1166,1168}, // 5
2077  { 953, 928}, // 10
2078  { 805, 795}, // 15
2079  { 655, 658}, // 20
2080  { 535, 538}, // 25
2081  { 435, 435}, // 30
2082  { 349, 350}, // 35
2083  { 275, 276}, // 40
2084  { 214, 214}, // 45
2085  { 165, 162}// 50 only max accessible
2086  };
2087  Int_t PrimaryTracksLHC15o5a[11][2] =
2088  {
2089  { 2700, 2700}, // 0-5% cent class max # of tracks: max value of the data distribution
2090  { 1827, 1827}, // 0-5% cent class min # of tracks
2091  { 1498, 1498}, // 5-10
2092  { 1234, 1234}, // 10-15
2093  { 1012, 1012}, // 15-20
2094  { 827, 827}, // 20-25
2095  { 669, 669}, // 25-30
2096  { 536, 536}, // 30-35
2097  { 423, 423}, // 35-40
2098  { 329, 329}, // 40-45 cent class min # of tracks (cut digit 9)
2099  { 0, 0} // not used
2100  };
2101  Int_t PrimaryTracks5b[11][2] =
2102  {
2103  { 260, 214}, // 45
2104  { 197, 162}, // 50
2105  { 147, 125}, // 55
2106  { 106, 100}, // 60
2107  { 75, 63}, // 65
2108  { 51, 44}, // 70
2109  { 34, 29}, // 75
2110  { 21, 18}, // 80
2111  { 13, 11}, // 85
2112  { 0, 0}, // 90
2113  { 0, 0}// 100 only max accessible
2114  };
2115  Int_t PrimaryTracksLHC11h5b[11][2] =
2116  {
2117  { 214, 214}, // 45
2118  { 165, 162}, // 50
2119  { 127, 125}, // 55
2120  { 93, 100}, // 60
2121  { 64, 63}, // 65
2122  { 44, 44}, // 70
2123  { 30, 29}, // 75
2124  { 18, 18}, // 80
2125  { 11, 11}, // 85
2126  { 0, 0}, // 90
2127  { 0, 0}// 100 only max accessible
2128  };
2129  Int_t PrimaryTracksLHC15o5b[11][2] =
2130  {
2131  { 329, 329}, // 45-50% cent class max # of tracks
2132  { 251, 251}, // 45-50% cent class min # of tracks
2133  { 188, 188}, // 50-55
2134  { 136, 136}, // 55-60
2135  { 97, 97}, // 60-65
2136  { 67, 67}, // 65-70
2137  { 44, 44}, // 70-75
2138  { 28, 28}, // 75-80
2139  { 17, 17}, // 80-85
2140  { 0, 0}, // 85-90 cent class minimum # of tracks
2141  { 0, 0} // not used
2142  };
2143  Int_t PrimaryTracksLHC17n10[11][2] =
2144  {
2145  {9999,9999}, // 0 // 1500 max in hist but set to real max
2146  { 800, 800}, // 10 // guess
2147  { 628, 628}, // 20
2148  { 350, 350}, // 30 // guess
2149  { 268, 268}, // 40
2150  { 200, 200}, // 50 // guess
2151  { 100, 100}, // 60 // guess
2152  { 51, 44}, // 70 // guess
2153  { 21, 18}, // 80 // guess
2154  { 0, 0}, // 90 // guess
2155  { 0, 0} // 100 // only max accessible
2156  };
2157 
2158  Int_t column = 0;
2159  if(event->IsA()==AliESDEvent::Class()) column = 0;
2160  if(event->IsA()==AliAODEvent::Class()) column = 1;
2161 
2162  if (fModCentralityClass == 3){
2163  if(mcEvent){
2164  // setting specific arry for LHC11h for MC track mult
2166  if(nprimaryTracks > PrimaryTracksLHC11h10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h10[fCentralityMin][column])
2167  return kTRUE;
2168  else return kFALSE;
2169  // setting specific arry for LHC17n for MC track mult
2170  } else if(fPeriodEnum == kLHC17j7 ){
2171  if(nprimaryTracks > PrimaryTracksLHC17n10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC17n10[fCentralityMin][column])
2172  return kTRUE;
2173  else return kFALSE;
2174  // setting specific arry for LHC15o for MC track mult
2176  if(nprimaryTracks > PrimaryTracksLHC15o10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC15o10[fCentralityMin][column])
2177  return kTRUE;
2178  else return kFALSE;
2179  // setting specific arry for LHC10h for MC track mult
2180  } else {
2181  if(nprimaryTracks > PrimaryTracks10[fCentralityMax][column] && nprimaryTracks <= PrimaryTracks10[fCentralityMin][column])
2182  return kTRUE;
2183  else return kFALSE;
2184  }
2185  }
2186  else{
2187  centralityC= Int_t(centrality/10);
2188  if(centralityC >= fCentralityMin && centralityC < fCentralityMax)
2189  return kTRUE;
2190  else return kFALSE;
2191  }
2192  }
2193  else if (fModCentralityClass ==4){
2194  if(mcEvent){
2195  // setting specific arry for LHC11h for MC track mult
2197  if(nprimaryTracks > PrimaryTracksLHC11h5a[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h5a[fCentralityMin][column])
2198  return kTRUE;
2199  else return kFALSE;
2200  // setting specific arry for LHC15o for MC track mult
2202  if(nprimaryTracks > PrimaryTracksLHC15o5a[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC15o5a[fCentralityMin][column])
2203  return kTRUE;
2204  else return kFALSE;
2205  // setting specific arry for LHC10h for MC track mult
2206  } else {
2207  if(nprimaryTracks > PrimaryTracks5a[fCentralityMax][column] && nprimaryTracks <= PrimaryTracks5a[fCentralityMin][column])
2208  return kTRUE;
2209  else return kFALSE;
2210  }
2211  }
2212  else{
2213  centralityC= Int_t(centrality);
2214  if(centralityC >= fCentralityMin*5 && centralityC < fCentralityMax*5){
2215  return kTRUE;
2216  } else return kFALSE;
2217  }
2218  }
2219  else if (fModCentralityClass ==5){
2220  if(mcEvent){
2221  // setting specific arry for LHC11h for MC track mult
2223  if(nprimaryTracks > PrimaryTracksLHC11h5b[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC11h5b[fCentralityMin][column])
2224  return kTRUE;
2225  else return kFALSE;
2226  // setting specific arry for LHC15o for MC track mult
2228  if(nprimaryTracks > PrimaryTracksLHC15o5b[fCentralityMax][column] && nprimaryTracks <= PrimaryTracksLHC15o5b[fCentralityMin][column])
2229  return kTRUE;
2230  else return kFALSE;
2231  // setting specific arry for LHC10h for MC track mult
2232  } else {
2233  if(nprimaryTracks > PrimaryTracks5b[fCentralityMax][column] && nprimaryTracks <= PrimaryTracks5b[fCentralityMin][column])
2234  return kTRUE;
2235  else return kFALSE;
2236  }
2237  }
2238  else{
2239  centralityC= Int_t(centrality);
2240  if(centralityC >= ((fCentralityMin*5)+45) && centralityC < ((fCentralityMax*5)+45))
2241  return kTRUE;
2242  else return kFALSE;
2243  }
2244  }
2245 
2246  return kFALSE;
2247 }
2248 
2249 //________________________________________________________________________
2251  // Cut on z position of primary vertex
2252  Double_t fVertexZ=event->GetPrimaryVertex()->GetZ();
2253  Double_t fVertexZSPD = 0;
2254  AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2255  if(fESDEvent){
2256  fVertexZSPD = fESDEvent->GetPrimaryVertexSPD()->GetZ();
2257  }
2258  AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2259  if(fAODEvent){
2260  fVertexZSPD = fAODEvent->GetPrimaryVertexSPD()->GetZ();
2261  }
2262 
2263  if(TMath::Abs(fVertexZ)>fMaxVertexZ)return kFALSE;
2264 
2265 
2266  if (fPeriodEnum == kLHC11h){
2267  if (TMath::Abs(fVertexZ-fVertexZSPD) > 0.1) return kFALSE;
2268  }
2269  if (fIsHeavyIon == 2){
2270  if(!fUtils->IsVertexSelected2013pA(event)) return kFALSE;
2271  }
2272 
2273  return kTRUE;
2274 }
2275 
2276 //________________________________________________________________________
2278 {
2280  return kFALSE;
2281  TBits fIR1 = event->GetHeader()->GetIRInt1InteractionMap(); // IR1 contains V0 information (VIR)
2282  TBits fIR2 = event->GetHeader()->GetIRInt2InteractionMap(); // IR2 contains T0 information
2283  UShort_t bunchCrossings = event->GetBunchCrossNumber();
2285  for(Int_t i = 0; i<180;i++){
2286  if(fIR1.TestBitNumber(i))
2287  fHistoPastFutureBits->Fill((i*25)-90*25);
2288  }
2289  }
2290 
2291  Bool_t isOutOfBunchPileup = 0;
2292  Int_t pf1 = fPastFutureRejectionLow +bunchCrossings%4;
2293  Int_t pf2 = fPastFutureRejectionHigh+bunchCrossings%4;
2294  if(pf1 < -89) pf1 = -89;
2295  if(pf2 > 89) pf2 = 89;
2296  Int_t pf2maxForT0 = pf2;
2297  Int_t ir1skip = 0;
2298  for (Int_t i=pf1;i<=pf2;i++) {
2299  if (i==0) continue;
2300  if (i<=pf2maxForT0) isOutOfBunchPileup|=fIR2.TestBitNumber(90+i); // T0-based clean-up
2301  if (i>0 && i<=ir1skip) continue; // skip next 2 for old IR definitions
2302  isOutOfBunchPileup|=fIR1.TestBitNumber(90+i); // V0-based clean-up
2303  }
2304  return isOutOfBunchPileup;
2305 }
2306 //________________________________________________________________________
2307 
2309 {
2310  Bool_t isPileUpV0MTPCout=0;
2311 
2312  Double_t multV0M;
2313  Double_t valFunc;
2314  if (fIsHeavyIon==2){
2315  multV0M = event->GetVZEROData()->GetMTotV0A();
2316  }else{
2317  multV0M = event->GetVZEROData()->GetMTotV0A() + event->GetVZEROData()->GetMTotV0C() ;
2318  }
2319 
2320  if ( fFPileUpRejectV0MTPCout != 0x0 ){
2321  valFunc= fFPileUpRejectV0MTPCout->Eval(((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetNumberOfTPCoutTracks());
2322  if (multV0M < valFunc ) isPileUpV0MTPCout=1;
2323  }
2324 
2325  return isPileUpV0MTPCout;
2326 
2327 }
2328 //________________________________________________________________________
2330  // returns number of contributors to the vertex
2331 
2332  AliESDEvent *fESDEvent=dynamic_cast<AliESDEvent*>(event);
2333  if(fESDEvent){
2334  if (fESDEvent->GetPrimaryVertex() != NULL){
2335  if(fESDEvent->GetPrimaryVertex()->GetNContributors()>0) {
2336  // cout << "accepted global" << fESDEvent->GetEventNumberInFile() << " with NCont: " << fESDEvent->GetPrimaryVertex()->GetNContributors() << endl;
2337  return fESDEvent->GetPrimaryVertex()->GetNContributors();
2338  }
2339  }
2340 
2341  if(fESDEvent->GetPrimaryVertexSPD() !=NULL){
2342  if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2343  // cout << "accepted SPD" << fESDEvent->GetEventNumberInFile() << " with NCont: " << fESDEvent->GetPrimaryVertexSPD()->GetNContributors() << endl;
2344  return fESDEvent->GetPrimaryVertexSPD()->GetNContributors();
2345  }else {
2346  AliWarning(Form("Number of contributors from bad vertex type:: %s",fESDEvent->GetPrimaryVertex()->GetName()));
2347  // cout << "rejected " << fESDEvent->GetEventNumberInFile() << endl;
2348  return 0;
2349  }
2350  }
2351  }
2352 
2353  AliAODEvent *fAODEvent=dynamic_cast<AliAODEvent*>(event);
2354  if(fAODEvent){
2355  if (fAODEvent->GetPrimaryVertex() != NULL){
2356  if(fAODEvent->GetPrimaryVertex()->GetNContributors()>0) {
2357  return fAODEvent->GetPrimaryVertex()->GetNContributors();
2358  }
2359  }
2360  if(fAODEvent->GetPrimaryVertexSPD() !=NULL){
2361  if(fAODEvent->GetPrimaryVertexSPD()->GetNContributors()>0) {
2362  return fAODEvent->GetPrimaryVertexSPD()->GetNContributors();
2363  } else {
2364  AliWarning(Form("Number of contributors from bad vertex type:: %s",fAODEvent->GetPrimaryVertex()->GetName()));
2365  return 0;
2366  }
2367  }
2368  }
2369  // cout << "rejected " << fESDEvent->GetEventNumberInFile() << endl;
2370  return 0;
2371 }
2372 
2373 //________________________________________________________________________
2374 // Analysing Jet-Jet MC's
2375 //________________________________________________________________________
2377  AliGenCocktailEventHeader *cHeader = 0x0;
2378  Bool_t headerFound = kFALSE;
2379  weight = -1;
2380  fMaxPtJetMC = 0;
2381 
2382  if ( fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2383  fPeriodEnum != kLHC17g8b && fPeriodEnum != kLHC17g8c && // LHC16sr pPb 8TeV JetJet MC's
2384  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2385  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2386  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2387  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2388  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2389  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2390  fPeriodEnum != kLHC16c2 && fPeriodEnum != kLHC16c2_plus // LHC12 JetJet MC
2391  ){
2392 
2393  weight = 1;
2394  return kTRUE;
2395  }
2396 
2397  if(mcEvent){
2398  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2399  if(cHeader) headerFound = kTRUE;
2400  }else{
2401  //no mcEvent available -> not running on MC
2402  weight = 1;
2403  return kTRUE;
2404  }
2405 
2406  if(headerFound){
2407  TList *genHeaders = 0x0;
2408  if(cHeader) genHeaders = cHeader->GetHeaders();
2409  AliGenEventHeader* gh = 0;
2410  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2411  gh = (AliGenEventHeader*)genHeaders->At(i);
2412  TString GeneratorName = gh->GetName();
2413  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2414  Bool_t eventAccepted = kTRUE;
2415  TParticle * jet = 0;
2416  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(gh)->NTriggerJets();
2417  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
2418  Float_t tmpjet[]={0,0,0,0};
2419  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2420  dynamic_cast<AliGenPythiaEventHeader*>(gh)->TriggerJet(ijet, tmpjet);
2421  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2422  //Compare jet pT and pt Hard
2423  if(jet->Pt() > fMaxFacPtHard * ptHard){
2424  eventAccepted= kFALSE;
2425  }
2426  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2427  }
2428  if (jet) delete jet;
2429  if (mcEvent){
2430  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2431  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2432  if (!particle) continue;
2433  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2434  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2435  eventAccepted= kFALSE;
2436  }
2437  }
2438 
2439  }
2440  }
2441 
2442  if ( fPeriodEnum == kLHC16P1JJLowB) {
2443  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2444  21, 28, 36, 45, 57,
2445  70, 85, 99, 115, 132,
2446  150, 169, 190, 212, 235,
2447  1000000};
2448  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2449  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2450  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2451  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2452  Int_t bin = 0;
2453  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2454  if (bin < 20) weight = weightsBins[bin];
2455 
2456  } else if ( fPeriodEnum == kLHC16P1JJ ){
2457  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2458  21, 28, 36, 45, 57,
2459  70, 85, 99, 115, 132,
2460  150, 169, 190, 212, 235,
2461  1000000};
2462  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2463  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2464  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2465  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2466 
2467  Int_t bin = 0;
2468  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2469  if (bin < 20) weight = weightsBins[bin];
2470 
2471  } else if ( fPeriodEnum == kLHC16h3 ){
2472  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2473  21, 28, 36, 45, 57,
2474  70, 85, 99, 115, 132,
2475  150, 169, 190, 212, 235,
2476  1000000};
2477  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2478  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2479  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2480  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2481  Int_t bin = 0;
2482  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2483  if (bin < 20) weight = weightsBins[bin];
2484 
2485 
2486  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2487  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2488  21, 28, 36, 45, 57,
2489  70, 85, 1000};
2490  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2491  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2492  1.933238e-05, 1.562895e-05};
2493  Int_t bin = 0;
2494  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2495  if (bin < 12) weight = weightsBins[bin];
2496 
2497  } else if ( fPeriodEnum == kLHC15g1a ){
2498  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2499  84, 117, 152, 191, 1000000,
2500  5, 7, 9, 12, 16,
2501  21, 28, 36, 45, 57 };
2502  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2503  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2504  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2505  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2506 
2507  Int_t bin = 0;
2508  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2509  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2510  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2511  if (bin < 19) weight = weightsBins[bin];
2512 
2513  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2514  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2515  84, 117, 152, 191, 1000000,
2516  5, 7, 9, 12, 16,
2517  21, 28, 36, 45, 57 };
2518  // LHC15a3a
2519  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2520  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2521  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2522  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2523  Int_t bin = 0;
2524  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2525  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2526  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2527  if (bin < 19) weight = weightsBins[bin];
2528 
2529  } else if ( fPeriodEnum == kLHC16c2 || fPeriodEnum == kLHC16c2_plus ){
2530  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2531  21, 28, 36, 45, 57,
2532  70, 85, 99, 115, 132,
2533  150, 169, 190, 212, 235,
2534  1000000};
2535  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
2536  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
2537  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
2538  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
2539  Int_t bin = 0;
2540  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2541  if (bin < 20) weight = weightsBins[bin];
2542 
2543  } else if ( fPeriodEnum == kLHC16c3a ){
2544  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
2545  Double_t weightsBins[5] = { 0.00672445, 0.00799158, 0.00678934, 0.00463908, 0.00600068}; //preliminary estimates
2546  Int_t bin = 0;
2547  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2548  if (bin < 5) weight = weightsBins[bin];
2549 
2550  } else if (fPeriodEnum == kLHC16c3b ){
2551  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
2552  Double_t weightsBins[6] = { 0.00608281, 0.00393646, 0.00200138, 0.000986267, 0.000389051, 0.0001863}; //preliminary estimates
2553  Int_t bin = 0;
2554  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2555  if (bin < 6) weight = weightsBins[bin];
2556 
2557  } else if (fPeriodEnum == kLHC16c3c ){
2558  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
2559  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
2560  Int_t bin = 0;
2561  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2562  if (bin < 7) weight = weightsBins[bin];
2563 
2564  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
2565  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
2566  84, 117, 152, 191, 234,
2567  1000};
2568  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
2569  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
2570  Int_t bin = 0;
2571  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2572  if (bin < 10) weight = weightsBins[bin];
2573 
2574  } else if ( fPeriodEnum == kLHC17g8b ){ // preliminary weights obtained from local running
2575  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};
2576  Double_t weightsBins[20] = {2.648510E+01, 7.963350E+00, 3.926460E+00, 1.535630E+00, 5.125940E-01, 1.982910E-01, 6.705810E-02, 2.214220E-02, 9.872830E-03, 3.460430E-03, 1.426840E-03, 5.212990E-04, 2.534030E-04, 1.157210E-04, 6.609650E-05, 3.424850E-05, 1.833500E-05, 1.022650E-05, 5.878600E-06, 8.550350E-06};
2577  Int_t bin = 0;
2578  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2579  if (bin < 20) weight = weightsBins[bin];
2580  } else if ( fPeriodEnum == kLHC17g8c ){ // preliminary weights obtained from local running
2581  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};
2582  Double_t weightsBins[20] = {2.638850E+01, 8.160880E+00, 3.937510E+00, 1.485000E+00, 5.382460E-01, 2.034610E-01, 6.293600E-02, 2.206170E-02, 9.319700E-03, 3.354230E-03, 1.392300E-03, 5.023470E-04, 2.645860E-04, 1.299660E-04, 6.415310E-05, 3.469890E-05, 1.816550E-05, 1.047480E-05, 5.728760E-06, 8.547820E-06};
2583  Int_t bin = 0;
2584  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2585  if (bin < 20) weight = weightsBins[bin];
2586 
2587  } else {
2588  weight = 1;
2589  }
2590 
2591  if (weight == -1) return kFALSE;
2592  else return eventAccepted;
2593 
2594  }
2595  }
2596  } else {
2597  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2598  TString eventHeaderName = eventHeader->ClassName();
2599  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2600  Bool_t eventAccepted = kTRUE;
2601  TParticle * jet = 0;
2602  Int_t nTriggerJets = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->NTriggerJets();
2603  Float_t ptHard = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
2604  Float_t tmpjet[]={0,0,0,0};
2605  for(Int_t ijet = 0; ijet< nTriggerJets; ijet++){
2606  dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->TriggerJet(ijet, tmpjet);
2607  jet = new TParticle(94, 21, -1, -1, -1, -1, tmpjet[0],tmpjet[1],tmpjet[2],tmpjet[3], 0,0,0,0);
2608  //Compare jet pT and pt Hard
2609  if(jet->Pt() > fMaxFacPtHard * ptHard){
2610  eventAccepted= kFALSE;
2611  }
2612  if (jet->Pt() > fMaxPtJetMC) fMaxPtJetMC = jet->Pt();
2613  }
2614  if (mcEvent){
2615  for(Long_t i = 0; i < mcEvent->GetNumberOfPrimaries(); i++) {
2616  TParticle* particle = (TParticle *)mcEvent->Particle(i);
2617  if (!particle) continue;
2618  if (TMath::Abs(particle->GetPdgCode()) == 111 || TMath::Abs(particle->GetPdgCode()) == 221){
2619  if (particle->Pt() > fMaxFacPtHardSingleParticle*ptHard){
2620  eventAccepted= kFALSE;
2621  }
2622  }
2623 
2624  }
2625  }
2626 
2627  if ( fPeriodEnum == kLHC16P1JJLowB) {
2628  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2629  21, 28, 36, 45, 57,
2630  70, 85, 99, 115, 132,
2631  150, 169, 190, 212, 235,
2632  1000000};
2633  Double_t weightsBins[20] = { 43.7553, 13.5848, 6.788, 2.67826, 0.975255,
2634  0.39069, 0.127342, 0.0465597, 0.0206539, 0.00750243,
2635  0.00319118, 0.00122291, 0.000641232, 0.000321437, 0.000168273,
2636  9.17033e-05, 5.34755e-05, 3.01354e-05, 1.74518e-05, 2.8004e-05};
2637  Int_t bin = 0;
2638  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2639  if (bin < 20) weight = weightsBins[bin];
2640 
2641  } else if ( fPeriodEnum == kLHC16P1JJ ){
2642  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2643  21, 28, 36, 45, 57,
2644  70, 85, 99, 115, 132,
2645  150, 169, 190, 212, 235,
2646  1000000};
2647  Double_t weightsBins[20] = { 43.8654, 13.6215, 6.79856, 2.67526, 0.978794,
2648  0.390797, 0.127769, 0.0465714, 0.0206173, 0.00750282,
2649  0.00318773, 0.00122533, 0.000644385, 0.000321225, 0.00016846,
2650  9.18305e-05, 5.33507e-05, 3.00677e-05, 1.74608e-05, 2.80823e-05};
2651 
2652  Int_t bin = 0;
2653  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2654  if (bin < 20) weight = weightsBins[bin];
2655 
2656  } else if ( fPeriodEnum == kLHC16h3 ){
2657  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2658  21, 28, 36, 45, 57,
2659  70, 85, 99, 115, 132,
2660  150, 169, 190, 212, 235,
2661  1000000};
2662  Double_t weightsBins[20] = { 16.0869, 4.61169, 2.14976, 0.782544, 0.264854,
2663  9.7619E-02, 2.92747E-02, 9.89515E-03, 4.05152E-03, 1.35393E-03,
2664  5.29864E-04, 1.88317E-04, 9.23E-05, 4.29E-05, 2.09E-05,
2665  1.06E-05, 5.76E-06, 3.00E-06, 1.62E-06, 2.10E-06 };
2666  Int_t bin = 0;
2667  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2668  if (bin < 20) weight = weightsBins[bin];
2669 
2670 
2671  } else if ( fPeriodEnum == kLHC15a3b || fPeriodEnum == kLHC15g1b ){
2672  Double_t ptHardBinRanges[13] = { 5, 7, 9, 12, 16,
2673  21, 28, 36, 45, 57,
2674  70, 85, 1000};
2675  Double_t weightsBins[12] = { 7.858393e-03, 4.718691e-03, 4.077575e-03, 2.814527e-03, 1.669625e-03,
2676  1.007535e-03, 4.536554e-04, 2.111041e-04, 1.094840e-04, 4.404973e-05,
2677  1.933238e-05, 1.562895e-05};
2678  Int_t bin = 0;
2679  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2680  if (bin < 12) weight = weightsBins[bin];
2681 
2682  } else if ( fPeriodEnum == kLHC15g1a ){
2683  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2684  84, 117, 152, 191, 1000000,
2685  5, 7, 9, 12, 16,
2686  21, 28, 36, 45, 57 };
2687  Double_t weightsBins[19] = { 4.43629 , 0.49523, 0.0394921, 0.00383174, 0.000446559,
2688  6.37374e-05, 1.03134e-05, 2.27012e-06, 7.59281e-07, 0,
2689  2.62906, 1.12884, 0.656873, 0.262822, 0.0876732,
2690  0.0307759, 0.0087083, 0.0027664, 0.00106203};
2691 
2692  Int_t bin = 0;
2693  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2694  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2695  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2696  if (bin < 19) weight = weightsBins[bin];
2697 
2698  } else if ( fPeriodEnum == kLHC15a3a || fPeriodEnum == kLHC15a3a_plus ) {
2699  Double_t ptHardBinRanges[20] = { 5, 11, 21, 36, 57,
2700  84, 117, 152, 191, 1000000,
2701  5, 7, 9, 12, 16,
2702  21, 28, 36, 45, 57 };
2703  // LHC15a3a
2704  Double_t weightsBins[19] = { 4.43897 , 0.495766, 0.039486, 0.00383011, 0.000447104,
2705  6.37277e-05, 1.03166e-05, 2.26971e-06, 7.59023e-07, 0,
2706  2.63331, 1.12815, 0.657034, 0.262756, 0.0877227,
2707  0.0307638, 0.00870635, 0.00276658, 0.00106229};
2708  Int_t bin = 0;
2709  Int_t binFromFile = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPtHardFromFile();
2710  if (binFromFile != -1 && binFromFile >9 && ptHard < 57) bin = 9;
2711  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2712  if (bin < 19) weight = weightsBins[bin];
2713 
2714  } else if ( fPeriodEnum == kLHC16c2 || fPeriodEnum == kLHC16c2_plus ){
2715  Double_t ptHardBinRanges[21] = { 5, 7, 9, 12, 16,
2716  21, 28, 36, 45, 57,
2717  70, 85, 99, 115, 132,
2718  150, 169, 190, 212, 235,
2719  1000000};
2720  Double_t weightsBins[20] = { 28.3084, 8.43277, 4.07753, 1.54359, 0.543318,
2721  0.208394, 0.0652349, 0.0186904, 0.00834528, 0.00301414,
2722  0.00125939, 0.000474403, 0.000244052, 0.00011924, 6.09838e-05,
2723  3.24148e-05, 1.84314e-05, 1.00926e-05, 5.68632e-06, 8.38092e-06};
2724  Int_t bin = 0;
2725  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2726  if (bin < 20) weight = weightsBins[bin];
2727 
2728  } else if ( fPeriodEnum == kLHC16c3a ){
2729  Double_t ptHardBinRanges[6] = { 7, 9, 12, 16, 21, 1000};
2730  Double_t weightsBins[5] = { 0.00672445, 0.00799158, 0.00678934, 0.00463908, 0.00600068}; //preliminary estimates
2731  Int_t bin = 0;
2732  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2733  if (bin < 5) weight = weightsBins[bin];
2734 
2735  } else if (fPeriodEnum == kLHC16c3b ){
2736  Double_t ptHardBinRanges[7] = { 14, 19, 26, 35, 48, 66, 1000};
2737  Double_t weightsBins[6] = { 0.00608281, 0.00393646, 0.00200138, 0.000986267, 0.000389051, 0.0001863}; //preliminary estimates
2738  Int_t bin = 0;
2739  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2740  if (bin < 6) weight = weightsBins[bin];
2741 
2742  } else if (fPeriodEnum == kLHC16c3c ){
2743  Double_t ptHardBinRanges[8] = { 0, 5, 11, 21, 36, 57, 84, 1000};
2744  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
2745  Int_t bin = 0;
2746  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2747  if (bin < 7) weight = weightsBins[bin];
2748 
2749  } else if ( fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus ){
2750  Double_t ptHardBinRanges[11] = { 5, 11, 21, 36, 57,
2751  84, 117, 152, 191, 234,
2752  1000};
2753  Double_t weightsBins[10] = { 2.24185e-6 , 2.48463e-7, 2.23171e-8, 2.43667e-9, 3.29934e-10,
2754  5.34592e-11, 1.00937e-11, 2.6493e-12, 8.53912e-13, 5.43077e-13};
2755  Int_t bin = 0;
2756  while (!((ptHard< ptHardBinRanges[bin+1] && ptHard > ptHardBinRanges[bin]) || (ptHard == ptHardBinRanges[bin]) ) )bin++;
2757  if (bin < 10) weight = weightsBins[bin];
2758  } else {
2759  weight = 1;
2760  }
2761 
2762  if (weight == -1) return kFALSE;
2763  else return eventAccepted;
2764 
2765  } else {
2766  return kFALSE;
2767  }
2768  }
2769 
2770  return kFALSE;
2771 }
2772 
2773 //________________________________________________________________________
2774 // Analysing Jet-Jet MC's
2775 //________________________________________________________________________
2776 void AliConvEventCuts::GetXSectionAndNTrials(AliMCEvent *mcEvent, Float_t &XSection, Float_t &NTrials){
2777 
2778  AliGenCocktailEventHeader *cHeader = 0x0;
2779  Bool_t headerFound = kFALSE;
2780 
2781  if ( fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2782  fPeriodEnum != kLHC17g8b && fPeriodEnum != kLHC17g8c && // LHC16sr pPb 8TeV JetJet MC's
2783  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2784  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2785  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2786  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2787  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2788  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2789  fPeriodEnum != kLHC16c2 && fPeriodEnum != kLHC16c2_plus // LHC12 JetJet MC
2790  ){
2791  NTrials = -1;
2792  XSection = -1;
2793  return;
2794  }
2795 
2796  if(mcEvent){
2797  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2798  if(cHeader) headerFound = kTRUE;
2799  }else{
2800  //no mcEvent available -> not running on MC
2801  NTrials = -1;
2802  XSection = -1;
2803  return;
2804  }
2805 
2806  if(headerFound){
2807  TList *genHeaders = 0x0;
2808  if(cHeader) genHeaders = cHeader->GetHeaders();
2809  AliGenEventHeader* gh = 0;
2810  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2811  gh = (AliGenEventHeader*)genHeaders->At(i);
2812  TString GeneratorName = gh->GetName();
2813  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2814  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(gh);
2815  NTrials = gPythia->Trials();
2816  XSection = gPythia->GetXsection();
2817  return;
2818  }
2819  }
2820  } else {
2821  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2822  if(eventHeader){
2823  TString eventHeaderName = eventHeader->ClassName();
2824  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2825  AliGenPythiaEventHeader* gPythia = dynamic_cast<AliGenPythiaEventHeader*>(eventHeader);
2826  NTrials = gPythia->Trials();
2827  XSection = gPythia->GetXsection();
2828  return;
2829  }
2830  }
2831  }
2832 
2833  NTrials = -1;
2834  XSection = -1;
2835  return;
2836 }
2837 
2838 
2839 //________________________________________________________________________
2840 // Analysing Jet-Jet MC's
2841 //________________________________________________________________________
2843  AliGenCocktailEventHeader *cHeader = 0x0;
2844  Bool_t headerFound = kFALSE;
2845 
2846  if ( fPeriodEnum != kLHC17g8a && // LHC16qt pPb 5TeV JetJet MC's
2847  fPeriodEnum != kLHC17g8b && fPeriodEnum != kLHC17g8c && // LHC16sr pPb 8TeV JetJet MC's
2848  fPeriodEnum != kLHC16P1JJ && fPeriodEnum != kLHC16P1JJLowB && // LHC16X Jet Jet MC's
2849  fPeriodEnum != kLHC16h3 && // LHC15n Jet Jet MC's
2850  fPeriodEnum != kLHC15a3a && fPeriodEnum != kLHC15a3a_plus && fPeriodEnum != kLHC15a3b && // LHC13g Jet Jet MC's
2851  fPeriodEnum != kLHC15g1a && fPeriodEnum != kLHC15g1b && // LHC11a Jet Jet MC's
2852  fPeriodEnum != kLHC13b4_fix && fPeriodEnum != kLHC13b4_plus && // LHC13 pPb Jet Jet MC's
2853  fPeriodEnum != kLHC16c3a && fPeriodEnum != kLHC16c3b && fPeriodEnum != kLHC16c3c && // LHC13 pPb Jet Jet MC's
2854  fPeriodEnum != kLHC16c2 && fPeriodEnum != kLHC16c2_plus // LHC12 JetJet MC
2855  ) return -1;
2856 
2857  if(mcEvent){
2858  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(mcEvent->GenEventHeader());
2859  if(cHeader) headerFound = kTRUE;
2860  }else{
2861  //no mcEvent available -> not running on MC
2862  return -1;
2863  }
2864 
2865  if(headerFound){
2866  TList *genHeaders = 0x0;
2867  if(cHeader) genHeaders = cHeader->GetHeaders();
2868  AliGenEventHeader* gh = 0;
2869  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
2870  gh = (AliGenEventHeader*)genHeaders->At(i);
2871  TString GeneratorName = gh->GetName();
2872  if (GeneratorName.CompareTo("AliGenPythiaEventHeader") == 0 || GeneratorName.Contains("Pythia8Jets")){
2873  return dynamic_cast<AliGenPythiaEventHeader*>(gh)->GetPtHard();
2874  }
2875  }
2876  } else {
2877  AliGenEventHeader * eventHeader = mcEvent->GenEventHeader();
2878  if(eventHeader){
2879  TString eventHeaderName = eventHeader->ClassName();
2880  if (eventHeaderName.CompareTo("AliGenPythiaEventHeader") == 0 || eventHeaderName.Contains("Pythia8Jets")){
2881  return dynamic_cast<AliGenPythiaEventHeader*>(eventHeader)->GetPtHard();
2882  }
2883  }
2884  }
2885 
2886  return -1;
2887 }
2888 
2889 
2890 //________________________________________________________________________
2892  // abort if mimicing not enabled
2893 
2894  if (!fMimicTrigger) return kTRUE;
2895 
2896  Int_t runRangesEMCalL0 [35] = { 144871, 145288, 146375, 146382, // LHC11a
2897  146502, 148522, // LHC11a
2898  150209, 153056, 153911, 153915, // LHC11b,c,d
2899  158135, 158136, 158178, 158182, 160683,
2900  160764, 161139, 161256, 161379, 161457,
2901  161525, 161556, 161558, 161609, 161630,
2902  161724, // LHC11d,e
2903  173731, 177144, 177147, 177653, 177724, 178327,
2904  195180, // LHC13b-f
2905  197469, 197692 // LHC13g
2906  };
2907 
2908  Double_t thresholdEMCalL0[34] = { 2.11, 3.43, 1.71, 2.05, // LHC11a 7 TeV
2909  3.43, // LHC11a 2.76TeV
2910  1.94, 3.39, 4.01, 5.25, 5.5, // LHC11b, LHC11c, LHC11d
2911  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,
2912  2.01, 1.75, 1.52, 2.01, 1.52, 1.85,
2913  3.2,
2914  /*2.01*/1.8
2915  };
2916  Double_t spreadEMCalL0[34] = { 0., 0., 0, 0, // LHC11a 7TeV
2917  /*0.7*/0.65, // LHC11a 2.76TeV
2918  0., 0., 0., 0., 0., // LHC11b, LHC11c, LHC11d
2919  0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
2920  0., 0., 0., 0., 0.2, 0.2,/*0.,0.,*/
2921  0.1,
2922  /*0.1*/0.12
2923  };
2924 
2925  Int_t runRangesEMCalL1[4] = { 179796, // LHC12c-i
2926  195180, // LHC13b-f
2927  197469, 197692 // LHC13g
2928  };
2929 
2930  Double_t thresholdEMCalL1[3] = { 9.5/*8.398*/, 11.5, /*6.*/5.5};
2931  Double_t spreadEMCalL1[3] = { 1.0/*0.*/, 0.5, /*0.4*/0.6};
2932 
2933  Int_t runRangesEMCalL1G2[3] = { 195180, // LHC13b-f
2934  197469, 197692 // LHC13g
2935  };
2936 
2937  Double_t thresholdEMCalL1G2[2] = { 7.2, /*3.9*/3.75};
2938  Double_t spreadEMCalL1G2[2] = { 0.3, /*0.2*/0.25};
2939 
2940  Int_t runnumber = event->GetRunNumber();
2941 
2942  if (fSpecialTrigger == 5 ){
2943  if (runnumber < runRangesEMCalL0[0]) return kTRUE;
2944  Int_t binRun = 0;
2945  while (!(runnumber >= runRangesEMCalL0[binRun] && runnumber < runRangesEMCalL0[binRun+1] ) && binRun < 34 ){
2946 // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << endl;
2947  binRun++;
2948  }
2949  if (binRun==34) return kFALSE;
2950  Double_t threshold = thresholdEMCalL0[binRun];
2951 
2952  if (isMC && spreadEMCalL0[binRun] != 0.){
2953  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
2954  triggerSmearing->SetParameter(0, 1/(spreadEMCalL0[binRun]*TMath::Sqrt(TMath::Pi()*2)));
2955  triggerSmearing->SetParameter(1, thresholdEMCalL0[binRun]);
2956  triggerSmearing->SetParameter(2, spreadEMCalL0[binRun]);
2957  threshold = triggerSmearing->GetRandom();
2958  delete triggerSmearing;
2959  }
2960 
2961 // cout << runnumber << "\t"<< binRun << "\t"<< threshold << endl;
2962  Int_t nclus = 0;
2963  TClonesArray * arrClustersMimic = NULL;
2964  if(!fCorrTaskSetting.CompareTo("")){
2965  nclus = event->GetNumberOfCaloClusters();
2966  } else {
2967  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
2968  if(!arrClustersMimic)
2969  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
2970  nclus = arrClustersMimic->GetEntries();
2971  }
2972 
2973  if(nclus == 0) return kFALSE;
2974 
2975  // Loop over EMCal clusters
2976  Bool_t eventIsAccepted = kFALSE;
2977  for(Int_t i = 0; i < nclus; i++){
2978  AliVCluster* clus = NULL;
2979  if(event->IsA()==AliESDEvent::Class()){
2980  if(arrClustersMimic)
2981  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
2982  else
2983  clus = event->GetCaloCluster(i);
2984  } else if(event->IsA()==AliAODEvent::Class()){
2985  if(arrClustersMimic)
2986  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
2987  else
2988  clus = event->GetCaloCluster(i);
2989  }
2990 
2991  if (!clus) continue;
2992  if (!clus->IsEMCAL()) continue;
2993  if (clus->GetM02()<0.1) continue;
2994  if (clus->GetNCells()<2) continue;
2995  if (clus->E() > threshold ){
2996 // cout << "found L0" << endl;
2997  eventIsAccepted = kTRUE;
2998  }
2999  }
3000  return eventIsAccepted;
3001 
3002  } else if (fSpecialTrigger == 6 ) {
3003 
3004  return kTRUE;
3005  } else if (fSpecialTrigger == 8 ) {
3006  if (fSpecialSubTriggerName.CompareTo("7EGA")==0 || fSpecialSubTriggerName.CompareTo("8EGA")==0 || fSpecialSubTriggerName.CompareTo("7EG1")==0 ||fSpecialSubTriggerName.CompareTo("8EG1")==0 ){
3007  if (runnumber < runRangesEMCalL1[0]) return kTRUE;
3008  Int_t binRun = 0;
3009  while (!(runnumber >= runRangesEMCalL1[binRun] && runnumber < runRangesEMCalL1[binRun+1] ) && binRun < 3 ){
3010  // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << endl;
3011  binRun++;
3012  }
3013  if (binRun==3) return kFALSE;
3014  Double_t threshold = thresholdEMCalL1[binRun];
3015 
3016  if (isMC && spreadEMCalL1[binRun] != 0.){
3017  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3018  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3019  triggerSmearing->SetParameter(1, thresholdEMCalL1[binRun]);
3020  triggerSmearing->SetParameter(2, spreadEMCalL1[binRun]);
3021  threshold = triggerSmearing->GetRandom();
3022  delete triggerSmearing;
3023  }
3024 
3025 // cout << runnumber << "\t"<< binRun << "\t L1 \t"<< threshold << endl;
3026 
3027  TClonesArray * arrClustersMimic = NULL;
3028  Int_t nclus = 0;
3029  if(!fCorrTaskSetting.CompareTo("")){
3030  nclus = event->GetNumberOfCaloClusters();
3031  } else {
3032  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3033  if(!arrClustersMimic)
3034  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3035  nclus = arrClustersMimic->GetEntries();
3036  }
3037 
3038  if(nclus == 0) return kFALSE;
3039 
3040  // Loop over EMCal clusters
3041  Bool_t eventIsAccepted = kFALSE;
3042  for(Int_t i = 0; i < nclus; i++){
3043  AliVCluster* clus = NULL;
3044  if(event->IsA()==AliESDEvent::Class()){
3045  if(arrClustersMimic)
3046  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3047  else
3048  clus = event->GetCaloCluster(i);
3049  } else if(event->IsA()==AliAODEvent::Class()){
3050  if(arrClustersMimic)
3051  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3052  else
3053  clus = event->GetCaloCluster(i);
3054  }
3055  if (!clus) continue;
3056  if (!clus->IsEMCAL()) continue;
3057  if (clus->GetM02()<0.1) continue;
3058  if (clus->GetNCells()<2) continue;
3059  if (clus->E() > threshold ){
3060 // cout << "found L1G1" << endl;
3061  eventIsAccepted = kTRUE;
3062  }
3063  }
3064  return eventIsAccepted;
3065  } else if ( fSpecialSubTriggerName.CompareTo("7EG2")==0 ||fSpecialSubTriggerName.CompareTo("8EG2")==0 ){
3066  if (runnumber < runRangesEMCalL1G2[0]) return kTRUE;
3067  Int_t binRun = 0;
3068  while (!(runnumber >= runRangesEMCalL1G2[binRun] && runnumber < runRangesEMCalL1G2[binRun+1] ) && binRun < 2 ){
3069  // cout << runnumber << "\t" << binRun << "\t" << runRangesEMCalL0[binRun] << "\t" << runRangesEMCalL0[binRun+1] << endl;
3070  binRun++;
3071  }
3072  if (binRun==2) return kFALSE;
3073  Double_t threshold = thresholdEMCalL1G2[binRun];
3074  if (isMC && spreadEMCalL1G2[binRun] != 0.){
3075  TF1* triggerSmearing = new TF1("triggerSmearing","[0]*exp(-0.5*((x-[1])/[2])**2)",0,15);
3076  triggerSmearing->SetParameter(0, 1/(spreadEMCalL1G2[binRun]*TMath::Sqrt(TMath::Pi()*2)));
3077  triggerSmearing->SetParameter(1, thresholdEMCalL1G2[binRun]);
3078  triggerSmearing->SetParameter(2, spreadEMCalL1G2[binRun]);
3079  threshold = triggerSmearing->GetRandom();
3080  delete triggerSmearing;
3081  }
3082 // cout << runnumber << "\t"<< binRun << "\t L2 \t"<< threshold << endl;
3083 
3084  Int_t nclus = 0;
3085  TClonesArray * arrClustersMimic = NULL;
3086  if(!fCorrTaskSetting.CompareTo("")){
3087  nclus = event->GetNumberOfCaloClusters();
3088  } else {
3089  arrClustersMimic = dynamic_cast<TClonesArray*>(event->FindListObject(Form("%sClustersBranch",fCorrTaskSetting.Data())));
3090  if(!arrClustersMimic)
3091  AliFatal(Form("%sClustersBranch was not found in AliConvEventCuts! Check the correction framework settings!",fCorrTaskSetting.Data()));
3092  nclus = arrClustersMimic->GetEntries();
3093  }
3094 
3095  if(nclus == 0) return kFALSE;
3096 
3097  // Loop over EMCal clusters
3098  Bool_t eventIsAccepted = kFALSE;
3099  for(Int_t i = 0; i < nclus; i++){
3100  AliVCluster* clus = NULL;
3101  if(event->IsA()==AliESDEvent::Class()){
3102  if(arrClustersMimic)
3103  clus = new AliESDCaloCluster(*(AliESDCaloCluster*)arrClustersMimic->At(i));
3104  else
3105  clus = event->GetCaloCluster(i);
3106  } else if(event->IsA()==AliAODEvent::Class()){
3107  if(arrClustersMimic)
3108  clus = new AliAODCaloCluster(*(AliAODCaloCluster*)arrClustersMimic->At(i));
3109  else
3110  clus = event->GetCaloCluster(i);
3111  }
3112  if (!clus) continue;
3113  if (!clus->IsEMCAL()) continue;
3114  if (clus->GetM02()<0.1) continue;
3115  if (clus->GetNCells()<2) continue;
3116  if (clus->E() > threshold ){
3117 // cout << "found L1G2" << endl;
3118  eventIsAccepted = kTRUE;
3119  }
3120  }
3121  return eventIsAccepted;
3122  }
3123  return kTRUE;
3124  } else if (fSpecialTrigger == 9 ) {
3125  return kTRUE;
3126  } else {
3127  return kTRUE;
3128  }
3129 
3130  return kTRUE;
3131 }
3132 
3133 
3134 //________________________________________________________________________
3136 {
3137 
3138  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
3139 
3140 
3141  UInt_t isSelected = AliVEvent::kAny;
3142 
3143  if (fInputHandler==NULL) return kFALSE;
3144  if( fInputHandler->GetEventSelection() || event->IsA()==AliAODEvent::Class()) {
3145 
3146  TString firedTrigClass = event->GetFiredTriggerClasses();
3147  // if no trigger has been selected manually, select kAny in case of presel (also important for AOD filtering!)
3148  // in other cases select standards depending on system
3150  if (fPreSelCut) fOfflineTriggerMask = AliVEvent::kAny;
3151  else {
3152  if (fIsHeavyIon == 1){
3153  fOfflineTriggerMask = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
3154  } else if (fIsHeavyIon == 2){
3155  fOfflineTriggerMask = AliVEvent::kINT7;
3156  } else {
3157  fOfflineTriggerMask = AliVEvent::kMB;
3158  }
3159  }
3160  }
3161 
3162  // in case of MC switch to kAny if no MB/INT7/INT8 has been selected
3163  if(isMC){
3164  if( fIsHeavyIon == 0){
3165  if( fOfflineTriggerMask != AliVEvent::kMB && fOfflineTriggerMask != AliVEvent::kINT7 && fOfflineTriggerMask != AliVEvent::kINT8 ){
3166  fOfflineTriggerMask = AliVEvent::kAny;
3167  }
3168  }else{
3169  fOfflineTriggerMask = AliVEvent::kAny;
3170  }
3171  }
3172 
3173  if (fOfflineTriggerMask){
3174  isSelected = fOfflineTriggerMask & fInputHandler->IsEventSelected();
3175  if (isSelected && !fPreSelCut){
3176 // cout << firedTrigClass.Data() << endl;
3177 // cout << "Special trigger: "<< fSpecialTrigger << " initialized " << fEMCALTrigInitialized << endl;
3178 // if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3179 // if (!fEMCALTrigInitialized ) InitializeEMCALTrigger(event);
3180 // fTriggersEMCAL= GetTriggerList();
3181 // }
3182  if (fSpecialSubTrigger>0 && !isMC){
3183  if (!firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 0;
3184  if (fRejectTriggerOverlap){
3185  // trigger rejection EMC1,7,8
3186  if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC7") == 0){
3187  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3188  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC1") == 0){
3189  if (fInputHandler->IsEventSelected() & AliVEvent::kMB) isSelected = 0;
3190  } else if (fSpecialTrigger == 5 && fSpecialSubTriggerName.CompareTo("CEMC8") == 0){
3191  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3192  }
3193  // trigger rejection EGA
3194  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EGA") == 0){
3195  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3196  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3197  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EGA") == 0){
3198  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3199  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3200  }
3201  // trigger rejection EG1 & EG2
3202  if (fPeriodEnum == kLHC13g){
3203  // EG1 is the trigger with the highest threshold
3204  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3205 // cout << firedTrigClass.Data() << endl;
3206  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3207 // cout << "INT7? " << isSelected << endl;
3208  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3209 // cout << "CEM7? " << isSelected << endl;
3210  if (firedTrigClass.Contains("7EG2")) isSelected = 0;
3211 // cout << "7EG2? " << isSelected << endl;
3212  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3213  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3214  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3215  if (firedTrigClass.Contains("8EG2")) isSelected = 0;
3216  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3217 // cout << firedTrigClass.Data() << endl;
3218  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3219 // cout << "INT7? " << isSelected << endl;
3220  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3221 // cout << "CEM7? " << isSelected << endl;
3222  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3223  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3224  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3225  }
3226  } else {
3227  // EG2 is the trigger with the highest threshold
3228  if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG2") == 0){
3229  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3230  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3231  if (firedTrigClass.Contains("7EG1")) isSelected = 0;
3232  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG2") == 0){
3233  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8) isSelected = 0;
3234  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3235  if (firedTrigClass.Contains("8EG1")) isSelected = 0;
3236  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("7EG1") == 0){
3237  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3238  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3239  } else if (fSpecialTrigger == 8 && fSpecialSubTriggerName.CompareTo("8EG1") == 0){
3240  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7) isSelected = 0;
3241  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7) isSelected = 0;
3242  }
3243  }
3244  }
3245  if (isSelected != 0 ){
3246 // cout << "I am here" << " :" << fSpecialSubTriggerName.Data() <<endl;
3247  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9 ){
3249  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassesCorrelated->Fill(0);
3250  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassesCorrelated->Fill(1);
3251  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassesCorrelated->Fill(2);
3252  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassesCorrelated->Fill(3);
3253  if (firedTrigClass.Contains("7EJE") || firedTrigClass.Contains("8EJE")) hTriggerClassesCorrelated->Fill(4);
3254  if (firedTrigClass.Contains("7EJ1") || firedTrigClass.Contains("8EJ1")) hTriggerClassesCorrelated->Fill(5);
3255  if (firedTrigClass.Contains("7EJ2") || firedTrigClass.Contains("8EJ2")) hTriggerClassesCorrelated->Fill(6);
3256  if (firedTrigClass.Contains("7EGA") || firedTrigClass.Contains("8EGA")) hTriggerClassesCorrelated->Fill(7);
3257  if (firedTrigClass.Contains("7EG1") || firedTrigClass.Contains("8EG1")) hTriggerClassesCorrelated->Fill(8);
3258  if (firedTrigClass.Contains("7EG2") || firedTrigClass.Contains("8EG2")) hTriggerClassesCorrelated->Fill(9);
3259  }
3260  }
3261  }
3262 
3263  } else if (isMC){
3264  if (fSpecialTrigger == 5 || fSpecialTrigger == 8 || fSpecialTrigger == 9){ // EMCAL triggers
3265 // isSelected = 0;
3266 // if (fTriggersEMCAL > 0)cout << "Special Trigger " << fSpecialTrigger << " triggers: " << fTriggersEMCAL << " selected triggers: " << fTriggersEMCALSelected << " run number: " <<event->GetRunNumber()<<endl;
3267 // if (fTriggersEMCAL&fTriggersEMCALSelected){
3268 // cout << "accepted ++++++++++++++++++++" << endl;
3269  isSelected = 1;
3270 // }
3271  }
3272  }
3273  //if for specific centrality trigger selection
3274  if(fSpecialSubTrigger == 1){
3275  if(fSpecialSubTriggerName.Contains("|") && GetCentrality(event) <= 10.){
3276  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("|");
3277  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3278  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3279  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3280  }
3281  } else if(fSpecialSubTriggerName.Contains("%")){
3282  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("%");
3283  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3284  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3285  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3286  }
3287  } else if(fSpecialSubTriggerName.Contains("@")){
3288  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("@");
3289  for (Int_t i=0; i<ClassesList->GetEntriesFast();++i){
3290  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3291  if (firedTrigClass.Contains(NameClass->GetString())) isSelected = 1;
3292  }
3293  } else if(fSpecialSubTriggerName.Contains("&")){ //logic AND of two classes
3294  TObjArray *ClassesList = fSpecialSubTriggerName.Tokenize("&");
3295  TString CheckClass = "";
3296  for (Int_t i=0; i<ClassesList->GetEntriesFast(); i++){
3297  TObjString *NameClass = (TObjString*)ClassesList->At(i);
3298  if (firedTrigClass.Contains(NameClass->GetString())) CheckClass+="1";
3299  else CheckClass+="0";
3300  }
3301  if(CheckClass.Contains("0")) isSelected = 0;
3302  }
3303  else if(firedTrigClass.Contains(fSpecialSubTriggerName.Data())) isSelected = 1;
3304  }
3305  }
3306  }
3307  }
3308  fIsSDDFired = !(fInputHandler->IsEventSelected() & AliVEvent::kFastOnly);
3309 
3310  Bool_t mimickedTrigger = kTRUE;
3311  if (fMimicTrigger) mimickedTrigger = MimicTrigger(event, isMC);
3312 // cout << "mimicked decision \t" << mimickedTrigger << "expect decision? "<< fMimicTrigger<< endl;
3313 
3314  // Fill Histogram
3315  if(hTriggerClass){
3316  if (fIsSDDFired) hTriggerClass->Fill(33);
3317  if (mimickedTrigger){
3318  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClass->Fill(0);
3319  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClass->Fill(1);
3320  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClass->Fill(2);
3321  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClass->Fill(3);
3322  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClass->Fill(4);
3323  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClass->Fill(5);
3324  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClass->Fill(6);
3325  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClass->Fill(6);
3326  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClass->Fill(7);
3327  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClass->Fill(7);
3328  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClass->Fill(8);
3329  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClass->Fill(8);
3330  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClass->Fill(9);
3331  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClass->Fill(9);
3332  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClass->Fill(10);
3333  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClass->Fill(10);
3334  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClass->Fill(11);
3335  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClass->Fill(12);
3336  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClass->Fill(13);
3337  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClass->Fill(13);
3338  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClass->Fill(13);
3339  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClass->Fill(14);
3340  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClass->Fill(15);
3341  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClass->Fill(16);
3342  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClass->Fill(17);
3343  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClass->Fill(18);
3344  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClass->Fill(19);
3345  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClass->Fill(20);
3346  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClass->Fill(20);
3347  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClass->Fill(21);
3348  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClass->Fill(22);
3349  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClass->Fill(23);
3350  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClass->Fill(24);
3351  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClass->Fill(25);
3352  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClass->Fill(26);
3353  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClass->Fill(27);
3354  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClass->Fill(28);
3355  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClass->Fill(29);
3356  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClass->Fill(30);
3357  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClass->Fill(31);
3358  if (!fInputHandler->IsEventSelected()) hTriggerClass->Fill(34);
3359  }
3360  if (mimickedTrigger && fMimicTrigger) hTriggerClass->Fill(35);
3361  }
3362 
3363  if(hTriggerClassSelected && isSelected){
3364  if (mimickedTrigger){
3365  if (!fIsSDDFired) hTriggerClassSelected->Fill(33);
3366  if (fInputHandler->IsEventSelected() & AliVEvent::kMB)hTriggerClassSelected->Fill(0);
3367  if (fInputHandler->IsEventSelected() & AliVEvent::kINT7)hTriggerClassSelected->Fill(1);
3368  if (fInputHandler->IsEventSelected() & AliVEvent::kMUON)hTriggerClassSelected->Fill(2);
3369  if (fInputHandler->IsEventSelected() & AliVEvent::kHighMult)hTriggerClassSelected->Fill(3);
3370  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC1)hTriggerClassSelected->Fill(4);
3371  if (fInputHandler->IsEventSelected() & AliVEvent::kCINT5)hTriggerClassSelected->Fill(5);
3372  if (fInputHandler->IsEventSelected() & AliVEvent::kCMUS5)hTriggerClassSelected->Fill(6);
3373  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSPB)hTriggerClassSelected->Fill(6);
3374  if (fInputHandler->IsEventSelected() & AliVEvent::kMUSH7)hTriggerClassSelected->Fill(7);
3375  // if (fInputHandler->IsEventSelected() & AliVEvent::kMUSHPB)hTriggerClassSelected->Fill(7);
3376  if (fInputHandler->IsEventSelected() & AliVEvent::kMUL7)hTriggerClassSelected->Fill(8);
3377  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikePB)hTriggerClassSelected->Fill(8);
3378  if (fInputHandler->IsEventSelected() & AliVEvent::kMUU7)hTriggerClassSelected->Fill(9);
3379  // if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikePB)hTriggerClassSelected->Fill(9);
3380  if (fInputHandler->IsEventSelected() & AliVEvent::kEMC7)hTriggerClassSelected->Fill(10);
3381  // if (fInputHandler->IsEventSelected() & AliVEvent::kEMC8)hTriggerClassSelected->Fill(10);
3382  if (fInputHandler->IsEventSelected() & AliVEvent::kMUS7)hTriggerClassSelected->Fill(11);
3383  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI1)hTriggerClassSelected->Fill(12);
3384  if (fInputHandler->IsEventSelected() & AliVEvent::kPHI7)hTriggerClassSelected->Fill(13);
3385  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHI8)hTriggerClassSelected->Fill(13);
3386  // if (fInputHandler->IsEventSelected() & AliVEvent::kPHOSPb)hTriggerClassSelected->Fill(13);
3387  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE)hTriggerClassSelected->Fill(14);
3388  if (fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA)hTriggerClassSelected->Fill(15);
3389  if (fInputHandler->IsEventSelected() & AliVEvent::kCentral)hTriggerClassSelected->Fill(16);
3390  if (fInputHandler->IsEventSelected() & AliVEvent::kSemiCentral)hTriggerClassSelected->Fill(17);
3391  if (fInputHandler->IsEventSelected() & AliVEvent::kDG5)hTriggerClassSelected->Fill(18);
3392  if (fInputHandler->IsEventSelected() & AliVEvent::kZED)hTriggerClassSelected->Fill(19);
3393  if (fInputHandler->IsEventSelected() & AliVEvent::kSPI7)hTriggerClassSelected->Fill(20);
3394  // if (fInputHandler->IsEventSelected() & AliVEvent::kSPI)hTriggerClassSelected->Fill(20);
3395  if (fInputHandler->IsEventSelected() & AliVEvent::kINT8)hTriggerClassSelected->Fill(21);
3396  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleLowPt8)hTriggerClassSelected->Fill(22);
3397  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonSingleHighPt8)hTriggerClassSelected->Fill(23);
3398  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonLikeLowPt8)hTriggerClassSelected->Fill(24);
3399  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt8)hTriggerClassSelected->Fill(25);
3400  if (fInputHandler->IsEventSelected() & AliVEvent::kMuonUnlikeLowPt0)hTriggerClassSelected->Fill(26);
3401  if (fInputHandler->IsEventSelected() & AliVEvent::kUserDefined)hTriggerClassSelected->Fill(27);
3402  if (fInputHandler->IsEventSelected() & AliVEvent::kTRD)hTriggerClassSelected->Fill(28);
3403  if (fInputHandler->IsEventSelected() & AliVEvent::kFastOnly)hTriggerClassSelected->Fill(29);
3404  if (fInputHandler->IsEventSelected() & AliVEvent::kAnyINT)hTriggerClassSelected->Fill(30);
3405  if (fInputHandler->IsEventSelected() & AliVEvent::kAny)hTriggerClassSelected->Fill(31);
3406  }
3407  if (mimickedTrigger && fMimicTrigger) hTriggerClassSelected->Fill(34);
3408  }
3409 
3410  if(!isSelected)return kFALSE;
3411  if (fMimicTrigger)
3412  if (!mimickedTrigger ) return kFALSE;
3413  return kTRUE;
3414 
3415 }
3416 
3417 //________________________________________________________________________
3419  // returns TString with current cut number
3420  return fCutStringRead;
3421 }
3422 
3423 //________________________________________________________________________
3424 void AliConvEventCuts::GetNotRejectedParticles(Int_t rejection, TList *HeaderList, AliVEvent *event){
3425 
3426  if(fNotRejectedStart){
3427  delete[] fNotRejectedStart;
3428  fNotRejectedStart = NULL;
3429  }
3430  if(fNotRejectedEnd){
3431  delete[] fNotRejectedEnd;
3432  fNotRejectedEnd = NULL;
3433  }
3434  if(fGeneratorNames){
3435  delete[] fGeneratorNames;
3436  fGeneratorNames = NULL;
3437  }
3438 
3439  if(rejection == 0) return; // No Rejection
3440 
3441  AliGenCocktailEventHeader *cHeader = 0x0;
3442  AliAODMCHeader *cHeaderAOD = 0x0;
3443  Bool_t headerFound = kFALSE;
3444  AliMCEvent *fMCEvent = 0x0;
3445  TClonesArray *fMCEventAOD = 0x0;
3446  if(event->IsA()==AliMCEvent::Class()){
3447  if(dynamic_cast<AliMCEvent*>(event)){
3448  cHeader = dynamic_cast<AliGenCocktailEventHeader*>(dynamic_cast<AliMCEvent*>(event)->GenEventHeader());
3449  fMCEvent = dynamic_cast<AliMCEvent*>(event);
3450  if(cHeader) headerFound = kTRUE;
3451  }
3452  }
3453  if(event->IsA()==AliAODEvent::Class()){ // event is a AODEvent in case of AOD
3454  cHeaderAOD = dynamic_cast<AliAODMCHeader*>(event->FindListObject(AliAODMCHeader::StdBranchName()));
3455  fMCEventAOD = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
3456  if(cHeaderAOD) headerFound = kTRUE;
3457  }
3458 
3459  if (fDebugLevel > 0 ) cout << "event starts here" << endl;
3460  if(headerFound){
3461  TList *genHeaders = 0x0;
3462  if(cHeader) genHeaders = cHeader->GetHeaders();
3463  if(cHeaderAOD){
3464  genHeaders = cHeaderAOD->GetCocktailHeaders();
3465  if(genHeaders->GetEntries()==1){
3467  return;
3468  }
3469  }
3470  AliGenEventHeader* gh = 0;
3471  fnHeaders = 0;
3472  Int_t firstindexA = 0;
3473  Int_t lastindexA = -1;
3474  if(rejection == 1 || rejection == 3) fnHeaders = 1; // MinBiasHeader
3475  if(rejection == 2){ // TList of Headers Names
3476  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3477  gh = (AliGenEventHeader*)genHeaders->At(i);
3478  TString GeneratorName = gh->GetName();
3479  lastindexA = lastindexA + gh->NProduced();
3480 // if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
3481  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
3482  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
3483 // if (fDebugLevel > 0 ) cout << GeneratorInList.Data() << endl;
3484  if(GeneratorName.CompareTo(GeneratorInList) == 0){
3485 // if (fDebugLevel > 0 ) cout << "accepted" << endl;
3486  if (GeneratorInList.CompareTo("PARAM") == 0 || GeneratorInList.CompareTo("BOX") == 0 ){
3487  if(fMCEvent){
3488  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
3489  if (fMCEvent->Particle(firstindexA)->GetPdgCode() == fAddedSignalPDGCode ) {
3490  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindexA+10)->GetPdgCode() == fAddedSignalPDGCode ){
3491 // if (fDebugLevel > 0 ) cout << "cond 1: "<< fnHeaders << endl;
3492  fnHeaders++;
3493  continue;
3494  }
3495  continue;
3496  }
3497  } else {
3498 // if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
3499  fnHeaders++;
3500  continue;
3501  }
3502  }
3503  if ( fMCEventAOD){
3504  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA));
3505  if (aodMCParticle && (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c) ){
3506  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
3507  if (gh->NProduced() > 10){
3508  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindexA+10));
3509  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
3510 // if (fDebugLevel > 0 ) cout << "cond 1: " << fnHeaders << endl;
3511  fnHeaders++;
3512  continue;
3513  }
3514  }
3515  continue;
3516  }
3517  } else {
3518 // if (fDebugLevel > 0 ) cout << "cond 2: " << fnHeaders << endl;
3519  fnHeaders++;
3520  continue;
3521  }
3522  }
3523  continue;
3524  }
3525 // if (fDebugLevel > 0 ) cout << "cond 3: "<< fnHeaders << endl;
3526  fnHeaders++;
3527  continue;
3528  }
3529  }
3530  firstindexA = firstindexA + gh->NProduced();
3531  }
3532  }
3533  if (fDebugLevel > 0 ) cout << "number of headers: " <<fnHeaders << endl;
3534 
3538 
3539  if(rejection == 1 || rejection == 3){
3540  fNotRejectedStart[0] = 0;
3541  fNotRejectedEnd[0] = ((AliGenEventHeader*)genHeaders->At(0))->NProduced()-1;
3542  fGeneratorNames[0] = ((AliGenEventHeader*)genHeaders->At(0))->GetName();
3543  if (fDebugLevel > 0 ) cout << 0 << "\t" <<fGeneratorNames[0] << "\t" << fNotRejectedStart[0] << "\t" <<fNotRejectedEnd[0] << endl;
3544  return;
3545  }
3546 
3547  Int_t firstindex = 0;
3548  Int_t lastindex = -1;
3549  Int_t number = 0;
3550 
3551  for(Int_t i = 0; i<genHeaders->GetEntries();i++){
3552  gh = (AliGenEventHeader*)genHeaders->At(i);
3553  TString GeneratorName = gh->GetName();
3554  lastindex = lastindex + gh->NProduced();
3555  if (fDebugLevel > 0 ) cout << i << "\t" << GeneratorName.Data() << endl;
3556  for(Int_t j = 0; j<HeaderList->GetEntries();j++){
3557  TString GeneratorInList = ((TObjString*)HeaderList->At(j))->GetString();
3558  if(GeneratorName.CompareTo(GeneratorInList) == 0){
3559  if (GeneratorInList.CompareTo("PARAM") == 0 || GeneratorInList.CompareTo("BOX") == 0 ){
3560  if(fMCEvent){
3561  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
3562  if (fMCEvent->Particle(firstindex)->GetPdgCode() == fAddedSignalPDGCode ) {
3563 // if (fDebugLevel > 0 ) cout << "produced " << gh->NProduced() << " with box generator" << endl;
3564  if (gh->NProduced() > 10 && fMCEvent->Particle(firstindex+10)->GetPdgCode() == fAddedSignalPDGCode){
3565 // if (fDebugLevel > 0 ) cout << "one of them was a pi0 or eta" << endl;
3566  fNotRejectedStart[number] = firstindex;
3567  fNotRejectedEnd[number] = lastindex;
3568  fGeneratorNames[number] = GeneratorName;
3569  number++;
3570 // if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3571  continue;
3572  }
3573  }
3574  } else {
3575  fNotRejectedStart[number] = firstindex;
3576  fNotRejectedEnd[number] = lastindex;
3577  fGeneratorNames[number] = GeneratorName;
3578  number++;
3579  continue;
3580  }
3581  }
3582  if ( fMCEventAOD){
3583  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex));
3584  if (fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c ){
3585  if ( aodMCParticle->GetPdgCode() == fAddedSignalPDGCode ){
3586  if (gh->NProduced() > 10) {
3587  AliAODMCParticle *aodMCParticle2 = static_cast<AliAODMCParticle*>(fMCEventAOD->At(firstindex+10));
3588  if ( aodMCParticle2->GetPdgCode() == fAddedSignalPDGCode ){
3589  fNotRejectedEnd[number] = lastindex;
3590  fNotRejectedStart[number] = firstindex;
3591  fGeneratorNames[number] = GeneratorName;
3592  number++;
3593  }
3594  continue;
3595  }
3596  }
3597  } else {
3598  fNotRejectedStart[number] = firstindex;
3599  fNotRejectedEnd[number] = lastindex;
3600  fGeneratorNames[number] = GeneratorName;
3601  number++;
3602  continue;
3603  }
3604  }
3605  continue;
3606  } else {
3607  fNotRejectedStart[number] = firstindex;
3608  fNotRejectedEnd[number] = lastindex;
3609  fGeneratorNames[number] = GeneratorName;
3610 // if (fDebugLevel > 0 ) cout << "Number of particles produced for: " << i << "\t" << GeneratorName.Data() << "\t" << lastindex-firstindex+1 << endl;
3611  number++;
3612  continue;
3613  }
3614 
3615  }
3616  }
3617  firstindex = firstindex + gh->NProduced();
3618  }
3619  if (fDebugLevel > 0 ) {
3620  for (Int_t i = 0; i < number; i++){
3621  cout << i << "\t" <<fGeneratorNames[i] << "\t" << fNotRejectedStart[i] << "\t" <<fNotRejectedEnd[i] << endl;
3622  }
3623  }
3624  } else { // No Cocktail Header Found
3625  fNotRejectedStart = new Int_t[1];
3626  fNotRejectedEnd = new Int_t[1];
3627 
3628  fnHeaders = 1;
3629  fNotRejectedStart[0] = 0;
3630  fNotRejectedEnd[0] = static_cast<AliMCEvent*>(event)->GetNumberOfPrimaries()-1;
3631  if (rejection > 1){
3632  fNotRejectedStart[0] = -1;
3633  fNotRejectedEnd[0] = -1;
3634  }
3635 
3636  fGeneratorNames = new TString[1];
3637  fGeneratorNames[0] = "NoCocktailGeneratorFound";
3638 // SetRejectExtraSignalsCut(0);
3639  }
3640 
3641 }
3642 
3643 //_________________________________________________________________________
3644 Int_t AliConvEventCuts::IsParticleFromBGEvent(Int_t index, AliMCEvent *mcEvent, AliVEvent *InputEvent, Int_t debug ){
3645 
3646  // if (debug > 2 ) cout << index << endl;
3647  if(index < 0) return 0; // No Particle
3648 
3649  Int_t accepted = 0;
3650  if(!InputEvent || InputEvent->IsA()==AliESDEvent::Class()){
3651  if(!mcEvent) return 0; // no mcEvent available, return 0
3652  if(index >= mcEvent->GetNumberOfPrimaries()){ // initial particle is secondary particle
3653  if( ((TParticle*)mcEvent->Particle(index))->GetMother(0) < 0) return 0; // material particle, return 0
3654  return IsParticleFromBGEvent(((TParticle*)mcEvent->Particle(index))->GetMother(0),mcEvent,InputEvent, debug);
3655  }
3656  for(Int_t i = 0;i<fnHeaders;i++){
3657  // if (debug > 2 ) cout << "header " << fGeneratorNames[i].Data() << ":"<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
3658  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
3659  if (debug > 1 ) cout << "accepted:" << index << "\t header " << fGeneratorNames[i].Data() << ": "<< fNotRejectedStart[i] << "\t" << fNotRejectedEnd[i] << endl;
3660  accepted = 1;
3661  if(i == 0) accepted = 2; // MB Header
3662  }
3663  }
3664  if (debug > 1 && !accepted) cout << "rejected:" << index << endl;
3665  }
3666  else if(InputEvent->IsA()==AliAODEvent::Class()){
3667  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(InputEvent->FindListObject(AliAODMCParticle::StdBranchName()));
3668  if (AODMCTrackArray){
3669  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
3670  if(!aodMCParticle) return 0; // no particle
3671  if(!aodMCParticle->IsPrimary()){
3672  if( aodMCParticle->GetMother() < 0) return 0;// material particle, return 0
3673  return IsParticleFromBGEvent(aodMCParticle->GetMother(),mcEvent,InputEvent, debug);
3674  }
3675  index = TMath::Abs(static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index))->GetLabel());
3676  for(Int_t i = 0;i<fnHeaders;i++){
3677  if(index >= fNotRejectedStart[i] && index <= fNotRejectedEnd[i]){
3678  accepted = 1;
3679  if(i == 0) accepted = 2; // MB Header
3680  }
3681  }
3682  }
3683  }
3684 
3685  return accepted;
3686 }
3687 
3688 //_________________________________________________________________________
3689 Int_t AliConvEventCuts::IsEventAcceptedByCut(AliConvEventCuts *ReaderCuts, AliVEvent *event, AliMCEvent *mcEvent, Int_t isHeavyIon, Bool_t isEMCALAnalysis){
3690 
3691  Bool_t isMC = kFALSE;
3692  if (mcEvent){isMC = kTRUE;}
3693 
3694  if ( !IsTriggerSelected(event, isMC) )
3695  return 3;
3696 
3697  if( !(IsCentralitySelected(event,mcEvent)))
3698  return 1; // Check Centrality --> Not Accepted => eventQuality = 1
3699 
3700  Bool_t hasV0And = ReaderCuts->HasV0AND();
3701  Bool_t isSDDFired = ReaderCuts->IsSDDFired();
3702 
3703  if( ( (IsSpecialTrigger() == 0 && IsSpecialSubTrigger() == 1) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !isSDDFired && !mcEvent)
3704  //if V0OR with SDD requested or V0AND with SDD request but the SDD has not fired
3705  return 7; // V0 with SDD requested but no fired
3706 
3707  if( ( (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 0) || (IsSpecialTrigger() == 1 && IsSpecialSubTrigger() == 1) ) && !hasV0And)
3708  //if V0AND (only) or V0AND with SDD requested but V0AND requested but no fired
3709  return 8; // V0AND requested but no fired
3710 
3711 
3712  if( (IsSpecialTrigger() == 2 || IsSpecialTrigger() == 3) && !isSDDFired && !mcEvent)
3713  return 7; // With SDD requested but no fired
3714 
3715  if( (IsSpecialTrigger() == 1 || IsSpecialTrigger() == 3) && !hasV0And)
3716  return 8; // V0AND requested but no fired
3717 
3718  // Special EMCAL checks due to hardware issues in LHC11a
3719  if (isEMCALAnalysis || IsSpecialTrigger() == 5 || IsSpecialTrigger() == 8 || IsSpecialTrigger() == 9 ){
3720  Int_t runnumber = event->GetRunNumber();
3721  if ((runnumber>=144871) && (runnumber<=146860)) {
3722 
3723  AliVCaloCells *cells = event->GetEMCALCells();
3724  const Short_t nCells = cells->GetNumberOfCells();
3725 
3726  if (event->IsA()==AliESDEvent::Class()) AliAnalysisManager::GetAnalysisManager()->LoadBranch("EMCALCells.");
3727 
3728  AliInputEventHandler *fInputHandler=(AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler());
3729  if (!fInputHandler) return 3;
3730 
3731  // count cells above threshold
3732  Int_t nCellCount[12] = {0,0,0,0,0,0,0,0,0,0,0,0};
3733  for(Int_t iCell=0; iCell<nCells; ++iCell) {
3734  Short_t cellId = cells->GetCellNumber(iCell);
3735  Double_t cellE = cells->GetCellAmplitude(cellId);
3736  Int_t sm = cellId / (24*48);
3737  if (cellE>0.1) ++nCellCount[sm];
3738  }
3739 
3740  Bool_t fIsLedEvent = kFALSE;
3741  if (nCellCount[4] > 100) {
3742  fIsLedEvent = kTRUE;
3743  } else {
3744  if ((runnumber>=146858) && (runnumber<=146860)) {
3745  if ((fInputHandler->IsEventSelected() & AliVEvent::kMB) && (nCellCount[3]>=21))
3746  fIsLedEvent = kTRUE;
3747  else if ((fInputHandler->IsEventSelected() & AliVEvent::kEMC1) && (nCellCount[3]>=35))
3748  fIsLedEvent = kTRUE;
3749  }
3750  }
3751  if (fIsLedEvent) {
3752  return 9;
3753  }
3754  }
3755  }
3756 
3757  // SPD clusters vs tracklets to check for pileup/background
3758  Int_t nClustersLayer0 = event->GetNumberOfITSClusters(0);
3759  Int_t nClustersLayer1 = event->GetNumberOfITSClusters(1);
3760  Int_t nTracklets = event->GetMultiplicity()->GetNumberOfTracklets();
3761  if(hSPDClusterTrackletBackgroundBefore) hSPDClusterTrackletBackgroundBefore->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
3762 
3763 
3764  Double_t distZMax = 0;
3765  if(event->IsA()==AliESDEvent::Class()){
3766  Int_t nPileVert = ((AliESDEvent*)event)->GetNumberOfPileupVerticesSPD();
3767  if (hNPileupVertices) hNPileupVertices->Fill(nPileVert);
3768  if (nPileVert > 0){
3769  for(Int_t i=0; i<nPileVert;i++){
3770  const AliESDVertex* pv= ((AliESDEvent*)event)->GetPileupVertexSPD(i);
3771  Int_t nc2 = pv->GetNContributors();
3772  if(nc2>=3){
3773  Double_t z1 = ((AliESDEvent*)event)->GetPrimaryVertexSPD()->GetZ();
3774  Double_t z2 = pv->GetZ();
3775  Double_t distZ = z2-z1;
3776  if (TMath::Abs(distZMax) < TMath::Abs(distZ) ){
3777  distZMax = distZ;
3778  }
3779  }
3780  }
3781  if (hPileupVertexToPrimZ) hPileupVertexToPrimZ->Fill(distZMax);
3782  }
3783  }
3784  if(GetPastFutureLowBC()!=0 && GetPastFutureHighBC()!=0 ){
3785  if(IsOutOfBunchPileupPastFuture(event))
3786  return 12;
3787  }
3788 
3789  if( isHeavyIon != 2 && GetIsFromPileup()){
3790  if(event->IsPileupFromSPD(3,0.8,3.,2.,5.) ){
3792  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
3793  }
3794  if (fUtils->IsSPDClusterVsTrackletBG(event)){
3796  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
3797  }
3798  }
3799  if(isHeavyIon == 2 && GetIsFromPileup()){
3800  if(fUtils->IsPileUpEvent(event) ){
3802  return 6; // Check Pileup --> Not Accepted => eventQuality = 6
3803  }
3804  if (fUtils->IsSPDClusterVsTrackletBG(event)){
3806  return 11; // Check Pileup --> Not Accepted => eventQuality = 11
3807  }
3808  }
3809 
3811  if( IsPileUpV0MTPCout(event) ){
3812  return 13;
3813  }
3814  }
3815 
3816  if(hCentrality)hCentrality->Fill(GetCentrality(event));
3817 
3818  if(hVertexZ)hVertexZ->Fill(event->GetPrimaryVertex()->GetZ());
3819 // if(hCentralityVsNumberOfPrimaryTracks)
3820 // hCentralityVsNumberOfPrimaryTracks->Fill(GetCentrality(event),
3821 // ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()
3822 // ->GetTask(fV0ReaderName.Data()))->GetNumberOfPrimaryTracks());
3823 
3824  if(fIsHeavyIon == 1){
3825  AliEventplane *EventPlane = event->GetEventplane();
3826  fEventPlaneAngle = EventPlane->GetEventplane("V0",event,2);
3827  if(hEventPlaneAngle)hEventPlaneAngle->Fill(TMath::Abs(fEventPlaneAngle));
3828  }
3829  if(hSPDClusterTrackletBackground) hSPDClusterTrackletBackground->Fill(nTracklets, (nClustersLayer0 + nClustersLayer1));
3830 
3831  return 0;
3832 }
3833 
3834 
3835 //_________________________________________________________________________
3837 
3838  AliInfo("Inside the GetWeightForCentralityFlattening function");
3839  Double_t centrality = 0.;
3840  //obtain centrality for ESD or AOD
3841  if(!event || event->IsA()==AliESDEvent::Class()){
3842  AliESDEvent *esdEvent=dynamic_cast<AliESDEvent*>(event);
3843  if(esdEvent){
3844  AliCentrality *fESDCentrality=(AliCentrality*)esdEvent->GetCentrality();
3845  if(fDetectorCentrality==0 && fIsHeavyIon==1){
3846  centrality = fESDCentrality->GetCentralityPercentile("V0M"); // default for PbPb
3847  }
3848  }
3849  } else if(event->IsA()==AliAODEvent::Class()){
3850  AliAODEvent *aodEvent=dynamic_cast<AliAODEvent*>(event);
3851  if(aodEvent){
3852  if(aodEvent->GetHeader()){
3853  centrality = ((AliVAODHeader*)aodEvent->GetHeader())->GetCentrality();
3854  }
3855  }
3856  }
3857 
3858  //Get the maximum vlaue from the reference distribution and interpolated value
3859  Float_t GetValueForWeight = 1.;
3860  Float_t maximum = 1.;
3861  Double_t weightCentrality = 1.;
3862  Bool_t CorrCentrLoop = kFALSE;
3863 
3864  //depending on the value of the flag, flattening in different cent. range
3865  if ( fDoCentralityFlat == 1 && (centrality >= 0. && centrality <= 20.) ){
3866  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
3867  maximum = hCentralityNotFlat->GetMaximum();
3868  CorrCentrLoop = kTRUE;
3869  } else if ( fDoCentralityFlat == 8 ){
3870  GetValueForWeight = hCentralityNotFlat->Interpolate(centrality);
3871  maximum = hCentralityNotFlat->GetMaximum();
3872  CorrCentrLoop = kTRUE;
3873  } else {
3874  CorrCentrLoop = kFALSE;
3875  }
3876 
3877  if (CorrCentrLoop && GetValueForWeight != 0. && maximum !=0. && isfinite(GetValueForWeight) && isfinite(maximum) ){
3878  weightCentrality = maximum/GetValueForWeight;
3879  if (!isfinite(GetValueForWeight)) weightCentrality = 1.;
3880  if (!isfinite(weightCentrality)) weightCentrality = 1.;
3881  }
3882 
3883  return weightCentrality;
3884 }
3885 
3886 //_________________________________________________________________________
3888 
3889  Double_t weightMult = 1.;
3890 
3891  Float_t valueMultData = -1.;
3892  Float_t valueMultMC = -1.;
3893 
3894  if (hReweightMultData == NULL || hReweightMultMC == NULL ) return weightMult;
3895 
3896  valueMultData = hReweightMultData->Interpolate(mult);
3897  valueMultMC = hReweightMultMC->Interpolate(mult);
3898 
3899  Float_t relativeErrorMC = hReweightMultMC->GetBinError(hReweightMultMC->FindBin(mult))/hReweightMultMC->GetBinContent(hReweightMultMC->FindBin(mult));
3900  Float_t relativeErrorData = hReweightMultData->GetBinError(hReweightMultData->FindBin(mult))/hReweightMultData->GetBinContent(hReweightMultData->FindBin(mult));
3901 
3902  if (relativeErrorData < 0.2 && relativeErrorMC < 0.2 ){
3903  if (isfinite(valueMultData) && isfinite(valueMultMC) ){
3904  weightMult = valueMultData/valueMultMC;
3905  }
3906  }
3907 
3908  return weightMult;
3909 }
3910 
3911 
3912 
3913 //_________________________________________________________________________
3914 Float_t AliConvEventCuts::GetWeightForMeson(Int_t index, AliMCEvent *mcEvent, AliVEvent *event){
3915  if (!( fPeriodEnum == kLHC13d2 || fPeriodEnum == kLHC13d2b || // LHC10h MCs
3916  fPeriodEnum == kLHC14a1a || fPeriodEnum == kLHC14a1b || fPeriodEnum == kLHC14a1c || // LHC11h MCs
3917  fPeriodEnum == kLHC13e7 || fPeriodEnum == kLHC13b2_efix || fPeriodEnum == kLHC14b2 || // LHC13bc MCs
3918  fPeriodEnum == kLHC14e2a || fPeriodEnum == kLHC14e2b || fPeriodEnum == kLHC14e2c || // LHC12[a-i] pass 1 MCs
3919  fPeriodEnum == kLHC12f1a || fPeriodEnum == kLHC12f1b || fPeriodEnum == kLHC12i3 // LHC11a MCs
3920  ) ) return 1.;
3921  Int_t kCaseGen = 0;
3922 
3923  if(index < 0) return 0; // No Particle
3924 
3925  if (IsParticleFromBGEvent(index, mcEvent, event)){
3928  kCaseGen = 1;
3929  }
3930  }
3931  if (kCaseGen == 0) return 1;
3932 
3933  Double_t mesonPt = 0;
3934  //Double_t mesonMass = 0;
3935  Int_t PDGCode = 0;
3936  if(!event || event->IsA()==AliESDEvent::Class()){
3937  mesonPt = ((TParticle*)mcEvent->Particle(index))->Pt();
3938  //mesonMass = ((TParticle*)mcEvent->Particle(index))->GetCalcMass();
3939  PDGCode = ((TParticle*)mcEvent->Particle(index))->GetPdgCode();
3940  } else if(event->IsA()==AliAODEvent::Class()){
3941  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
3942  if (AODMCTrackArray){
3943  AliAODMCParticle *aodMCParticle = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(index));
3944  mesonPt = aodMCParticle->Pt();
3945  //mesonMass = aodMCParticle->GetCalcMass();
3946  PDGCode = aodMCParticle->GetPdgCode();
3947  } else {
3948  return 1;
3949  }
3950  }
3951 
3952  Float_t functionResultMC = 1.;
3953  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0){
3954  functionResultMC = hReweightMCHistPi0->Interpolate(mesonPt);
3955  }
3956  if ( PDGCode == 221 && fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0){
3957  functionResultMC = hReweightMCHistEta->Interpolate(mesonPt);
3958  }
3959  if ( PDGCode == 310 && fDoReweightHistoMCK0s && hReweightMCHistK0s!= 0x0){
3960  functionResultMC = hReweightMCHistK0s->Interpolate(mesonPt);
3961  }
3962 
3963  Float_t functionResultData = 1;
3964  if ( PDGCode == 111 && fDoReweightHistoMCPi0 && fFitDataPi0!= 0x0){
3965  functionResultData = fFitDataPi0->Eval(mesonPt);
3966  }
3967  if ( PDGCode == 221 && fDoReweightHistoMCEta && fFitDataEta!= 0x0){
3968  functionResultData = fFitDataEta->Eval(mesonPt);
3969  }
3970  if ( PDGCode == 310 && fDoReweightHistoMCK0s && fFitDataK0s!= 0x0){
3971  functionResultData = fFitDataK0s->Eval(mesonPt);
3972  }
3973 
3974  Double_t weight = 1;
3975  if (PDGCode == 111 || PDGCode == 221){
3976  if (functionResultData != 0. && functionResultMC != 0. && isfinite(functionResultData) && isfinite(functionResultMC)){
3977  weight = functionResultData/functionResultMC;
3978  if ( kCaseGen == 3){
3979  if (PDGCode == 111){
3980  if (!(fDoReweightHistoMCPi0 && hReweightMCHistPi0!= 0x0 && PDGCode == 111)){
3981  weight = 1.;
3982  }
3983  }
3984  if (PDGCode == 221){
3985  if (!(fDoReweightHistoMCEta && hReweightMCHistEta!= 0x0 && PDGCode == 221)){
3986  weight = 1.;
3987  }
3988  }
3989  }
3990  if (!isfinite(functionResultData)) weight = 1.;
3991  if (!isfinite(weight)) weight = 1.;
3992  }
3993  } else if (PDGCode == 310 && functionResultMC != 0 && isfinite(functionResultMC)){
3994  weight = functionResultMC;
3995  }
3996  return weight;
3997 }
3998 
3999 
4002 
4003  if( fPeriodEnum == kLHC13bc || // mainly minimum bias
4004  fPeriodEnum == kLHC13de || // mainly triggered
4005  fPeriodEnum == kLHC13b4_fix || fPeriodEnum == kLHC13b4_plus || // MC Pythia 6 (Jet-Jet), anchor LHC13b-e
4006  fPeriodEnum == kLHC13b2_efix || //MC DPMJET, anchr LHC13b+c
4007  fPeriodEnum == kLHC13e7 || //MC HIJING, anchr LHC13b+c
4008  fPeriodEnum == kLHC14b2 //MC HIJING, anchr LHC13b+c
4009  ){
4010  printf(" Gamma Conversion Cuts %s :: pPb Run doing Eta Shift of %f \n\n",(GetCutNumber()).Data(),-0.465);
4011  SetEtaShift(-0.465);
4012  } else if( fPeriodEnum == kLHC13f ) {
4013  printf(" Gamma Conversion Cuts %s :: Pbp Run doing Eta Shift of %f \n\n",(GetCutNumber()).Data(),0.465);
4014  SetEtaShift(+0.465);
4015  }
4016  else printf(" Gamma Conversion Cuts %s :: Automatic Eta Shift requested but Period is not known -> No Shift \n\n",(GetCutNumber()).Data());
4017 }
4018 
4019 //________________________________________________________________________
4020 AliEMCALTriggerPatchInfo* AliConvEventCuts::GetMainTriggerPatch()
4021 {
4022  //get main trigger match; if not known yet, look for it and cache
4023 
4025  return fMainTriggerPatchEMCAL;
4026 
4027  if (!fTriggerPatchInfo) {
4028  AliError(Form("%s: fTriggerPatchInfo not available",GetName()));
4029  return 0;
4030  }
4031 
4032  //number of patches in event
4033  Int_t nPatch = fTriggerPatchInfo->GetEntries();
4034 
4035  //extract main trigger patch
4036  AliEMCALTriggerPatchInfo *patch;
4037  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
4038  patch = (AliEMCALTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
4039  if (patch->IsMainTrigger()) {
4040  fMainTriggerPatchEMCAL = patch;
4041  break;
4042  }
4043  }
4044 
4045  return fMainTriggerPatchEMCAL;
4046 }
4047 
4048 
4049 //________________________________________________________________________
4051 {
4052 // cout << "entered EMCAL trigger initialization" << endl;
4053 
4054  // Init the analysis.
4055  if (fCaloTriggersName.IsNull()){
4056  if (event->IsA()==AliESDEvent::Class()){
4057  fCaloTriggersName = "EMCALTrigger";
4058  } else {
4059  fCaloTriggersName = "emcalTrigger";
4060  }
4061  }
4062 
4063  if (!fCaloTriggersName.IsNull() && !fCaloTriggers) {
4064  fCaloTriggers = dynamic_cast<AliVCaloTrigger*>(event->FindListObject(fCaloTriggersName));
4065  if (!fCaloTriggers) {
4066  AliError(Form("%s: Could not retrieve calo triggers %s!", GetName(), fCaloTriggersName.Data()));
4067  return;
4068  }
4069  }
4070 
4071  if (fCaloTriggerPatchInfoName.IsNull()){
4072  if (event->IsA()==AliESDEvent::Class()){
4073  fCaloTriggerPatchInfoName = "EmcalTriggers";
4074  } else {
4075  fCaloTriggerPatchInfoName = "EmcalTriggers";
4076  }
4077  }
4078 
4079  if (!fCaloTriggerPatchInfoName.IsNull() && !fTriggerPatchInfo) {
4080  fTriggerPatchInfo = GetArrayFromEvent(event, fCaloTriggerPatchInfoName.Data(), "AliEMCALTriggerPatchInfo");
4081  if (!fTriggerPatchInfo) {
4082  AliError(Form("%s: Could not retrieve calo trigger patch info %s!", GetName(), fCaloTriggerPatchInfoName.Data()));
4083  return;
4084  }
4085 
4086  }
4087 
4088  fEMCALTrigInitialized = kTRUE;
4089 }
4090 
4091 //________________________________________________________________________
4093  if (!fTriggerPatchInfo)
4094  return 0;
4095  //number of patches in event
4096  Int_t nPatch = fTriggerPatchInfo->GetEntries();
4097 
4098  //loop over patches to define trigger type of event
4099  Int_t nG1 = 0;
4100  Int_t nG2 = 0;
4101  Int_t nJ1 = 0;
4102  Int_t nJ2 = 0;
4103  Int_t nL0 = 0;
4104  AliEMCALTriggerPatchInfo *patch;
4105 // if (nPatch> 0) {cout << "NEW Triggers in this event*********************************" << endl;}
4106  for (Int_t iPatch = 0; iPatch < nPatch; iPatch++) {
4107  patch = (AliEMCALTriggerPatchInfo*)fTriggerPatchInfo->At( iPatch );
4108 // cout << "Patch energy: "<<patch->GetPatchE() << "\t ADC counts: " << patch->GetADCAmp() << endl;
4109 // cout << "Phi: " << patch->GetPhiMin() << " - " << patch->GetPhiMax() << " delta phi: " <<TMath::Abs(patch->GetPhiMin()-patch->GetPhiMax())<< endl;
4110 // cout << "Eta: " << patch->GetEtaMin() << " - " << patch->GetEtaMax() << " delta eta: " <<TMath::Abs(patch->GetEtaMin()-patch->GetEtaMax())<< endl;
4111  if (patch->IsGammaHigh()){
4112 // cout << "fired L1GA high" << endl;
4113  nG1++;
4114  }
4115  if (patch->IsGammaLow()){
4116 // cout << "fired L1GA low" << endl;
4117  nG2++;
4118  }
4119  if (patch->IsJetHigh()){
4120 // cout << "fired L1JE high" << endl;
4121  nJ1++;
4122  }
4123  if (patch->IsJetLow()){
4124 // cout << "fired L1JE low" << endl;
4125  nJ2++;
4126  }
4127  if (patch->IsLevel0()){
4128 // cout << "fired L0" << endl;
4129  nL0++;
4130  }
4131 // cout << patch->GetPatchE() << "\t" << patch->GetADCAmp() << "\t" << patch->IsGammaHigh() << "\t" << patch->IsGammaLow()
4132 // << "\t" << patch->IsJetHigh() << "\t" << patch->IsJetLow() << "\t" << patch->IsLevel0()
4133 // << "\t" << patch->GetPhiMin() << "\t" << patch->GetPhiMax() << "\t" << TMath::Abs(patch->GetPhiMin()-patch->GetPhiMax())
4134 // << "\t" << patch->GetEtaMin() << "\t" << patch->GetEtaMax() << "\t" << TMath::Abs(patch->GetEtaMin()-patch->GetEtaMax()) << endl;
4135  }
4136 
4137  if (nPatch > 0){
4138  AliDebug(2, "Patch summary: ");
4139  AliDebug(2, Form("Number of patches: %d", nPatch));
4140  AliDebug(2, Form("Level0: [%d]" ,nL0));
4141  AliDebug(2, Form("Jet: low[%d], high[%d]" ,nJ2, nJ1));
4142  AliDebug(2, Form("Gamma: low[%d], high[%d]" ,nG2, nG1));
4143  }
4144 
4145 // if (nPatch > 0){
4146 // cout << Form("Number of patches: %d", nPatch) << endl;
4147 // cout << Form("Level0: [%d]" ,nL0) << endl;
4148 // cout << Form("Jet: low[%d], high[%d]" ,nJ2, nJ1) << endl;
4149 // cout << Form("Gamma: low[%d], high[%d]" ,nG2, nG1) << endl;
4150 // }
4151 
4152  ULong_t triggers(0);
4153  if (nG1>0)
4154  SETBIT(triggers, kG1);
4155  if (nG2>0)
4156  SETBIT(triggers, kG2);
4157  if (nJ1>0)
4158  SETBIT(triggers, kJ1);
4159  if (nJ2>0)
4160  SETBIT(triggers, kJ2);
4161  if (nL0>0)
4162  SETBIT(triggers, kL0);
4163  return triggers;
4164 }
4165 
4166 //________________________________________________________________________
4168  // Check if event has a given trigger type
4169  if(t == kND){
4170  return fTriggersEMCAL == 0;
4171  }
4172  return TESTBIT(fTriggersEMCAL, int(t));
4173 }
4174 
4175 
4176 //________________________________________________________________________
4177 TClonesArray *AliConvEventCuts::GetArrayFromEvent(AliVEvent* event, const char *name, const char *clname)
4178 {
4179  // Get array from event.
4180 
4181  TClonesArray *arr = 0;
4182  TString sname(name);
4183  if (!sname.IsNull()) {
4184  arr = dynamic_cast<TClonesArray*>(event->FindListObject(sname));
4185  if (!arr) {
4186  AliWarning(Form("%s: Could not retrieve array with name %s!", GetName(), name));
4187  return 0;
4188  }
4189  } else {
4190  return 0;
4191  }
4192 
4193  if (!clname)
4194  return arr;
4195 
4196  TString objname(arr->GetClass()->GetName());
4197  TClass cls(objname);
4198  if (!cls.InheritsFrom(clname)) {
4199  AliWarning(Form("%s: Objects of type %s in %s are not inherited from %s!",
4200  GetName(), cls.GetName(), name, clname));
4201  return 0;
4202  }
4203  return arr;
4204 }
4205 
4206 //_________________________________________________________________________
4207 Bool_t AliConvEventCuts::IsConversionPrimaryESD( AliMCEvent *mcEvent, Long_t eventpos, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ){
4208 
4209  if (eventpos < 0) return kFALSE;
4210  TParticle* particle = (TParticle *)mcEvent->Particle(eventpos);
4211  if (!particle) return kFALSE;
4212  if (TMath::Abs(particle->GetPdgCode()) == 11 ){
4213  if (particle->GetMother(0) != -1){
4214  TParticle* particleMother = (TParticle *)mcEvent->Particle(particle->GetMother(0));
4215  if (particleMother){
4216  if (TMath::Abs(particleMother->GetPdgCode()) == 22)
4217  particle = particleMother;
4218  }
4219  }
4220  }
4221  if (particle->GetMother(0) != -1){
4222  Double_t deltaX = particle->Vx() - prodVtxX;
4223  Double_t deltaY = particle->Vy() - prodVtxY;
4224  Double_t deltaZ = particle->Vz() - prodVtxZ;
4225 
4226  //Double_t realRadius2D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY);
4227  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
4228 
4229 
4230  Bool_t dalitzCand = kFALSE;
4231 
4232  TParticle* firstmother = (TParticle *)mcEvent->Particle(particle->GetMother(0));
4233  if (!firstmother) return kFALSE;
4234  Int_t pdgCodeFirstMother = firstmother->GetPdgCode();
4235  Bool_t intDecay = kFALSE;
4236  if ( pdgCodeFirstMother == 111 || pdgCodeFirstMother == 221 ) intDecay = kTRUE;
4237  if ( intDecay && TMath::Abs(particle->GetPdgCode()) == 11 ){
4238  dalitzCand = kTRUE;
4239 // cout << "dalitz candidate found" << endl;
4240  }
4241 
4242  Long_t source = particle->GetMother(0);
4243  Bool_t foundExcludedPart = kFALSE;
4244  Bool_t foundShower = kFALSE;
4245  Int_t pdgCodeMotherPrev = 0;
4246  Int_t pdgCodeMotherPPrevMother = 0;
4247  Int_t depth = 0;
4248  if (dalitzCand || realRadius3D < fSecProdBoundary ){
4249 // if (particle->GetPdgCode() == 22){
4250 // cout << endl << endl << "new particle: " << eventpos <<endl;
4251 // cout << particle->GetPdgCode() << "\t" << particle->R() << "\t" << realRadius2D << "\t" << realRadius3D << endl;
4252 // }
4253  while (depth < 20){
4254  TParticle* mother = (TParticle *)mcEvent->Particle(source);
4255  source = mother->GetMother(0);
4256 // if (particle->GetPdgCode() == 22)cout << "eventposition: "<< source << endl;
4257  Int_t pdgCodeMother = mother->GetPdgCode();
4258 // if (particle->GetPdgCode() == 22)cout << "Previous mothers: " << pdgCodeMother << "\t"<< pdgCodeMotherPrev<< "\t" << pdgCodeMotherPPrevMother << endl;
4259  if (pdgCodeMother == pdgCodeMotherPrev && pdgCodeMother == pdgCodeMotherPPrevMother) depth = 20;
4260  if (TMath::Abs(pdgCodeMother) == 11 && TMath::Abs(pdgCodeMotherPrev) == 22 && TMath::Abs(pdgCodeMotherPPrevMother) == 11 ){
4261  foundShower = kTRUE;
4262  depth =20;
4263  }
4264  if (TMath::Abs(pdgCodeMother) == 22 && TMath::Abs(pdgCodeMotherPrev) == 11 && TMath::Abs(pdgCodeMotherPPrevMother) == 22 ){
4265  foundShower = kTRUE;
4266  depth =20;
4267  }
4268 
4269  // particles to be excluded:
4270  // K0s - 310
4271  // K0l - 130
4272  // K+/- - 321
4273  // Lambda - 3122
4274  // Sigma0 - 3212
4275  // Sigma+/- - 3222, 3112
4276  // Cascades - 3322, 3312
4277  if (TMath::Abs(pdgCodeMother) == 310 || TMath::Abs(pdgCodeMother) == 130 || TMath::Abs(pdgCodeMother) == 321 ||
4278  TMath::Abs(pdgCodeMother) == 3122 || TMath::Abs(pdgCodeMother) == 3212 || TMath::Abs(pdgCodeMother) == 3222 ||
4279  TMath::Abs(pdgCodeMother) == 3112 || TMath::Abs(pdgCodeMother) == 3322 || TMath::Abs(pdgCodeMother) == 3312
4280  ) {
4281  foundExcludedPart = kTRUE;
4282  }
4283 // if (particle->GetPdgCode() == 22)cout << mother->GetPdgCode() << "\t" << source << "\t" << foundExcludedPart<< endl;
4284  pdgCodeMotherPPrevMother = pdgCodeMotherPrev;
4285  pdgCodeMotherPrev = pdgCodeMother;
4286  if (source == -1) depth = 20;
4287 
4288 // if (particle->GetPdgCode() == 22)cout << depth << endl;
4289  depth++;
4290  }
4291  }
4292  if (foundExcludedPart){
4293 // if (particle->GetPdgCode() == 22)cout << "This is definitely a secondary, manually excluded" << endl;
4294  return kFALSE;
4295  } else if (dalitzCand && realRadius3D < fSecProdBoundary ){
4296 // if (particle->GetPdgCode() == 22)cout << "This was a decay via a virtual photon" << endl;
4297  return kTRUE;
4298  } else if (foundShower){
4299 // if (particle->GetPdgCode() == 22)cout << "This is a shower" << endl;
4300  return kFALSE;
4301  } else if (realRadius3D >= fSecProdBoundary){
4302 // cout << "This is a secondary, to large production radius" << endl;
4303  return kFALSE;
4304  }
4305  }
4306 
4307  return kTRUE;
4308 }
4309 
4310 //_________________________________________________________________________
4311 Bool_t AliConvEventCuts::IsConversionPrimaryAOD(AliVEvent *event, AliAODMCParticle* AODMCParticle, Double_t prodVtxX, Double_t prodVtxY, Double_t prodVtxZ){
4312 
4313  TClonesArray *AODMCTrackArray = dynamic_cast<TClonesArray*>(event->FindListObject(AliAODMCParticle::StdBranchName()));
4314  if (AODMCTrackArray == NULL) return kFALSE;
4315  AliAODMCParticle* currentParticle = AODMCParticle;
4316  if (TMath::Abs(currentParticle->GetPdgCode()) == 11 ){
4317  if (currentParticle->GetMother() != -1){
4318  AliAODMCParticle* particleMother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(currentParticle->GetMother()));
4319  if (particleMother){
4320  if (TMath::Abs(particleMother->GetPdgCode()) == 22)
4321  currentParticle = particleMother;
4322  }
4323  }
4324  }
4325  if (currentParticle->GetMother() > -1){
4326  Double_t deltaX = currentParticle->Xv() - prodVtxX;
4327  Double_t deltaY = currentParticle->Yv() - prodVtxY;
4328  Double_t deltaZ = currentParticle->Zv() - prodVtxZ;
4329 
4330  //Double_t realRadius2D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY);
4331  Double_t realRadius3D = TMath::Sqrt(deltaX*deltaX+deltaY*deltaY+deltaZ*deltaZ);
4332 
4333  Bool_t dalitzCand = kFALSE;
4334 
4335  AliAODMCParticle* firstmother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(currentParticle->GetMother()));
4336  if (!firstmother) return kFALSE;
4337  Int_t pdgCodeFirstMother = firstmother->GetPdgCode();
4338  Bool_t intDecay = kFALSE;
4339  if ( pdgCodeFirstMother == 111 || pdgCodeFirstMother == 221 ) intDecay = kTRUE;
4340  if ( intDecay && TMath::Abs(currentParticle->GetPdgCode()) == 11 ){
4341  dalitzCand = kTRUE;
4342 // cout << "dalitz candidate found" << endl;
4343  }
4344 
4345  Long_t source = currentParticle->GetMother();
4346  Bool_t foundExcludedPart = kFALSE;
4347  Bool_t foundShower = kFALSE;
4348  Int_t pdgCodeMotherPrev = 0;
4349  Int_t pdgCodeMotherPPrevMother = 0;
4350  Int_t depth = 0;
4351  if (dalitzCand || realRadius3D < fSecProdBoundary ){
4352 // if (currentParticle->GetPdgCode() == 22){
4353 // cout << endl << endl << "new particle: " << eventpos <<endl;
4354 // cout << currentParticle->GetPdgCode() << "\t" << currentParticle->R() << "\t" << realRadius2D << "\t" << realRadius3D << endl;
4355 // }
4356  while (depth < 20){
4357  AliAODMCParticle* mother = static_cast<AliAODMCParticle*>(AODMCTrackArray->At(source));
4358  source = mother->GetMother();
4359 // if (currentParticle->GetPdgCode() == 22)cout << "eventposition: "<< source << endl;
4360  Int_t pdgCodeMother = mother->GetPdgCode();
4361 // if (currentParticle->GetPdgCode() == 22)cout << "Previous mothers: " << pdgCodeMother << "\t"<< pdgCodeMotherPrev<< "\t" << pdgCodeMotherPPrevMother << endl;
4362  if (pdgCodeMother == pdgCodeMotherPrev && pdgCodeMother == pdgCodeMotherPPrevMother) depth = 20;
4363  if (TMath::Abs(pdgCodeMother) == 11 && TMath::Abs(pdgCodeMotherPrev) == 22 && TMath::Abs(pdgCodeMotherPPrevMother) == 11 ){
4364  foundShower = kTRUE;
4365  depth =20;
4366  }
4367  if (TMath::Abs(pdgCodeMother) == 22 && TMath::Abs(pdgCodeMotherPrev) == 11 && TMath::Abs(pdgCodeMotherPPrevMother) == 22 ){
4368  foundShower = kTRUE;
4369  depth =20;
4370  }
4371 
4372  // particles to be excluded:
4373  // K0s - 310
4374  // K0l - 130
4375  // K+/- - 321
4376  // Lambda - 3122
4377  // Sigma0 - 3212
4378  // Sigma+/- - 3222, 3112
4379  // Cascades - 3322, 3312
4380  if (TMath::Abs(pdgCodeMother) == 310 || TMath::Abs(pdgCodeMother) == 130 || TMath::Abs(pdgCodeMother) == 321 ||
4381  TMath::Abs(pdgCodeMother) == 3122 || TMath::Abs(pdgCodeMother) == 3212 || TMath::Abs(pdgCodeMother) == 3222 ||
4382  TMath::Abs(pdgCodeMother) == 3112 || TMath::Abs(pdgCodeMother) == 3322 || TMath::Abs(pdgCodeMother) == 3312)
4383  {
4384  foundExcludedPart = kTRUE;
4385  }
4386 // if (currentParticle->GetPdgCode() == 22)cout << mother->GetPdgCode() << "\t" << source << "\t" << foundExcludedPart<< endl;
4387  pdgCodeMotherPPrevMother = pdgCodeMotherPrev;
4388  pdgCodeMotherPrev = pdgCodeMother;
4389  if (source == -1) depth = 20;
4390 
4391 // if (currentParticle->GetPdgCode() == 22)cout << depth << endl;
4392  depth++;
4393  }
4394  }
4395  if (foundExcludedPart){
4396 // if (currentParticle->GetPdgCode() == 22)cout << "This is definitely a secondary, manually excluded" << endl;
4397  return kFALSE;
4398  } else if (dalitzCand && realRadius3D < fSecProdBoundary ){
4399 // if (currentParticle->GetPdgCode() == 22)cout << "This was a decay via a virtual photon" << endl;
4400  return kTRUE;
4401  } else if (foundShower){
4402 // if (currentParticle->GetPdgCode() == 22)cout << "This is a shower" << endl;
4403  return kFALSE;
4404  } else if (realRadius3D >= fSecProdBoundary){
4405 // cout << "This is a secondary, too large production radius" << endl;
4406  return kFALSE;
4407  }
4408  }
4409 
4410  return kTRUE;
4411 }
4412 
4413 
4414 //________________________________________________________________________
4415 Int_t AliConvEventCuts::SecondaryClassificationPhoton( TParticle *particle, AliMCEvent* mcEvent, Bool_t isConversion ){
4416  if (particle != NULL && mcEvent != NULL){
4417  Int_t pdgSecondary = 0;
4418  if (!isConversion){
4419  //Bool_t hasMother = kFALSE;
4420  //Bool_t hasGrandMother = kFALSE;
4421  Long_t motherID = particle->GetMother(0);
4422  Long_t grandMotherID = -1;
4423  // is the photon a direct photons, without a mother?
4424  if (motherID > -1){
4425  //hasMother = kTRUE;
4426  grandMotherID = mcEvent->Particle(motherID)->GetMother(0);
4427  // is the meson a primary?
4428  if (grandMotherID > -1){
4429  //hasGrandMother = kTRUE;
4430  pdgSecondary = mcEvent->Particle(grandMotherID)->GetPdgCode();
4431  }
4432  }
4433  } else {
4434  //Bool_t hasMother = kFALSE;
4435  //Bool_t hasGrandMother = kFALSE;
4436  //Bool_t hasGreatGrandMother = kFALSE;
4437  Long_t motherID = particle->GetMother(0);
4438  Long_t grandMotherID = -1;
4439  Long_t greatGrandMotherID = -1;
4440  // is the electron a direct electron, without a mother?
4441  if (motherID > -1){
4442  //hasMother = kTRUE;
4443  grandMotherID = mcEvent->Particle(motherID)->GetMother(0);
4444  // is the photon a direct photons, without a mother?
4445  if (grandMotherID > -1){
4446  //hasGrandMother = kTRUE;
4447  greatGrandMotherID = mcEvent->Particle(grandMotherID)->GetMother(0);
4448  // is the meson a primary?
4449  if (greatGrandMotherID > -1){
4450  //hasGreatGrandMother = kTRUE;
4451  pdgSecondary = mcEvent->Particle(greatGrandMotherID)->GetPdgCode();
4452  }
4453  }
4454  }
4455  }
4456  // is the secondary photon from a lambda
4457  if (TMath::Abs(pdgSecondary) == 3122 )
4458  return 3;
4459  // is the secondary photon from a K0s
4460  else if ( TMath::Abs(pdgSecondary) == 310 )
4461  return 2;
4462  // is the secondary photon from a K0l
4463  else if ( TMath::Abs(pdgSecondary) == 130 )
4464  return 5;
4465  // is the secondary photon from a eta
4466  else if ( TMath::Abs(pdgSecondary) == 221 )
4467  return 4;
4468  // is the secondary photon from something else
4469  else if ( TMath::Abs(pdgSecondary) != 0 )
4470  return 1;
4471 
4472  }
4473 
4474  return 0;
4475 }
4476 
4477 //________________________________________________________________________
4478 Int_t AliConvEventCuts::SecondaryClassificationPhotonAOD( AliAODMCParticle *particle, TClonesArray *aodmcArray, Bool_t isConversion ){
4479  if (particle != NULL && aodmcArray != NULL){
4480  Int_t pdgSecondary = 0;
4481  if (!isConversion){
4482  //Bool_t hasMother = kFALSE;
4483  //Bool_t hasGrandMother = kFALSE;
4484  Long_t motherID = particle->GetMother();
4485  Long_t grandMotherID = -1;
4486  // is the photon a direct photons, without a mother?
4487  if (motherID > -1){
4488  //hasMother = kTRUE;
4489  grandMotherID = ((AliAODMCParticle*)aodmcArray->At(motherID))->GetMother();
4490  // is the meson a primary?
4491  if (grandMotherID > -1){
4492  //hasGrandMother = kTRUE;
4493  pdgSecondary = ((AliAODMCParticle*)aodmcArray->At(grandMotherID))->GetPdgCode();
4494  }
4495  }
4496  } else {
4497  //Bool_t hasMother = kFALSE;
4498  //Bool_t hasGrandMother = kFALSE;
4499  //Bool_t hasGreatGrandMother = kFALSE;
4500  Long_t motherID = particle->GetMother();
4501  Long_t grandMotherID = -1;
4502  Long_t greatGrandMotherID = -1;
4503  // is the electron a direct electron, without a mother?
4504  if (motherID > -1){
4505  //hasMother = kTRUE;
4506  grandMotherID = ((AliAODMCParticle*)aodmcArray->At(motherID))->GetMother();
4507  // is the photon a direct photons, without a mother?
4508  if (grandMotherID > -1){
4509  //hasGrandMother = kTRUE;
4510  greatGrandMotherID = ((AliAODMCParticle*)aodmcArray->At(grandMotherID))->GetMother();
4511  // is the meson a primary?
4512  if (greatGrandMotherID > -1){
4513  //hasGreatGrandMother = kTRUE;
4514  pdgSecondary = ((AliAODMCParticle*)aodmcArray->At(greatGrandMotherID))->GetPdgCode();
4515  }
4516  }
4517  }
4518  }
4519  // is the secondary photon from a lambda
4520  if (TMath::Abs(pdgSecondary) == 3122 )
4521  return 3;
4522  // is the secondary photon from a K0s
4523  else if ( TMath::Abs(pdgSecondary) == 310 )
4524  return 2;
4525  // is the secondary photon from a K0l
4526  else if ( TMath::Abs(pdgSecondary) == 130 )
4527  return 5;
4528  // is the secondary photon from a eta
4529  else if ( TMath::Abs(pdgSecondary) == 221 )
4530  return 4;
4531  // is the secondary photon from something else
4532  else if ( TMath::Abs(pdgSecondary) != 0 )
4533  return 1;
4534 
4535  }
4536 
4537  return 0;
4538 }
4539 
4541 
4542  if (periodName.CompareTo("") == 0){
4543  periodName = ((AliV0ReaderV1*)AliAnalysisManager::GetAnalysisManager()->GetTask(fV0ReaderName.Data()))->GetPeriodName();
4544  }
4545  if (periodName.CompareTo("") == 0) {
4547  fEnergyEnum = kUnset;
4548  AliError("No correct period could be set, periodName string empty");
4549  return;
4550  }
4551 
4552  // Data
4553  if (periodName.CompareTo("LHC10b") == 0 || periodName.CompareTo("LHC10c") == 0 || periodName.CompareTo("LHC10d") == 0 || periodName.CompareTo("LHC10e") == 0 ||
4554  periodName.CompareTo("LHC10f") == 0 || periodName.CompareTo("LHC10g") == 0 || periodName.CompareTo("LHC10bg") == 0
4555  ){
4557  fEnergyEnum = k7TeV;
4558  } else if (periodName.CompareTo("LHC10h") == 0) {
4559  fPeriodEnum = kLHC10h;
4561  } else if (periodName.CompareTo("LHC11a") == 0) {
4562  fPeriodEnum = kLHC11a;
4564  } else if (periodName.CompareTo("LHC11b") == 0) {
4565  fPeriodEnum = kLHC11b;
4566  fEnergyEnum = k7TeV;
4567  } else if (periodName.CompareTo("LHC11c") == 0 || periodName.CompareTo("LHC11d") == 0 || periodName.CompareTo("LHC11e") == 0 || periodName.CompareTo("LHC11f") == 0 ||
4568  periodName.CompareTo("LHC11g") == 0
4569  ) {
4571  fEnergyEnum = k7TeV;
4572  } else if (periodName.CompareTo("LHC11h") == 0) {
4573  fPeriodEnum = kLHC11h;
4575  } else if (periodName.CompareTo("LHC12a") == 0 || periodName.CompareTo("LHC12b") == 0 || periodName.CompareTo("LHC12c") == 0 || periodName.CompareTo("LHC12d") == 0 ||
4576  periodName.CompareTo("LHC12e") == 0 || periodName.CompareTo("LHC12f") == 0 || periodName.CompareTo("LHC12g") == 0 || periodName.CompareTo("LHC12h") == 0 ||
4577  periodName.CompareTo("LHC12i") == 0 || periodName.CompareTo("LHC12ai") == 0
4578  ) {
4579  fPeriodEnum = kLHC12;
4580  fEnergyEnum = k8TeV;
4581  } else if (periodName.CompareTo("LHC13b") == 0 || periodName.CompareTo("LHC13c") == 0 || periodName.CompareTo("LHC13bc") == 0){
4584  } else if (periodName.CompareTo("LHC13d") == 0 || periodName.CompareTo("LHC13e") == 0 || periodName.CompareTo("LHC13de") == 0){
4587  } else if (periodName.CompareTo("LHC13f") == 0 ){
4588  fPeriodEnum = kLHC13f;
4590  } else if (periodName.CompareTo("LHC13g") == 0 ){
4591  fPeriodEnum = kLHC13g;
4593  } else if ( periodName.CompareTo("LHC15f") == 0 || periodName.CompareTo("LHC15g") == 0 || periodName.CompareTo("LHC15h") == 0 || periodName.CompareTo("LHC15i") == 0 ||
4594  periodName.CompareTo("LHC15j") == 0 || periodName.CompareTo("LHC15k") == 0 || periodName.CompareTo("LHC15l") == 0 || periodName.CompareTo("LHC15m") == 0 ||
4595  periodName.CompareTo("LHC15fm") == 0
4596  ) {
4598  fEnergyEnum = k13TeV;
4599  } else if (periodName.CompareTo("LHC15n") == 0 ){
4600  fPeriodEnum = kLHC15n;
4601  fEnergyEnum = k5TeV;
4602  } else if (periodName.CompareTo("LHC15o") == 0 ){
4603  fPeriodEnum = kLHC15o;
4605  } else if ( periodName.CompareTo("LHC16d") == 0 || periodName.CompareTo("LHC16e") == 0 || periodName.CompareTo("LHC16g") == 0 || periodName.CompareTo("LHC16h") == 0 ||
4606  periodName.CompareTo("LHC16i") == 0 || periodName.CompareTo("LHC16j") == 0 || periodName.CompareTo("LHC16k") == 0 || periodName.CompareTo("LHC16l") == 0 ||
4607  periodName.CompareTo("LHC16m") == 0 || periodName.CompareTo("LHC16n") == 0 || periodName.CompareTo("LHC16o") == 0 || periodName.CompareTo("LHC16p") == 0){
4609  fEnergyEnum = k13TeV;
4610  } else if (periodName.CompareTo("LHC16f") == 0 ){
4613  } else if (periodName.CompareTo("LHC16q") == 0 ){
4614  fPeriodEnum = kLHC16q;
4616  } else if (periodName.CompareTo("LHC16r") == 0 ){
4617  fPeriodEnum = kLHC16r;
4619  } else if (periodName.CompareTo("LHC16s") == 0 ){
4620  fPeriodEnum = kLHC16s;
4622  } else if (periodName.CompareTo("LHC16t") == 0 ){
4623  fPeriodEnum = kLHC16t;
4625  } else if ( periodName.CompareTo("LHC17c") == 0 || periodName.CompareTo("LHC17d") == 0 || periodName.CompareTo("LHC17e") == 0 || periodName.CompareTo("LHC17f") == 0 ||
4626  periodName.CompareTo("LHC17h") == 0 || periodName.CompareTo("LHC17i") == 0 || periodName.CompareTo("LHC17j") == 0 || periodName.CompareTo("LHC17k") == 0 ||
4627  periodName.CompareTo("LHC17l") == 0 || periodName.CompareTo("LHC17m") == 0 || periodName.CompareTo("LHC17o") == 0 ){
4629  fEnergyEnum = k13TeV;
4630  } else if ( periodName.CompareTo("LHC17g") == 0 ){
4633  } else if ( periodName.CompareTo("LHC17n") == 0 ){
4634  fPeriodEnum = kLHC17n;
4636  } else if ( periodName.CompareTo("LHC17p") == 0 ){
4637  fPeriodEnum = kLHC17p;
4638  fEnergyEnum = k5TeV;
4639  } else if ( periodName.CompareTo("LHC17q") == 0 ){
4640  fPeriodEnum = kLHC17q;
4641  fEnergyEnum = k5TeV;
4642 
4643  // LHC10x anchored MCs
4644  } else if (periodName.CompareTo("LHC10d1") == 0){
4646  fEnergyEnum = k7TeV;
4647  } else if (periodName.CompareTo("LHC10d2") == 0){
4649  fEnergyEnum = k7TeV;
4650  } else if (periodName.CompareTo("LHC10d4a") == 0){
4652  fEnergyEnum = k7TeV;
4653  } else if (periodName.CompareTo("LHC10d4") == 0){
4655  fEnergyEnum = k7TeV;
4656  } else if (periodName.CompareTo("LHC10e12") == 0){
4658  fEnergyEnum = k900GeV;
4659  } else if (periodName.CompareTo("LHC10e13") == 0){
4661  fEnergyEnum = k900GeV;
4662  } else if (periodName.CompareTo("LHC10e20") == 0){
4664  fEnergyEnum = k7TeV;
4665  } else if (periodName.CompareTo("LHC10e21") == 0){
4667  fEnergyEnum = k7TeV;
4668  } else if (periodName.CompareTo("LHC10f6a") == 0){
4670  fEnergyEnum = k7TeV;
4671  } else if (periodName.CompareTo("LHC10f6") == 0){
4673  fEnergyEnum = k7TeV;
4674  } else if (periodName.Contains("LHC14j4")){
4676  fEnergyEnum = k7TeV;
4677  } else if (periodName.CompareTo("LHC13d2") == 0){
4680  } else if (periodName.CompareTo("LHC13d2b") == 0){
4683  } else if (periodName.CompareTo("LHC12a11a") == 0){
4686  } else if (periodName.CompareTo("LHC12a11b") == 0){
4689  } else if (periodName.CompareTo("LHC12a11c") == 0){
4692  } else if (periodName.CompareTo("LHC12a11d") == 0){
4695  } else if (periodName.CompareTo("LHC12a11e") == 0){
4698  } else if (periodName.CompareTo("LHC12a11f") == 0){
4701  // LHC11x anchored MCs
4702  } else if (periodName.CompareTo("LHC12a15c") == 0){
4705  } else if (periodName.Contains("LHC12f1a") ){
4708  } else if (periodName.Contains("LHC12f1b") ){
4711  } else if (periodName.Contains("LHC12i3") ){
4714  } else if (periodName.CompareTo("LHC15g1a") == 0){
4717  } else if (periodName.CompareTo("LHC15g1b") == 0){
4720  } else if (periodName.CompareTo("LHC13e4") == 0){
4722  fEnergyEnum = k7TeV;
4723  } else if (periodName.CompareTo("LHC13e5") == 0){
4725  fEnergyEnum = k7TeV;
4726  } else if (periodName.CompareTo("LHC14k1a") == 0){
4728  fEnergyEnum = k7TeV;
4729  } else if (periodName.CompareTo("LHC14k1b") == 0){
4731  fEnergyEnum = k7TeV;
4732  } else if (periodName.CompareTo("LHC12a15f") == 0){
4734  fEnergyEnum = k7TeV;
4735  } else if (periodName.CompareTo("LHC12a15g") == 0){
4737  fEnergyEnum = k7TeV;
4738  } else if (periodName.CompareTo("LHC12f2a") == 0){
4740  fEnergyEnum = k7TeV;
4741  } else if (periodName.CompareTo("LHC14a1a") == 0){
4744  } else if (periodName.CompareTo("LHC14a1b") == 0){
4747  } else if (periodName.CompareTo("LHC14a1c") == 0){
4750  // LHC12x anchored MCs
4751  } else if (periodName.CompareTo("LHC14e2a") == 0){
4753  fEnergyEnum = k8TeV;
4754  } else if (periodName.CompareTo("LHC14e2b") == 0){
4756  fEnergyEnum = k8TeV;
4757  } else if (periodName.CompareTo("LHC14e2c") == 0){
4759  fEnergyEnum = k8TeV;
4760  } else if (periodName.Contains("LHC15h1")){
4762  fEnergyEnum = k8TeV;
4763  } else if (periodName.Contains("LHC15h2")){
4765  fEnergyEnum = k8TeV;
4766  } else if (periodName.CompareTo("LHC16c2") == 0){
4768  fEnergyEnum = k8TeV;
4769  } else if (periodName.CompareTo("LHC16c2_plus") == 0){
4771  fEnergyEnum = k8TeV;
4772  // LHC13x anchored MCs
4773  } else if (periodName.Contains("LHC13b2_efix")){
4776  } else if (periodName.CompareTo("LHC13e7") == 0){
4779  } else if (periodName.CompareTo("LHC14b2") == 0){
4782  } else if (periodName.CompareTo("LHC13b4_fix") == 0){
4785  } else if (periodName.CompareTo("LHC13b4_plus") == 0){
4788  } else if (periodName.CompareTo("LHC16c3a") == 0){
4791  } else if (periodName.CompareTo("LHC16c3b") == 0){
4794  } else if (periodName.CompareTo("LHC16c3c") == 0){
4797  } else if (periodName.CompareTo("LHC15g2") == 0){
4800  } else if (periodName.CompareTo("LHC15a3a") == 0){
4803  } else if (periodName.CompareTo("LHC15a3a_plus") == 0){
4806  } else if (periodName.CompareTo("LHC15a3b") == 0){
4809  } else if (periodName.CompareTo("LHC15d3a") == 0){
4812  } else if (periodName.CompareTo("LHC15d3b") == 0){
4815  // LHC15x anchored MCs
4816  } else if (periodName.CompareTo("LHC15g3a3") == 0){
4818  fEnergyEnum = k13TeV;
4819  } else if (periodName.CompareTo("LHC15g3a") == 0){
4821  fEnergyEnum = k13TeV;
4822  } else if (periodName.CompareTo("LHC15g3c2") == 0){
4824  fEnergyEnum = k13TeV;
4825  } else if (periodName.CompareTo("LHC15g3c3") == 0){
4827  fEnergyEnum = k13TeV;
4828  } else if (periodName.CompareTo("LHC15g3") == 0){
4830  fEnergyEnum = k13TeV;
4831  } else if (periodName.CompareTo("LHC16a2a") == 0){
4833  fEnergyEnum = k13TeV;
4834  } else if (periodName.CompareTo("LHC16a2b") == 0){
4836  fEnergyEnum = k13TeV;
4837  } else if (periodName.CompareTo("LHC16a2c") == 0){
4839  fEnergyEnum = k13TeV;
4840  } else if (periodName.CompareTo("LHC16d3") == 0){
4842  fEnergyEnum = k13TeV; //LHC15f
4843  } else if (periodName.CompareTo("LHC17i4") == 0){
4845  fEnergyEnum = k13TeV; //LHC15i
4846  } else if (periodName.CompareTo("LHC17g7") == 0){
4848  fEnergyEnum = k13TeV; //LHC15h
4849  } else if (periodName.CompareTo("LHC15l1a2") == 0){
4851  fEnergyEnum = k5TeV;
4852  } else if (periodName.CompareTo("LHC15l1b2") == 0){
4854  fEnergyEnum = k5TeV;
4855  } else if (periodName.CompareTo("LHC16h3") == 0){
4857  fEnergyEnum = k5TeV;
4858  } else if (periodName.CompareTo("LHC16h8a") == 0){
4860  fEnergyEnum = k5TeV;
4861  } else if (periodName.CompareTo("LHC16h8b") == 0){
4863  fEnergyEnum = k5TeV;
4864  } else if (periodName.CompareTo("LHC16k5a") == 0){
4866  fEnergyEnum = k5TeV;
4867  } else if (periodName.CompareTo("LHC16k5b") == 0){
4869  fEnergyEnum = k5TeV;
4870  } else if (periodName.CompareTo("LHC16k3a") == 0){
4872  fEnergyEnum = k5TeV;
4873  } else if (periodName.CompareTo("LHC16k3a2") == 0){
4875  fEnergyEnum = k5TeV;
4876  } else if (periodName.CompareTo("LHC17e2") == 0){
4878  fEnergyEnum = k5TeV;
4879  } else if (periodName.Contains("LHC15k1a1")){
4882  } else if (periodName.Contains("LHC15k1a2")){
4885  } else if (periodName.Contains("LHC15k1a3")){
4888  } else if (periodName.Contains("LHC16j7")){
4891  } else if (periodName.Contains("LHC16g1")){
4894  } else if (periodName.Contains("LHC16g1a")){