ATLAS Offline Software
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() );
17 
18  return StatusCode::SUCCESS;
19 }
20 
21 
22 StatusCode 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 
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 
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArBadChannelCondAlg::m_inputFileName
Gaudi::Property< std::string > m_inputFileName
Definition: LArBadChannelCondAlg.h:34
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArBadXCont::setOflVec
void setOflVec(BadChanVec &input)
python.LArCondContChannels.decoder
decoder
def channelSelection(self, channelList, groupType): if groupType == self.SingleGroup: pass elif group...
Definition: LArCondContChannels.py:618
SG::VarHandleKey::storeHandle
const ServiceHandle< IProxyDict > & storeHandle() const
Return handle to the referenced store.
LArBadChannelCondAlg::m_isSC
Gaudi::Property< bool > m_isSC
Definition: LArBadChannelCondAlg.h:36
LArBadChannelDecoder
Definition: LArBadChannelDecoder.h:21
ReadCellNoiseFromCool.cabling
cabling
Definition: ReadCellNoiseFromCool.py:154
LArBadChannelDecoder.h
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
LArBadChannelCondAlg::m_BCOutputKey
SG::WriteCondHandleKey< LArBadChannelCont > m_BCOutputKey
Definition: LArBadChannelCondAlg.h:33
LArBadXCont::sort
void sort()
Sort and purge the list of bad channels The list of bad channels get sorted by channel-ID For channel...
LArBadXCont::BadChanVec
std::vector< BadChanEntry > BadChanVec
Definition: LArBadChannelCont.h:32
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
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
CondAttrListCollection
This class is a collection of AttributeLists where each one is associated with a channel number....
Definition: CondAttrListCollection.h:52
AthCommonDataStore< AthCommonMsg< Gaudi::Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
LArBadXCont::fullCont
const BadChanVec & fullCont() const
Definition: LArBadChannelCont.h:84
LArBadChannelCondAlg::initialize
virtual StatusCode initialize() override final
Definition: LArBadChannelCondAlg.cxx:12
LArBadChannelCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: LArBadChannelCondAlg.cxx:22
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArBadChanBlobUtils.h
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
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
LArBadChannelCondAlg::m_cablingKey
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
Definition: LArBadChannelCondAlg.h:32
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArBadChannelCondAlg::m_reloadEveryEvent
Gaudi::Property< bool > m_reloadEveryEvent
Definition: LArBadChannelCondAlg.h:37
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
LArBadChannelCondAlg.h
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
LArBadXCont::size
size_type size() const
Number of known bad channels.
Definition: LArBadChannelCont.h:79
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition: LArOnlineID_Base.h:105
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
SG::VarHandleKey::clid
CLID clid() const
Return the class ID for the referenced object.
Definition: StoreGate/src/VarHandleKey.cxx:177
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
get_generator_info.version
version
Definition: get_generator_info.py:33
CondAttrListCollection::const_iterator
ChanAttrListMap::const_iterator const_iterator
Definition: CondAttrListCollection.h:63
DEBUG
#define DEBUG
Definition: page_access.h:11
AthCommonMsg< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArBadXCont::add
void add(const HWIdentifier channel, const LArBC_t stat)
Add a channel/FEB to the list of bad channels.
LArOnline_SuperCellID.h
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
LArBadChannelState::MAXCOOLCHAN
@ MAXCOOLCHAN
Definition: LArBadChannelState.h:23
LArOnlineID.h
ServiceHandle< IIOVSvc >
LArOnOffIdMapping
Definition: LArOnOffIdMapping.h:20
LArBadChannelCondAlg::m_BCInputKey
SG::ReadCondHandleKey< CondAttrListCollection > m_BCInputKey
Definition: LArBadChannelCondAlg.h:30