ATLAS Offline Software
Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
NswCalibDbTimeChargeData Class Reference

#include <NswCalibDbTimeChargeData.h>

Inheritance diagram for NswCalibDbTimeChargeData:
Collaboration diagram for NswCalibDbTimeChargeData:

Classes

struct  CalibConstants
 Helper struct to cache all calibration constants in a common place of the memory. More...
 
struct  CalibModule
 

Public Types

enum  CalibDataType { CalibDataType::TDO, CalibDataType::PDO }
 

Public Member Functions

 NswCalibDbTimeChargeData (const Muon::IMuonIdHelperSvc *idHelperSvc)
 
 ~NswCalibDbTimeChargeData ()=default
 
void setData (CalibDataType type, const Identifier &chnlId, CalibConstants constants)
 
void setZero (CalibDataType type, MuonCond::CalibTechType tech, CalibConstants constants)
 
std::vector< IdentifiergetChannelIds (const CalibDataType type, const std::string &tech, const std::string &side) const
 
const CalibConstantsgetCalibForChannel (const CalibDataType type, const Identifier &channelId) const
 Retrieves the calibration constant for a particular readout channel. More...
 
const CalibConstantsgetZeroCalibChannel (const CalibDataType type, const MuonCond::CalibTechType tech) const
 Returns the dummy calibration constant for the given technology type. More...
 
bool msgLvl (const MSG::Level lvl) const
 Test the output level. More...
 
MsgStream & msg () const
 The standard message stream. More...
 
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream. More...
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Types

using ChannelCalibMap = std::vector< CalibModule >
 
using ZeroCalibMap = std::map< CalibDataType, CalibConstants >
 

Private Member Functions

int identToModuleIdx (const Identifier &chan_id) const
 
void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

const Muon::IMuonIdHelperSvcm_idHelperSvc {}
 
const size_t m_nMmElements
 Segmentation of the elements is per NSW gasGap. Each wedge has 4 gasgaps. More...
 
const size_t m_nStgcElements
 Additionally reserve space for the 3 channel types. More...
 
ChannelCalibMap m_pdo_data {}
 
ChannelCalibMap m_tdo_data {}
 
std::map< MuonCond::CalibTechType, ZeroCalibMapm_zero {}
 
std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

Detailed Description

Definition at line 19 of file NswCalibDbTimeChargeData.h.

Member Typedef Documentation

◆ ChannelCalibMap

Definition at line 70 of file NswCalibDbTimeChargeData.h.

◆ ZeroCalibMap

Definition at line 74 of file NswCalibDbTimeChargeData.h.

Member Enumeration Documentation

◆ CalibDataType

Enumerator
TDO 
PDO 

Definition at line 22 of file NswCalibDbTimeChargeData.h.

22  {
23  TDO,
24  PDO
25  };

Constructor & Destructor Documentation

◆ NswCalibDbTimeChargeData()

NswCalibDbTimeChargeData::NswCalibDbTimeChargeData ( const Muon::IMuonIdHelperSvc idHelperSvc)

Definition at line 17 of file NswCalibDbTimeChargeData.cxx.

17  :
18  AthMessaging{"NswCalibDbTimeChargeData"},
19  m_idHelperSvc{idHelperSvc} {
22 }

◆ ~NswCalibDbTimeChargeData()

NswCalibDbTimeChargeData::~NswCalibDbTimeChargeData ( )
default

Member Function Documentation

◆ getCalibForChannel()

const NswCalibDbTimeChargeData::CalibConstants * NswCalibDbTimeChargeData::getCalibForChannel ( const CalibDataType  type,
const Identifier channelId 
) const

Retrieves the calibration constant for a particular readout channel.

If there is no calibration constant available, then the zero calibChannel is returned.

Definition at line 113 of file NswCalibDbTimeChargeData.cxx.

113  {
114  const ChannelCalibMap& calibMap = type == CalibDataType::PDO ? m_pdo_data : m_tdo_data;
115  const int array_idx = identToModuleIdx(channelId);
116  const unsigned int channel = (m_idHelperSvc->isMM(channelId) ?
119  if (calibMap.at(array_idx).channels.size() > channel && calibMap[array_idx].channels[channel]) {
120  return calibMap[array_idx].channels[channel].get();
121  }
122  // search for data for channel zero
124  return getZeroCalibChannel(type, tech);
125 
126 }

◆ getChannelIds()

std::vector< Identifier > NswCalibDbTimeChargeData::getChannelIds ( const CalibDataType  type,
const std::string &  tech,
const std::string &  side 
) const

No calibration constants saved here

Definition at line 78 of file NswCalibDbTimeChargeData.cxx.

78  {
79  std::vector<Identifier> chnls;
81  chnls.reserve(calibMap.size());
82  for (const CalibModule& module : calibMap) {
84  if (module.channels.empty()) continue;
85  if (side == "A" && m_idHelperSvc->stationEta(module.layer_id) < 0) continue;
86  if (side == "C" && m_idHelperSvc->stationEta(module.layer_id) > 0) continue;
87 
88  if (m_idHelperSvc->isMM(module.layer_id)) {
89  if (tech == "STGC") continue;
90  const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
91  for (unsigned int chn = 1 ; chn <= module.channels.size() ; ++chn) {
92  if (!module.channels[chn -1]) continue;
93 
94  chnls.push_back(idHelper.channelID(module.layer_id,
95  idHelper.multilayer(module.layer_id),
96  idHelper.gasGap(module.layer_id), chn ));
97  }
98  } else if (m_idHelperSvc->issTgc(module.layer_id)) {
99  if (tech == "MM") break;
100  const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
101  for (unsigned int chn = 1 ; chn <= module.channels.size() ; ++chn) {
102  if (!module.channels[chn -1]) continue;
103  chnls.push_back(idHelper.channelID(module.layer_id,
104  idHelper.multilayer(module.layer_id),
105  idHelper.gasGap(module.layer_id),
106  idHelper.channelType(module.layer_id), chn ));
107  }
108  }
109  }
110 
111  return chnls;
112 }

◆ getZeroCalibChannel()

const NswCalibDbTimeChargeData::CalibConstants * NswCalibDbTimeChargeData::getZeroCalibChannel ( const CalibDataType  type,
const MuonCond::CalibTechType  tech 
) const

Returns the dummy calibration constant for the given technology type.

Definition at line 127 of file NswCalibDbTimeChargeData.cxx.

127  {
128  std::map<MuonCond::CalibTechType, ZeroCalibMap>::const_iterator itr = m_zero.find(tech);
129  if(itr != m_zero.end()) {
130  const ZeroCalibMap& zeroMap = itr->second;
131  ZeroCalibMap::const_iterator type_itr = zeroMap.find(type);
132  if(type_itr != zeroMap.end()) return &type_itr->second;
133  }
134  return nullptr;
135 }

◆ identToModuleIdx()

int NswCalibDbTimeChargeData::identToModuleIdx ( const Identifier chan_id) const
private

Definition at line 24 of file NswCalibDbTimeChargeData.cxx.

24  {
26  if (m_idHelperSvc->isMM(chan_id)) {
27  const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
28  return 4 * static_cast<int>(hash) + idHelper.gasGap(chan_id) -1;
29  }
30  const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
31  return m_nMmElements + static_cast<int>(hash)*12 +
32  3* (idHelper.gasGap(chan_id) - 1) + idHelper.channelType(chan_id);
33  }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40 {
42  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ msg() [1/2]

MsgStream & AthMessaging::msg ( ) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 164 of file AthMessaging.h.

165 {
166  MsgStream* ms = m_msg_tls.get();
167  if (!ms) {
168  if (!m_initialized.test_and_set()) initMessaging();
169  ms = new MsgStream(m_imsg,m_nm);
170  m_msg_tls.reset( ms );
171  }
172 
173  ms->setLevel (m_lvl);
174  return *ms;
175 }

◆ msg() [2/2]

MsgStream & AthMessaging::msg ( const MSG::Level  lvl) const
inlineinherited

The standard message stream.

Returns a reference to the default message stream May not be invoked before sysInitialize() has been invoked.

Definition at line 179 of file AthMessaging.h.

180 { return msg() << lvl; }

◆ msgLvl()

bool AthMessaging::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Test the output level.

Parameters
lvlThe message level to test against
Returns
boolean Indicating if messages at given level will be printed
Return values
trueMessages at level "lvl" will be printed

Definition at line 151 of file AthMessaging.h.

152 {
153  if (!m_initialized.test_and_set()) initMessaging();
154  if (m_lvl <= lvl) {
155  msg() << lvl;
156  return true;
157  } else {
158  return false;
159  }
160 }

◆ setData()

void NswCalibDbTimeChargeData::setData ( CalibDataType  type,
const Identifier chnlId,
CalibConstants  constants 
)

Definition at line 39 of file NswCalibDbTimeChargeData.cxx.

41  {
43 
44 
45  const int array_idx = identToModuleIdx(chnlId);
46  ATH_MSG_VERBOSE("Set "<<(type == CalibDataType::PDO ? "PDO" : "TDO")<<" calibration constants for channel "
47  <<m_idHelperSvc->toString(chnlId)<<", slot: "<< array_idx<<", "<<constants);
48  CalibModule& calib_mod = calibMap.at(array_idx);
49  const unsigned int channel = (m_idHelperSvc->isMM(chnlId) ?
50  m_idHelperSvc->mmIdHelper().channel(chnlId) :
51  m_idHelperSvc->stgcIdHelper().channel(chnlId)) -1;
52  if (calib_mod.channels.empty()) {
53  calib_mod.layer_id = m_idHelperSvc->layerId(chnlId);
54  }
55  if (calib_mod.channels.size() <= channel) calib_mod.channels.resize(channel +1);
56  if (calib_mod.channels[channel]) {
57  THROW_EXCEPTION("setData() -- Cannot overwrite channel "<<m_idHelperSvc->toString(chnlId)
58  <<"Layer ID: "<<m_idHelperSvc->toString(calib_mod.layer_id)<<
59  " "<<(*calib_mod.channels[channel] ));
60  return;
61  }
62  calib_mod.channels[channel] = std::make_unique<CalibConstants>(std::move(constants));
63 }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level  lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29 {
30  m_lvl = lvl;
31 }

◆ setZero()

void NswCalibDbTimeChargeData::setZero ( CalibDataType  type,
MuonCond::CalibTechType  tech,
CalibConstants  constants 
)

Definition at line 67 of file NswCalibDbTimeChargeData.cxx.

67  {
68  ZeroCalibMap& calibMap = m_zero[tech];
69  calibMap.insert(std::make_pair(type, std::move(constants)));
70 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_idHelperSvc

const Muon::IMuonIdHelperSvc* NswCalibDbTimeChargeData::m_idHelperSvc {}
private

Definition at line 56 of file NswCalibDbTimeChargeData.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_nMmElements

const size_t NswCalibDbTimeChargeData::m_nMmElements
private
Initial value:

Segmentation of the elements is per NSW gasGap. Each wedge has 4 gasgaps.

Definition at line 58 of file NswCalibDbTimeChargeData.h.

◆ m_nStgcElements

const size_t NswCalibDbTimeChargeData::m_nStgcElements
private
Initial value:

Additionally reserve space for the 3 channel types.

Definition at line 61 of file NswCalibDbTimeChargeData.h.

◆ m_pdo_data

ChannelCalibMap NswCalibDbTimeChargeData::m_pdo_data {}
private

Definition at line 71 of file NswCalibDbTimeChargeData.h.

◆ m_tdo_data

ChannelCalibMap NswCalibDbTimeChargeData::m_tdo_data {}
private

Definition at line 72 of file NswCalibDbTimeChargeData.h.

◆ m_zero

std::map<MuonCond::CalibTechType, ZeroCalibMap> NswCalibDbTimeChargeData::m_zero {}
private

Definition at line 75 of file NswCalibDbTimeChargeData.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
Muon::IMuonIdHelperSvc::stgcIdHelper
virtual const sTgcIdHelper & stgcIdHelper() const =0
access to TgcIdHelper
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
NswCalibDbTimeChargeData::CalibDataType::PDO
@ PDO
NswCalibDbTimeChargeData::m_nMmElements
const size_t m_nMmElements
Segmentation of the elements is per NSW gasGap. Each wedge has 4 gasgaps.
Definition: NswCalibDbTimeChargeData.h:58
MuonIdHelper::detectorElement_hash_max
size_type detectorElement_hash_max() const
Definition: MuonIdHelper.h:186
Muon::IMuonIdHelperSvc::stationEta
virtual int stationEta(const Identifier &id) const =0
Return stationEta for all technologies.
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
THROW_EXCEPTION
#define THROW_EXCEPTION(MSG)
Definition: MMReadoutElement.cxx:48
Muon::IMuonIdHelperSvc::mmIdHelper
virtual const MmIdHelper & mmIdHelper() const =0
access to CscIdHelper
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
NswCalibDbTimeChargeData::m_nStgcElements
const size_t m_nStgcElements
Additionally reserve space for the 3 channel types.
Definition: NswCalibDbTimeChargeData.h:61
python.SystemOfUnits.ms
int ms
Definition: SystemOfUnits.py:132
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
TRT::Hit::side
@ side
Definition: HitInfo.h:83
NswCalibDbTimeChargeData::getZeroCalibChannel
const CalibConstants * getZeroCalibChannel(const CalibDataType type, const MuonCond::CalibTechType tech) const
Returns the dummy calibration constant for the given technology type.
Definition: NswCalibDbTimeChargeData.cxx:127
python.PyAthena.module
module
Definition: PyAthena.py:134
NswCalibDbTimeChargeData::m_tdo_data
ChannelCalibMap m_tdo_data
Definition: NswCalibDbTimeChargeData.h:72
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
sTgcIdHelper::channel
int channel(const Identifier &id) const override
Definition: sTgcIdHelper.cxx:1027
Muon::IMuonIdHelperSvc::layerId
virtual Identifier layerId(const Identifier &id) const =0
create a layer ID, returns tube id for the MDTs
AthMessaging
Class to provide easy MsgStream access and capabilities.
Definition: AthMessaging.h:55
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
AthMessaging::msg
MsgStream & msg() const
The standard message stream.
Definition: AthMessaging.h:164
NswCalibDbTimeChargeData::m_zero
std::map< MuonCond::CalibTechType, ZeroCalibMap > m_zero
Definition: NswCalibDbTimeChargeData.h:75
Muon::IMuonIdHelperSvc::isMM
virtual bool isMM(const Identifier &id) const =0
returns whether this is a MM Identifier or not
NswCalibDbTimeChargeData::ChannelCalibMap
std::vector< CalibModule > ChannelCalibMap
Definition: NswCalibDbTimeChargeData.h:70
NswCalibDbTimeChargeData::m_idHelperSvc
const Muon::IMuonIdHelperSvc * m_idHelperSvc
Definition: NswCalibDbTimeChargeData.h:56
sTgcIdHelper
Definition: sTgcIdHelper.h:55
MuonCond::CalibTechType::STGC
@ STGC
Muon::IMuonIdHelperSvc::hasMM
virtual bool hasMM() const =0
returns whether the Mircomegas identifiers are loaded
MmIdHelper::channel
int channel(const Identifier &id) const override
Definition: MmIdHelper.cxx:800
MmIdHelper
Definition: MmIdHelper.h:54
MmIdHelper::gasGap
int gasGap(const Identifier &id) const override
get the hashes
Definition: MmIdHelper.cxx:798
CaloCondBlobAlgs_fillNoiseFromASCII.hash
dictionary hash
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:109
Muon::IMuonIdHelperSvc::toString
virtual std::string toString(const Identifier &id) const =0
print all fields to string
constants
Definition: Calorimeter/CaloClusterCorrection/python/constants.py:1
NswCalibDbTimeChargeData::m_pdo_data
ChannelCalibMap m_pdo_data
Definition: NswCalibDbTimeChargeData.h:71
MuonCond::CalibTechType
CalibTechType
Definition: MuonSpectrometer/MuonConditions/MuonCondGeneral/MuonCondData/MuonCondData/Defs.h:37
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
NswCalibDbTimeChargeData::ZeroCalibMap
std::map< CalibDataType, CalibConstants > ZeroCalibMap
Definition: NswCalibDbTimeChargeData.h:74
AthMessaging::initMessaging
void initMessaging() const
Initialize our message level and MessageSvc.
Definition: AthMessaging.cxx:39
IdentifierHash
Definition: IdentifierHash.h:38
NswCalibDbTimeChargeData::identToModuleIdx
int identToModuleIdx(const Identifier &chan_id) const
Definition: NswCalibDbTimeChargeData.cxx:24
AthMessaging::m_msg_tls
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
Definition: AthMessaging.h:132
Muon::IMuonIdHelperSvc::issTgc
virtual bool issTgc(const Identifier &id) const =0
returns whether this is a sTGC Identifier or not
MuonCond::CalibTechType::MM
@ MM
Muon::IMuonIdHelperSvc::detElementHash
virtual IdentifierHash detElementHash(const Identifier &id) const =0
Returns the detector element hash associated to an Identifier.
Muon::IMuonIdHelperSvc::hasSTGC
virtual bool hasSTGC() const =0
returns whether the sTGC identifiers are loaded