ATLAS Offline Software
Loading...
Searching...
No Matches
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 class  CalibDataType { TDO , PDO , nTypes }

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.
const CalibConstantsgetZeroCalibChannel (const CalibDataType type, const MuonCond::CalibTechType tech) const
 Returns the dummy calibration constant for the given technology type.
bool msgLvl (const MSG::Level lvl) const
 Test the output level.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.
void setLevel (MSG::Level lvl)
 Change the current logging level.

Private Types

using ChannelCalibMap = std::vector<CalibModule>
using ZeroCalibMap = std::array<CalibConstants, Muon::MuonStationIndex::toInt(CalibDataType::nTypes)>

Private Member Functions

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

Private Attributes

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

Detailed Description

Definition at line 25 of file NswCalibDbTimeChargeData.h.

Member Typedef Documentation

◆ ChannelCalibMap

Definition at line 77 of file NswCalibDbTimeChargeData.h.

◆ ZeroCalibMap

Member Enumeration Documentation

◆ CalibDataType

Enumerator
TDO 
PDO 
nTypes 

Definition at line 28 of file NswCalibDbTimeChargeData.h.

28 {
29 TDO,
30 PDO,
31 nTypes
32 };

Constructor & Destructor Documentation

◆ NswCalibDbTimeChargeData()

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

Definition at line 18 of file NswCalibDbTimeChargeData.cxx.

18 :
19 AthMessaging{"NswCalibDbTimeChargeData"},
20 m_idHelperSvc{idHelperSvc} {
23}
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
const Muon::IMuonIdHelperSvc * m_idHelperSvc
const size_t m_nMmElements
Segmentation of the elements is per NSW gasGap. Each wedge has 4 gasgaps.
const size_t m_nStgcElements
Additionally reserve space for the 3 channel types.

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

123 {
125 const int array_idx = identToModuleIdx(channelId);
126 if (array_idx < 0){
127 ATH_MSG_ERROR("NswCalibDbTimeChargeData::getCalibForChannel: array index is negative.");
128 return nullptr;
129 }
130 const unsigned channel = (m_idHelperSvc->isMM(channelId) ?
131 m_idHelperSvc->mmIdHelper().channel(channelId) :
132 m_idHelperSvc->stgcIdHelper().channel(channelId)) -1;
133 if (calibMap.at(array_idx).channels.size() > channel && calibMap[array_idx].channels[channel]) {
134 return calibMap[array_idx].channels[channel].get();
135 }
136 // search for data for channel zero
138 return getZeroCalibChannel(type, tech);
139
140}
#define ATH_MSG_ERROR(x)
int identToModuleIdx(const Identifier &chan_id) const
const CalibConstants * getZeroCalibChannel(const CalibDataType type, const MuonCond::CalibTechType tech) const
Returns the dummy calibration constant for the given technology type.
std::vector< CalibModule > ChannelCalibMap

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

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

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

142 {
143 using namespace Muon::MuonStationIndex;
144 return &m_zero[toInt(tech)][toInt(type)];
145}
std::array< ZeroCalibMap, Muon::MuonStationIndex::toInt(MuonCond::CalibTechType::nTypes)> m_zero
constexpr int toInt(const EnumType enumVal)

◆ identToModuleIdx()

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

Definition at line 25 of file NswCalibDbTimeChargeData.cxx.

25 {
26 const IdentifierHash hash = m_idHelperSvc->detElementHash(chan_id);
27 if (m_idHelperSvc->isMM(chan_id)) {
28 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
29 return static_cast<unsigned>(hash)*(idHelper.gasGapMax()) + (idHelper.gasGap(chan_id) -1);
30 } else if (m_idHelperSvc->issTgc(chan_id)) {
31 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
32 return static_cast<unsigned>(hash)*(idHelper.gasGapMax() * 3 /*3 channel types*/) +
33 (idHelper.gasGap(chan_id) -1 + idHelper.gasGapMax() * idHelper.channelType(chan_id)) + m_nMmElements;
34 }
35 return -1;
36}
static int gasGapMax()
static int gasGapMax()

◆ 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 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ 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 167 of file AthMessaging.h.

168{
169 MsgStream* ms = m_msg_tls.get();
170 if (!ms) {
171 if (!m_initialized.test_and_set()) initMessaging();
172 ms = new MsgStream(m_imsg,m_nm);
173 m_msg_tls.reset( ms );
174 }
175
176 ms->setLevel (m_lvl);
177 return *ms;
178}
boost::thread_specific_ptr< MsgStream > m_msg_tls
MsgStream instance (a std::cout like with print-out levels)
void initMessaging() const
Initialize our message level and MessageSvc.

◆ 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 182 of file AthMessaging.h.

183{ return msg() << lvl; }
MsgStream & msg() const
The standard message stream.

◆ 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 user did not set explicit message level we have to initialize
154 // the messaging and retrieve the default via the MessageSvc.
155 if (m_lvl==MSG::NIL && !m_initialized.test_and_set()) initMessaging();
156
157 if (m_lvl <= lvl) {
158 msg() << lvl;
159 return true;
160 } else {
161 return false;
162 }
163}

◆ setData()

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

Definition at line 42 of file NswCalibDbTimeChargeData.cxx.

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

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

76 {
77 using namespace Muon::MuonStationIndex;
78 m_zero[toInt(tech)][toInt(type)] = std::move(constants);
79}

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 63 of file NswCalibDbTimeChargeData.h.

63{};

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ 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:
{m_idHelperSvc->hasMM() ?
4* (m_idHelperSvc->mmIdHelper().detectorElement_hash_max() + 1) : 0}

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

Definition at line 65 of file NswCalibDbTimeChargeData.h.

65 {m_idHelperSvc->hasMM() ?
66 4* (m_idHelperSvc->mmIdHelper().detectorElement_hash_max() + 1) : 0};

◆ m_nStgcElements

const size_t NswCalibDbTimeChargeData::m_nStgcElements
private
Initial value:
{m_idHelperSvc->hasSTGC() ?
3*4 *(m_idHelperSvc->stgcIdHelper().detectorElement_hash_max() +1): 0}

Additionally reserve space for the 3 channel types.

Definition at line 68 of file NswCalibDbTimeChargeData.h.

68 {m_idHelperSvc->hasSTGC() ?
69 3*4 *(m_idHelperSvc->stgcIdHelper().detectorElement_hash_max() +1): 0};

◆ m_pdo_data

ChannelCalibMap NswCalibDbTimeChargeData::m_pdo_data {}
private

Definition at line 78 of file NswCalibDbTimeChargeData.h.

78{};

◆ m_tdo_data

ChannelCalibMap NswCalibDbTimeChargeData::m_tdo_data {}
private

Definition at line 79 of file NswCalibDbTimeChargeData.h.

79{};

◆ m_zero

std::array<ZeroCalibMap, Muon::MuonStationIndex::toInt(MuonCond::CalibTechType::nTypes)> NswCalibDbTimeChargeData::m_zero {}
private

Definition at line 82 of file NswCalibDbTimeChargeData.h.

82{};

The documentation for this class was generated from the following files: