ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11
13 // Read Handles
15 ATH_CHECK( m_BCOutputKey.initialize() );
16 ATH_CHECK(m_cablingKey.initialize());
17
18 return StatusCode::SUCCESS;
19}
20
21
22StatusCode LArBadChannelCondAlg::execute(const EventContext& ctx) const{
23
25 if (writeHandle.isValid()) {
26 msg(MSG::DEBUG) << "Found valid write handle" << endmsg;
27 return StatusCode::SUCCESS;
28 }
29
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
38 const LArOnOffIdMapping* cabling{*cablingHdl};
39
40 writeHandle.addDependency(cablingHdl);
41
42
43 if(!m_BCInputKey.key().empty()) {
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
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}
#define endmsg
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
#define CHECK(...)
Evaluate an expression and check for errors.
const ServiceHandle< StoreGateSvc > & detStore() const
This class is a collection of AttributeLists where each one is associated with a channel number.
const_iterator end() const
const_iterator begin() const
Access to Chan/AttributeList pairs via iterators.
ChanAttrListMap::const_iterator const_iterator
Gaudi::Property< bool > m_reloadEveryEvent
virtual StatusCode execute(const EventContext &ctx) const override final
Gaudi::Property< bool > m_isSC
Gaudi::Property< std::string > m_inputFileName
SG::WriteCondHandleKey< LArBadChannelCont > m_BCOutputKey
SG::ReadCondHandleKey< CondAttrListCollection > m_BCInputKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
virtual StatusCode initialize() override final
std::vector< BadChanEntry > BadChanVec
Helper for the Liquid Argon Calorimeter cell identifiers.
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
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...