ATLAS Offline Software
Loading...
Searching...
No Matches
egammaLargeClusterMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
18
20 const std::string& name,
21 const IInterface* parent)
22 : AthAlgTool(type, name, parent)
23{
24
25 // declare interface
26 declareInterface<CaloClusterCollectionProcessor>(this);
27}
28
29StatusCode
31{
33 ATH_CHECK(m_cellsKey.initialize());
34 ATH_CHECK(m_caloDetDescrMgrKey.initialize());
35 return StatusCode::SUCCESS;
36}
37
38StatusCode
39egammaLargeClusterMaker::execute(const EventContext& ctx,
40 xAOD::CaloClusterContainer* collection) const
41{
42
43 if (!collection) {
44 ATH_MSG_ERROR("A null collection was passed, which should never happen");
45 return StatusCode::FAILURE;
46 }
47
50 // retrieve the cell containers
52
53 // retrieve CaloDetDescr
54 SG::ReadCondHandle<CaloDetDescrManager> caloDetDescrMgrHandle{
56 };
57 ATH_CHECK(caloDetDescrMgrHandle.isValid());
58
59 const CaloDetDescrManager* calodetdescrmgr = *caloDetDescrMgrHandle;
60
61 DataLink<CaloCellContainer> cellLink (cellcoll.ptr(), ctx);
62
63 // The main loop over clusters
64 for (const auto* cluster : *inputClusters) {
65
66 if (!m_isFWD) {
67
68 if (cluster->et() < m_centEtThr)
69 continue;
70
71 // find the center of the cluster, copying the logic of
72 // egammaMiddleShape.cxx
73
74 // check if cluster is in barrel or end-cap
75 if (!cluster->inBarrel() && !cluster->inEndcap()) {
76 continue;
77 }
78
79 // check if cluster is in barrel or end-cap
80 bool in_barrel = egammaEnergyPositionAllSamples::inBarrel(*cluster, 2);
81 CaloSampling::CaloSample sam = CaloSampling::EMB2;
82 if (!in_barrel) {
83 sam = CaloSampling::EME2;
84 }
85
86 // granularity in (eta,phi) in the pre sampler
87 // CaloCellList needs both enums: subCalo and CaloSample
88 auto eta = cluster->etaSample(sam);
89 auto phi = cluster->phiSample(sam);
90
91 if ((eta == 0. && phi == 0.) || std::abs(eta) > 100) {
92 ATH_MSG_WARNING("Weird input cluster, eta = " << eta
93 << " phi = " << phi);
94 continue;
95 }
96
97 // Should get overritten
98 bool barrel = false;
100 int sampling_or_module = 0;
101
103 subcalo, barrel, sampling_or_module, (CaloCell_ID::CaloSample)sam);
104
105 // Get the corresponding grannularities : needs to know where you are
106 // the easiest is to look for the CaloDetDescrElement
107
108 const CaloDetDescrElement* dde = calodetdescrmgr->get_element(
109 CaloCell_ID::LAREM, sampling_or_module, barrel, eta, phi);
110
111 // if object does not exist then return
112 if (!dde) {
113 ATH_MSG_WARNING("Weird input cluster eta = " << eta
114 << " phi = " << phi);
115 ATH_MSG_WARNING("No detetector element for seeding");
116 continue;
117 }
118
119 // local granularity
120 auto deta = dde->deta();
121 auto dphi = dde->dphi();
122
123 // search the hottest cell around the (eta,phi)
124 // (eta,phi) are defined as etaSample() and phiSample
125 // around this position a hot cell is searched for in a window
126 // (m_neta*m_deta,m_nphi*m_dphi), by default (m_neta,m_nphi)=(7,7)
128 StatusCode sc =
129 calc.fill(*calodetdescrmgr, cellcoll.ptr(), cluster->etaSample(sam),
130 cluster->phiSample(sam), m_neta * deta, m_nphi * dphi,
132 if (sc.isFailure()) {
133 ATH_MSG_WARNING("CaloLayerCalculator failed fill ");
134 continue;
135 }
136 double etamax = calc.etarmax();
137 double phimax = calc.phirmax();
138
139 // create the new cluster
140 xAOD::CaloCluster* newCluster =
141 CaloClusterStoreHelper::makeCluster(collection, cellLink);
142 newCluster->setEta0(etamax);
143 newCluster->setPhi0(phimax);
145
146 } else {
147 // FWD cluster collection
148 if (cluster->et() < m_fwdEtThr){
149 continue;
150 }
151
152 // check if cluster is in EMEC or FCAL
153 if (cluster->inBarrel()) {
154 continue;
155 }
156
157 // need some positive energy in EME2 or FCAL0 to be a good candidate
158 if (cluster->eSample(CaloSampling::EME2) <= 0 &&
159 cluster->eSample(CaloSampling::FCAL0) <= 0){
160 continue;
161 }
162
163 // check if cluster is in FCAL or EMEC
164 CaloSampling::CaloSample sam = CaloSampling::FCAL0;
165 bool in_EMEC = !(xAOD::EgammaHelpers::isFCAL(cluster));
166 if(in_EMEC){
167 sam = CaloSampling::EME2;
168 }
169 // granularity in (eta,phi) in the pre sampler
170 // CaloCellList needs both enums: subCalo and CaloSample
171 auto eta = cluster->etaSample(sam);
172 auto phi = cluster->phiSample(sam);
173
174 if ((eta == 0. && phi == 0.) || std::abs(eta) > 100) {
175 ATH_MSG_WARNING("Weird input cluster, maxeta = "
176 << eta << " phi = " << phi << " Eeme2 = "
177 << cluster->eSample(CaloSampling::EME2) << " Efcal = "
178 << cluster->eSample(CaloSampling::FCAL0));
179 continue;
180 }
181
182 // Should get overritten
183 bool emec = false;
185 int sampling_or_module = 0;
186
188 subcalo, emec, sampling_or_module, (CaloCell_ID::CaloSample)sam);
189
190 // Get the corresponding grannularities : needs to know where you are
191 // the easiest is to look for the CaloDetDescrElement
192 // const CaloDetDescrElement* get_element_FCAL (const
193 // CaloDetDescriptor* reg, double eta, double phi) const;
194 const CaloDetDescrElement* dde = calodetdescrmgr->get_element(
195 subcalo, sampling_or_module, emec, eta, phi);
196
197 // if object does not exist then return
198 if (!dde) {
199 ATH_MSG_WARNING("Weird input cluster eta = " << eta
200 << " phi = " << phi);
201 ATH_MSG_WARNING("No detetector element for seeding");
202 continue;
203 }
204
205 // local granularity
206 auto deta = dde->deta();
207 auto dphi = dde->dphi();
208
209 // search the hottest cell around the (eta,phi)
210 // (eta,phi) are defined as etaSample() and phiSample
211 // around this position a hot cell is searched for in a window
212 // (m_neta*m_deta,m_nphi*m_dphi), by default (m_neta,m_nphi)=(6,6)
213 // for EMEC-OUTER FWD much bigger cell size
214
215 // create the new cluster
216 xAOD::CaloCluster* newCluster =
217 CaloClusterStoreHelper::makeCluster(collection, cellLink);
218
219 // if In EMEC
221 StatusCode sc = calc.fill(
222 *calodetdescrmgr, cellcoll.ptr(), cluster->etaSample(sam),
223 cluster->phiSample(sam), m_netaFWD * deta, m_nphiFWD * dphi,
224 (CaloSampling::CaloSample)sam, in_EMEC ? newCluster : nullptr);
225
226 if (sc.isFailure()) {
227 ATH_MSG_WARNING("CaloLayerCalculator failed fill for FWD cluster");
228 continue;
229 }
230 double etamax = calc.etarmax();
231 double phimax = calc.phirmax();
232
233 newCluster->setEta0(etamax);
234 newCluster->setPhi0(phimax);
235
236 std::map<CaloSampling::CaloSample, double> caloSamV;
237 if (!in_EMEC) {
238 caloSamV[CaloSampling::FCAL0] = m_drFWD;
239 }
241 caloSamV[CaloSampling::EME1] = m_drEM;
242 if (in_EMEC) {
243 caloSamV[CaloSampling::FCAL0] = m_drFWD;
244 } else {
245 caloSamV[CaloSampling::EME2] = m_drFWD;
246 }
247 }
248
249 if (!caloSamV.empty()) {
250 // If FCAL need to add cell to cluster in a cone.
251 // Also if we want cells from other samplings
252 std::vector<const CaloCell*> cells;
253 cells.reserve(300);
254 CaloCellList myList(calodetdescrmgr, cellcoll.ptr());
255 for (auto s : caloSamV) {
256 myList.select(cluster->etaSample(sam), cluster->phiSample(sam),
257 s.second, (CaloSampling::CaloSample)s.first);
258 cells.insert(cells.end(), myList.begin(), myList.end());
259 }
260 for (const auto* cell : cells) {
261 if (!cell || !cell->caloDDE()) {
262 continue;
263 }
264 int index = cellcoll.ptr()->findIndex(cell->caloDDE()->calo_hash());
265 if (index == -1) {
266 continue;
267 }
268 newCluster->addCell(index, 1.);
269 }
270 }
271 } // end isFWD
272 } // main loop over clusters
273 return StatusCode::SUCCESS;
274}
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
Definition of CaloDetDescrManager.
Calculate total energy, position, etc. for a given layer of a cluster.
static Double_t sc
Handle class for reading from StoreGate.
Handle class for recording to StoreGate.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
list_iterator end() const
void select(double eta, double phi, double deta, double dphi)
list_iterator begin() const
CaloCell_Base_ID::SUBCALO SUBCALO
Definition CaloCell_ID.h:50
CaloSampling::CaloSample CaloSample
Definition CaloCell_ID.h:53
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
This class groups all DetDescr information related to a CaloCell.
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
static void decode_sample(CaloCell_ID::SUBCALO &subCalo, bool &barrel, int &sampling_or_module, CaloCell_ID::CaloSample sample)
translate between the 2 ways to label a sub-detector:
This class provides the client interface for accessing the detector description information common to...
const_pointer_type ptr()
Dereference the pointer.
virtual StatusCode initialize() override final
initialize method
Gaudi::Property< double > m_neta
Gaudi::Property< double > m_nphi
Gaudi::Property< bool > m_addCellsFromOtherSamplings
Et cut on input forward clusters to produce large clusters.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloDetDescrMgrKey
Gaudi::Property< double > m_netaFWD
virtual StatusCode execute(const EventContext &ctx, xAOD::CaloClusterContainer *collection) const override final
execute on container
Gaudi::Property< double > m_nphiFWD
Gaudi::Property< double > m_centEtThr
Et cut on input central clusters to produce large clusters.
Gaudi::Property< double > m_fwdEtThr
Et cut on input forward clusters to produce large clusters.
egammaLargeClusterMaker(const std::string &type, const std::string &name, const IInterface *parent)
@bried constructor
Gaudi::Property< double > m_drEM
SG::ReadHandleKey< xAOD::CaloClusterContainer > m_inputClusterCollection
The name of the cluster container for electrons and photons.
Gaudi::Property< double > m_drFWD
SG::ReadHandleKey< CaloCellContainer > m_cellsKey
Cell container.
Gaudi::Property< bool > m_isFWD
do FWD cell
void setClusterSize(const ClusterSize)
Get cluster size.
void setPhi0(flt_t)
Set raw of cluster seed.
bool addCell(const unsigned index, const double weight)
Method to add a cell to the cluster (Beware: Kinematics not updated!)
bool inBarrel(const xAOD::CaloCluster &cluster, int is)
return boolean to know if we are in barrel/end-cap
Definition index.py:1
bool isFCAL(const xAOD::CaloCluster *cluster)
return true if the cluster (or the majority of its energy) is in the FCAL0
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.