ATLAS Offline Software
Loading...
Searching...
No Matches
LArDeadOTXCondAlg.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "LArDeadOTXCondAlg.h"
7#include "CaloDetDescr/CaloDetDescrElement.h"
8
10
11 ATH_CHECK(m_MFKey.initialize());
12 ATH_CHECK(m_badSCKey.initialize());
13 ATH_CHECK(m_cablingKey.initialize());
14 ATH_CHECK(m_cablingSCKey.initialize());
15 ATH_CHECK(m_caloMgrKey.initialize());
16
17 ATH_CHECK(m_outputKey.initialize());
18
19 ATH_CHECK(detStore()->retrieve(m_onlineID, "LArOnlineID"));
20 ATH_CHECK(detStore()->retrieve(m_calo_id, "CaloCell_ID"));
21
22 ATH_CHECK(m_scidtool.retrieve());
23
24
25 return StatusCode::SUCCESS;
26}
27
28StatusCode LArDeadOTXCondAlg::execute(const EventContext& ctx) const {
29
30 ATH_MSG_DEBUG("executing");
31
33
34 if (outputHdl.isValid()) {
35 ATH_MSG_DEBUG("Found valid write handle");
36 return StatusCode::SUCCESS;
37 }
38
40 if (!cablingHdl.isValid()) {
41 ATH_MSG_ERROR("Do not have Onl-Ofl cabling map !!!!");
42 return StatusCode::FAILURE;
43 }
44 outputHdl.addDependency(cablingHdl);
45 const LArOnOffIdMapping* oflCabling = cablingHdl.cptr();
46
48 if (!cablingSCHdl.isValid()) {
49 ATH_MSG_ERROR("Do not have Onl-Ofl cabling map for SuperCells !!!!");
50 return StatusCode::FAILURE;
51 }
52 outputHdl.addDependency(cablingSCHdl);
53 const LArOnOffIdMapping* scCabling = cablingSCHdl.cptr();
54
56 if (!mfHdl.isValid()) {
57 ATH_MSG_ERROR("Do not have Missing FEBs container !!!!");
58 return StatusCode::FAILURE;
59 }
60 outputHdl.addDependency(mfHdl);
61
63 if (!caloMgrHandle.isValid()) {
64 ATH_MSG_ERROR("Do not have CaloDetDescManager !!!");
65 return StatusCode::FAILURE;
66 }
67 outputHdl.addDependency(caloMgrHandle);
68 const CaloDetDescrManager* caloDDM = *caloMgrHandle;
69
71 if (!bcSCHdl.isValid()) {
72 ATH_MSG_ERROR("Do not have BadSCContainer !!!!");
73 return StatusCode::FAILURE;
74 }
75 outputHdl.addDependency(bcSCHdl);
76 const LArBadChannelCont* bcSCCont = *bcSCHdl;
77
78 const auto& badFebs = mfHdl->fullCont();
79
80 std::unique_ptr<LArDeadOTXCorrFactors> output=std::make_unique<LArDeadOTXCorrFactors>();
81
82 auto& scToHwidMap=output->get();
83
84 unsigned nDeadFebs = 0;
85 for (const auto& idBF : badFebs) {
86 if (idBF.second.deadReadout()) {
87 ++nDeadFebs;
88 const HWIdentifier febid(idBF.first);
89 ATH_MSG_INFO("FEB " << m_onlineID->channel_name(febid) << " labelled as deadReadout");
90 const int nChans = m_onlineID->channelInSlotMax(febid);
91 if (nChans < 1) continue; //channelInSlotMax can return -999
92 for (int ch = 0; ch < nChans; ++ch) {
93 const HWIdentifier chid = m_onlineID->channel_Id(febid, ch);
94 const Identifier id = oflCabling->cnvToIdentifier(chid);
95 if (!id.is_valid()) {
96 ATH_MSG_DEBUG("Regular channel " << m_onlineID->channel_name(chid) << " disconnected. Ignoring.");
97 continue; //Disconnected channel (regular readout)
98 }
99 const IdentifierHash hashId = m_calo_id->calo_cell_hash(id);
100 const Identifier scID = m_scidtool->offlineToSuperCellID(id);
101 const HWIdentifier scHwid = scCabling->createSignalChannelID(scID);
102 if (!bcSCCont->status(scHwid).good()) {
103 ATH_MSG_DEBUG("SuperCell with id 0x" << std::hex << scHwid.get_identifier32().get_compact() << std::dec
104 << " is ignored b/c of it's bad-channel word. Connected to deadFEB channel " << m_onlineID->channel_name(chid));
105 continue;
106 }
107 const unsigned nCell = (m_scidtool->superCellToOfflineID(scID)).size();
108 const CaloDetDescrElement* dde = caloDDM->get_element(hashId);
109 if (ATH_UNLIKELY(!dde)) {
110 ATH_MSG_ERROR("No DetDescElement for cell hash " << hashId);
111 return StatusCode::FAILURE;
112 }
113 const float convFactor = 12.5 * (1.0 / nCell) * (1.0 / dde->sinTh());
114 // 12.5: Convert SC ADC to MeV (Et), et ->e, scale by the number of regular cells connected to this super-cell
115 scToHwidMap[scHwid].emplace_back(hashId, convFactor); //scToHWidMap is a reference to the payload of the output cond obj
116 } // end loop over channels of one dead FEB
117 } // end if feb is deadAll
118 } // end loop over dead febs
119
120 if(outputHdl.record(std::move(output)).isFailure()) {
121 ATH_MSG_ERROR("Could not record LArOnOffMapping object with "
122 << outputHdl.key()
123 << " with EventRange " << outputHdl.getRange()
124 << " into Conditions Store");
125 return StatusCode::FAILURE;
126 }
127 ATH_MSG_INFO("recorded new " << outputHdl.key() << " with range " << outputHdl.getRange() << " into Conditions Store");
128
129
130
131 // bit of log-output ...
132 ATH_MSG_INFO("Number of deadReadout FEBs for this IOV: " << nDeadFebs);
133 if (msgLvl(MSG::DEBUG)) {
134 for (const auto& p : scToHwidMap) {
135 ATH_MSG_DEBUG(" SuperCell with id 0x" << std::hex << p.first.get_identifier32().get_compact() << std::dec << " connected to " << p.second.size()
136 << " deadFEB channels.");
137 for (const auto& [h, convFactor] : p.second) {
138 const HWIdentifier hwid = cablingHdl->createSignalChannelIDFromHash(h);
139 ATH_MSG_DEBUG(" " << m_onlineID->channel_name(hwid) << " " << convFactor);
140 }
141 }
142 }
143 return StatusCode::SUCCESS;
144}
145
146
147
148
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define ATH_MSG_DEBUG(x)
#define ATH_UNLIKELY(x)
LArBadXCont< LArBadChannel > LArBadChannelCont
const ServiceHandle< StoreGateSvc > & detStore() const
bool msgLvl(const MSG::Level lvl) const
Header file for AthHistogramAlgorithm.
This class groups all DetDescr information related to a CaloCell.
float sinTh() const
for algorithm working in transverse Energy
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
This class provides the client interface for accessing the detector description information common to...
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
bool good() const
Returns true if no problems at all (all bits at zero)
LArBC_t status(const HWIdentifier channel) const
Query the status of a particular channel or FEB This is the main client access method.
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
SG::ReadCondHandleKey< LArBadChannelCont > m_badSCKey
const CaloCell_ID * m_calo_id
virtual StatusCode initialize() override final
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
SG::WriteCondHandleKey< LArDeadOTXCorrFactors > m_outputKey
virtual StatusCode execute(const EventContext &ctx) const override final
ToolHandle< ICaloSuperCellIDTool > m_scidtool
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingSCKey
SG::ReadCondHandleKey< LArBadFebCont > m_MFKey
const LArOnlineID * m_onlineID
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
HWIdentifier createSignalChannelID(const Identifier &id) const
create a HWIdentifier from an Identifier (not inline)
const_pointer_type cptr()
const std::string & key() const
void addDependency(const EventIDRange &range)
const EventIDRange & getRange() const
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED