ATLAS Offline Software
Loading...
Searching...
No Matches
NswDcsDbData Class Reference

#include <NswDcsDbData.h>

Collaboration diagram for NswDcsDbData:

Classes

struct  DcsModule
struct  TDaqConstants

Public Types

enum class  DcsTechType { MMG , MMD , STG }
using DcsDataType = MuonCond::DcsDataType
using DcsFsmState = MuonCond::DcsFsmState
using DcsConstants = MuonCond::DcsConstants

Public Member Functions

 NswDcsDbData (const Muon::IMuonIdHelperSvc *idHelperSvc, const MuonGM::MuonDetectorManager *muonGeoMgr)
virtual ~NswDcsDbData ()=default
void setDataHv (const DcsTechType tech, const Identifier &chnlId, DcsConstants constants)
void setDataTDaq (const DcsTechType tech, const Identifier &chnlId, uint64_t timeSince, uint64_t timeUntil, unsigned int elink, bool permanentlyDisabled)
void setDataEltx (const DcsTechType tech, const Identifier &chnlId)
std::vector< IdentifiergetChannelIdsHv (const DcsTechType tech, const std::string &side) const
const DcsConstantsgetDataForChannelHv (const DcsTechType tech, const Identifier &channelId, bool issTgcQ1OuterHv) const
 Retrieves the calibration constant for a particular readout channel.
bool isGood (const EventContext &ctx, const Identifier &channelId, bool issTgcQ1OuterHv=false) const
 Returns whether the channel is alive, i.e. DCS state on, etc...
bool isGoodHv (const Identifier &channelId, bool issTgcQ1OuterHv=false) const
bool isGoodTDaq (const EventContext &ctx, const Identifier &channelId, bool &permanentlyDisabled) const
bool isGoodEltx (const Identifier &channelId) const
bool isConnectedChannel (const Identifier &channelId) const

Private Types

using ChannelDcsMap = std::vector<DcsModule>
using ChannelTDaqMap = std::vector<std::map<Identifier, std::set<TDaqConstants>>>
using ChannelEltxMap = std::vector<std::set<Identifier>>

Private Member Functions

unsigned int identToModuleIdx (const Identifier &chan_id) const

Private Attributes

ChannelDcsMap m_data_hv_mmg {}
ChannelDcsMap m_data_hv_mmd {}
ChannelDcsMap m_data_hv_stg {}
ChannelTDaqMap m_data_tdaq_mmg {}
ChannelTDaqMap m_data_tdaq_stg {}
ChannelEltxMap m_data_eltx_mmg {}
ChannelEltxMap m_data_eltx_stg {}
const Muon::IMuonIdHelperSvcm_idHelperSvc {}
const MuonGM::MuonDetectorManagerm_muonGeoMgr {nullptr}

Detailed Description

Definition at line 19 of file NswDcsDbData.h.

Member Typedef Documentation

◆ ChannelDcsMap

using NswDcsDbData::ChannelDcsMap = std::vector<DcsModule>
private

Definition at line 74 of file NswDcsDbData.h.

◆ ChannelEltxMap

using NswDcsDbData::ChannelEltxMap = std::vector<std::set<Identifier>>
private

Definition at line 81 of file NswDcsDbData.h.

◆ ChannelTDaqMap

using NswDcsDbData::ChannelTDaqMap = std::vector<std::map<Identifier, std::set<TDaqConstants>>>
private

Definition at line 78 of file NswDcsDbData.h.

◆ DcsConstants

◆ DcsDataType

◆ DcsFsmState

Member Enumeration Documentation

◆ DcsTechType

enum class NswDcsDbData::DcsTechType
strong
Enumerator
MMG 
MMD 
STG 

Definition at line 22 of file NswDcsDbData.h.

22 {
23 MMG, // MM channels
24 MMD, // MM drift channels
25 STG // sTGC
26 };

Constructor & Destructor Documentation

◆ NswDcsDbData()

NswDcsDbData::NswDcsDbData ( const Muon::IMuonIdHelperSvc * idHelperSvc,
const MuonGM::MuonDetectorManager * muonGeoMgr )

Definition at line 24 of file NswDcsDbData.cxx.

24 :
25 m_idHelperSvc(idHelperSvc),
26 m_muonGeoMgr(muonGeoMgr){}
const Muon::IMuonIdHelperSvc * m_idHelperSvc
const MuonGM::MuonDetectorManager * m_muonGeoMgr

◆ ~NswDcsDbData()

virtual NswDcsDbData::~NswDcsDbData ( )
virtualdefault

Member Function Documentation

◆ getChannelIdsHv()

std::vector< Identifier > NswDcsDbData::getChannelIdsHv ( const DcsTechType tech,
const std::string & side ) const

Definition at line 113 of file NswDcsDbData.cxx.

113 {
114 std::vector<Identifier> chnls;
115 if(tech == DcsTechType::MMG || tech == DcsTechType::MMD){
116 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
117 const ChannelDcsMap& dcsMap = tech == DcsTechType::MMG ? m_data_hv_mmg : m_data_hv_mmd;
118 chnls.reserve(dcsMap.size());
119 for(const DcsModule& module : dcsMap) {
120 if(module.channels.empty()) continue;
121 if(side == "A" && idHelper.stationEta(module.layer_id) < 0) continue;
122 if(side == "C" && idHelper.stationEta(module.layer_id) > 0) continue;
123 for(unsigned int chn = 1 ; chn <= module.channels.size() ; ++chn) {
124 if(!module.channels[chn -1]) continue;
125 chnls.push_back(idHelper.channelID(module.layer_id, idHelper.multilayer(module.layer_id), idHelper.gasGap(module.layer_id), chn ));
126 }
127 }
128 } else if(tech == DcsTechType::STG){
129 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
130 const ChannelDcsMap& dcsMap = m_data_hv_stg;
131 chnls.reserve(dcsMap.size());
132 for(const DcsModule& module : dcsMap) {
133 if(module.channels.empty()) continue;
134 if(side == "A" && idHelper.stationEta(module.layer_id) < 0) continue;
135 if(side == "C" && idHelper.stationEta(module.layer_id) > 0) continue;
136 for(unsigned int chn = 1 ; chn <= module.channels.size() ; ++chn) {
137 if(!module.channels[chn -1]) continue;
138 chnls.push_back(idHelper.channelID(module.layer_id, idHelper.multilayer(module.layer_id),
139 idHelper.gasGap(module.layer_id), idHelper.channelType(module.layer_id), chn ));
140 }
141 }
142 }
143 return chnls;
144}
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 stationEta(const Identifier &id) const
std::vector< DcsModule > ChannelDcsMap
ChannelDcsMap m_data_hv_stg
ChannelDcsMap m_data_hv_mmd
ChannelDcsMap m_data_hv_mmg
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

◆ getDataForChannelHv()

const NswDcsDbData::DcsConstants * NswDcsDbData::getDataForChannelHv ( const DcsTechType tech,
const Identifier & channelId,
bool issTgcQ1OuterHv ) const

Retrieves the calibration constant for a particular readout channel.

Definition at line 147 of file NswDcsDbData.cxx.

147 {
148 if(tech == DcsTechType::MMG){
149 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
150 if(!idHelper.is_mm(channelId)) return nullptr;
151 Identifier dcsChannelIdStripHv = idHelper.pcbID(channelId);
152 const ChannelDcsMap& dcsMap = m_data_hv_mmg; // later add something like: type == DcsDataType::HV ? m_data_hv : m_data_lv;
153 const unsigned int array_idx = identToModuleIdx(dcsChannelIdStripHv);
154 const unsigned int channel = idHelper.channel(dcsChannelIdStripHv) -1;
155 if (dcsMap.size() > array_idx && dcsMap.at(array_idx).channels.size() > channel && dcsMap[array_idx].channels[channel]) return dcsMap[array_idx].channels[channel].get();
156 } else if (tech == DcsTechType::MMD) {
157 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
158 if(!idHelper.is_mm(channelId)) return nullptr;
159 Identifier dcsChannelIdDriftHv = idHelper.multilayerID(channelId);
160 const ChannelDcsMap& dcsMap = m_data_hv_mmd;
161 const unsigned int array_idx = identToModuleIdx(dcsChannelIdDriftHv);
162 const unsigned int channel = idHelper.channel(dcsChannelIdDriftHv) -1;
163 if (dcsMap.size() > array_idx && dcsMap.at(array_idx).channels.size() > channel && dcsMap[array_idx].channels[channel]) return dcsMap[array_idx].channels[channel].get();
164 } else if(tech == DcsTechType::STG){
165 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
166 if(!idHelper.is_stgc(channelId)) return nullptr;
167
168 // the parameter issTgcQ1OuterHv is only relevant for the Q1s of the stgcs. So set it to false if we are not in Q1, just in case
169 if(std::abs(idHelper.stationEta(channelId))!= 1) {issTgcQ1OuterHv=false;}
170 Identifier dcsChannelId = idHelper.hvID(channelId, !issTgcQ1OuterHv /* the function takes isInnerQ1 therefore invert the isOuterQ1 variable*/);
171 const ChannelDcsMap& dcsMap = m_data_hv_stg;
172 const unsigned int array_idx = identToModuleIdx(dcsChannelId);
173 const unsigned int channel = idHelper.channel(dcsChannelId) -1;
174 if (dcsMap.size() > array_idx && dcsMap.at(array_idx).channels.size() > channel && dcsMap[array_idx].channels[channel]) return dcsMap[array_idx].channels[channel].get();
175 }
176 return nullptr;
177}
Identifier pcbID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int pcb) const
Identifier multilayerID(const Identifier &channeldID) const
int channel(const Identifier &id) const override
bool is_stgc(const Identifier &id) const
bool is_mm(const Identifier &id) const
unsigned int identToModuleIdx(const Identifier &chan_id) const
Identifier hvID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, bool isInnerQ1) const
int channel(const Identifier &id) const override

◆ identToModuleIdx()

unsigned int NswDcsDbData::identToModuleIdx ( const Identifier & chan_id) const
private

Definition at line 33 of file NswDcsDbData.cxx.

33 {
34 const IdentifierHash hash = m_idHelperSvc->detElementHash(chan_id);
35 if (m_idHelperSvc->isMM(chan_id)) {
36 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
37 return static_cast<unsigned int>(hash)*(idHelper.gasGapMax()) + (idHelper.gasGap(chan_id) -1);
38 } else if (m_idHelperSvc->issTgc(chan_id)) {
39 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
40 return static_cast<unsigned int>(hash)*(idHelper.gasGapMax()) + (idHelper.gasGap(chan_id) -1);
41 }
42 THROW_EXCEPTION("NswDcsDbData() - No NSW identifier");
43 return -1;
44 }
static int gasGapMax()
static int gasGapMax()
#define THROW_EXCEPTION(MESSAGE)
Definition throwExcept.h:10

◆ isConnectedChannel()

bool NswDcsDbData::isConnectedChannel ( const Identifier & channelId) const

Definition at line 257 of file NswDcsDbData.cxx.

257 {
258 // for stgc we do not have unconnected channels
259 if(m_idHelperSvc->issTgc(channelId)) return true;
260
261 if(!m_idHelperSvc->isMM(channelId)) THROW_EXCEPTION("the check for unconnected channels was called with an identifier that is in MM and not sTGC");
262
263 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
264
265 const MuonGM::MMReadoutElement* detectorReadoutElement = m_muonGeoMgr->getMMReadoutElement(channelId);
266 if(!detectorReadoutElement) {
267 THROW_EXCEPTION("failed to retrieve MMReadoutElement");
268 }
269 const MuonGM::MuonChannelDesign* channelDesign = detectorReadoutElement->getDesign(channelId);
270 if(!channelDesign) {
271 THROW_EXCEPTION("failed to retrieve MuonChannelDesign");
272 }
273
274 int channel_number = idHelper.channel(channelId);
275 if(idHelper.isStereo(channelId)){
276 if(channel_number <= channelDesign->nMissedBottomStereo || channel_number >= channelDesign->totalStrips - channelDesign->nMissedTopStereo) {
277 return false;
278 }
279 } else {
280 if(channel_number <= channelDesign->nMissedBottomEta || channel_number >= channelDesign->totalStrips - channelDesign->nMissedTopEta) {
281 return false;
282 }
283 }
284 return true;
285
286}
bool isStereo(const Identifier &id) const
const MuonChannelDesign * getDesign(const Identifier &id) const
returns the MuonChannelDesign class for the given identifier

◆ isGood()

bool NswDcsDbData::isGood ( const EventContext & ctx,
const Identifier & channelId,
bool issTgcQ1OuterHv = false ) const

Returns whether the channel is alive, i.e. DCS state on, etc...

Definition at line 180 of file NswDcsDbData.cxx.

180 {
181 // here we will check the different DCS components that need to be good to declare a detector region as good
182 // for now we only we only have the HV data
183 if(!isGoodHv(channelId, issTgcQ1OuterHv)) return false;
184 //isGoodEltx and isGoodTdaq are still under validation, but since they are switched off in the NswDcsAlg their data will be empty so they do not reject hits for now.
185 bool permanentlyDisabled{false};
186 if(!isGoodTDaq(ctx, channelId, permanentlyDisabled)) return false;
187 if(!isGoodEltx(channelId)) return false;
188 if(!isConnectedChannel(channelId)) return false;
189 return true;
190
191}
bool isGoodEltx(const Identifier &channelId) const
bool isConnectedChannel(const Identifier &channelId) const
bool isGoodHv(const Identifier &channelId, bool issTgcQ1OuterHv=false) const
bool isGoodTDaq(const EventContext &ctx, const Identifier &channelId, bool &permanentlyDisabled) const

◆ isGoodEltx()

bool NswDcsDbData::isGoodEltx ( const Identifier & channelId) const

Definition at line 248 of file NswDcsDbData.cxx.

248 {
249 const ChannelTDaqMap & data = m_idHelperSvc->isMM(channelId) ? m_data_tdaq_mmg : m_data_tdaq_stg;
250 const unsigned int array_idx = identToModuleIdx(channelId);
251 if(data.size()<=array_idx || data[array_idx].empty()) return true; // for this ro element no bad elink have been recorded
252 if(data[array_idx].find(channelId) != data[array_idx].end()) return false;
253 return true;
254}
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
ChannelTDaqMap m_data_tdaq_mmg
ChannelTDaqMap m_data_tdaq_stg
std::vector< std::map< Identifier, std::set< TDaqConstants > > > ChannelTDaqMap
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138

◆ isGoodHv()

bool NswDcsDbData::isGoodHv ( const Identifier & channelId,
bool issTgcQ1OuterHv = false ) const

For the moment do not kill the hit if there's no dcs data

Definition at line 194 of file NswDcsDbData.cxx.

194 {
195 if (m_idHelperSvc->issTgc(channelId)){
196 const NswDcsDbData::DcsConstants* dcs = getDataForChannelHv(DcsTechType::STG, channelId, issTgcQ1OuterHv);
198 return !dcs || dcs->fsmState == DcsFsmState::ON;
199 } else if (m_idHelperSvc->isMM(channelId)){
200 const NswDcsDbData::DcsConstants* dcsDrift = getDataForChannelHv(DcsTechType::MMD, channelId, issTgcQ1OuterHv);
201 bool driftHvIsGood = (!dcsDrift || dcsDrift->fsmState == DcsFsmState::ON);
202
203 const NswDcsDbData::DcsConstants* dcsStrips = getDataForChannelHv(DcsTechType::MMG, channelId, issTgcQ1OuterHv);
204 bool stripHvIsGood = (!dcsStrips || dcsStrips->fsmState == DcsFsmState::ON);
205
206 return driftHvIsGood && stripHvIsGood;
207 }
208 return false;
209}
MuonCond::DcsConstants DcsConstants
const DcsConstants * getDataForChannelHv(const DcsTechType tech, const Identifier &channelId, bool issTgcQ1OuterHv) const
Retrieves the calibration constant for a particular readout channel.

◆ isGoodTDaq()

bool NswDcsDbData::isGoodTDaq ( const EventContext & ctx,
const Identifier & channelId,
bool & permanentlyDisabled ) const

Definition at line 211 of file NswDcsDbData.cxx.

211 {
212 const ChannelTDaqMap & data = m_idHelperSvc->isMM(channelId) ? m_data_tdaq_mmg : m_data_tdaq_stg;
213 const unsigned int array_idx = identToModuleIdx(channelId);
214 if(data.size()<=array_idx || data[array_idx].empty()) return true; // for this ro element no bad elink have been recorded
215 const std::map<Identifier, std::set<TDaqConstants>>& dataInRoElement = data[array_idx];
216 Identifier mapIdentifier{0};
217 uint elink{0};
218
219 if(m_idHelperSvc->issTgc(channelId)){
220 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
221 mapIdentifier = idHelper.febID(channelId);
222 auto mapper = Muon::nsw::MapperSTG();
223 mapper.elink_info(idHelper.channelType(channelId), !idHelper.isSmall(channelId), std::abs(idHelper.stationEta(channelId))-1, 4*(idHelper.multilayer(channelId)-1) + idHelper.gasGap(channelId) -1, idHelper.channel(channelId), elink);
224 } else {
225 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
226 mapIdentifier = idHelper.febID(channelId);
227 auto mapper = Muon::nsw::MapperMMG();
228 mapper.elink_info(std::abs(idHelper.stationEta(channelId))-1, idHelper.channel(channelId), elink);
229 }
230
231 auto elm = dataInRoElement.find(mapIdentifier);
232 if(elm == dataInRoElement.end()) return true; // channel in question was not deactivated at all
234 uint64_t evtTime = ctx.eventID().time_stamp()*1e9; // go from seconds to nanoseconds
235 evtTime += ctx.eventID().time_stamp_ns_offset();
236 x.timeSince = evtTime;
237 x.timeUntil = evtTime;
238 x.elink = elink;
239
240 auto disabledLink = elm->second.find(x);
241 if(disabledLink != elm->second.end()){// elink was deactivated for this time period
242 permanentlyDisabled = disabledLink->permanentlyDisabled;
243 return false;
244 }
245 return true; // checked the channel in question, not deactivated for given run and lumi block combination, all good
246}
unsigned int uint
#define x
Identifier febID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int radius) const
bool isSmall(const Identifier &id) const
Identifier febID(int stationName, int stationEta, int stationPhi, int multilayer, int gasGap, int channelType) const

◆ setDataEltx()

void NswDcsDbData::setDataEltx ( const DcsTechType tech,
const Identifier & chnlId )

Definition at line 100 of file NswDcsDbData.cxx.

100 {
102 const uint array_idx = identToModuleIdx(channelId);
103 if (array_idx >= data.size()) data.resize(array_idx + 1);
104 data[array_idx].insert(channelId);
105}
ChannelEltxMap m_data_eltx_stg
ChannelEltxMap m_data_eltx_mmg
std::vector< std::set< Identifier > > ChannelEltxMap

◆ setDataHv()

void NswDcsDbData::setDataHv ( const DcsTechType tech,
const Identifier & chnlId,
DcsConstants constants )

Definition at line 50 of file NswDcsDbData.cxx.

50 {
51 if((tech == DcsTechType::MMG || tech == DcsTechType::MMD) ) {
52 const MmIdHelper& idHelper{m_idHelperSvc->mmIdHelper()};
54 const unsigned int array_idx = identToModuleIdx(chnlId);
55 if (array_idx >= dcsMap.size()) dcsMap.resize(array_idx + 1);
56 DcsModule& dcs_mod = dcsMap[array_idx];
57 const unsigned int channel = idHelper.channel(chnlId)-1;
58 if(dcs_mod.channels.empty())
59 dcs_mod.layer_id = m_idHelperSvc->gasGapId(chnlId);
60 if(dcs_mod.channels.size() <= channel) dcs_mod.channels.resize(channel +1);
61 if(dcs_mod.channels[channel]) {
62 THROW_EXCEPTION("NswDcsDbData::setData() -- Cannot overwrite channel");
63 return;
64 }
65 dcs_mod.channels[channel] = std::make_unique<DcsConstants>(std::move(constants));
66 } else if(tech == DcsTechType::STG) {
67 const sTgcIdHelper& idHelper{m_idHelperSvc->stgcIdHelper()};
69 const unsigned int array_idx = identToModuleIdx(chnlId);
70 if (array_idx >= dcsMap.size()) dcsMap.resize(array_idx + 1);
71 DcsModule& dcs_mod = dcsMap.at(array_idx);
72 const unsigned int channel = idHelper.channel(chnlId)-1;
73 if(dcs_mod.channels.empty()) {
74 dcs_mod.layer_id = m_idHelperSvc->layerId(chnlId);
75 }
76 if(dcs_mod.channels.size() <= channel) dcs_mod.channels.resize(channel +1);
77 if(dcs_mod.channels[channel]) {
78 THROW_EXCEPTION("setData() -- Cannot overwrite channel");
79 return;
80 }
81 dcs_mod.channels[channel] = std::make_unique<DcsConstants>(std::move(constants));
82 }
83}

◆ setDataTDaq()

void NswDcsDbData::setDataTDaq ( const DcsTechType tech,
const Identifier & chnlId,
uint64_t timeSince,
uint64_t timeUntil,
unsigned int elink,
bool permanentlyDisabled )

Definition at line 87 of file NswDcsDbData.cxx.

87 {
89 const unsigned int array_idx = identToModuleIdx(chnlId);
90 if (array_idx >= data.size()) data.resize(array_idx + 1);
92 x.timeSince = timeSince;
93 x.timeUntil = timeUntil;
94 x.elink = elink;
95 x.permanentlyDisabled = permanentlyDisabled;
96 data[array_idx][chnlId].insert(x);
97}

Member Data Documentation

◆ m_data_eltx_mmg

ChannelEltxMap NswDcsDbData::m_data_eltx_mmg {}
private

Definition at line 82 of file NswDcsDbData.h.

82{};

◆ m_data_eltx_stg

ChannelEltxMap NswDcsDbData::m_data_eltx_stg {}
private

Definition at line 83 of file NswDcsDbData.h.

83{};

◆ m_data_hv_mmd

ChannelDcsMap NswDcsDbData::m_data_hv_mmd {}
private

Definition at line 76 of file NswDcsDbData.h.

76{};

◆ m_data_hv_mmg

ChannelDcsMap NswDcsDbData::m_data_hv_mmg {}
private

Definition at line 75 of file NswDcsDbData.h.

75{};

◆ m_data_hv_stg

ChannelDcsMap NswDcsDbData::m_data_hv_stg {}
private

Definition at line 77 of file NswDcsDbData.h.

77{};

◆ m_data_tdaq_mmg

ChannelTDaqMap NswDcsDbData::m_data_tdaq_mmg {}
private

Definition at line 79 of file NswDcsDbData.h.

79{};

◆ m_data_tdaq_stg

ChannelTDaqMap NswDcsDbData::m_data_tdaq_stg {}
private

Definition at line 80 of file NswDcsDbData.h.

80{};

◆ m_idHelperSvc

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

Definition at line 86 of file NswDcsDbData.h.

86{};

◆ m_muonGeoMgr

const MuonGM::MuonDetectorManager* NswDcsDbData::m_muonGeoMgr {nullptr}
private

Definition at line 87 of file NswDcsDbData.h.

87{nullptr};

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