AliPhysics  63e47e1 (63e47e1)
AliAnalysisTaskEmcalJetPbPbTriggerTests.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2017, Copyright Holders of the ALICE Collaboration *
3  * All rights reserved. *
4  * *
5  * Redistribution and use in source and binary forms, with or without *
6  * modification, are permitted provided that the following conditions are met: *
7  * * Redistributions of source code must retain the above copyright *
8  * notice, this list of conditions and the following disclaimer. *
9  * * Redistributions in binary form must reproduce the above copyright *
10  * notice, this list of conditions and the following disclaimer in the *
11  * documentation and/or other materials provided with the distribution. *
12  * * Neither the name of the <organization> nor the *
13  * names of its contributors may be used to endorse or promote products *
14  * derived from this software without specific prior written permission. *
15  * *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND *
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED *
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE *
19  * DISCLAIMED. IN NO EVENT SHALL ALICE COLLABORATION BE LIABLE FOR ANY *
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES *
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; *
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND *
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT *
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26  ************************************************************************************/
27 #include <algorithm>
28 #include <array>
29 #include <sstream>
30 #include <string>
31 #include <vector>
32 
33 #include <THistManager.h>
34 #include <TLinearBinning.h>
35 #include <TVariableBinning.h>
36 
37 #include "AliAODInputHandler.h"
38 #include "AliAnalysisManager.h"
41 #include "AliEmcalJet.h"
42 #include "AliInputEventHandler.h"
43 #include "AliJetContainer.h"
44 #include "AliLog.h"
45 #include "AliVEvent.h"
46 
48 
49 using namespace EmcalTriggerJets;
50 
53  fHistos(nullptr),
54  fIsMC(false),
55  fNameJetContainer("datajets"),
56  fTriggerSelectionBits(AliVEvent::kAny),
57  fUseAliEventCuts(kTRUE),
58  fEventCuts(0)
59 {
60  SetUseAliAnaUtils(true);
61 }
62 
64  AliAnalysisTaskEmcalJet(name, true),
66  fIsMC(false),
67  fNameJetContainer("datajets"),
68  fTriggerSelectionBits(AliVEvent::kAny),
69  fUseAliEventCuts(kTRUE),
70  fEventCuts(0)
71 {
72  SetUseAliAnaUtils(true);
73 }
74 
76  if(fHistos) delete fHistos;
77 }
78 
81 
82  if (fUseAliEventCuts) fEventCuts.OverrideAutomaticTriggerSelection(fOffTrigger);
83 
84  if(!fUserPtBinning.GetSize()) {
85  // binning not set. apply default binning
86  AliInfoStream() << "Using default pt binning";
87  fUserPtBinning.Set(201);
88  double current(0.);
89  for(int istep = 0; istep < 201; istep++) {
90  fUserPtBinning[istep] = current;
91  current += 1;
92  }
93  }
94 
95  TLinearBinning etabinning(100, -1., 1.), phibinning(100., 0., 7.), nefbinning(100, 0., 1.), centralitybinning(10, 0, 100);
96  TVariableBinning jetptbinning(fUserPtBinning);
97  const TBinning *binnings[5] = {&jetptbinning, &etabinning, &phibinning, &nefbinning, &centralitybinning};
98  fHistos = new THistManager(Form("Histos_%s", GetName()));
99  fHistos->CreateTH1("hEventCounter", "Event counter histogram", 1, 0.5, 1.5);
100  fHistos->CreateTHnSparse("hJetTHnSparse", "jet thnsparse", 6, binnings, "s");
101  fHistos->CreateTHnSparse("hMaxJetTHnSparse", "jet thnsparse", 6, binnings, "s");
102 
103  for(auto h : *fHistos->GetListOfHistograms()) fOutput->Add(h);
104  PostData(1, fOutput);
105 }
106 
108  auto datajets = this->GetJetContainer(fNameJetContainer);
109  if(!datajets) {
110  AliErrorStream() << "Jet container " << fNameJetContainer << " not found" << std::endl;
111  return false;
112  }
113 
114  fHistos->FillTH1("hEventCounter", 1);
115  AliEmcalJet *maxjet(nullptr);
116  for(auto j : datajets->accepted()){
117  if(!maxjet || (j->E() > maxjet->E())) maxjet = j;
118  double datapoint[5] = {j->Pt(), j->Eta(), j->Phi(), j->NEF(), 0.};
119  fHistos->FillTHnSparse("hJetTHnSparse", datapoint);
120  }
121 
122  double maxdata[6];
123  memset(maxdata, 0., sizeof(double) * 6);
124  if(maxjet){
125  maxdata[0] = maxjet->Pt();
126  maxdata[1] = maxjet->Eta();
127  maxdata[2] = maxjet->Phi();
128  maxdata[3] = maxjet->NEF();
129  maxdata[4] = fCent;
130  fHistos->FillTHnSparse("hMaxJetTHnSparse", maxdata);
131  }
132  return true;
133 }
134 
136  if(!(fInputHandler->IsEventSelected() & fTriggerSelectionBits)) return false;
137  if (fUseAliEventCuts && !fEventCuts.AcceptEvent(InputEvent())) return false;
138  return true;
139 }
140 
142  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
143  if(!mgr) {
144  std::cerr << "Analysis manager not initialized" << std::endl;
145  return nullptr;
146  }
147 
148  Bool_t isAOD(kFALSE);
149  AliInputEventHandler *inputhandler = static_cast<AliInputEventHandler *>(mgr->GetInputEventHandler());
150  if(inputhandler) {
151  if(inputhandler->IsA() == AliAODInputHandler::Class()){
152  std::cout << "Analysing AOD events\n";
153  isAOD = kTRUE;
154  } else {
155  std::cout << "Analysing ESD events\n";
156  }
157  }
158 
159  std::string jettypestring;
161  switch(jettype){
162  case AliJetContainer::kChargedJet: jettypestring = "ChargedJets"; acctype = AliJetContainer::kTPCfid; break;
163  case AliJetContainer::kFullJet: jettypestring = "FullJets"; acctype = AliJetContainer::kEMCALfid; break;
164  case AliJetContainer::kNeutralJet: jettypestring = "NeutralJets"; acctype = AliJetContainer::kEMCALfid; break;
165  };
166 
167  std::stringstream tag, outfilename;
168  tag << jettypestring << "_R" << std::setw(2) << std::setfill('0') << int(radius * 10.) << "_";
169  if(strlen(suffix)) {
170  tag << "_" << suffix;
171  }
172  auto task = new AliAnalysisTaskEmcalJetPbPbTriggerTests(Form("JetEnergySpectrum_%s", tag.str().data()));
173  task->SetIsMC(isMC);
174  mgr->AddTask(task);
175 
176  // Connect particle and cluster container
177  AliTrackContainer *tracks(nullptr);
178  AliClusterContainer *clusters(nullptr);
179  if(jettype == AliJetContainer::kChargedJet || jettype == AliJetContainer::kFullJet) {
181  tracks->SetMinPt(0.15);
182  }
183  if(jettype == AliJetContainer::kNeutralJet || jettype == AliJetContainer::kFullJet){
184  clusters = task->AddClusterContainer(EMCalTriggerPtAnalysis::AliEmcalAnalysisFactory::ClusterContainerNameFactory(isAOD));
185  clusters->SetDefaultClusterEnergy(AliVCluster::kHadCorr);
186  clusters->SetClusHadCorrEnergyCut(0.3);
187  }
188 
189 
190  // Create proper jet container
191  auto jetcont = task->AddJetContainer(jettype, AliJetContainer::antikt_algorithm, AliJetContainer::E_scheme, radius, acctype, tracks, clusters);
192  jetcont->SetName("datajets");
193  task->SetNameJetContainer("datajets");
194  std::cout << "Adding jet container with underlying array:" << jetcont->GetArrayName() << std::endl;
195 
196  // Link input and output container
197  outfilename << mgr->GetCommonFileName() << ":JetSpectrum_" << tag.str().data();
198  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
199  mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form("JetSpectrum_%s", tag.str().data()), TList::Class(), AliAnalysisManager::kOutputContainer, outfilename.str().data()));
200 
201  return task;
202 }
EMCal fiducial acceptance (each eta, phi edge narrowed by jet R)
Bool_t fUseAliEventCuts
Flag to use AliEventCuts (otherwise AliAnalysisTaskEmcal will be used)
Class creating a variable binning, used in the histogram manager.
Class creating a linear binning, used in the histogram manager.
AliJetContainer * GetJetContainer(Int_t i=0) const
UInt_t fOffTrigger
offline trigger for event selection
Double_t Eta() const
Definition: AliEmcalJet.h:121
Double_t Phi() const
Definition: AliEmcalJet.h:117
Container with name, TClonesArray and cuts for particles.
void SetUseAliAnaUtils(Bool_t b, Bool_t bRejPilup=kTRUE)
Double_t E() const
Definition: AliEmcalJet.h:119
Interface for binnings used by the histogram handler.
Definition: TBinning.h:21
void FillTHnSparse(const char *name, const double *x, double weight=1., Option_t *opt="")
unsigned int UInt_t
Definition: External.C:33
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
Double_t fCent
!event centrality
TPC fiducial acceptance (each eta edge narrowed by jet R)
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
Double_t Pt() const
Definition: AliEmcalJet.h:109
Bool_t isMC
AliEmcalList * fOutput
!output list
Base task in the EMCAL jet framework.
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:51
Container class for histograms.
Definition: THistManager.h:99
virtual bool Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
void UserCreateOutputObjects()
Main initialization function on the worker.
bool Bool_t
Definition: External.C:53
Double_t NEF() const
Definition: AliEmcalJet.h:148
void SetDefaultClusterEnergy(Int_t d)
THnSparse * CreateTHnSparse(const char *name, const char *title, int ndim, const int *nbins, const double *min, const double *max, Option_t *opt="")
Create a new THnSparse within the container.
Container structure for EMCAL clusters.
static AliAnalysisTaskEmcalJetPbPbTriggerTests * AddTaskJetPbPbTriggerTests(Bool_t isMC, AliJetContainer::EJetType_t jettype, double radius, const char *suffix="")
void SetClusHadCorrEnergyCut(Double_t cut)
static TString ClusterContainerNameFactory(Bool_t isAOD)
Get name of the default cluster container.
static TString TrackContainerNameFactory(Bool_t isAOD)
Get name of the default track container.