AliPhysics  857879d (857879d)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliAnalysisTaskEmcalTriggerJets.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 <THistManager.h>
28 #include <TMath.h>
29 #include <TString.h>
30 
31 #include "AliAnalysisManager.h"
32 #include "AliClusterContainer.h"
33 #include "AliEmcalJet.h"
34 #include "AliInputEventHandler.h"
35 #include "AliJetContainer.h"
36 #include "AliLog.h"
37 #include "AliPIDResponse.h"
38 #include "AliTrackContainer.h"
40 #include "AliVEvent.h"
41 
42 #include <array>
43 #include <iostream>
44 
48 
49 namespace EmcalTriggerJets {
50 
51 AliAnalysisTaskEmcalTriggerJets::AliAnalysisTaskEmcalTriggerJets():
53  fPIDResponse(nullptr),
54  fHistos(nullptr)
55 {
56 
57 }
58 
60  AliAnalysisTaskEmcalJet(name, true),
61  fPIDResponse(nullptr),
62  fHistos(nullptr)
63 {
64 
65 }
66 
68  delete fHistos;
69 }
70 
73 
74  const std::array<TString, 5> kEmcalTriggers = {"INT7", "EJ1", "EJ2", "DJ1", "DJ2"};
75  const int kNJetPtBins = 9;
76  const std::array<int, kNJetPtBins+1> kJetPtBins = {20, 40, 60, 80, 100, 120, 140, 160, 180, 200};
77  fHistos = new THistManager("EmcalJetHistos");
78  for(auto t : kEmcalTriggers){
79  fHistos->CreateTH1("hEventCount" + t, "Event counter for trigger " + t, 1., 0.5, 1.5);
80  fHistos->CreateTH1("hPtRawFullJetR02EMCAL" + t, "Raw pt spectrum for full jets with R=0.2 in EMCAL for trigger " + t, 200, 0., 200);
81  fHistos->CreateTH1("hPtRawFullJetR04EMCAL" + t, "Raw pt spectrum for full jets with R=0.4 in EMCAL for trigger " + t, 200, 0., 200);
82  fHistos->CreateTH1("hPtRawChargedJetR02EMCAL" + t, "Raw pt spectrum for charged jets with R=0.2 in EMCAL for trigger " + t, 200, 0., 200);
83  fHistos->CreateTH1("hPtRawChargedJetR04EMCAL" + t, "Raw pt spectrum for charged jets with R=0.4 in EMCAL for trigger " + t, 200, 0., 200);
84  fHistos->CreateTH1("hPtRawNeutralJetR02EMCAL" + t, "Raw pt spectrum for neutral jets with R=0.2 in EMCAL for trigger " + t, 200, 0., 200);
85  fHistos->CreateTH1("hPtRawNeutralJetR04EMCAL" + t, "Raw pt spectrum for neutral jets with R=0.4 in EMCAL for trigger " + t, 200, 0., 200);
86  fHistos->CreateTH1("hPtRawFullJetR02DCAL" + t, "Raw pt spectrum for full jets with R=0.2 in DCAL for trigger " + t, 200, 0., 200);
87  fHistos->CreateTH1("hPtRawFullJetR04DCAL" + t, "Raw pt spectrum for full jets with R=0.4 in DCAL for trigger " + t, 200, 0., 200);
88  fHistos->CreateTH1("hPtRawChargedJetR02DCAL" + t, "Raw pt spectrum for charged jets with R=0.2 in DCAL for trigger " + t, 200, 0., 200);
89  fHistos->CreateTH1("hPtRawChargedJetR04DCAL" + t, "Raw pt spectrum for charged jets with R=0.4 in DCAL for trigger " + t, 200, 0., 200);
90  fHistos->CreateTH1("hPtRawNeutralJetR02DCAL" + t, "Raw pt spectrum for neutral jets with R=0.2 in DCAL for trigger " + t, 200, 0., 200);
91  fHistos->CreateTH1("hPtRawNeutralJetR04DCAL" + t, "Raw pt spectrum for neutral jets with R=0.4 in DCAL for trigger " + t, 200, 0., 200);
92 
93  // PID histograms for full jets, R=0.4
94  for(int ib = 0; ib < kNJetPtBins+1; ib++){
95  fHistos->CreateTH2(TString::Format("hTPCdEdxFullJetMin%dMax%dR04EMCAL", kJetPtBins[ib], kJetPtBins[ib+1]) + t,
96  TString::Format("TPC dE/dx vs. p for jet constituents for full jets with %d < p_{t} < %d and R=0.4 in EMCAL for trigger ", kJetPtBins[ib], kJetPtBins[ib+1]) + t,
97  300, 0., 30., 1000., 0., 200.);
98  fHistos->CreateTH2(TString::Format("hTOFBetaFullJetMin%dMax%dR04EMCAL", kJetPtBins[ib], kJetPtBins[ib+1]) + t,
99  TString::Format("TOF #beta vs. p for jet constituents for full jets with %d < p_{t} < %d and R=0.4 in EMCAL for trigger ", kJetPtBins[ib], kJetPtBins[ib+1]) + t,
100  300., 0., 30., 120., 0., 1.2);
101  fHistos->CreateTH2(TString::Format("hTPCdEdxFullJetMin%dMax%dR04DCAL", kJetPtBins[ib], kJetPtBins[ib+1]) + t,
102  TString::Format("TPC dE/dx vs. p for jet constituents for full jets with %d < pt < %d and R=0.4 in DCAL for trigger ", kJetPtBins[ib], kJetPtBins[ib+1]) +t,
103  300, 0., 30., 1000., 0., 200.);
104  fHistos->CreateTH2(TString::Format("hTOFBetaFullJetMin%dMax%dR04DCAL", kJetPtBins[ib], kJetPtBins[ib+1]) + t,
105  TString::Format("TOF #beta vs. p for jet constituents for full jets with %d < p_{t} < %d and R=0.4 in EMCAL for trigger ", kJetPtBins[ib], kJetPtBins[ib+1]) + t,
106  300., 0., 30., 120., 0., 1.2);
107  }
108  }
109  for(auto h : *(fHistos->GetListOfHistograms())){
110  fOutput->Add(h);
111  }
112  PostData(1, fOutput);
113 }
114 
116  fPIDResponse = fInputHandler->GetPIDResponse();
117  if(!fPIDResponse){
118  AliErrorStream() << "PID Response not available - PID plots will not be filled" << std::endl;
119  }
120 }
121 
123  std::vector<TString> triggers, kEmcalTriggers = {"EJ1", "EJ2", "DJ1", "DJ2"};
124  if(fInputHandler->IsEventSelected() & AliVEvent::kINT7) triggers.push_back("INT7");
125  if(fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE){
126  TString fired = fInputEvent->GetFiredTriggerClasses();
127  for(auto e : kEmcalTriggers){
128  if(fired.Contains(e)) triggers.push_back(e);
129  }
130  }
131  if(!triggers.size()) return false;
132 
133  for(auto t : triggers) fHistos->FillTH1("hEventCount" + t, 1);
134  std::vector<TString> jettypes = {"Full", "Charged", "Neutral"}, detectors = {"EMCAL", "DCAL"}, radii = {"R02", "R04"};
135  for(auto jt : jettypes) {
136  for(auto det : detectors){
137  for(auto r : radii) {
138  TString namejcont = jt + "Jets" + r + det,
139  histnamebase = "hPtRaw" + jt + "Jet" + r + det;
140  AliJetContainer *c = this->GetJetContainer(namejcont);
141  if(!c) AliErrorStream() << "Not found jet container " << namejcont << std::endl;
142  bool doPID = fPIDResponse && (jt == "Full") && (r == "R04");
143  for(auto j : c->accepted()){
144  for(auto t : triggers) {
145  fHistos->FillTH1(histnamebase + t, TMath::Abs(j->Pt()));
146  if(doPID) FillJetPIDPlots(j, t, det);
147  }
148  }
149  }
150  }
151  }
152  return true;
153 }
154 
155 void AliAnalysisTaskEmcalTriggerJets::FillJetPIDPlots(const AliEmcalJet *jet, const char *trigger, const char *detector){
156  const int kNJetPtBins = 9;
157  const std::array<int, kNJetPtBins+1> kJetPtBins = {20, 40, 60, 80, 100, 120, 140, 160, 180, 200};
158  int jetptbin = -1;
159  for(int ib = 0; ib < kNJetPtBins; ib++){
160  if(TMath::Abs(jet->Pt()) >= kJetPtBins[ib] && TMath::Abs(jet->Pt()) < kJetPtBins[ib+1]) {
161  jetptbin = ib;
162  break;
163  }
164  }
165  if(jetptbin < 0) return;
166  TString histnameTPC = TString::Format("hTPCdEdxFullJetMin%dMax%dR04%s%s", kJetPtBins[jetptbin], kJetPtBins[jetptbin+1], detector, trigger),
167  histnameTOF = TString::Format("hTOFBetaFullJetMin%dMax%dR04%s%s", kJetPtBins[jetptbin], kJetPtBins[jetptbin+1], detector, trigger);
168  AliTrackContainer *tc = GetTrackContainer("tracks");
169 
170  for(int icharged = 0; icharged < jet->GetNumberOfTracks(); icharged++){
171  AliVTrack *constituent = static_cast<AliVTrack *>(jet->TrackAt(icharged, tc->GetArray()));
172  // Select only constituents with sufficient PID information in both TPC and TOF
173  if(constituent->GetTPCsignalN() < 30) continue;
174  if(!((constituent->GetStatus() & AliVTrack::kTOFout) && (constituent->GetStatus() & AliVTrack::kTIME))) continue;
175  Double_t trtime = (constituent->GetTOFsignal() - fPIDResponse->GetTOFResponse().GetTimeZero()) * 1e-12;
176  Double_t v = constituent->GetIntegratedLength()/(100. * trtime);
177  Double_t beta = v / TMath::C();
178  fHistos->FillTH2(histnameTPC, TMath::Abs(constituent->P()), constituent->GetTPCsignal());
179  fHistos->FillTH2(histnameTOF, TMath::Abs(constituent->P()), beta);
180  }
181 }
182 
184  AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
185 
187  mgr->AddTask(task);
188 
189  // Adding containers for clusters and tracks
190  AliClusterContainer *clustercont = task->AddClusterContainer("caloClusters");
191  clustercont->SetMinE(0.3);
192  AliTrackContainer *trackcont = task->AddTrackContainer("tracks");
193  trackcont->SetMinPt(0.15);
194 
195  // Adding Jet containers
196  // - Using jet radii 0.2 and 0.4
197  // - Splitting between EMCAL and DCAL side
198  // - processing full, charged and neutral jets
199 
200  // Full jets, R=0.2, EMCAL
201  AliJetContainer *cont = task->AddJetContainer(
205  0.2,
207  trackcont, clustercont
208  );
209  cont->SetName("FullJetsR02EMCAL");
210 
211  // Full jets, R=0.4, EMCAL
212  cont = task->AddJetContainer(
216  0.4,
218  trackcont, clustercont
219  );
220  cont->SetName("FullJetsR04EMCAL");
221 
222  // Full jets, R=0.2, DCAL
223  cont = task->AddJetContainer(
227  0.2,
229  trackcont, clustercont
230  );
231  cont->SetName("FullJetsR02DCAL");
232 
233  // Full jets, R=0.4, EMCAL
234  cont = task->AddJetContainer(
238  0.4,
240  trackcont, clustercont
241  );
242  cont->SetName("FullJetsR04DCAL");
243 
244 
245  // Charged jets, R=0.2, EMCAL
246  cont = task->AddJetContainer(
250  0.2,
252  trackcont, nullptr
253  );
254  cont->SetName("ChargedJetsR02EMCAL");
255 
256  // Charged jets, R=0.4, EMCAL
257  cont = task->AddJetContainer(
261  0.4,
263  trackcont, nullptr
264  );
265  cont->SetName("ChargedJetsR04EMCAL");
266 
267  // Charged jets, R=0.2, DCAL
268  cont = task->AddJetContainer(
272  0.2,
274  trackcont, nullptr
275  );
276  cont->SetName("ChargedJetsR02DCAL");
277 
278  // Charged jets, R=0.4, DCAL
279  cont = task->AddJetContainer(
283  0.4,
285  trackcont, nullptr
286  );
287  cont->SetName("ChargedJetsR04DCAL");
288 
289 
290  // Neutral jets, R=0.2, EMCAL
291  cont = task->AddJetContainer(
295  0.2,
297  nullptr, clustercont
298  );
299  cont->SetName("NeutralJetsR02EMCAL");
300 
301  // Neutral jets, R=0.4, EMCAL
302  cont = task->AddJetContainer(
306  0.4,
308  nullptr, clustercont
309  );
310  cont->SetName("NeutralJetsR04EMCAL");
311 
312  // Neutral jets, R=0.2, DCAL
313  cont = task->AddJetContainer(
317  0.2,
319  nullptr, clustercont
320  );
321  cont->SetName("NeutralJetsR02DCAL");
322 
323  // Neutral jets, R=0.4, DCAL
324  cont = task->AddJetContainer(
328  0.4,
330  nullptr, clustercont
331  );
332  cont->SetName("NeutralJetsR04DCAL");
333 
334  // Connect Input / Output containers
335  TString outfilename = mgr->GetCommonFileName();
336  outfilename += ":EmcalTriggerJets";
337  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
338  mgr->ConnectOutput(task, 1, mgr->CreateContainer("HistsEmcalTriggerJets", TList::Class(), AliAnalysisManager::kOutputContainer, outfilename));
339 
340  return task;
341 }
342 
343 } /* namespace EmcalTriggerJets */
double Double_t
Definition: External.C:58
AliJetContainer * GetJetContainer(Int_t i=0) const
Container with name, TClonesArray and cuts for particles.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
TCanvas * c
Definition: TestFitELoss.C:172
AliJetContainer * AddJetContainer(const char *n, TString defaultCutType, Float_t jetRadius=0.4)
AliClusterContainer * AddClusterContainer(const char *n)
Create new cluster container and attach it to the task.
Int_t TrackAt(Int_t idx) const
Definition: AliEmcalJet.h:153
UShort_t GetNumberOfTracks() const
Definition: AliEmcalJet.h:132
TH2 * CreateTH2(const char *name, const char *title, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax, Option_t *opt="")
Create a new TH2 within the container.
THashList * GetListOfHistograms() const
Get the list of histograms.
Definition: THistManager.h:671
void FillJetPIDPlots(const AliEmcalJet *jet, const char *trigger, const char *detector)
TH1 * CreateTH1(const char *name, const char *title, int nbins, double xmin, double xmax, Option_t *opt="")
Create a new TH1 within the container.
void FillTH1(const char *hname, double x, double weight=1., Option_t *opt="")
Fill a 1D histogram within the container.
virtual void UserExecOnce()
Task initializations handled in user tasks.
Double_t Pt() const
Definition: AliEmcalJet.h:102
AliEmcalList * fOutput
!output list
ClassImp(AliAnalysisTaskCRC) AliAnalysisTaskCRC
AliTrackContainer * AddTrackContainer(const char *n)
Create new track container and attach it to the task.
AliTrackContainer * GetTrackContainer(Int_t i=0) const
Base task in the EMCAL jet framework.
Represent a jet reconstructed using the EMCal jet framework.
Definition: AliEmcalJet.h:44
Container class for histograms.
Definition: THistManager.h:99
void UserCreateOutputObjects()
Main initialization function on the worker.
DCal fiducial acceptance (each eta, phi edge narrowed by jet R)
Definition: AliEmcalJet.h:65
const AliJetIterableContainer accepted() const
Container structure for EMCAL clusters.
EMCal fiducial acceptance (each eta, phi edge narrowed by jet R)
Definition: AliEmcalJet.h:63
Container for jet within the EMCAL jet framework.
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.
static AliAnalysisTaskEmcalTriggerJets * AddTaskEmcalTriggerJets(const char *name)