ATLAS Offline Software
Loading...
Searching...
No Matches
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
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
22 ATH_CHECK( m_readKey.initialize() );
23 ATH_CHECK( m_writeKey.initialize() );
24
25 return StatusCode::SUCCESS;
26}
27
28
29StatusCode LArFebRodMappingAlg::execute(const EventContext& ctx) const {
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
#define endmsg
#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)
const ServiceHandle< StoreGateSvc > & detStore() const
An AttributeList represents a logical row of attributes in a metadata table.
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
virtual StatusCode initialize() override
SG::WriteCondHandleKey< LArFebRodMapping > m_writeKey
virtual StatusCode execute(const EventContext &ctx) const override
size_type febHashMax() const
define feb hash tables max size
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