ATLAS Offline Software
Loading...
Searching...
No Matches
CaloCornerRingsBuilder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
6
8
9// Cell includes:
11#include "CaloGeoHelpers/CaloSampling.h"
13
14// RingSet includes:
16
17// CaloRings includes:
19
20// Ringer Conf include:
22
23// Other xAOD includes:
24#include "xAODBase/IParticle.h"
26
27// STL
28#include <algorithm>
29#include <cfloat>
30#include <cmath>
31#include <sstream>
32#include <span>
33
34namespace Ringer
35{
36
38 const std::string &name,
39 const ::IInterface *parent)
40 : CaloRingsBuilder(type, name, parent)
41 {
42
43 declareInterface<ICaloRingsBuilder>(this);
44 }
45
47
50 {
51 double et(0.);
52 const double eta2 = std::fabs(cluster.etaBE(2));
53 const double energy = cluster.e();
54 if (eta2 < 999.)
55 {
56 const double cosheta = std::cosh(eta2);
57 et = (cosheta != 0.) ? energy / cosheta : 0.;
58 }
59 if (et > m_minEnergy)
60 {
61 // This now correctly calls the CaloCornerRingsBuilder::executeTemp
62 return executeTemp(cluster, clRings);
63 }
64 else
65 {
66 ATH_MSG_DEBUG("Skipping cluster with low energy (" << et << " MeV) .");
67 return StatusCode::SUCCESS;
68 }
69 }
70
73 {
74 double et = particle.pt();
75 if (et > m_minEnergy)
76 {
77 // This now correctly calls the CaloCornerRingsBuilder::executeTemp
78 return executeTemp(particle, clRings);
79 }
80 else
81 {
82 ATH_MSG_DEBUG("Skipping particle with low energy (" << et << " MeV) .");
83 return StatusCode::SUCCESS;
84 }
85 }
86
87 template <typename T>
89 const T &input,
91 {
92
93 ATH_MSG_DEBUG("Entering executeTemp with input eta=" << input.eta()
94 << " phi=" << input.phi());
95
96 xAOD::CaloRings *clRings = new xAOD::CaloRings();
97 m_crCont->push_back(clRings);
98
99 clRingsLink.toContainedElement(*m_crCont, clRings);
100
102 {
103 m_lastValidSeed = AtlasGeoPoint(input.eta(), input.phi());
104 ATH_MSG_DEBUG("Using input as seed eta=" << input.eta()
105 << " phi=" << input.phi());
106 }
107
109 {
110
111 xAOD::RingSet *rs = new xAOD::RingSet(rawConf.nRings);
112 m_rsCont->push_back(rs);
113
114 unsigned int nSubRings = rawConf.nRings / 5;
115
116 ATH_MSG_DEBUG("Creating RingSet with total rings=" << rawConf.nRings
117 << " subrings=" << nSubRings);
118
119 std::vector<AtlasGeoPoint> seeds;
120 seeds.reserve(5);
121
122 AtlasGeoPoint centralSeed;
123
124 CHECK(getRingSetSeed(rawConf, input, centralSeed));
125
126 ATH_MSG_DEBUG("Central seed eta=" << centralSeed.eta()
127 << " phi=" << centralSeed.phi());
128
129 seeds.push_back(centralSeed);
130
131 CHECK(getCornerRingsSeeds(rawConf, centralSeed, seeds));
132
133 for (size_t i = 0; i < seeds.size(); ++i)
134 {
135 const AtlasGeoPoint &seed = seeds[i];
136 const unsigned int offset = i * nSubRings;
137
138 CHECK(buildRingSet(rawConf, seed, rs, offset, nSubRings));
139 }
140
142 clRings->addRingSetEL(rsEL);
143 }
144
145 if (msgLevel() <= MSG::DEBUG)
146 {
147 std::ostringstream str;
148 clRings->print(str);
149 ATH_MSG_DEBUG(str.str());
150 }
151
152 return StatusCode::SUCCESS;
153 }
154
157 const AtlasGeoPoint &seed,
158 std::vector<AtlasGeoPoint> &cornerSeeds)
159 {
160
161 const float deltaEta = m_cornerShift * rawConf.etaWidth;
162 const float deltaPhi = m_cornerShift * rawConf.phiWidth;
163
164 ATH_MSG_DEBUG("Corner seed shifts: deltaEta=" << deltaEta
165 << " deltaPhi=" << deltaPhi);
166
167 AtlasGeoPoint top_right, top_left, bottom_right, bottom_left;
168
169 top_right.setEta(seed.eta() + deltaEta);
170 top_right.setPhi(seed.phi() + deltaPhi);
171
172 top_left.setEta(seed.eta() + deltaEta);
173 top_left.setPhi(seed.phi() - deltaPhi);
174
175 bottom_right.setEta(seed.eta() - deltaEta);
176 bottom_right.setPhi(seed.phi() + deltaPhi);
177
178 bottom_left.setEta(seed.eta() - deltaEta);
179 bottom_left.setPhi(seed.phi() - deltaPhi);
180
181 ATH_MSG_DEBUG("Corner seeds:");
182 ATH_MSG_DEBUG("top_right eta=" << top_right.eta() << " phi=" << top_right.phi());
183 ATH_MSG_DEBUG("top_left eta=" << top_left.eta() << " phi=" << top_left.phi());
184 ATH_MSG_DEBUG("bottom_right eta=" << bottom_right.eta() << " phi=" << bottom_right.phi());
185 ATH_MSG_DEBUG("bottom_left eta=" << bottom_left.eta() << " phi=" << bottom_left.phi());
186
187 cornerSeeds.push_back(top_right);
188 cornerSeeds.push_back(top_left);
189 cornerSeeds.push_back(bottom_left);
190 cornerSeeds.push_back(bottom_right);
191
192 return StatusCode::SUCCESS;
193 }
194
197 const AtlasGeoPoint &seed,
199 const unsigned int offset,
200 const unsigned int nSubRings)
201 {
202
204 ATH_CHECK(cellsCont.isValid());
205
207 ATH_CHECK(caloMgrHandle.isValid());
208
209 const CaloDetDescrManager *caloMgr = *caloMgrHandle;
210 CaloCellList cells(caloMgr, cellsCont.ptr());
211
212 for (const int layer : rawConf.layers)
213 {
214
215 ATH_MSG_DEBUG("Selecting cells in layer " << layer);
216
217 cells.select(seed.eta(), seed.phi(), m_cellMaxDEtaDist, m_cellMaxDPhiDist, layer);
218
219 for (const CaloCell *cell : cells)
220 {
221
222 unsigned int ringNumber(0);
223
224 const float deltaEta = std::abs((cell->eta() - seed.eta())) / rawConf.etaWidth;
225 const float deltaPhi = std::abs(CaloPhiRange::diff(cell->phi(), seed.phi())) / rawConf.phiWidth;
226
227 const float deltaGreater = std::max(deltaEta, deltaPhi);
228
229 ringNumber = static_cast<unsigned int>(std::floor(deltaGreater + .5));
230
231 if (ringNumber < nSubRings)
232 {
233 ringNumber += offset;
234
235 float energyToAdd = 0;
236
238 {
239 energyToAdd = cell->energy() / std::cosh(cell->eta());
240 }
241 else
242 {
243 energyToAdd = cell->energy();
244 }
245
246 rs->at(ringNumber) += energyToAdd;
247
248 ATH_MSG_DEBUG("New ring energy=" << rs->at(ringNumber));
249 }
250 }
251 }
252
253 return StatusCode::SUCCESS;
254 }
255 // =====================================================================================
256
257} // namespace Ringer
Scalar deltaPhi(const MatrixBase< Derived > &vec) const
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
float et(const xAOD::jFexSRJetRoI *j)
static Double_t rs
void setEta(const float eta)
float eta() const
void setPhi(const float phi)
float phi() const
Data object for each calorimeter readout cell.
Definition CaloCell.h:57
This class provides the client interface for accessing the detector description information common to...
static double diff(double phi1, double phi2)
simple phi1 - phi2 calculation, but result is fixed to respect range.
StatusCode getCornerRingsSeeds(const xAOD::RingSetConf::RawConf &rawConf, const AtlasGeoPoint &centralSeed, std::vector< AtlasGeoPoint > &cornerSeeds)
Get the seeds for the corner rings (top-left, etc).
Gaudi::Property< int > m_cornerShift
Number of cells to shift for corner seeds (top-left, etc).
virtual StatusCode execute(const xAOD::CaloCluster &cluster, ElementLink< xAOD::CaloRingsContainer > &clRings) override
Tool main methods:
virtual StatusCode buildRingSet(const xAOD::RingSetConf::RawConf &rawConf, const AtlasGeoPoint &seed, xAOD::RingSet *rs, const unsigned int offset, const unsigned int nSubRings)
CaloCornerRingsBuilder(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
StatusCode executeTemp(const T &input, ElementLink< xAOD::CaloRingsContainer > &crEL)
Tool private methods:
CaloRingsBuilder(const std::string &type, const std::string &name, const IInterface *parent)
Default constructor.
const xAOD::RingSetConf::RawConfCollection & rawConf() override
Extra methods:
xAOD::RingSetConf::RawConfCollection m_rsRawConfCol
holds each RingSet configuration (filled at initialize)
StatusCode getRingSetSeed(const xAOD::RingSetConf::RawConf &conf, const xAOD::CaloCluster &cluster, AtlasGeoPoint &seed)
Fill RingSet seed for CaloCluster.
Gaudi::Property< float > m_minEnergy
Minimum particle energy to build rings (GeV).
Gaudi::Property< bool > m_doTransverseEnergy
Switch to use raw cell energy instead ET.
Gaudi::Property< float > m_cellMaxDEtaDist
Maximum cell distance in eta to seed.
xAOD::RingSetContainer * m_rsCont
Tool props (non configurables):
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
xAOD::CaloRingsContainer * m_crCont
Create and hold CaloRingsContainer for each event.
SG::ReadHandleKey< CaloCellContainer > m_cellsContName
Name of CaloCellContainer.
AtlasGeoPoint m_lastValidSeed
last valid RingSet seed
Gaudi::Property< bool > m_useShowShapeBarycenter
Switch to use shower barycenter seed for each RingSets.
Gaudi::Property< float > m_cellMaxDPhiDist
Maximum cell distance in phi to seed.
const_pointer_type ptr()
Dereference the pointer.
virtual bool isValid() override final
Can the handle be successfully dereferenced?
virtual double e() const
The total energy of the particle.
float etaBE(const unsigned layer) const
Get the eta in one layer of the EM Calo.
void print(std::ostream &stream) const
Print-out methods:
void addRingSetEL(const ElementLink< RingSetContainer_v1 > &rsEL)
Add ElementLink to holden vector.
Class providing the definition of the 4-vector interface.
Namespace dedicated for Ringer utilities.
RingSet_v1 RingSet
Definition of the current "RingSet version".
Definition RingSet.h:15
CaloRings_v1 CaloRings
Definition of the current "CaloRings version".
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
Extra patterns decribing particle interation process.