ATLAS Offline Software
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());
16 
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 
29  const EventContext& ctx = Gaudi::Hive::currentContext();
30 
31  ATH_MSG_DEBUG("executing");
32 
34 
35  if (outputHdl.isValid()) {
36  ATH_MSG_DEBUG("Found valid write handle");
37  return StatusCode::SUCCESS;
38  }
39 
41  if (!cablingHdl.isValid()) {
42  ATH_MSG_ERROR("Do not have Onl-Ofl cabling map !!!!");
43  return StatusCode::FAILURE;
44  }
45  outputHdl.addDependency(cablingHdl);
46  const LArOnOffIdMapping* oflCabling = cablingHdl.cptr();
47 
49  if (!cablingSCHdl.isValid()) {
50  ATH_MSG_ERROR("Do not have Onl-Ofl cabling map for SuperCells !!!!");
51  return StatusCode::FAILURE;
52  }
53  outputHdl.addDependency(cablingSCHdl);
54  const LArOnOffIdMapping* scCabling = cablingSCHdl.cptr();
55 
57  if (!mfHdl.isValid()) {
58  ATH_MSG_ERROR("Do not have Missing FEBs container !!!!");
59  return StatusCode::FAILURE;
60  }
61  outputHdl.addDependency(mfHdl);
62 
64  if (!caloMgrHandle.isValid()) {
65  ATH_MSG_ERROR("Do not have CaloDetDescManager !!!");
66  return StatusCode::FAILURE;
67  }
68  outputHdl.addDependency(caloMgrHandle);
69  const CaloDetDescrManager* caloDDM = *caloMgrHandle;
70 
72  if (!bcSCHdl.isValid()) {
73  ATH_MSG_ERROR("Do not have BadSCContainer !!!!");
74  return StatusCode::FAILURE;
75  }
76  outputHdl.addDependency(bcSCHdl);
77  const LArBadChannelCont* bcSCCont = *bcSCHdl;
78 
79  const auto& badFebs = mfHdl->fullCont();
80 
81  std::unique_ptr<LArDeadOTXCorrFactors> output=std::make_unique<LArDeadOTXCorrFactors>();
82 
83  auto& scToHwidMap=output->get();
84 
85  unsigned nDeadFebs = 0;
86  for (const auto& idBF : badFebs) {
87  if (idBF.second.deadReadout()) {
88  ++nDeadFebs;
89  const HWIdentifier febid(idBF.first);
90  ATH_MSG_INFO("FEB " << m_onlineID->channel_name(febid) << " labelled as deadReadout");
91  const int nChans = m_onlineID->channelInSlotMax(febid);
92  if (nChans < 1) continue; //channelInSlotMax can return -999
93  for (int ch = 0; ch < nChans; ++ch) {
94  const HWIdentifier chid = m_onlineID->channel_Id(febid, ch);
95  const Identifier id = oflCabling->cnvToIdentifier(chid);
96  if (!id.is_valid()) {
97  ATH_MSG_DEBUG("Regular channel " << m_onlineID->channel_name(chid) << " disconnected. Ignoring.");
98  continue; //Disconnected channel (regular readout)
99  }
100  const IdentifierHash hashId = m_calo_id->calo_cell_hash(id);
101  const Identifier scID = m_scidtool->offlineToSuperCellID(id);
102  const HWIdentifier scHwid = scCabling->createSignalChannelID(scID);
103  if (!bcSCCont->status(scHwid).good()) {
104  ATH_MSG_DEBUG("SuperCell with id 0x" << std::hex << scHwid.get_identifier32().get_compact() << std::dec
105  << " is ignored b/c of it's bad-channel word. Connected to deadFEB channel " << m_onlineID->channel_name(chid));
106  continue;
107  }
108  const unsigned nCell = (m_scidtool->superCellToOfflineID(scID)).size();
109  const CaloDetDescrElement* dde = caloDDM->get_element(hashId);
110  if (ATH_UNLIKELY(!dde)) {
111  ATH_MSG_ERROR("No DetDescElement for cell hash " << hashId);
112  return StatusCode::FAILURE;
113  }
114  const float convFactor = 12.5 * (1.0 / nCell) * (1.0 / dde->sinTh());
115  // 12.5: Convert SC ADC to MeV (Et), et ->e, scale by the number of regular cells connected to this super-cell
116  scToHwidMap[scHwid].emplace_back(hashId, convFactor); //scToHWidMap is a reference to the payload of the output cond obj
117  } // end loop over channels of one dead FEB
118  } // end if feb is deadAll
119  } // end loop over dead febs
120 
121  if(outputHdl.record(std::move(output)).isFailure()) {
122  ATH_MSG_ERROR("Could not record LArOnOffMapping object with "
123  << outputHdl.key()
124  << " with EventRange " << outputHdl.getRange()
125  << " into Conditions Store");
126  return StatusCode::FAILURE;
127  }
128  ATH_MSG_INFO("recorded new " << outputHdl.key() << " with range " << outputHdl.getRange() << " into Conditions Store");
129 
130 
131 
132  // bit of log-output ...
133  ATH_MSG_INFO("Number of deadReadout FEBs for this IOV: " << nDeadFebs);
134  if (msgLvl(MSG::DEBUG)) {
135  for (const auto& p : scToHwidMap) {
136  ATH_MSG_DEBUG(" SuperCell with id 0x" << std::hex << p.first.get_identifier32().get_compact() << std::dec << " connected to " << p.second.size()
137  << " deadFEB channels.");
138  for (const auto& [h, convFactor] : p.second) {
139  const HWIdentifier hwid = cablingHdl->createSignalChannelIDFromHash(h);
140  ATH_MSG_DEBUG(" " << m_onlineID->channel_name(hwid) << " " << convFactor);
141  }
142  }
143  }
144  return StatusCode::SUCCESS;
145 }
146 
147 
148 
149 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArOnOffIdMapping::createSignalChannelIDFromHash
HWIdentifier createSignalChannelIDFromHash(const IdentifierHash &id_hash) const
create a HWIdentifier from an Identifier (from hash) (inline)
Definition: LArOnOffIdMapping.h:104
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
LArDeadOTXCondAlg::m_cablingSCKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingSCKey
Definition: LArDeadOTXCondAlg.h:33
CaloCell_Base_ID::calo_cell_hash
IdentifierHash calo_cell_hash(const Identifier cellId) const
create hash id from 'global' cell id
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArBadXCont
Conditions-Data class holding LAr Bad Channel or Bad Feb information.
Definition: LArBadChannelCont.h:28
CaloDetDescrElement
This class groups all DetDescr information related to a CaloCell. Provides a generic interface for al...
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:66
CaloDetDescrManager_Base::get_element
const CaloDetDescrElement * get_element(const Identifier &cellId) const
get element by its identifier
Definition: CaloDetDescrManager.cxx:159
LArDeadOTXCondAlg::initialize
virtual StatusCode initialize() override final
Definition: LArDeadOTXCondAlg.cxx:9
SG::ReadCondHandle::isValid
bool isValid()
Definition: ReadCondHandle.h:210
Identifier::get_identifier32
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
AthCommonMsg< Algorithm >::msgLvl
bool msgLvl(const MSG::Level lvl) const
Definition: AthCommonMsg.h:30
LArDeadOTXCondAlg::m_scidtool
ToolHandle< ICaloSuperCellIDTool > m_scidtool
Definition: LArDeadOTXCondAlg.h:40
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
HWIdentifier
Definition: HWIdentifier.h:13
LArBadXCont::status
LArBC_t status(const HWIdentifier channel) const
Query the status of a particular channel or FEB This is the main client access method.
Identifier32::get_compact
value_type get_compact() const
Get the compact id.
Definition: Identifier32.h:44
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
LArBadXCont::fullCont
const BadChanVec & fullCont() const
Definition: LArBadChannelCont.h:84
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
LArDeadOTXCondAlg::m_calo_id
const CaloCell_ID * m_calo_id
Definition: LArDeadOTXCondAlg.h:39
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArDeadOTXCondAlg::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArDeadOTXCondAlg.h:32
LArOnlineID_Base::channelInSlotMax
int channelInSlotMax(const HWIdentifier Id) const
Return the Maximum channel number of a given feb slot.
Definition: LArOnlineID_Base.cxx:289
LArDeadOTXCondAlg::execute
virtual StatusCode execute() override final
Definition: LArDeadOTXCondAlg.cxx:28
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
LArOnlineID_Base::channel_Id
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
Definition: LArOnlineID_Base.cxx:1565
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArDeadOTXCondAlg::m_badSCKey
SG::ReadCondHandleKey< LArBadChannelCont > m_badSCKey
Definition: LArDeadOTXCondAlg.h:31
LArOnOffIdMapping::createSignalChannelID
HWIdentifier createSignalChannelID(const Identifier &id) const
create a HWIdentifier from an Identifier (not inline)
Definition: LArOnOffIdMapping.h:126
LArDeadOTXCondAlg.h
merge.output
output
Definition: merge.py:16
LArDeadOTXCondAlg::m_outputKey
SG::WriteCondHandleKey< LArDeadOTXCorrFactors > m_outputKey
Definition: LArDeadOTXCondAlg.h:36
LArDeadOTXCondAlg::m_MFKey
SG::ReadCondHandleKey< LArBadFebCont > m_MFKey
Definition: LArDeadOTXCondAlg.h:30
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArDeadOTXCondAlg::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: LArDeadOTXCondAlg.h:34
h
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
LArOnOffIdMapping::cnvToIdentifier
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
Definition: LArOnOffIdMapping.h:116
DEBUG
#define DEBUG
Definition: page_access.h:11
CaloDetDescrElement::sinTh
float sinTh() const
for algorithm working in transverse Energy
Definition: Calorimeter/CaloDetDescr/CaloDetDescr/CaloDetDescrElement.h:383
IdentifierHash
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
LArOnlineID_Base::channel_name
std::string channel_name(const HWIdentifier id) const
Return a string corresponding to a feedthrough name given an identifier.
Definition: LArOnlineID_Base.cxx:221
LArDeadOTXCondAlg::m_onlineID
const LArOnlineID * m_onlineID
Definition: LArDeadOTXCondAlg.h:38
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
LArOnlineID.h
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:71
Identifier
Definition: IdentifierFieldParser.cxx:14