ATLAS Offline Software
LArCelldeadOTXAlg.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 "LArCelldeadOTXAlg.h"
6 
8 #include "CaloDetDescr/CaloDetDescrElement.h"
12 #include "StoreGate/WriteHandle.h"
13 
15 
18  ATH_CHECK(m_MFKey.initialize());
19  ATH_CHECK(m_badSCKey.initialize());
23 
24  ATH_CHECK(detStore()->retrieve(m_onlineID, "LArOnlineID"));
25  ATH_CHECK(detStore()->retrieve(m_onlineSCID, "LArOnline_SuperCellID"));
26  ATH_CHECK(detStore()->retrieve(m_calo_id, "CaloCell_ID"));
27 
28  ATH_CHECK(m_scidtool.retrieve());
29 
30  return StatusCode::SUCCESS;
31 }
32 
33 StatusCode LArCelldeadOTXAlg::execute(const EventContext& ctx) const {
34 
35  ATH_MSG_VERBOSE(" in execute...");
36 
37  StatusCode sc = StatusCode::SUCCESS;
38  std::call_once(m_onceFlag, &LArCelldeadOTXAlg::buildMap, this, ctx, sc);
39 
40  if (sc.isFailure()) {
41  ATH_MSG_ERROR("Call to LArCelldeadOTXAlg::buidMap returned an error");
42  return StatusCode::FAILURE;
43  }
44 
46  std::unique_ptr<LArDeadOTXFromSC> deadHandle = std::make_unique<LArDeadOTXFromSC>();
47 
48  // get SuperCellContainer
50  if (!scHdl.isValid()) {
51  ATH_MSG_WARNING("Do not have SuperCell container no patching !!!!");
52  return StatusCode::SUCCESS;
53  }
54 
55  const unsigned int bcid = ctx.eventID().bunch_crossing_id();
56 
57  // get the SC, container is unordered, so have to loop
58  const LArRawSCContainer* scells = scHdl.cptr();
59  std::vector<float> vecEnergies;
60  vecEnergies.reserve(m_onlineSCID->channelHashMax());
61  vecEnergies.resize(m_onlineSCID->channelHashMax(),0.0);
62  for (const auto* supercell : *scells) {
63  if (!supercell)
64  continue;
65  const HWIdentifier scHwid = supercell->hardwareID();
66  uint32_t scIDHash = (m_onlineSCID->channel_Hash(scHwid)).value();
67 
68  const std::vector<unsigned short>& bcids = supercell->bcids();
69  const std::vector<int>& energies = supercell->energies();
70  const std::vector<bool>& satur = supercell->satur();
71 
72  // Look for bcid:
73  float scEne = 0;
74  const size_t nBCIDs = bcids.size();
75  size_t i = 0;
76  for (i = 0; i < nBCIDs && bcids[i] != bcid; i++)
77  ;
78 
79  if (ATH_LIKELY(!satur[i]))
80  scEne = energies[i];
81  if (scEne < m_scCut) {
82  ATH_MSG_VERBOSE("SC value " << scEne << " below threshold, ignoring");
83  continue;
84  }
85  vecEnergies[scIDHash]=scEne;
86  } // End loop over SuperCell container
87 
88  for(size_t i=0;i<m_channels.size();i++){
89  std::vector<uint32_t>& chans = m_channels.at(i);
90  std::vector<float>& mults = m_multipliers.at(i);
91  std::vector<float> cellEnergies;
92  cellEnergies.resize(128,0);
93  for(size_t j=0; j<chans.size(); j++) {
94  if ( chans[j] < 0xfffffffe ) cellEnergies[j] = mults[j]*vecEnergies[chans[j]];
95  }
96  deadHandle->addFEB(m_febs[i],cellEnergies);
97  }
98  ATH_CHECK(deadHdl.record(std::move(deadHandle)) );
99 
101  //cell->setProvenance(cell->provenance() | LArProv::PATCHED);
102 
103  return StatusCode::SUCCESS;
104 }
105 
106 void LArCelldeadOTXAlg::buildMap(const EventContext& ctx, StatusCode& sc) const {
107 
108  sc = StatusCode::FAILURE;
109 
111  if (!cablingHdl.isValid()) {
112  ATH_MSG_ERROR("Do not have Onl-Ofl cabling map !!!!");
113  return;
114  }
115  const LArOnOffIdMapping* oflCabling = cablingHdl.cptr();
116 
118  if (!cablingSCHdl.isValid()) {
119  ATH_MSG_ERROR("Do not have Onl-Ofl cabling map for SuperCells !!!!");
120  return;
121  }
122 
123  const LArOnOffIdMapping* scCabling = cablingSCHdl.cptr();
124 
126  if (!mfHdl.isValid()) {
127  ATH_MSG_ERROR("Do not have Missing FEBs container !!!!");
128  return;
129  }
130 
132  if (!caloMgrHandle.isValid()) {
133  ATH_MSG_ERROR("Do not have CaloDetDescManager !!!");
134  return;
135  }
136 
137  const CaloDetDescrManager* caloDDM = *caloMgrHandle;
138 
140  if (!bcSCHdl.isValid()) {
141  ATH_MSG_ERROR("Do not have BadSCContainer !!!!");
142  return;
143  }
144  const LArBadChannelCont* bcSCCont = *bcSCHdl;
145 
146  const std::vector<std::pair<unsigned int, LArBadFeb> >& badFebs = mfHdl->fullCont();
147 
148  for (const auto& idBF : badFebs) {
149  if (idBF.second.deadReadout()) {
150  const HWIdentifier febid(idBF.first);
151  m_febs.push_back(febid);
152  ATH_MSG_INFO("FEB " << m_onlineID->channel_name(febid) << " labelled as dead");
153  std::vector<float> vector_of_multipliers;
154  std::vector<uint32_t> vector_of_chans;
155  const int nChans = m_onlineID->channelInSlotMax(febid);//may return -999
156  if (ATH_UNLIKELY(nChans < 0)) {
157  ATH_MSG_WARNING("LArCelldeadOTXAlg::buildMap : nChans<0");
158  continue;
159  }
160  vector_of_multipliers.resize(nChans,0.0);
161  vector_of_chans.resize(nChans,0xffffffff);
162  for (int ch = 0; ch < nChans; ++ch) {
163  const HWIdentifier chid = m_onlineID->channel_Id(febid, ch);
164  const Identifier id = oflCabling->cnvToIdentifier(chid);
165  const IdentifierHash hashId = m_calo_id->calo_cell_hash(id);
166  const Identifier scID = m_scidtool->offlineToSuperCellID(id);
167  const HWIdentifier scHwid = scCabling->createSignalChannelID(scID);
168  const IdentifierHash hashidSC = m_onlineSCID->channel_Hash(scHwid);
169  if (!bcSCCont->status(scHwid).good()) {
170  ATH_MSG_DEBUG("SuperCell with id 0x" << std::hex << scHwid.get_identifier32().get_compact() << std::dec
171  << " is ignored b/c of it's bad-channel word. Connected to deadFEB channel " << m_onlineID->channel_name(chid));
172  continue;
173  }
174  const unsigned nCell = (m_scidtool->superCellToOfflineID(scID)).size();
175  const CaloDetDescrElement* dde = caloDDM->get_element(hashId);
176  if (ATH_UNLIKELY(!dde)) {
177  ATH_MSG_INFO("No DetDescElement for cell hash : " << hashId);
178  } else {
179  // 12.5: Convert SC ADC to MeV (Et), et ->e, scale by the number of regular cells connected to this super-cell
180  const float convFactor = 12.5 * (1.0 / nCell) * (1.0 / dde->sinTh());
181  vector_of_multipliers[ch]=convFactor;
182  vector_of_chans[ch]=hashidSC.value();
183  }
184  } // end loop over channels of one dead FEB
185  m_multipliers.push_back(vector_of_multipliers);
186  m_channels.push_back(vector_of_chans);
187  } // end if feb is deadAll
188  } // end loop over dead febs
189 
190  sc = StatusCode::SUCCESS;
191  return;
192 }
193 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArCelldeadOTXAlg::m_calo_id
const CaloCell_ID * m_calo_id
Definition: LArCelldeadOTXAlg.h:47
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
LArOnlineID_Base::channel_Hash
IdentifierHash channel_Hash(HWIdentifier channelId) const
Create channel_hash from channel_Id.
Definition: LArOnlineID_Base.cxx:1632
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
SG::ReadHandle::cptr
const_pointer_type cptr()
Dereference the pointer.
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SG::ReadHandle
Definition: StoreGate/StoreGate/ReadHandle.h:67
LArRawSCContainer
Container class for LArRawSC.
Definition: LArRawSCContainer.h:17
LArCelldeadOTXAlg::m_badSCKey
SG::ReadCondHandleKey< LArBadChannelCont > m_badSCKey
Definition: LArCelldeadOTXAlg.h:39
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
LArCelldeadOTXAlg::m_scCut
Gaudi::Property< int > m_scCut
Definition: LArCelldeadOTXAlg.h:44
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.
LArCelldeadOTXAlg::m_caloMgrKey
SG::ReadCondHandleKey< CaloDetDescrManager > m_caloMgrKey
Definition: LArCelldeadOTXAlg.h:42
athena.value
value
Definition: athena.py:124
ATH_UNLIKELY
#define ATH_UNLIKELY(x)
Definition: AthUnlikelyMacros.h:17
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
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
LArCelldeadOTXAlg::m_onlineSCID
const LArOnline_SuperCellID * m_onlineSCID
Definition: LArCelldeadOTXAlg.h:46
LArCelldeadOTXAlg::m_deadOTXFromSCKey
SG::WriteHandleKey< LArDeadOTXFromSC > m_deadOTXFromSCKey
Definition: LArCelldeadOTXAlg.h:37
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
CaloCell_ID.h
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArOnlineID_Base::channelHashMax
size_type channelHashMax() const
Define channel hash tables max size.
Definition: LArOnlineID_Base.cxx:1897
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
WriteHandle.h
Handle class for recording to StoreGate.
LArBadXCont::fullCont
const BadChanVec & fullCont() const
Definition: LArBadChannelCont.h:84
LArCelldeadOTXAlg::m_MFKey
SG::ReadCondHandleKey< LArBadFebCont > m_MFKey
Definition: LArCelldeadOTXAlg.h:38
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArCelldeadOTXAlg::m_onlineID
const LArOnlineID * m_onlineID
Definition: LArCelldeadOTXAlg.h:45
lumiFormat.i
int i
Definition: lumiFormat.py:85
LArOnlineID_Base::channelInSlotMax
int channelInSlotMax(const HWIdentifier Id) const
Return the Maximum channel number of a given feb slot.
Definition: LArOnlineID_Base.cxx:289
LArCelldeadOTXAlg::initialize
virtual StatusCode initialize() override final
Definition: LArCelldeadOTXAlg.cxx:14
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
LArCelldeadOTXAlg::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArCelldeadOTXAlg.h:40
LArCelldeadOTXAlg::buildMap
void buildMap(const EventContext &ctx, StatusCode &sc) const
Definition: LArCelldeadOTXAlg.cxx:106
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SG::VarHandleKey::initialize
StatusCode initialize(bool used=true)
If this object is used as a property, then this should be called during the initialize phase.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:103
LArOnOffIdMapping::createSignalChannelID
HWIdentifier createSignalChannelID(const Identifier &id) const
create a HWIdentifier from an Identifier (not inline)
Definition: LArOnOffIdMapping.h:126
SG::ReadHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
xAOD::bcid
setEventNumber setTimeStamp bcid
Definition: EventInfo_v1.cxx:133
IdentifierHash::value
value_type value() const
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:73
ATH_LIKELY
#define ATH_LIKELY(x)
Definition: AthUnlikelyMacros.h:16
CaloDetDescrManager
This class provides the client interface for accessing the detector description information common to...
Definition: CaloDetDescrManager.h:473
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
LArOnOffIdMapping::cnvToIdentifier
Identifier cnvToIdentifier(const HWIdentifier &sid) const
create an Identifier from a HWIdentifier (inline)
Definition: LArOnOffIdMapping.h:116
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArCelldeadOTXAlg::m_cablingSCKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingSCKey
Definition: LArCelldeadOTXAlg.h:41
LArCelldeadOTXAlg::m_scidtool
ToolHandle< ICaloSuperCellIDTool > m_scidtool
Definition: LArCelldeadOTXAlg.h:48
LArCelldeadOTXAlg::m_SCKey
SG::ReadHandleKey< LArRawSCContainer > m_SCKey
Definition: LArCelldeadOTXAlg.h:36
LArProvenance.h
LArOnline_SuperCellID.h
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
LArCelldeadOTXAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: LArCelldeadOTXAlg.cxx:33
LArDeadOTXFromSC::addFEB
void addFEB(HWIdentifier febid, std::vector< float > &vec)
Definition: LArDeadOTXFromSC.h:22
LArCelldeadOTXAlg.h
python.LArCondContChannels.chans
list chans
Definition: LArCondContChannels.py:638
LArOnlineID.h
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition: ReadCondHandle.h:71
Identifier
Definition: IdentifierFieldParser.cxx:14