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 if (!theCellN3){
233 return StatusCode::FAILURE;
234 }
235 cellItEng = energyMap.find(theCellN3->
ID());
236 if (cellItEng==energyMap.end()) {
238 return StatusCode::FAILURE;
239 }
240 eN3 = (*cellItEng).second;
241 EMEC3neighbors++;
242 }
243 }
244
245
246 int EMEC2neighbors = 0;
247 myHashId =
m_calo_id->subcalo_cell_hash(theCell->
ID(),otherSubDet);
248
250 ATH_MSG_DEBUG (
"N4 theNeighbors.size() = " << theNeighbors.size() );
251 CaloCell * theCellN4 = 0x0;
252 double eN4 = 0.;
253 if (theNeighbors.size()>0) {
254 nId = theNeighbors.at(0)-myCellHashOffset;
256 cellIt = cellMap.find(myId);
257 if (cellIt!=cellMap.end()) {
258 theCellN4 = (*cellIt).second;
259 if (!theCellN4){
261 return StatusCode::FAILURE;
262 }
263 cellItEng = energyMap.find(theCellN4->
ID());
264 if (cellItEng==energyMap.end()) {
266 return StatusCode::FAILURE;
267 }
268 eN4 = (*cellItEng).second;
269 EMEC2neighbors++;
270 }
271 }
272
274 ATH_MSG_DEBUG (
"N5 theNeighbors.size() = " << theNeighbors.size() );
275 CaloCell * theCellN5 = 0x0;
276 double eN5 = 0.;
277 if (theNeighbors.size()>0) {
278 nId = theNeighbors.at(0)-myCellHashOffset;
280 cellIt = cellMap.find(myId);
281 if (cellIt!=cellMap.end()) {
282 theCellN5 = (*cellIt).second;
283 cellItEng = energyMap.find(theCellN5->
ID());
284 if (cellItEng==energyMap.end()) {
286 return StatusCode::FAILURE;
287 }
288 eN5 = (*cellItEng).second;
289 EMEC2neighbors++;
290 }
291 }
292
296 double rescaled_eN1 = 0;
298 double rescaled_eN2 = 0.;
300 double rescaled_eN3 = 0.;
302
303
304
305
306
307
308
311 if (theCellN1)
313 if (theCellN2)
315 if (theCellN3)
317 if (theCellN4)
319 if (theCellN5)
321
322 ATH_MSG_DEBUG (
"EMEC2 cell : energy before = " << e <<
" | energy after rescaling = " << rescaled_e );
328 <<
" | " << (theCell->
energy()-e) );
329 ATH_MSG_DEBUG (
"EMEC3 cell (N1): energy before = " << eN1 <<
" | energy after rescaling = " << rescaled_eN1 );
331 <<
" | " << (theCellN1->
energy()-eN1) );
332 if (theCellN2) {
333 ATH_MSG_DEBUG (
"EMEC3 cell (N2): energy before = " << eN2 <<
" | energy after rescaling = " << rescaled_eN2 );
335 <<
" | " << (theCellN2->
energy()-eN2) );
336 }
337 if (theCellN3) {
338 ATH_MSG_DEBUG (
"EMEC3 cell (N3): energy before = " << eN3 <<
" | energy after rescaling = " << rescaled_eN3 );
340 <<
" | " << (theCellN3->
energy()-eN3) );
341 }
342
343
344
345
346
347
348
349
350
351
352
353
355 if (theCellN1) theCellN1->
setEnergy(rescaled_eN1);
356 if (theCellN2) theCellN2->
setEnergy(rescaled_eN2);
357 if (theCellN3) theCellN3->
setEnergy(rescaled_eN3);
358
359
360 }
361 }
362 }
363 return StatusCode::SUCCESS;
364}
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