Skip to content

Commit e2eb320

Browse files
staricSANTELJ Luka
authored andcommitted
excluded BS from string PV
1 parent 5fff58e commit e2eb320

File tree

4 files changed

+69
-38
lines changed

4 files changed

+69
-38
lines changed

dqm/analysis/modules/include/DQMHistAnalysisTOP.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,12 @@ namespace Belle2 {
179179
*/
180180
void updateLimits();
181181

182+
/**
183+
* Sets flags for boardstacks to be included in alarming
184+
* @param excludedBoardstacks list of boarstacks to be excluded from alarming
185+
*/
186+
void setIncludedBoardstacks(const std::vector<std::string>& excludedBoardstacks);
187+
182188
// module parameters
183189

184190
std::vector<int> m_asicWindowsBand = {215, 235}; /**< lower and upper bin of a band denoting good windows */
@@ -195,6 +201,7 @@ namespace Belle2 {
195201

196202
std::vector<int> m_alarmColors = {kGray, kGreen, kYellow, kRed}; /**< alarm colors */
197203
std::vector<bool> m_includedBoardstacks; /**< boardstacks included in alarming */
204+
std::map<std::string, int> m_bsmap; /**< a map of boardstack names to ID's */
198205

199206
bool m_IsNullRun = false; /**< Run type flag for null runs. */
200207

dqm/analysis/modules/src/DQMHistAnalysisTOP.cc

Lines changed: 52 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -74,26 +74,21 @@ void DQMHistAnalysisTOPModule::initialize()
7474
if (m_backgroundAlarmLevels.size() != 2) B2ERROR("Parameter list 'backgroundAlarmLevels' must contain two numbers");
7575
if (m_photonYieldsAlarmLevels.size() != 2) B2ERROR("Parameter list 'photonYieldsAlarmLevels' must contain two numbers");
7676

77-
// parse excluded boardstacks
77+
// make a map of boardstack names to ID's
7878

79-
m_includedBoardstacks.resize(64, true);
80-
if (not m_excludedBoardstacks.empty()) {
81-
std::map<std::string, int> bsmap;
82-
int id = 1;
83-
for (int slot = 1; slot <= 16; slot++) {
84-
string slotstr = to_string(slot);
85-
for (std::string bs : {"a", "b", "c", "d"}) {
86-
bsmap[slotstr + bs] = id;
87-
id++;
88-
}
89-
}
90-
for (const auto& bsname : m_excludedBoardstacks) {
91-
id = bsmap[bsname];
92-
if (id > 0) m_includedBoardstacks[id - 1] = false;
93-
else B2ERROR("Invalid boardstack name: " << bsname);
79+
int id = 1;
80+
for (int slot = 1; slot <= 16; slot++) {
81+
string slotstr = to_string(slot);
82+
for (std::string bs : {"a", "b", "c", "d"}) {
83+
m_bsmap[slotstr + bs] = id;
84+
id++;
9485
}
9586
}
9687

88+
// parse excluded boardstacks
89+
90+
setIncludedBoardstacks(m_excludedBoardstacks);
91+
9792
// MiraBelle monitoring
9893

9994
m_monObj = getMonitoringObject("top");
@@ -104,6 +99,7 @@ void DQMHistAnalysisTOPModule::initialize()
10499
registerEpicsPV(m_pvPrefix + "badCarriers", "badCarriers");
105100
registerEpicsPV(m_pvPrefix + "badAsics", "badAsics");
106101
registerEpicsPV(m_pvPrefix + "badPMTs", "badPMTs");
102+
registerEpicsPV(m_pvPrefix + "numExcludedBS", "numExcludedBS");
107103

108104
// Epics used to get limits from configuration file - override module parameters (input only)
109105

@@ -114,10 +110,7 @@ void DQMHistAnalysisTOPModule::initialize()
114110
registerEpicsPV(m_pvPrefix + "deadChannelsAlarmLevels", "deadChannelsAlarmLevels");
115111
registerEpicsPV(m_pvPrefix + "backgroundAlarmLevels", "backgroundAlarmLevels");
116112
registerEpicsPV(m_pvPrefix + "photonYieldsAlarmLevels", "photonYieldsAlarmLevels");
117-
for (int slot = 1; slot <= 16; slot++) {
118-
std::string varName = "slot" + to_string(slot);
119-
registerEpicsPV(m_pvPrefix + varName, varName); // excludedBoardstacks (lolo = BS0, low = BS1, high = BS2, hihi = BS3)
120-
}
113+
registerEpicsPV(m_pvPrefix + "excludedBoardstacks", "excludedBoardstacks");
121114

122115
updateEpicsPVs(5.0);
123116

@@ -266,6 +259,7 @@ void DQMHistAnalysisTOPModule::updateWindowVsSlotCanvas()
266259
canvas->cd();
267260
m_text1->Draw();
268261
for (auto* line : m_asicWindowsBandLines) line->Draw();
262+
canvas->Pad()->SetFrameFillColor(10);
269263
canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
270264
canvas->Modified();
271265
}
@@ -292,6 +286,7 @@ void DQMHistAnalysisTOPModule::updateEventMonitorCanvas()
292286
if (canvas) {
293287
canvas->cd();
294288
m_text2->Draw();
289+
canvas->Pad()->SetFrameFillColor(10);
295290
canvas->Pad()->SetFillColor(getAlarmColor(alarmState));
296291
canvas->Modified();
297292
}
@@ -705,12 +700,16 @@ void DQMHistAnalysisTOPModule::setEpicsVariables()
705700
setEpicsPV("badCarriers", badCarriers);
706701
setEpicsPV("badAsics", badAsics);
707702
setEpicsPV("badPMTs", badPMTs);
703+
int numBS = 0;
704+
for (auto included : m_includedBoardstacks) if (not included) numBS++;
705+
setEpicsPV("numExcludedBS", numBS);
708706
updateEpicsPVs(5.0);
709707

710708
B2DEBUG(20, "badBoardstacks: " << badBoardstacks);
711709
B2DEBUG(20, "badCarriers: " << badCarriers);
712710
B2DEBUG(20, "badAsics: " << badAsics);
713711
B2DEBUG(20, "badPMTs: " << badPMTs);
712+
B2DEBUG(20, "excludedBS: " << numBS);
714713
}
715714

716715
void DQMHistAnalysisTOPModule::updateLimits()
@@ -732,30 +731,49 @@ void DQMHistAnalysisTOPModule::updateLimits()
732731

733732
setAlarmLines();
734733

735-
m_excludedBoardstacks.clear();
736-
std::vector<std::string> bsLabels = {"a", "b", "c", "d"};
737-
for (int slot = 1; slot <= 16; slot++) {
738-
std::vector<double> includedBS(4);
739-
for (int bs = 0; bs < 4; bs++) includedBS[bs] = m_includedBoardstacks[(slot - 1) * 4 + bs];
740-
std::string varName = "slot" + to_string(slot);
741-
requestLimitsFromEpicsPVs(varName, includedBS[0], includedBS[1], includedBS[2], includedBS[3]);
742-
for (int bs = 0; bs < 4; bs++) {
743-
int index = (slot - 1) * 4 + bs;
744-
m_includedBoardstacks[index] = (includedBS[bs] != 0);
745-
if (not m_includedBoardstacks[index]) m_excludedBoardstacks.push_back(to_string(slot) + bsLabels[bs]);
734+
bool status = false;
735+
std::string excludedBS = getEpicsStringPV("excludedBoardstacks", status);
736+
737+
if (status) {
738+
m_excludedBoardstacks.clear();
739+
std::string name;
740+
for (auto c : excludedBS) {
741+
if (isspace(c)) continue;
742+
else if (ispunct(c)) {
743+
if (not name.empty()) {
744+
m_excludedBoardstacks.push_back(name);
745+
name.clear();
746+
}
747+
} else name.push_back(c);
746748
}
749+
if (not name.empty()) {
750+
m_excludedBoardstacks.push_back(name);
751+
}
752+
setIncludedBoardstacks(m_excludedBoardstacks);
747753
}
748754

749-
B2DEBUG(20, "asicWindowsBand: [" << m_asicWindowsBand[0] << ", " << m_asicWindowsBand[1] << "]");
750-
B2DEBUG(20, "asicWindowsAlarmLevels: [" << m_asicWindowsAlarmLevels[0] << ", " << m_asicWindowsAlarmLevels[1] << "]");
755+
B2DEBUG(20, "asicWindowsBand: [" << m_asicWindowsBand[0] << ", " << m_asicWindowsBand[1] << "]");
756+
B2DEBUG(20, "asicWindowsAlarmLevels: [" << m_asicWindowsAlarmLevels[0] << ", " << m_asicWindowsAlarmLevels[1] << "]");
751757
B2DEBUG(20, "eventMonitorAlarmLevels: [" << m_eventMonitorAlarmLevels[0] << ", " << m_eventMonitorAlarmLevels[1] << "]");
752-
B2DEBUG(20, "junkHitsAlarmLevels: [" << m_junkHitsAlarmLevels[0] << ", " << m_junkHitsAlarmLevels[1] << "]");
758+
B2DEBUG(20, "junkHitsAlarmLevels: [" << m_junkHitsAlarmLevels[0] << ", " << m_junkHitsAlarmLevels[1] << "]");
753759
B2DEBUG(20, "deadChannelsAlarmLevels: [" << m_deadChannelsAlarmLevels[0] << ", " << m_deadChannelsAlarmLevels[1] << "]");
754760
B2DEBUG(20, "backgroundAlarmLevels: [" << m_backgroundAlarmLevels[0] << ", " << m_backgroundAlarmLevels[1] << "]");
755761
B2DEBUG(20, "photonYieldsAlarmLevels: [" << m_photonYieldsAlarmLevels[0] << ", " << m_photonYieldsAlarmLevels[1] << "]");
756762
std::string ss;
757763
for (const auto& s : m_excludedBoardstacks) ss += "'" + s + "', ";
758764
if (ss.size() > 2) {ss.pop_back(); ss.pop_back();}
759765
B2DEBUG(20, "excludedBoardstacks: [" << ss << "]");
766+
760767
}
761768

769+
void DQMHistAnalysisTOPModule::setIncludedBoardstacks(const std::vector<std::string>& excludedBoardstacks)
770+
{
771+
m_includedBoardstacks.clear();
772+
m_includedBoardstacks.resize(64, true);
773+
774+
for (const auto& bsname : excludedBoardstacks) {
775+
int id = m_bsmap[bsname];
776+
if (id > 0) m_includedBoardstacks[id - 1] = false;
777+
else B2ERROR("Invalid boardstack name: " << bsname);
778+
}
779+
}

dqm/core/include/DQMHistAnalysis.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,16 +380,18 @@ namespace Belle2 {
380380
/**
381381
* Read value from a EPICS PV
382382
* @param keyname key name (or full PV name) of PV
383+
* @param status return status (true on success)
383384
* @return string value (empty string if non existing)
384385
*/
385-
std::string getEpicsStringPV(std::string keyname);
386+
std::string getEpicsStringPV(std::string keyname, bool& status);
386387

387388
/**
388389
* Read value from a EPICS PV
389390
* @param index index of PV
391+
* @param status return status (true on success)
390392
* @return string value (empty string if non existing)
391393
*/
392-
std::string getEpicsStringPV(int index);
394+
std::string getEpicsStringPV(int index, bool& status);
393395

394396
/**
395397
* Update all EPICS PV (flush to network)

dqm/core/src/DQMHistAnalysis.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,9 @@ double DQMHistAnalysisModule::getEpicsPV(int index)
446446
return NAN;
447447
}
448448

449-
std::string DQMHistAnalysisModule::getEpicsStringPV(std::string keyname)
449+
std::string DQMHistAnalysisModule::getEpicsStringPV(std::string keyname, bool& status)
450450
{
451+
status = false;
451452
char value[40] = "";
452453
if (!m_useEpics) return std::string(value);
453454
#ifdef _BELLE2_EPICS
@@ -461,6 +462,7 @@ std::string DQMHistAnalysisModule::getEpicsStringPV(std::string keyname)
461462
auto r = ca_get(DBR_STRING, m_epicsNameToChID[keyname], value);
462463
if (r == ECA_NORMAL) r = ca_pend_io(5.0); // this is needed!
463464
if (r == ECA_NORMAL) {
465+
status = true;
464466
return std::string(value);
465467
} else {
466468
SEVCHK(r, "ca_get or ca_pend_io failure");
@@ -469,8 +471,9 @@ std::string DQMHistAnalysisModule::getEpicsStringPV(std::string keyname)
469471
return std::string(value);
470472
}
471473

472-
std::string DQMHistAnalysisModule::getEpicsStringPV(int index)
474+
std::string DQMHistAnalysisModule::getEpicsStringPV(int index, bool& status)
473475
{
476+
status = false;
474477
char value[40] = "";
475478
if (!m_useEpics) return std::string(value);
476479
#ifdef _BELLE2_EPICS
@@ -484,6 +487,7 @@ std::string DQMHistAnalysisModule::getEpicsStringPV(int index)
484487
auto r = ca_get(DBR_DOUBLE, m_epicsChID[index], value);
485488
if (r == ECA_NORMAL) r = ca_pend_io(5.0); // this is needed!
486489
if (r == ECA_NORMAL) {
490+
status = true;
487491
return std::string(value);
488492
} else {
489493
SEVCHK(r, "ca_get or ca_pend_io failure");

0 commit comments

Comments
 (0)