41{
42
43 if (!collection) {
44 ATH_MSG_ERROR(
"A null collection was passed, which should never happen");
45 return StatusCode::FAILURE;
46 }
47
48 SG::ReadHandle<xAOD::CaloClusterContainer> inputClusters(
50
51 SG::ReadHandle<CaloCellContainer> cellcoll(
m_cellsKey, ctx);
52
53
54 SG::ReadCondHandle<CaloDetDescrManager> caloDetDescrMgrHandle{
56 };
58
59 const CaloDetDescrManager* calodetdescrmgr = *caloDetDescrMgrHandle;
60
61 DataLink<CaloCellContainer> cellLink (cellcoll.ptr(), ctx);
62
63
64 for (const auto* cluster : *inputClusters) {
65
67
69 continue;
70
71
72
73
74
75 if (!cluster->inBarrel() && !cluster->inEndcap()) {
76 continue;
77 }
78
79
82 if (!in_barrel) {
83 sam = CaloSampling::EME2;
84 }
85
86
87
88 auto eta = cluster->etaSample(sam);
89 auto phi = cluster->phiSample(sam);
90
91 if ((
eta == 0. &&
phi == 0.) || std::abs(
eta) > 100) {
94 continue;
95 }
96
97
100 int sampling_or_module = 0;
101
104
105
106
107
108 const CaloDetDescrElement* dde = calodetdescrmgr->
get_element(
110
111
112 if (!dde) {
114 <<
" phi = " <<
phi);
116 continue;
117 }
118
119
120 auto deta = dde->
deta();
121 auto dphi = dde->
dphi();
122
123
124
125
126
127 CaloLayerCalculator
calc;
129 calc.fill(*calodetdescrmgr, cellcoll.ptr(), cluster->etaSample(sam),
132 if (
sc.isFailure()) {
134 continue;
135 }
136 double etamax =
calc.etarmax();
137 double phimax =
calc.phirmax();
138
139
145
146 } else {
147
149 continue;
150 }
151
152
153 if (cluster->inBarrel()) {
154 continue;
155 }
156
157
158 if (cluster->eSample(CaloSampling::EME2) <= 0 &&
159 cluster->eSample(CaloSampling::FCAL0) <= 0){
160 continue;
161 }
162
163
166 if(in_EMEC){
167 sam = CaloSampling::EME2;
168 }
169
170
171 auto eta = cluster->etaSample(sam);
172 auto phi = cluster->phiSample(sam);
173
174 if ((
eta == 0. &&
phi == 0.) || std::abs(
eta) > 100) {
176 <<
eta <<
" phi = " <<
phi <<
" Eeme2 = "
177 << cluster->eSample(CaloSampling::EME2) << " Efcal = "
178 << cluster->eSample(CaloSampling::FCAL0));
179 continue;
180 }
181
182
183 bool emec = false;
185 int sampling_or_module = 0;
186
189
190
191
192
193
194 const CaloDetDescrElement* dde = calodetdescrmgr->
get_element(
195 subcalo, sampling_or_module, emec,
eta,
phi);
196
197
198 if (!dde) {
200 <<
" phi = " <<
phi);
202 continue;
203 }
204
205
206 auto deta = dde->
deta();
207 auto dphi = dde->
dphi();
208
209
210
211
212
213
214
215
218
219
220 CaloLayerCalculator
calc;
222 *calodetdescrmgr, cellcoll.ptr(), cluster->etaSample(sam),
225
226 if (
sc.isFailure()) {
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
251
252 std::vector<const CaloCell*>
cells;
254 CaloCellList myList(calodetdescrmgr, cellcoll.ptr());
255 for (auto s : caloSamV) {
256 myList.select(cluster->etaSample(sam), cluster->phiSample(sam),
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 }
272 }
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_WARNING(x)
CaloCell_Base_ID::SUBCALO SUBCALO
CaloSampling::CaloSample CaloSample
static std::unique_ptr< xAOD::CaloCluster > makeCluster(const CaloCellContainer *cellCont)
Creates a valid CaloCluster with a private Aux-Store and CellLink container.
float dphi() const
cell dphi
float deta() const
cell deta
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:
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
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.
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.
::StatusCode StatusCode
StatusCode definition for legacy code.
bool inBarrel(const xAOD::CaloCluster &cluster, int is)
return boolean to know if we are in barrel/end-cap
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.