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 121 of file NswCalibDbTimeChargeData.cxx.

121  {
122  const ChannelCalibMap& calibMap = type == CalibDataType::PDO ? m_pdo_data : m_tdo_data;
123  const int array_idx = identToModuleIdx(channelId);
124  const unsigned int channel = (m_idHelperSvc->isMM(channelId) ?
127  if (calibMap.at(array_idx).channels.size() > channel && calibMap[array_idx].channels[channel]) {
128  return calibMap[array_idx].channels[channel].get();
129  }
130  // search for data for channel zero
132  return getZeroCalibChannel(type, tech);
133 
134 }

◆ 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 86 of file NswCalibDbTimeChargeData.cxx.

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

◆ 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 135 of file NswCalibDbTimeChargeData.cxx.

135  {
136  std::map<MuonCond::CalibTechType, ZeroCalibMap>::const_iterator itr = m_zero.find(tech);
137  if(itr != m_zero.end()) {
138  const ZeroCalibMap& zeroMap = itr->second;
139  ZeroCalibMap::const_iterator type_itr = zeroMap.find(type);
140  if(type_itr != zeroMap.end()) return &type_itr->second;
141  }
142  return nullptr;
143 }

◆ 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 static_cast<unsigned int>(hash)*(idHelper.gasGapMax()) + (idHelper.gasGap(chan_id) -1);
29  } else if (m_idHelperSvc->issTgc(chan_id)) {
30  const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
31  return static_cast<unsigned int>(hash)*(idHelper.gasGapMax() * 3 /*3 channel types*/) +
32  (idHelper.gasGap(chan_id) -1 + idHelper.gasGapMax() * idHelper.channelType(chan_id)) + m_nMmElements;
33  }
34  return -1;
35 }

◆ 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 41 of file NswCalibDbTimeChargeData.cxx.

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

◆ 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 75 of file NswCalibDbTimeChargeData.cxx.

75  {
76  ZeroCalibMap& calibMap = m_zero[tech];
77  calibMap.insert(std::make_pair(type, std::move(constants)));
78 }

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:24
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
sTgcIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType, int channel) const
Definition: sTgcIdHelper.cxx:886
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:135
python.PyAthena.module
module
Definition: PyAthena.py:131
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
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
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
This is a "hash" representation of an Identifier. This encodes a 32 bit index which can be used to lo...
Definition: IdentifierHash.h:25
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
MmIdHelper::channelID
Identifier channelID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channel) const
Definition: MmIdHelper.cxx:736
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