AliPhysics  master (3d17d9d)
AliAnalysisTaskEmcalFastorMultiplicity.cxx
Go to the documentation of this file.
1 /************************************************************************************
2  * Copyright (C) 2019, 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 <iostream>
28 #include <map>
29 #include <set>
30 
31 #include <THistManager.h>
32 
33 #include "AliAnalysisManager.h"
35 #include "AliEMCALGeometry.h"
36 #include "AliEMCALTriggerPatchInfo.h"
37 #include "AliInputEventHandler.h"
38 #include "AliLog.h"
39 #include "AliMultSelection.h"
40 #include "AliMultEstimator.h"
41 #include "AliVEvent.h"
42 #include "AliVCaloTrigger.h"
43 
45 
46 using namespace PWGJE::EMCALJetTasks;
47 
49  fHistos(nullptr),
50  fTriggerClass("INT7")
51 {
52 }
53 
56  fTriggerClass("INT7")
57 {
58  SetCaloTriggerPatchInfoName("EmcalTriggers");
59  SetNeedEmcalGeom(true);
60 }
61 
63 {
64  if (fHistos)
65  delete fHistos;
66 }
67 
69 {
71 
72  const std::array<int, 15> thresholds = {{0, 1, 2, 3, 4, 5, 10, 15, 20, 30, 40, 50, 60, 80, 100}};
73  fHistos = new THistManager(Form("%s_histos", GetName()));
74  for (auto t : thresholds)
75  {
76  fHistos->CreateTH2(Form("hFastorMultL0_ADC%d", t), Form("Multiplicity of FastORs with ADC >= %d at L0", t), 100, 0., 100, 6500, 0., 6500);
77  fHistos->CreateTH2(Form("hFastorMultL1_ADC%d", t), Form("Multiplicity of FastORs with ADC >= %d at L1", t), 100, 0., 100, 6500, 0., 6500);
78  fHistos->CreateTH2(Form("hFastorMultL1_EGA_ADC%d", t), Form("Multiplicity of FastORs with ADC >= %d at L1 in EGA patches", t), 100, 0., 100, 6500, 0., 6500);
79  fHistos->CreateTH2(Form("hFastorMultL1_EJE_ADC%d", t), Form("Multiplicity of FastORs with ADC >= %d at L1 in EJE patches", t), 100, 0., 100, 6500, 0., 6500);
80  }
81 
82  for (auto h : *fHistos->GetListOfHistograms())
83  fOutput->Add(h);
84 
85  PostData(1, fOutput);
86 }
87 
89 {
90  if (fTriggerClass == "INT7")
91  return (fInputHandler->IsEventSelected() & AliVEvent::kINT7);
92  if (fTriggerClass.find("J") != std::string::npos)
93  {
94  if (!(fInputHandler->IsEventSelected() & AliVEvent::kEMCEJE))
95  return false;
96  return (fInputEvent->GetFiredTriggerClasses().Contains(fTriggerClass.data()));
97  }
98  if (fTriggerClass.find("G") != std::string::npos)
99  {
100  if (!(fInputHandler->IsEventSelected() & AliVEvent::kEMCEGA))
101  return false;
102  return (fInputEvent->GetFiredTriggerClasses().Contains(fTriggerClass.data()));
103  }
104  return false;
105 }
106 
108 {
109  auto mult = dynamic_cast<AliMultSelection *>(InputEvent()->FindListObject("MultSelection"));
110  if (!mult)
111  {
112  AliErrorStream() << "Multiplicity object not available from event" << std::endl;
113  return false;
114  }
115  auto multval = mult->GetEstimator("V0M")->GetPercentile();
116 
117  std::map<int, int> countersL0, countersL1;
118  const std::array<int, 15> thresholds = {{0, 1, 2, 3, 4, 5, 10, 15, 20, 30, 40, 50, 60, 80, 100}};
119  for (auto t : thresholds)
120  {
121  countersL0[t] = 0;
122  countersL1[t] = 0;
123  }
124 
125  std::map<std::pair<int, int>, int> fastOrs;
126  auto triggers = fInputEvent->GetCaloTrigger("EMCAL");
127  triggers->Reset();
128  while (triggers->Next())
129  {
130  Float_t adcL0;
131  triggers->GetAmplitude(adcL0);
132  auto adcL1 = triggers->GetL1TimeSum();
133  int col, row;
134  triggers->GetPosition(col, row);
135  fastOrs.insert(std::pair<std::pair<int, int>, int>({col, row}, adcL1));
136  if (adcL1 < 0)
137  adcL1 = 0;
138  for (auto t : thresholds)
139  {
140  if (adcL0 >= t)
141  countersL0[t]++;
142  if (adcL1 >= t)
143  countersL1[t]++;
144  }
145  }
146 
147  for (auto t : thresholds)
148  {
149  fHistos->FillTH2(Form("hFastorMultL0_ADC%d", t), multval, countersL0[t]);
150  fHistos->FillTH2(Form("hFastorMultL1_ADC%d", t), multval, countersL1[t]);
151  }
152 
153  // Correlate to trigger patches
154  std::map<int, int> countersEGA, countersEJE;
155  std::map<int, std::set<int>> bookedFastorsGA, bookedFastorsJE; // book FastOR abs ID in order to avoid double counting when patches overlap
156  int thresholdEGA = 128,
157  thresholdEJE = 255; // thresholds LHC15o
158  auto medianEMCAL = triggers->GetMedian(0) / 64, // Area for median has the size of the jet patchsize (8x8 FastORs) - to be converter to a density per FastOR
159  medianDCAL = triggers->GetMedian(1) / 64;
160  for (auto t : thresholds)
161  {
162  countersEGA[t] = 0;
163  countersEJE[t] = 0;
164  bookedFastorsGA[t] = std::set<int>();
165  bookedFastorsJE[t] = std::set<int>();
166  }
167  for (auto p : *fTriggerPatchInfo)
168  {
169  auto patch = static_cast<AliEMCALTriggerPatchInfo *>(p);
170  auto patchsize = patch->GetPatchSize();
171  auto isJetPatch = patch->IsJetHighRecalc();
172  auto median = patch->IsEMCal() ? medianDCAL : medianEMCAL;
173  auto patchadc = patch->GetADCAmp() - median * patchsize * patchsize;
174  auto threshold = isJetPatch ? thresholdEJE : thresholdEGA;
175  if (patchadc < threshold)
176  continue;
177 
178  // patch selected - count cells
179  for (int icol = patch->GetColStart(); icol < patch->GetColStart() + patch->GetPatchSize(); icol++)
180  {
181  for (int irow = patch->GetRowStart(); irow < patch->GetRowStart() + patch->GetPatchSize(); irow++)
182  {
183  auto fastor = fastOrs.find({icol, irow});
184  if (fastor == fastOrs.end())
185  continue; // no FastOR entry found
186  int absID;
187  fGeom->GetTriggerMapping()->GetAbsFastORIndexFromPositionInEMCAL(icol, irow, absID);
188  for (auto t : thresholds)
189  {
190  if (fastor->second < t)
191  continue; // fastOR below threshold
192  // Check if the FastOr is already booked
193  std::set<int> &booking = isJetPatch ? bookedFastorsJE.find(t)->second : bookedFastorsGA.find(t)->second;
194  if (booking.find(absID) != booking.end())
195  continue;
196  // count fastor and book
197  if (isJetPatch)
198  countersEJE[t]++;
199  else
200  countersEGA[t]++;
201  booking.insert(absID);
202  }
203  }
204  }
205  }
206 
207  for (auto t : thresholds)
208  {
209  fHistos->FillTH2(Form("hFastorMultL1_EGA_ADC%d", t), multval, countersEGA[t]);
210  fHistos->FillTH2(Form("hFastorMultL1_EJE_ADC%d", t), multval, countersEJE[t]);
211  }
212 
213  return true;
214 }
215 
217 {
218  auto mgr = AliAnalysisManager::GetAnalysisManager();
219  if (!mgr)
220  {
221  AliErrorGeneralStream("AliAnalysisTaskEmcalFastorMultiplicity::AddTaskEmcalFastorMultiplicity") << "No Analysis Manager defined" << std::endl;
222  return nullptr;
223  }
224 
225  auto task = new AliAnalysisTaskEmcalFastorMultiplicity(name);
226  mgr->AddTask(task);
227 
228  mgr->ConnectInput(task, 0, mgr->GetCommonInputContainer());
229  mgr->ConnectOutput(task, 1, mgr->CreateContainer(Form("HistosFastorMultiplicity_%s", name), TList::Class(), AliAnalysisManager::kOutputContainer, mgr->GetCommonFileName()));
230  return task;
231 }
Base task in the EMCAL framework.
void FillTH2(const char *hname, double x, double y, double weight=1., Option_t *opt="")
Fill a 2D histogram within the container.
void SetCaloTriggerPatchInfoName(const char *n)
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
float Float_t
Definition: External.C:68
AliEMCALGeometry * fGeom
!emcal geometry
static AliAnalysisTaskEmcalFastorMultiplicity * AddTaskEmcalFastorMultiplicity(const char *name)
AliEmcalList * fOutput
!output list
TClonesArray * fTriggerPatchInfo
!trigger patch info array
void SetNeedEmcalGeom(Bool_t n)
Container class for histograms.
Definition: THistManager.h:99
void UserCreateOutputObjects()
Main initialization function on the worker.
bool Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.