ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArBadChannelTool
src
LArBadChannelCondAlg.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LArBadChannelTool/LArBadChannelCondAlg.h
"
6
#include "
LArBadChannelTool/LArBadChanBlobUtils.h
"
7
#include "
LArIdentifier/LArOnlineID.h
"
8
#include "
LArIdentifier/LArOnline_SuperCellID.h
"
9
#include "
LArBadChannelTool/LArBadChannelDecoder.h
"
10
11
12
StatusCode
LArBadChannelCondAlg::initialize
() {
13
// Read Handles
14
ATH_CHECK
(
m_BCInputKey
.initialize(
SG::AllowEmpty
) );
15
ATH_CHECK
(
m_BCOutputKey
.initialize() );
16
ATH_CHECK
(
m_cablingKey
.initialize());
17
18
return
StatusCode::SUCCESS;
19
}
20
21
22
StatusCode
LArBadChannelCondAlg::execute
(
const
EventContext& ctx)
const
{
23
24
SG::WriteCondHandle<LArBadChannelCont>
writeHandle{
m_BCOutputKey
,ctx};
25
if
(writeHandle.
isValid
()) {
26
msg
(MSG::DEBUG) <<
"Found valid write handle"
<<
endmsg
;
27
return
StatusCode::SUCCESS;
28
}
29
30
if
(
m_reloadEveryEvent
) {
31
// remove old object from db (necessary when running online)
32
CHECK
(
ServiceHandle<IIOVSvc>
(
"IOVSvc"
,
""
)->dropObjectFromDB(
m_BCInputKey
.clid(),
m_BCInputKey
.key(),
m_BCInputKey
.storeHandle().name()));
33
}
34
35
std::unique_ptr<LArBadChannelCont> badChannelCont=std::make_unique<LArBadChannelCont>();
36
37
SG::ReadCondHandle<LArOnOffIdMapping>
cablingHdl{
m_cablingKey
,ctx};
38
const
LArOnOffIdMapping
* cabling{*cablingHdl};
39
40
writeHandle.
addDependency
(cablingHdl);
41
42
43
if
(!
m_BCInputKey
.key().empty()) {
44
SG::ReadCondHandle<CondAttrListCollection>
readHandle{
m_BCInputKey
,ctx};
45
const
CondAttrListCollection
* attrListColl{*readHandle};
46
if
(attrListColl==
nullptr
) {
47
msg
(MSG::ERROR) <<
"Failed to retrieve CondAttributeListCollection with key "
<<
m_BCInputKey
.key() <<
endmsg
;
48
return
StatusCode::FAILURE;
49
}
50
writeHandle.
addDependency
(readHandle);
51
52
//Loop over COOL channels:
53
CondAttrListCollection::const_iterator
chanIt=attrListColl->
begin
();
54
CondAttrListCollection::const_iterator
chanIt_e=attrListColl->
end
();
55
for
(;chanIt!=chanIt_e;++chanIt) {
56
57
const
coral::AttributeList& attrList = chanIt->second;
58
const
coral::Blob& blob = attrList[
"Blob"
].data<coral::Blob>();
59
unsigned
int
chanSize = attrList[
"ChannelSize"
].data<
unsigned
int
>();
60
unsigned
int
stateSize = attrList[
"StatusWordSize"
].data<
unsigned
int
>();
61
unsigned
int
endian = attrList[
"Endianness"
].data<
unsigned
int
>();
62
unsigned
int
version = attrList[
"Version"
].data<
unsigned
int
>();
63
64
std::vector<std::pair<HWIdentifier,LArBadChannel> > bcVec =
65
LArBadChanBlobUtils::decodeBlob<LArBadChannel>
( &blob, chanSize, stateSize, endian,
66
version,
msg
());
67
68
for
(
auto
& idBC : bcVec) {
69
if
(
m_isSC
) {
70
idBC.second.setSC();
71
}
72
badChannelCont->add(idBC.first, idBC.second);
73
}
74
75
}
// end loop over COOL channels
76
}
77
78
if
(
m_inputFileName
.size()) {
//Read supplemental data from ASCII file (if required)
79
80
const
LArOnlineID_Base
* onlineID;
81
if
(
m_isSC
) {
//SuperCell case
82
const
LArOnline_SuperCellID
* scID =
nullptr
;
83
ATH_CHECK
(
detStore
()->retrieve(scID,
"LArOnline_SuperCellID"
));
84
onlineID=scID;
85
}
86
else
{
//regular readout
87
const
LArOnlineID
* onlID =
nullptr
;
88
ATH_CHECK
(
detStore
()->retrieve(onlID,
"LArOnlineID"
));
89
onlineID=onlID;
90
}
91
LArBadChannelDecoder
decoder(&(*onlineID),
m_isSC
);
92
std::vector<std::pair<HWIdentifier,LArBadChannel> > bcVec = decoder.readASCII(
m_inputFileName
,
LArBadChannelState::MAXCOOLCHAN
,
msg
());
93
for
(
auto
& idBC : bcVec) {
94
if
(
m_isSC
) {
95
idBC.second.setSC();
96
}
97
badChannelCont->add(idBC.first, idBC.second);
98
}
99
}
//end if have ASCII filename
100
101
size_t
nChanBeforeMege=badChannelCont->size();
102
badChannelCont->sort();
//Sorts vector of bad channels and merges duplicate entries
103
104
ATH_MSG_INFO
(
"Read a total of "
<< badChannelCont->size() <<
" problematic channels from database"
);
105
if
(nChanBeforeMege!=badChannelCont->size()) {
106
ATH_MSG_INFO
(
"Merged "
<< nChanBeforeMege-badChannelCont->size() <<
" duplicate entries"
);
107
}
108
109
110
//Fill vector by offline id
111
LArBadChannelCont::BadChanVec
oflVec;
112
for
(
const
auto
& entry : badChannelCont->fullCont()) {
113
const
Identifier
id
= cabling->cnvToIdentifier(
HWIdentifier
(entry.first));
114
if
(
id
.is_valid()) oflVec.emplace_back(
id
.get_identifier32().get_compact(),entry.second);
115
}
116
117
badChannelCont->setOflVec(oflVec);
118
119
if
(writeHandle.
record
(std::move(badChannelCont)).isFailure()) {
120
ATH_MSG_ERROR
(
"Could not record LArBadChannelCont object with "
121
<< writeHandle.
key
()
122
<<
" with EventRange "
<< writeHandle.
getRange
()
123
<<
" into Conditions Store"
);
124
return
StatusCode::FAILURE;
125
}
126
ATH_MSG_INFO
(
"Recorded LArBadChannelCont object with key "
127
<< writeHandle.
key
()
128
<<
" with EventRange "
<< writeHandle.
getRange
()
129
<<
" into Conditions Store"
);
130
return
StatusCode::SUCCESS;
131
}
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
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition
Control/AthenaKernel/AthenaKernel/errorcheck.h:422
LArBadChanBlobUtils.h
LArBadChannelCondAlg.h
LArBadChannelDecoder.h
LArOnlineID.h
LArOnline_SuperCellID.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
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number.
Definition
CondAttrListCollection.h:51
CondAttrListCollection::end
const_iterator end() const
Definition
CondAttrListCollection.h:314
CondAttrListCollection::begin
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
Definition
CondAttrListCollection.h:308
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition
CondAttrListCollection.h:62
HWIdentifier
Definition
HWIdentifier.h:13
LArBadChannelCondAlg::m_reloadEveryEvent
Gaudi::Property< bool > m_reloadEveryEvent
Definition
LArBadChannelCondAlg.h:36
LArBadChannelCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
LArBadChannelCondAlg.cxx:22
LArBadChannelCondAlg::m_isSC
Gaudi::Property< bool > m_isSC
Definition
LArBadChannelCondAlg.h:35
LArBadChannelCondAlg::m_inputFileName
Gaudi::Property< std::string > m_inputFileName
Definition
LArBadChannelCondAlg.h:33
LArBadChannelCondAlg::m_BCOutputKey
SG::WriteCondHandleKey< LArBadChannelCont > m_BCOutputKey
Definition
LArBadChannelCondAlg.h:32
LArBadChannelCondAlg::m_BCInputKey
SG::ReadCondHandleKey< CondAttrListCollection > m_BCInputKey
Definition
LArBadChannelCondAlg.h:29
LArBadChannelCondAlg::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition
LArBadChannelCondAlg.h:31
LArBadChannelCondAlg::initialize
virtual StatusCode initialize() override final
Definition
LArBadChannelCondAlg.cxx:12
LArBadChannelDecoder
Definition
LArBadChannelDecoder.h:21
LArBadChannelState::MAXCOOLCHAN
@ MAXCOOLCHAN
Definition
LArBadChannelState.h:23
LArBadXCont< LArBadChannel >::BadChanVec
std::vector< BadChanEntry > BadChanVec
Definition
LArBadChannelCont.h:33
LArOnOffIdMapping
Definition
LArOnOffIdMapping.h:20
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition
LArOnlineID_Base.h:97
LArOnlineID
Definition
LArOnlineID.h:21
LArOnline_SuperCellID
Definition
LArOnline_SuperCellID.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
ServiceHandle
Definition
ClusterMakerTool.h:36
Identifier
Definition
IdentifierFieldParser.cxx:14
LArBadChanBlobUtils::decodeBlob
std::vector< std::pair< HWIdentifier, T > > decodeBlob(const coral::Blob *blobp, std::size_t chanSize, std::size_t stateSize, int endian, int version, MsgStream &log)
Checks BLOB for differences in endian-ness and size of data types with respect to the architecture on...
SG::AllowEmpty
@ AllowEmpty
Definition
StoreGate/StoreGate/VarHandleKey.h:27
Generated on
for ATLAS Offline Software by
1.17.0