118{
119 SG::ReadCondHandle<ILArfSampl> fSamplHdl(
m_fSamplKey);
120 const ILArfSampl* fSampl=*fSamplHdl;
121
123 ATH_CHECK( tileSamplingFraction.isValid() );
124
126 std::vector<const CaloCalibrationHitContainer *> v_cchc;
129 {
130 ATH_MSG_WARNING(
"SG does not contain calibration hit container " << containerName);
131 }
132 else
133 {
136 {
137 ATH_MSG_ERROR(
"Cannot retrieve calibration hit container " << containerName);
139 }
140 else
141 {
142 v_cchc.push_back(cchc);
143 }
144 }
145 }
146
149 if (
sc.isFailure()||!truthEvent)
150 {
152 return StatusCode::FAILURE;
153 }
160
161
162
163
164
165 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{
m_caloMgrKey};
167 const CaloDetDescrManager* caloMgr = *caloMgrHandle;
168
171
177
184
194 }
195
196 struct cell_info {
197 Long64_t cell_identifier=0;
198 float cell_energy_reco=0;
199 float cell_energy_active_total_corrected=0;
200 float cell_energy_active_total=0;
201 float cell_energy_inactive_total=0;
202 int cell_sampling=0;
203 float cell_eta=0;
204 float cell_phi=0;
205 };
206
207 std::map< Long64_t , cell_info > cell_info_map;
208
209 for(
int s=0;
s<24;
s++)
210 {
213
219
226 }
227
230 {
232 for(const CaloCalibrationHit* calibHit : *calibHitContainer)
233 {
234 Identifier id=calibHit->cellID();
235
236 double Etot = calibHit->energyTotal();
237 double Eem = calibHit->energyEM();
238 double Enonem = calibHit->energyNonEM();
239 double Einv = calibHit->energyInvisible();
240 double Eesc = calibHit->energyEscaped();
241
242 double Efactor=1.0;
243
244 const CaloDetDescrElement* caloDDE = caloMgr->
get_element(
id);
245 int sampling=-1;
246 if(caloDDE) {
248
249 if((sampling>=0 && sampling<=11) || (sampling>=21 && sampling<=23)) Efactor=1/fSampl->
FSAMPL(
id);
250 if((sampling>=12 && sampling<=20)) {
253 int drawerIdx =
m_tileHWID->drawerIdx(channel_id);
254 Efactor = tileSamplingFraction->getSamplingFraction(drawerIdx, channel);
255 Identifier cell_id =
m_tileID->cell_id(
id);
257 id=cell_id;
258 }
259 }
260 }
261
262 ATH_MSG_VERBOSE(
"cellID "<<
id<<
" layer "<<sampling<<
" energyTotal "<<Etot<<
" Eem "<<Eem<<
" Enonem "<<Enonem<<
" Einv "<<Einv<<
" Eesc "<<Eesc<<
" Efactor="<<Efactor);
263
264 if(sampling>=0 && sampling<=23)
265 {
267 cell_info_map[id.get_compact()].cell_identifier=id.get_compact();
268 cell_info_map[id.get_compact()].cell_sampling=sampling;
269 cell_info_map[
id.get_compact()].cell_eta=caloDDE->
eta_raw();
270 cell_info_map[
id.get_compact()].cell_phi=caloDDE->
phi_raw();
271 }
272
274 {
280
281 if(
m_docells) cell_info_map[
id.get_compact()].cell_energy_inactive_total+=Etot;
282 }
283
285 {
292
294 cell_info_map[id.get_compact()].cell_energy_active_total_corrected+=Etot*Efactor;
295 cell_info_map[id.get_compact()].cell_energy_active_total+=Etot;
296 }
297 }
298
299 }
300
301 }
302
304 }
305
306
307 const CaloCellContainer *cellColl{};
308 sc =
evtStore()->retrieve(cellColl,
"AllCalo");
309
310 if (
sc.isFailure()) {
312
313 } else {
315 for (const CaloCell* cell : *cellColl) {
316 Identifier
id=
cell->ID();
317 const CaloDetDescrElement* caloDDE = caloMgr->
get_element(
id);
318 int sampling=-1;
319 if(caloDDE) {
322 if((sampling>=12 && sampling<=20)) {
323 Identifier cell_id =
m_tileID->cell_id(
id);
325 id=cell_id;
326 }
327 }
328 }
330 cell_info_map[id.get_compact()].cell_identifier=id.get_compact();
331 cell_info_map[id.get_compact()].cell_sampling=sampling;
333 cell_info_map[
id.get_compact()].cell_eta=caloDDE->
eta_raw();
334 cell_info_map[
id.get_compact()].cell_phi=caloDDE->
phi_raw();
335 }
336 cell_info_map[
id.get_compact()].cell_energy_reco+=
cell->energy();
337 }
338 }
339 }
340
341
342
343 const std::vector<std::string> lArKeys = {"LArHitEMB", "LArHitEMEC", "LArHitFCAL", "LArHitHEC"};
344 for (const std::string& containerName: lArKeys) {
347 if(
evtStore()->retrieve(larContainer,containerName)==StatusCode::SUCCESS) {
348 int hitnumber = 0;
349 for (const LArHit* larHit : *larContainer) {
350 hitnumber++;
351 const CaloDetDescrElement *hitElement = caloMgr->
get_element(larHit->cellID());
352 if(!hitElement) continue;
353 Identifier larhitid = hitElement->
identify();
357 }
358 }
359 ATH_MSG_DEBUG(
"Read "<<hitnumber<<
" G4Hits from "<<containerName);
360 }
361 else {
363 }
364 }
365
367 if (
evtStore()->retrieve(hitVec,
"TileHitVec")==StatusCode::SUCCESS &&
m_tileID ) {
368 int hitnumber = 0;
369 for(const TileHit& hit : *hitVec) {
370 ++hitnumber;
371 Identifier pmt_id = hit.identify();
372 Identifier cell_id =
m_tileID->cell_id(pmt_id);
373
376
377
378 for (int tilesubhit_i = 0; tilesubhit_i<hit.size(); tilesubhit_i++) {
380 ATH_MSG_DEBUG(
"Tile subhit: "<<tilesubhit_i<<
"/"<<hit.size()<<
" E: "<<hit.energy(tilesubhit_i) );
382 }
383 }
384 }
385 ATH_MSG_DEBUG(
"Read "<<hitnumber<<
" G4Hits from TileHitVec");
386 }
387
388 for(auto& cell:cell_info_map) {
397 }
398
400
408
415
425 }
426
427 return StatusCode::SUCCESS;
428}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
CaloCalibrationHitContainer
AtlasHitsVector< TileHit > TileHitVector
ServiceHandle< StoreGateSvc > & evtStore()
CaloSampling::CaloSample CaloSample
float eta_raw() const
cell eta_raw
CaloCell_ID::CaloSample getSampling() const
cell sampling
Identifier identify() const override final
cell identifier
float phi_raw() const
cell phi_raw
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
const T * at(size_type n) const
Access an element, as an rvalue.
size_type size() const noexcept
Returns the number of elements in the collection.
virtual const float & FSAMPL(const HWIdentifier &id) const =0
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
std::vector< float > * m_energy_inactive_nonem
std::vector< float > * m_cell_eta
const TileCablingService * m_tileCabling
std::vector< float > * m_energy_active_total
std::vector< float > * m_energy_active_em
std::vector< float > * m_energy_active_inv
std::vector< float > * m_energy_active_esc
std::vector< int > * m_cell_sampling
SG::ReadCondHandleKey< ILArfSampl > m_fSamplKey
std::vector< float > * m_cell_energy_active_total
std::vector< float > * m_energy_hit
std::vector< float > * m_energy_inactive_em
std::vector< float > * m_energy_inactive_inv
std::vector< float > * m_cell_energy_reco
SG::ReadCondHandleKey< TileSamplingFraction > m_tileSamplingFractionKey
Name of TileSamplingFraction in condition store.
std::vector< float > * m_cell_phi
std::vector< float > * m_energy_active_nonem
std::vector< float > * m_cell_energy_active_total_corrected
const TileHWID * m_tileHWID
std::vector< Long64_t > * m_cell_identifier
std::vector< float > * m_energy_inactive_total
std::vector< float > * m_energy_reco
std::vector< float > * m_cell_energy_inactive_total
std::vector< float > * m_energy_active_total_corrected
std::vector< float > * m_energy_inactive_esc
bool contains(const std::string &s, const std::string ®x)
does a string contain the substring
int count(std::string s, const std::string ®x)
count how many occurances of a regx are in a string
::StatusCode StatusCode
StatusCode definition for legacy code.
GenEvent::particle_iterator begin(HepMC::GenEvent &e)