ATLAS Offline Software
LArFebConfig.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
7 #include "GaudiKernel/ISvcLocator.h"
8 #include "GaudiKernel/IMessageSvc.h"
9 #include "CoralBase/Attribute.h"
10 
11 const std::string LArFebConfig::s_lower = "lower";
12 const std::string LArFebConfig::s_upper = "upper";
13 
15  AthMessaging(Gaudi::svcLocator()->service< IMessageSvc >( "MessageSvc" ),"LArFebConfig"),
16  m_onlineID(onlineId)
17 
18 { }
19 
20 
22  const coral::AttributeList* attrList)
23 {
24  m_attrPerFeb[febid.get_compact()] = attrList;
25 }
26 
27 
29  short& lower,
30  short& upper) const
31 {
32  int channel = 0;
33  const coral::AttributeList* attrList = getAttrList (chid, channel);
34  if (attrList == nullptr) {
35  lower = ERRORCODE;
36  upper = ERRORCODE;
37  return;
38  }
39  std::string chanstr = std::to_string(channel+1);
40  lower = getThresholdFromAttrList (s_lower, attrList, chanstr);
41  upper = getThresholdFromAttrList (s_upper, attrList, chanstr);
42 }
43 
44 
47  int& channel) const
48 {
49  if (m_attrPerFeb.empty()) {
50  ATH_MSG_WARNING("FEB threshold cache is empty");
51  return nullptr;
52  }
53 
54  const HWIdentifier fid=m_onlineID->feb_Id(chid);
55  channel = m_onlineID->channel(chid);
56  auto it = m_attrPerFeb.find(fid.get_compact());
57  if (it == m_attrPerFeb.end()) {
58  ATH_MSG_DEBUG("Such FEB was not found !");
59  return nullptr;
60  }
61  return it->second;
62 }
63 
64 
65 short
66 LArFebConfig::getThresholdFromAttrList(const std::string& MedLow,
67  const coral::AttributeList* attrList,
68  const std::string& chanstr) const
69 {
70  std::string channame = MedLow + chanstr;
71  return (short)(*attrList)[channame].data<int32_t>(); //Will throw and exception if channel does not exist
72 }
73 
74 
75 short LArFebConfig::getThreshold(const std::string& MedLow,
76  const HWIdentifier& chid) const
77 {
78  int channel = 0;
79  const coral::AttributeList* attrList = getAttrList (chid, channel);
80  if (attrList == nullptr) {
81  return ERRORCODE;
82  }
83  std::string chanstr = std::to_string(channel+1);
84  return getThresholdFromAttrList (MedLow, attrList, chanstr);
85 }
LArFebConfig::s_upper
static const std::string s_upper
Definition: LArFebConfig.h:43
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
skel.it
it
Definition: skel.GENtoEVGEN.py:396
Identifier::get_compact
value_type get_compact() const
Get the compact id.
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
python.PyKernel.AttributeList
AttributeList
Definition: PyKernel.py:36
LArFebConfig::ERRORCODE
@ ERRORCODE
Definition: LArFebConfig.h:45
HWIdentifier
Definition: HWIdentifier.h:13
LArFebConfig::add
void add(HWIdentifier febid, const coral::AttributeList *attrList)
Definition: LArFebConfig.cxx:21
LArFebConfig::getThreshold
short getThreshold(const std::string &MedLow, const HWIdentifier &chid) const
Definition: LArFebConfig.cxx:75
LArOnlineID_Base::channel
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
Definition: LArOnlineID_Base.cxx:1963
PlotCalibFromCool.channame
channame
Definition: PlotCalibFromCool.py:278
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
LArFebConfig::m_onlineID
const LArOnlineID * m_onlineID
Definition: LArFebConfig.h:30
LArOnlineID_Base::feb_Id
HWIdentifier feb_Id(int barrel_ec, int pos_neg, int feedthrough, int slot) const
Create feb_Id from fields.
Definition: LArOnlineID_Base.cxx:1479
ActsTrk::to_string
std::string to_string(const DetectorType &type)
Definition: GeometryDefs.h:34
LArOnlineID
Definition: LArOnlineID.h:20
LArFebConfig::m_attrPerFeb
std::unordered_map< HWIdentifier::value_type, const coral::AttributeList * > m_attrPerFeb
Definition: LArFebConfig.h:32
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
LArFebConfig::getAttrList
const coral::AttributeList * getAttrList(const HWIdentifier &chid, int &channel) const
Definition: LArFebConfig.cxx:46
LArFebConfig::LArFebConfig
LArFebConfig()=delete
LArFebConfig.h
Gaudi
=============================================================================
Definition: CaloGPUClusterAndCellDataMonitorOptions.h:273
LArFebConfig::thresholds
void thresholds(const HWIdentifier &chid, short &lower, short &upper) const
Definition: LArFebConfig.cxx:28
LArFebConfig::s_lower
static const std::string s_lower
Definition: LArFebConfig.h:42
LArOnlineID.h
LArFebConfig::getThresholdFromAttrList
short getThresholdFromAttrList(const std::string &MedLow, const coral::AttributeList *attrList, const std::string &chanstr) const
Definition: LArFebConfig.cxx:66