ATLAS Offline Software
LArBadChannelDBAlg.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
7 // AttributeList
8 #include "CoralBase/Attribute.h"
9 #include "CoralBase/Blob.h"
10 #include "CoralBase/AttributeListSpecification.h"
13 
15 
17 
18 LArBadChannelDBAlg::LArBadChannelDBAlg(const std::string& name, ISvcLocator* pSvcLocator) :
19  AthAlgorithm( name, pSvcLocator), m_BCKey("LArBadChannel"), m_BFKey("LArBadFeb"), m_isSC(false)
20 {
21  declareProperty("BadChanKey",m_BCKey);
22  declareProperty("MissingFEBKey",m_BFKey);
23  declareProperty("DBFolder",m_dbFolder="/LAR/BadChannels/BadChannels");
24  declareProperty("FEBFolder",m_dbFebFolder="/LAR/BadChannels/MissingFEBs");
25  declareProperty("WritingMode",m_mode=0,"selects information written to DB: 0 for bad channels, 1 for missing febs");
26  declareProperty("SuperCell",m_isSC);
27 }
28 
30 
31 
33 
34  ATH_MSG_INFO ( "initialize()" );
35 
36  ATH_CHECK (m_BCKey.initialize(m_mode==0) );
37  ATH_CHECK (m_BFKey.initialize(m_mode==1) );
38 
39  return StatusCode::SUCCESS;
40 }
41 
43 {return StatusCode::SUCCESS;}
44 
46  const LArOnlineID *onlineID=nullptr;
47  if(!m_isSC) {
48  ATH_CHECK( detStore()->retrieve(onlineID, "LArOnlineID") );
49  if(!onlineID) {
50  ATH_MSG_ERROR("Failed to retrieve LArOnlineID");
51  return StatusCode::FAILURE;
52  }
53  }
54  if (m_mode == 0) {
56  const LArBadChannelCont *bcCont {*readHandle};
57  if ( bcCont == nullptr) {
58  ATH_MSG_ERROR("Failed to retrieve BadChanCont with key "<<m_BCKey.key() );
59  return StatusCode::FAILURE;
60  }
61  ATH_MSG_INFO ( "Creating AttrListCollection in folder " << m_dbFolder );
62  LArBadChannelState bcState;
64  for (const auto& entry : bcCont->fullCont()) {
65  const HWIdentifier hid=HWIdentifier(entry.first);
67  else {
68  if (onlineID->isEMBchannel(hid)) {
69  if (onlineID->pos_neg(hid))
71  else
73  } else if (onlineID->isEMECchannel(hid)) {
74  if (onlineID->pos_neg(hid))
76  else
78  } else if (onlineID->isHECchannel(hid)) {
79  if (onlineID->pos_neg(hid))
81  else
83  } else if (onlineID->isFCALchannel(hid)) {
84  if (onlineID->pos_neg(hid))
86  else
88  } else {
89  ATH_MSG_WARNING ( "Wrong bad channel Id" << hid );
90  continue;
91  }
92  }
93  bcState.add(LArBadChannelDBTools::BadChanEntry(hid,entry.second),coolchan);
94  }
95 
96  CondAttrListCollection* attrListColl =
98 
99  ATH_CHECK( detStore()->record( attrListColl, m_dbFolder) );
100  }
101 
102  if (m_mode == 1) {
103  ATH_MSG_INFO ( "Creating AthenaAttributeList in folder " << m_dbFebFolder );
104 
106  const LArBadFebCont *bfCont {*readHandle};
107  if ( bfCont == nullptr) {
108  ATH_MSG_ERROR("Failed to retrieve BadFebCont with key "<<m_BFKey.key() );
109  return StatusCode::FAILURE;
110  }
112  for (const auto& entry : bfCont->fullCont()) {
113  const HWIdentifier hid=HWIdentifier(entry.first);
114  febs.emplace_back(LArBadChannelDBTools::BadFebEntry(hid,entry.second));
115  }
116  if (!febs.empty()) {
118 
119  ATH_CHECK( detStore()->record( attrList, m_dbFebFolder) );
120  }
121  ATH_MSG_INFO ( "exiting finalize successfully " << m_dbFebFolder );
122  }
123 
124  return StatusCode::SUCCESS;
125 }
126 
127 
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArBadChannelState
Definition: LArBadChannelState.h:15
HECA
@ HECA
Definition: CellClusterLinkTool.h:50
EMBA
@ EMBA
Definition: CellClusterLinkTool.h:50
CondAttrListCollection.h
This file defines the class for a collection of AttributeLists where each one is associated with a ch...
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FCALA
@ FCALA
Definition: CellClusterLinkTool.h:50
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
LArBadChannelDBTools::createFebPayload
AthenaAttributeList * createFebPayload(const BadFebVec &data)
Definition: LArBadChannelDBTools.cxx:65
LArBadXCont
Conditions-Data class holding LAr Bad Channel or Bad Feb information.
Definition: LArBadChannelCont.h:28
LArBadChannelDBAlg::m_BFKey
SG::ReadCondHandleKey< LArBadFebCont > m_BFKey
Definition: LArBadChannelDBAlg.h:30
LArBadChannelDBAlg::finalize
StatusCode finalize()
Definition: LArBadChannelDBAlg.cxx:45
LArBadChannelState::add
void add(const BadChanEntry &entry, CoolChannelEnum chan)
Add a bad channel entry to a specified cool channel data.
Definition: LArBadChannelState.cxx:16
LArBadChannelDBAlg::m_dbFebFolder
std::string m_dbFebFolder
Definition: LArBadChannelDBAlg.h:32
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
AthenaAttributeList.h
LArBadChannelDBAlg::initialize
StatusCode initialize()
Definition: LArBadChannelDBAlg.cxx:32
LArBadChanBlobUtils::BadFebVec
std::vector< BadFebEntry > BadFebVec
Definition: LArBadChanBlobUtils.h:23
LArBadChannelDBTools::createCoolCollection
CondAttrListCollection * createCoolCollection(const LArBadChannelState &bcState)
Definition: LArBadChannelDBTools.cxx:82
LArBadChanBlobUtils::BadChanEntry
std::pair< HWIdentifier, LArBadChannel > BadChanEntry
Definition: LArBadChanBlobUtils.h:20
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
EMECA
@ EMECA
Definition: CellClusterLinkTool.h:50
LArOnlineID_Base::isFCALchannel
bool isFCALchannel(const HWIdentifier id) const
Definition: LArOnlineID_Base.cxx:1653
EMBC
@ EMBC
Definition: CellClusterLinkTool.h:50
LArOnlineID::isEMECchannel
bool isEMECchannel(const HWIdentifier id) const override final
Definition: LArOnlineID.cxx:763
LArBadChanBlobUtils::BadFebEntry
std::pair< HWIdentifier, LArBadFeb > BadFebEntry
Definition: LArBadChanBlobUtils.h:21
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArBadChannelDBTools.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArBadChannelDBAlg::~LArBadChannelDBAlg
~LArBadChannelDBAlg()
LArOnlineID_Base::pos_neg
int pos_neg(const HWIdentifier id) const
Return the side of a hardware cell identifier pos_neg = [0,1] positive-side or negative-side Barrel...
Definition: LArOnlineID_Base.cxx:1950
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
LArBadChannelDBAlg::m_mode
int m_mode
Definition: LArBadChannelDBAlg.h:33
AthAlgorithm
Definition: AthAlgorithm.h:47
HECC
@ HECC
Definition: CellClusterLinkTool.h:50
GetAllXsec.entry
list entry
Definition: GetAllXsec.py:132
LArBadChannelDBAlg::execute
StatusCode execute()
Definition: LArBadChannelDBAlg.cxx:42
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LArOnlineID
Definition: LArOnlineID.h:20
LArOnlineID_Base::isEMBchannel
bool isEMBchannel(const HWIdentifier id) const
Definition: LArOnlineID_Base.cxx:1648
LArBadChannelDBAlg::m_BCKey
SG::ReadCondHandleKey< LArBadChannelCont > m_BCKey
Definition: LArBadChannelDBAlg.h:29
LArBadChannelState::CoolChannelEnum
CoolChannelEnum
Definition: LArBadChannelState.h:23
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArBadChannelDBAlg::m_isSC
bool m_isSC
Definition: LArBadChannelDBAlg.h:34
LArBadChannelDBAlg.h
LArBadChannelDBAlg::m_dbFolder
std::string m_dbFolder
Definition: LArBadChannelDBAlg.h:31
LArOnlineID::isHECchannel
bool isHECchannel(const HWIdentifier id) const override final
Definition: LArOnlineID.cxx:723
EMECC
@ EMECC
Definition: CellClusterLinkTool.h:50
LArBadChannelDBAlg::LArBadChannelDBAlg
LArBadChannelDBAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArBadChannelDBAlg.cxx:18
LArOnlineID.h
FCALC
@ FCALC
Definition: CellClusterLinkTool.h:50