115{
116 SG::ReadCondHandle<ILArfSampl> fSamplHdl(
m_fSamplKey);
117 const ILArfSampl* fSampl=*fSamplHdl;
118
120 ATH_CHECK( tileSamplingFraction.isValid() );
121
123 std::vector<const CaloCalibrationHitContainer *> v_cchc;
126 {
127 ATH_MSG_WARNING(
"SG does not contain calibration hit container " << containerName);
128 }
129 else
130 {
133 {
134 ATH_MSG_ERROR(
"Cannot retrieve calibration hit container " << containerName);
136 }
137 else
138 {
139 v_cchc.push_back(cchc);
140 }
141 }
142 }
143
146 if (
sc.isFailure()||!truthEvent)
147 {
149 return StatusCode::FAILURE;
150 }
157
158
159
160
161
162 SG::ReadCondHandle<CaloDetDescrManager> caloMgrHandle{
m_caloMgrKey};
164 const CaloDetDescrManager* caloMgr = *caloMgrHandle;
165
168
174
181
191 }
192
193 struct cell_info {
194 Long64_t cell_identifier=0;
195 float cell_energy_reco=0;
196 float cell_energy_active_total_corrected=0;
197 float cell_energy_active_total=0;
198 float cell_energy_inactive_total=0;
199 int cell_sampling=0;
200 float cell_eta=0;
201 float cell_phi=0;
202 };
203
204 std::map< Long64_t , cell_info > cell_info_map;
205
206 for(
int s=0;
s<24;
s++)
207 {
210
216
223 }
224
227 {
229 for(const CaloCalibrationHit* calibHit : *calibHitContainer)
230 {
231 Identifier id=calibHit->cellID();
232
233 double Etot = calibHit->energyTotal();
234 double Eem = calibHit->energyEM();
235 double Enonem = calibHit->energyNonEM();
236 double Einv = calibHit->energyInvisible();
237 double Eesc = calibHit->energyEscaped();
238
239 double Efactor=1.0;
240
241 const CaloDetDescrElement* caloDDE = caloMgr->
get_element(
id);
242 int sampling=-1;
243 if(caloDDE) {
245
246 if((sampling>=0 && sampling<=11) || (sampling>=21 && sampling<=23)) Efactor=1/fSampl->
FSAMPL(
id);
247 if((sampling>=12 && sampling<=20)) {
250 int drawerIdx =
m_tileHWID->drawerIdx(channel_id);
251 Efactor = tileSamplingFraction->getSamplingFraction(drawerIdx, channel);
252 Identifier cell_id =
m_tileID->cell_id(
id);
254 id=cell_id;
255 }
256 }
257 }
258
259 ATH_MSG_VERBOSE(
"cellID "<<
id<<
" layer "<<sampling<<
" energyTotal "<<Etot<<
" Eem "<<Eem<<
" Enonem "<<Enonem<<
" Einv "<<Einv<<
" Eesc "<<Eesc<<
" Efactor="<<Efactor);
260
261 if(sampling>=0 && sampling<=23)
262 {
264 cell_info_map[id.get_compact()].cell_identifier=id.get_compact();
265 cell_info_map[id.get_compact()].cell_sampling=sampling;
266 cell_info_map[
id.get_compact()].cell_eta=caloDDE->
eta_raw();
267 cell_info_map[
id.get_compact()].cell_phi=caloDDE->
phi_raw();
268 }
269
271 {
277
278 if(
m_docells) cell_info_map[
id.get_compact()].cell_energy_inactive_total+=Etot;
279 }
280
282 {
289
291 cell_info_map[id.get_compact()].cell_energy_active_total_corrected+=Etot*Efactor;
292 cell_info_map[id.get_compact()].cell_energy_active_total+=Etot;
293 }
294 }
295
296 }
297
298 }
299
301 }
302
303
304 const CaloCellContainer *cellColl{};
305 sc =
evtStore()->retrieve(cellColl,
"AllCalo");
306
307 if (
sc.isFailure()) {
309
310 } else {
312 for (const CaloCell* cell : *cellColl) {
313 Identifier
id=
cell->ID();
314 const CaloDetDescrElement* caloDDE = caloMgr->
get_element(
id);
315 int sampling=-1;
316 if(caloDDE) {
319 if((sampling>=12 && sampling<=20)) {
320 Identifier cell_id =
m_tileID->cell_id(
id);
322 id=cell_id;
323 }
324 }
325 }
327 cell_info_map[id.get_compact()].cell_identifier=id.get_compact();
328 cell_info_map[id.get_compact()].cell_sampling=sampling;
329 cell_info_map[
id.get_compact()].cell_eta=caloDDE->
eta_raw();
330 cell_info_map[
id.get_compact()].cell_phi=caloDDE->
phi_raw();
331 cell_info_map[
id.get_compact()].cell_energy_reco+=
cell->energy();
332 }
333 }
334 }
335
336
337
338 const std::vector<std::string> lArKeys = {"LArHitEMB", "LArHitEMEC", "LArHitFCAL", "LArHitHEC"};
339 for (const std::string& containerName: lArKeys) {
343 int hitnumber = 0;
344 for (const LArHit* larHit : *larContainer) {
345 hitnumber++;
346 const CaloDetDescrElement *hitElement = caloMgr->
get_element(larHit->cellID());
347 if(!hitElement) continue;
348 Identifier larhitid = hitElement->
identify();
352 }
353 }
354 ATH_MSG_DEBUG(
"Read "<<hitnumber<<
" G4Hits from "<<containerName);
355 }
356 else {
358 }
359 }
360
363 int hitnumber = 0;
364 for(const TileHit& hit : *hitVec) {
365 ++hitnumber;
366 Identifier pmt_id = hit.identify();
367 Identifier cell_id =
m_tileID->cell_id(pmt_id);
368
371
372
373 for (int tilesubhit_i = 0; tilesubhit_i<hit.size(); tilesubhit_i++) {
375 ATH_MSG_DEBUG(
"Tile subhit: "<<tilesubhit_i<<
"/"<<hit.size()<<
" E: "<<hit.energy(tilesubhit_i) );
377 }
378 }
379 }
380 ATH_MSG_DEBUG(
"Read "<<hitnumber<<
" G4Hits from TileHitVec");
381 }
382
383 for(auto& cell:cell_info_map) {
392 }
393
395
403
410
420 }
421
422 return StatusCode::SUCCESS;
423}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
CaloCalibrationHitContainer
AtlasHitsVector< TileHit > TileHitVector
constexpr int pow(int base, int exp) noexcept
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)
retrieve(aClass, aKey=None)