139{
140 IdentifierHash myHashMin,myHashMax;
142 unsigned int myCellHashOffset = myHashMin;
143
145 std::map<Identifier,CaloCell*> cellMap;
146 std::map<Identifier,float> energyMap;
147 for (itrCell=itrCellBeg;itrCell!=itrCellEnd;++itrCell) {
148 CaloCell * theCell = *itrCell;
149 cellMap.insert(std::pair<Identifier,CaloCell*>(theCell->
ID(),theCell));
150 energyMap.insert(std::pair<Identifier,float>(theCell->
ID(),theCell->
energy()));
151 }
152
153 for (itrCell=itrCellBeg;itrCell!=itrCellEnd;++itrCell) {
154 CaloCell * theCell = *itrCell;
155 const CaloDetDescrElement* element = theCell->
caloDDE();
156
159
160 if (sample==6) {
161 std::map<Identifier,float>::iterator cellItEng = energyMap.find(theCell->
ID());
162 if (cellItEng==energyMap.end()) {
164 return StatusCode::FAILURE;
165 }
166 double e = (*cellItEng).second;
167
169 std::vector<IdentifierHash> theNeighbors;
170
171 int otherSubDet;
172 Identifier myId = theCell->
ID();
173 IdentifierHash myHashId =
m_calo_id->subcalo_cell_hash(myId,otherSubDet);
174
175
177 ATH_MSG_DEBUG (
"N1 theNeighbors.size() = " << theNeighbors.size());
178 IdentifierHash nId = theNeighbors.at(0)-myCellHashOffset;
180 std::map<Identifier,CaloCell*>::iterator cellIt = cellMap.find(myId);
181 if (cellIt==cellMap.end()) {
182 ATH_MSG_ERROR (
"neighbor CaloCell object not found in cellMap");
183 return StatusCode::FAILURE;
184 }
185 CaloCell * theCellN1 = (*cellIt).second;
186 if (!theCellN1) {
187 ATH_MSG_ERROR (
"neighbor CaloCell object not found in cellMap");
188 return StatusCode::FAILURE;
189 }
190 cellItEng = energyMap.find(theCellN1->
ID());
191 if (cellItEng==energyMap.end()) {
193 return StatusCode::FAILURE;
194 }
195 double eN1 = (*cellItEng).second;
196
197
198 int EMEC3neighbors = 0;
199 myHashId =
m_calo_id->subcalo_cell_hash(theCellN1->
ID(),otherSubDet);
200
202 ATH_MSG_DEBUG (
"N2 theNeighbors.size() = " << theNeighbors.size() );
203 CaloCell * theCellN2 = 0x0;
204 double eN2 = 0.;
205 if (theNeighbors.size()>0) {
206 nId = theNeighbors.at(0)-myCellHashOffset;
208 cellIt = cellMap.find(myId);
209 if (cellIt!=cellMap.end()) {
210 theCellN2 = (*cellIt).second;
211 cellItEng = energyMap.find(theCellN2->
ID());
212 if (cellItEng==energyMap.end()) {
214 return StatusCode::FAILURE;
215 }
216 eN2 = (*cellItEng).second;
217 EMEC3neighbors++;
218 }
219 }
220
222 ATH_MSG_DEBUG (
"N3 theNeighbors.size() = " << theNeighbors.size() );
223 CaloCell * theCellN3 = 0x0;
224 double eN3 = 0.;
225 if (theNeighbors.size()>0) {
226 nId = theNeighbors.at(0)-myCellHashOffset;
228 cellIt = cellMap.find(myId);
229 if (cellIt!=cellMap.end()) {
230 theCellN3 = (*cellIt).second;
231 cellItEng = energyMap.find(theCellN3->
ID());
232 if (cellItEng==energyMap.end()) {
234 return StatusCode::FAILURE;
235 }
236 eN3 = (*cellItEng).second;
237 EMEC3neighbors++;
238 }
239 }
240
241
242 int EMEC2neighbors = 0;
243 myHashId =
m_calo_id->subcalo_cell_hash(theCell->
ID(),otherSubDet);
244
246 ATH_MSG_DEBUG (
"N4 theNeighbors.size() = " << theNeighbors.size() );
247 CaloCell * theCellN4 = 0x0;
248 double eN4 = 0.;
249 if (theNeighbors.size()>0) {
250 nId = theNeighbors.at(0)-myCellHashOffset;
252 cellIt = cellMap.find(myId);
253 if (cellIt!=cellMap.end()) {
254 theCellN4 = (*cellIt).second;
255 cellItEng = energyMap.find(theCellN4->
ID());
256 if (cellItEng==energyMap.end()) {
258 return StatusCode::FAILURE;
259 }
260 eN4 = (*cellItEng).second;
261 EMEC2neighbors++;
262 }
263 }
264
266 ATH_MSG_DEBUG (
"N5 theNeighbors.size() = " << theNeighbors.size() );
267 CaloCell * theCellN5 = 0x0;
268 double eN5 = 0.;
269 if (theNeighbors.size()>0) {
270 nId = theNeighbors.at(0)-myCellHashOffset;
272 cellIt = cellMap.find(myId);
273 if (cellIt!=cellMap.end()) {
274 theCellN5 = (*cellIt).second;
275 cellItEng = energyMap.find(theCellN5->
ID());
276 if (cellItEng==energyMap.end()) {
278 return StatusCode::FAILURE;
279 }
280 eN5 = (*cellItEng).second;
281 EMEC2neighbors++;
282 }
283 }
284
288 double rescaled_eN1 = 0;
290 double rescaled_eN2 = 0.;
292 double rescaled_eN3 = 0.;
294
295
296
297
298
299
300
303 if (theCellN1)
305 if (theCellN2)
307 if (theCellN3)
309 if (theCellN4)
311 if (theCellN5)
313
314 ATH_MSG_DEBUG (
"EMEC2 cell : energy before = " << e <<
" | energy after rescaling = " << rescaled_e );
320 <<
" | " << (theCell->
energy()-e) );
321 ATH_MSG_DEBUG (
"EMEC3 cell (N1): energy before = " << eN1 <<
" | energy after rescaling = " << rescaled_eN1 );
323 <<
" | " << (theCellN1->
energy()-eN1) );
324 if (theCellN2) {
325 ATH_MSG_DEBUG (
"EMEC3 cell (N2): energy before = " << eN2 <<
" | energy after rescaling = " << rescaled_eN2 );
327 <<
" | " << (theCellN2->
energy()-eN2) );
328 }
329 if (theCellN3) {
330 ATH_MSG_DEBUG (
"EMEC3 cell (N3): energy before = " << eN3 <<
" | energy after rescaling = " << rescaled_eN3 );
332 <<
" | " << (theCellN3->
energy()-eN3) );
333 }
334
335
336
337
338
339
340
341
342
343
344
345
347 if (theCellN1) theCellN1->
setEnergy(rescaled_eN1);
348 if (theCellN2) theCellN2->
setEnergy(rescaled_eN2);
349 if (theCellN3) theCellN3->
setEnergy(rescaled_eN3);
350
351
352 }
353 }
354 }
355 return StatusCode::SUCCESS;
356}
CaloSampling::CaloSample CaloSample
double energy() const
get energy (data member)
const CaloDetDescrElement * caloDDE() const
get pointer to CaloDetDescrElement (data member)
virtual void setEnergy(float energy)
set energy
Identifier ID() const
get ID (from cached data member) non-virtual and inline for fast access
CaloCell_ID::SUBCALO getSubCalo() const
cell subcalo
CaloCell_ID::CaloSample getSampling() const
cell sampling
bool is_lar_em_endcap_inner() const
cell belongs to the inner wheel of EM end cap