ATLAS Offline Software
LArBadFebCondAlg.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 
12 
13  // Read Handles
15  ATH_CHECK( m_BCOutputKey.initialize() );
16 
17  return StatusCode::SUCCESS;
18 }
19 
20 
21 StatusCode LArBadFebCondAlg::execute(const EventContext& ctx) const {
22 
24 
25  if (writeHandle.isValid()) {
26  msg(MSG::DEBUG) << "Found valid write handle" << endmsg;
27  return StatusCode::SUCCESS;
28  }
29 
30  std::unique_ptr<LArBadFebCont> badFebCont=std::make_unique<LArBadFebCont>();
31 
32 
33  if(!m_BCInputKey.key().empty()) {
34 
36  const AthenaAttributeList* attrList{*readHandle};
37  if (attrList==nullptr) {
38  msg(MSG::ERROR) << "Failed to retrieve CondAttributeListCollection with key " << m_BCInputKey.key() << endmsg;
39  return StatusCode::FAILURE;
40  }
41  writeHandle.addDependency(readHandle);
42 
43  const coral::Blob& blob = (*attrList)["Blob"].data<coral::Blob>();
44  unsigned int chanSize = (*attrList)["ChannelSize"].data<unsigned int>();
45  unsigned int stateSize = (*attrList)["StatusWordSize"].data<unsigned int>();
46  unsigned int endian = (*attrList)["Endianness"].data<unsigned int>();
47  unsigned int version = (*attrList)["Version"].data<unsigned int>();
48 
49  std::vector<std::pair<HWIdentifier,LArBadFeb> > bcVec =
50  LArBadChanBlobUtils::decodeBlob<LArBadFeb>( &blob, chanSize, stateSize, endian,
51  version, msg());
52 
53  for (auto& idBC : bcVec) {
54  badFebCont->add(idBC.first,idBC.second);
55  }
56  }
57  else {
58  //No input data from DB, set infinte range
59  writeHandle.addDependency(IOVInfiniteRange::infiniteRunLB());
60  }
61 
62  if (m_inputFileName.size()) {//Read supplemental data from ASCII file (if required)
63 
64  const LArOnlineID* onlineID;
65  ATH_CHECK(detStore()->retrieve(onlineID,"LArOnlineID"));
66  LArBadChannelDecoder decoder(&(*onlineID));
67  std::vector<std::pair<HWIdentifier,LArBadFeb> > bcVec = decoder.readFebASCII(m_inputFileName, msg());
68  for (auto& idBC : bcVec) {
69  badFebCont->add(idBC.first,idBC.second);
70  }
71  } //end if have ASCII filename
72 
73 
74 
75  size_t nChanBeforeMege=badFebCont->size();
76  badFebCont->sort(); //Sorts vector of bad febs and merges duplicate entries
77 
78  ATH_MSG_INFO("Read a total of " << badFebCont->size() << " problematic febs from database");
79  if (nChanBeforeMege!=badFebCont->size()) {
80  ATH_MSG_INFO("Merged " << nChanBeforeMege-badFebCont->size() << " duplicate entries");
81  }
82 
83  if(writeHandle.record(std::move(badFebCont)).isFailure()) {
84  ATH_MSG_ERROR("Could not record LArBadFebCont object with "
85  << writeHandle.key()
86  << " with EventRange " << writeHandle.getRange()
87  << " into Conditions Store");
88  return StatusCode::FAILURE;
89  }
90  ATH_MSG_INFO("Recorded LArBadFebCont object with "
91  << writeHandle.key()
92  << " with EventRange " << writeHandle.getRange()
93  << " into Conditions Store");
94 
95 
96  return StatusCode::SUCCESS;
97 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArBadFebCondAlg::m_BCOutputKey
SG::WriteCondHandleKey< LArBadFebCont > m_BCOutputKey
Definition: LArBadFebCondAlg.h:30
LArBadFebCondAlg::m_BCInputKey
SG::ReadCondHandleKey< AthenaAttributeList > m_BCInputKey
Definition: LArBadFebCondAlg.h:28
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
python.LArCondContChannels.decoder
decoder
def channelSelection(self, channelList, groupType): if groupType == self.SingleGroup: pass elif group...
Definition: LArCondContChannels.py:618
LArBadChannelDecoder
Definition: LArBadChannelDecoder.h:21
LArBadChannelDecoder.h
python.subdetectors.tile.Blob
Blob
Definition: tile.py:17
LArBadXCont::sort
void sort()
Sort and purge the list of bad channels The list of bad channels get sorted by channel-ID For channel...
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
LArBadFebCondAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition: LArBadFebCondAlg.cxx:21
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
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArBadChanBlobUtils.h
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
LArBadFebCondAlg::m_inputFileName
Gaudi::Property< std::string > m_inputFileName
Definition: LArBadFebCondAlg.h:32
LArBadFebCondAlg.h
IOVInfiniteRange::infiniteRunLB
static EventIDRange infiniteRunLB()
Produces an EventIDRange that is infinite in RunLumi and invalid in Time.
Definition: IOVInfiniteRange.h:39
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthenaAttributeList
An AttributeList represents a logical row of attributes in a metadata table. The name and type of eac...
Definition: PersistentDataModel/PersistentDataModel/AthenaAttributeList.h:45
IOVInfiniteRange.h
LArBadXCont::size
size_type size() const
Number of known bad channels.
Definition: LArBadChannelCont.h:79
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
LArBadFebCondAlg::initialize
virtual StatusCode initialize() override final
Definition: LArBadFebCondAlg.cxx:11
get_generator_info.version
version
Definition: get_generator_info.py:33
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.
SG::AllowEmpty
@ AllowEmpty
Definition: StoreGate/StoreGate/VarHandleKey.h:30
SG::WriteCondHandle
Definition: WriteCondHandle.h:26
CaloCondBlobAlgs_fillNoiseFromASCII.blob
blob
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:96
LArOnlineID.h