ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArRecUtils
src
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
"
8
#include "
AthenaPoolUtilities/AthenaAttributeList.h
"
9
#include "CoralBase/Blob.h"
10
11
#include "
LArIdentifier/LArOnlineID.h
"
12
13
#include <set>
14
#include <algorithm>
15
#include <iterator>
16
17
StatusCode
LArFebRodMappingAlg::initialize
() {
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
29
StatusCode
LArFebRodMappingAlg::execute
(
const
EventContext& ctx)
const
{
30
ATH_MSG_DEBUG
(
"executing"
);
31
32
SG::WriteCondHandle<LArFebRodMapping>
writeHandle{
m_writeKey
, ctx};
33
34
if
(writeHandle.
isValid
()) {
35
ATH_MSG_DEBUG
(
"Found valid write handle"
);
36
return
StatusCode::SUCCESS;
37
}
38
39
SG::ReadCondHandle<AthenaAttributeList>
readHandle{
m_readKey
, ctx};
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
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
AthenaAttributeList.h
LArFebRodMappingAlg.h
LArOnlineID.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table.
Definition
PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:46
HWIdentifier
Definition
HWIdentifier.h:13
LArFebRodMappingAlg::m_readKey
SG::ReadCondHandleKey< AthenaAttributeList > m_readKey
Definition
LArFebRodMappingAlg.h:31
LArFebRodMappingAlg::initialize
virtual StatusCode initialize() override
Definition
LArFebRodMappingAlg.cxx:17
LArFebRodMappingAlg::m_writeKey
SG::WriteCondHandleKey< LArFebRodMapping > m_writeKey
Definition
LArFebRodMappingAlg.h:32
LArFebRodMappingAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
LArFebRodMappingAlg.cxx:29
LArOnlineID_Base::febHashMax
size_type febHashMax() const
define feb hash tables max size
Definition
LArOnlineID_Base.cxx:1602
LArOnlineID
Definition
LArOnlineID.h:21
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::WriteCondHandle
Definition
WriteCondHandle.h:26
SG::WriteCondHandle::key
const std::string & key() const
Definition
WriteCondHandle.h:44
SG::WriteCondHandle::addDependency
void addDependency(const EventIDRange &range)
Definition
WriteCondHandle.h:279
SG::WriteCondHandle::getRange
const EventIDRange & getRange() const
Definition
WriteCondHandle.h:93
SG::WriteCondHandle::record
StatusCode record(const EventIDRange &range, T *t)
record handle, with explicit range DEPRECATED
Definition
WriteCondHandle.h:161
SG::WriteCondHandle::isValid
bool isValid() const
Definition
WriteCondHandle.h:252
Generated on
for ATLAS Offline Software by
1.17.0