ATLAS Offline Software
LArFebRodMappingAlg.cxx
Go to the documentation of this file.
1 //dear emacs, this is -*-c++-*-
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #include "LArFebRodMappingAlg.h"
9 #include "CoralBase/Blob.h"
10 
12 
13 #include <set>
14 #include <algorithm>
15 #include <iterator>
16 
18 
19  ATH_MSG_DEBUG("initializing");
20 
21  // Read Handles
24 
25  return StatusCode::SUCCESS;
26 }
27 
28 
30  ATH_MSG_DEBUG("executing");
31 
33 
34  if (writeHandle.isValid()) {
35  ATH_MSG_DEBUG("Found valid write handle");
36  return StatusCode::SUCCESS;
37  }
38 
40  const AthenaAttributeList* attr{*readHandle};
41 
42  if (attr==nullptr) {
43  ATH_MSG_ERROR("Failed to retrieve CondAttributeListCollection with key " << m_readKey.key());
44  return StatusCode::FAILURE;
45  }
46  writeHandle.addDependency(readHandle);
47 
48 
49  const LArOnlineID* onlineID;
50  ATH_CHECK(detStore()->retrieve(onlineID,"LArOnlineID"));
51 
52  std::unique_ptr<LArFebRodMapping> febRodMap=std::make_unique<LArFebRodMapping>(onlineID);
53 
54 
55  //The following lines are copied from the callback method of the old-style LArCablingService
56  ATH_MSG_DEBUG("Start reading Feb/Rod mapping");
57 
58  const coral::Blob& blobFebRod=(*attr)["FebHashToRODs"].data<coral::Blob>();
59  const unsigned nFebRod=blobFebRod.size()/sizeof(uint32_t);
60  if (nFebRod!=onlineID->febHashMax()) {
61  ATH_MSG_ERROR("Unexpected number of FEBs in the FEB/ROD mapping database. Expected " << onlineID->febHashMax()
62  << " from identifier dictionary, got " << nFebRod << " from mapping database.");
63  return StatusCode::FAILURE;
64  }
65 
66  febRodMap->m_pFebHashtoROD=static_cast<const uint32_t*>(blobFebRod.startingAddress());
67 
68  //Create a set of (unique) ROD ids
69  std::set<HWIdentifier> allReadoutModuleIds;
70  for (unsigned i=0;i<nFebRod;++i) {
71  allReadoutModuleIds.insert(HWIdentifier(febRodMap->m_pFebHashtoROD[i]));
72  }
73 
74  //Copy the set of unique ROD-ids to rod-id vector
75  febRodMap->m_readoutModuleIDVec.reserve(allReadoutModuleIds.size());
76  std::copy(allReadoutModuleIds.begin(),allReadoutModuleIds.end(),std::back_inserter(febRodMap->m_readoutModuleIDVec));
77 
78  msg(MSG::INFO) << "Done reading Feb/Rod mapping. Found " << nFebRod << " Febs and " << febRodMap->m_readoutModuleIDVec.size() << " Rods" << endmsg;
79 
80  if(writeHandle.record(std::move(febRodMap)).isFailure()) {
81  ATH_MSG_ERROR("Could not record LArFebRodMapping object with "
82  << writeHandle.key()
83  << " with EventRange " << writeHandle.getRange()
84  << " into Conditions Store");
85  return StatusCode::FAILURE;
86  }
87  ATH_MSG_INFO("recorded new " << writeHandle.key() << " with range " << writeHandle.getRange() << " into Conditions Store");
88 
89 
90  return StatusCode::SUCCESS;
91 }
92 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArFebRodMappingAlg::m_writeKey
SG::WriteCondHandleKey< LArFebRodMapping > m_writeKey
Definition: LArFebRodMappingAlg.h:31
LArOnlineID_Base::febHashMax
size_type febHashMax(void) const
define feb hash tables max size
Definition: LArOnlineID_Base.cxx:1896
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
HWIdentifier
Definition: HWIdentifier.h:13
AthenaAttributeList.h
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
LArFebRodMappingAlg::execute
virtual StatusCode execute() override
Definition: LArFebRodMappingAlg.cxx:29
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArFebRodMapping::m_pFebHashtoROD
const uint32_t * m_pFebHashtoROD
Definition: LArFebRodMapping.h:35
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
LArFebRodMapping::m_readoutModuleIDVec
std::vector< HWIdentifier > m_readoutModuleIDVec
Definition: LArFebRodMapping.h:36
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
LArFebRodMappingAlg.h
LArFebRodMappingAlg::m_readKey
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Definition: LArFebRodMappingAlg.h:30
LArFebRodMappingAlg::initialize
virtual StatusCode initialize() override
Definition: LArFebRodMappingAlg.cxx:17
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
calibdata.copy
bool copy
Definition: calibdata.py:27
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
LArOnlineID.h