14#include <dqm/analysis/modules/DQMHistAnalysisSVDOccupancy.h>
15#include <vxd/geometry/GeoCache.h>
41 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: Constructor done.");
43 setDescription(
"DQM Analysis Module that produces colored canvas for a straightforward interpretation of the SVD Data Quality.");
45 addParam(
"occLevel_Error",
m_occError,
"Maximum Occupancy (%) allowed for safe operations (red)",
double(3));
46 addParam(
"occLevel_Warning",
m_occWarning,
"Occupancy (%) at WARNING level (orange)",
double(2.5));
50 addParam(
"occLevel_Empty",
m_occEmpty,
"Maximum Occupancy (%) for which the sensor is considered empty",
double(0));
51 addParam(
"onlineOccLevel_Error",
m_onlineOccError,
"Maximum OnlineOccupancy (%) allowed for safe operations (red)",
double(10));
53 addParam(
"onlineOccLevel_Empty",
m_onlineOccEmpty,
"Maximum OnlineOccupancy (%) for which the sensor is considered empty",
59 addParam(
"samples3",
m_3Samples,
"if True 3 samples histograms analysis is performed",
bool(
false));
65 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: initialized.");
71 for (
const auto& aVxdID : sensors) {
94 m_cStripOccupancyU[i] =
new TCanvas(Form(
"SVDOccupancy/c_StripOccupancyU_%d_%d_%d", tmp_layer, tmp_ladder, tmp_sensor));
95 m_cStripOccupancyV[i] =
new TCanvas(Form(
"SVDOccupancy/c_StripOccupancyV_%d_%d_%d", tmp_layer, tmp_ladder, tmp_sensor));
132 "Average OFFLINE Sensor Occupancy (%), @view/@side Side for cluster time group Id = 0, 1, 2 & 3");
156 "Average ONLINE Sensor Occupancy (%), @view/@side Side for 3 samples");
169 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: beginRun called.");
227 double oocErrorLoOff = 0.;
228 double oocErrorLoOn = 0.;
229 double oocErrorLoIDs = 0.;
231 double occWarningOff = 0.;
232 double occWarningOn = 0.;
233 double occWarningIDs = 0.;
239 B2DEBUG(10,
" SVD occupancy thresholds taken from EPICS configuration file:");
244 " < error with minimum statistics of " <<
m_occEmpty);
248 " < error with minimum statistics of " <<
m_occEmpty);
271 m_legEmpty->AddText(
"at least one sensor is emtpy");
322 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: event called.");
325 TH1* hnEvnts =
findHist(
"SVDExpReco/SVDDQM_nEvents",
true);
326 if (hnEvnts == NULL) {
327 B2INFO(
"no events, nothing to do here");
330 B2DEBUG(10,
"SVDExpReco/SVDDQM_nEvents found");
334 TString tmp = hnEvnts->GetTitle();
335 Int_t pos = tmp.Last(
'~');
336 if (pos == -1) pos = 0;
338 TString runID = tmp(pos, tmp.Length() - pos);
339 B2INFO(
"DQMHistAnalysisSVDOccupancyModule::runID = " << runID);
340 Float_t nEvents = hnEvnts->GetEntries();
343 auto hChart =
findHist(
"SVDExpReco/SVDDQM_StripCountsChip");
345 if (hChart != NULL) {
403 gStyle->SetOptStat(0);
404 gStyle->SetPaintTextFormat(
"2.3f");
407 for (
unsigned int i = 0; i <
m_SVDModules.size(); i++) {
413 TString tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_StripCountU", tmp_layer, tmp_ladder, tmp_sensor);
415 auto hStripCountU =
findHist(tmpname.Data());
416 if (hStripCountU == NULL) {
417 B2INFO(
"Occupancy U histogram not found");
420 Float_t occU =
getOccupancy(hStripCountU->GetEntries(), tmp_layer, nEvents);
429 m_hStripOccupancyU[i].SetName(Form(
"%d_%d_%d_OccupancyU", tmp_layer, tmp_ladder, tmp_sensor));
430 m_hStripOccupancyU[i].SetTitle(Form(
"SVD Sensor %d_%d_%d U-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
431 tmp_sensor, runID.Data()));
433 if (i == 0 || i == 1) {
437 m_hStripOccupancyU[i].SetName(Form(
"%d_%d_%d_OccupancyU", tmp_layer, tmp_ladder, tmp_sensor));
438 m_hStripOccupancyU[i].SetTitle(Form(
"SVD Sensor %d_%d_%d U-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
439 tmp_sensor, runID.Data()));
446 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_Strip3CountU", tmp_layer, tmp_ladder, tmp_sensor);
448 auto hStrip3CountU =
findHist(tmpname.Data());
449 if (hStrip3CountU == NULL) {
450 B2INFO(
"Occupancy U histogram not found for 3 samples");
454 Float_t occU =
getOccupancy(hStrip3CountU->GetEntries(), tmp_layer, nEvents);
461 TString tmpnameGrpId0 = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_StripCountSignalGroupIDsU", tmp_layer, tmp_ladder, tmp_sensor);
462 auto hStripCountGroupIDsU =
findHist(tmpnameGrpId0.Data());
463 if (hStripCountGroupIDsU == NULL) {
464 B2INFO(
"Occupancy U histogram for group Id0 not found");
468 Float_t occU =
getOccupancy(hStripCountGroupIDsU->GetEntries(), tmp_layer, nEvents);
474 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_StripCountV", tmp_layer, tmp_ladder, tmp_sensor);
476 auto hStripCountV =
findHist(tmpname.Data());
477 if (hStripCountV == NULL) {
478 B2INFO(
"Occupancy V histogram not found");
482 Float_t occV =
getOccupancy(hStripCountV->GetEntries(), tmp_layer, nEvents,
true);
491 m_hStripOccupancyV[i].SetName(Form(
"%d_%d_%d_OccupancyV", tmp_layer, tmp_ladder, tmp_sensor));
492 m_hStripOccupancyV[i].SetTitle(Form(
"SVD Sensor %d_%d_%d V-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
493 tmp_sensor, runID.Data()));
499 m_hStripOccupancyV[i].SetName(Form(
"%d_%d_%d_OccupancyV", tmp_layer, tmp_ladder, tmp_sensor));
500 m_hStripOccupancyV[i].SetTitle(Form(
"SVD Sensor %d_%d_%d V-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
501 tmp_sensor, runID.Data()));
508 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_Strip3CountV", tmp_layer, tmp_ladder, tmp_sensor);
510 auto hStrip3CountV =
findHist(tmpname.Data());
511 if (hStrip3CountV == NULL) {
512 B2INFO(
"Occupancy V histogram not found");
516 Float_t occV =
getOccupancy(hStrip3CountV->GetEntries(), tmp_layer, nEvents,
true);
523 tmpnameGrpId0 = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_StripCountSignalGroupIDsV", tmp_layer, tmp_ladder, tmp_sensor);
525 auto hStripCountGroupIDsV =
findHist(tmpnameGrpId0.Data());
526 if (hStripCountGroupIDsV == NULL) {
527 B2INFO(
"Occupancy U histogram for group Id0 not found");
531 Float_t occV =
getOccupancy(hStripCountGroupIDsV->GetEntries(), tmp_layer, nEvents,
true);
537 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStripCountV", tmp_layer, tmp_ladder, tmp_sensor);
539 auto hOnlineStripCountV =
findHist(tmpname.Data());
540 if (hOnlineStripCountV == NULL) {
541 B2INFO(
"OnlineOccupancy V histogram not found");
545 Float_t onlineOccV =
getOccupancy(hOnlineStripCountV->GetEntries(), tmp_layer, nEvents,
true);
548 for (
int b = 1; b < hOnlineStripCountV->GetNbinsX() + 1; b++) {
549 hOnlineStripCountV->SetBinContent(b, hOnlineStripCountV->GetBinContent(b) / nEvents * 100);
551 hOnlineStripCountV->GetYaxis()->SetTitle(
"ZS3 occupancy (%)");
557 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStrip3CountV", tmp_layer, tmp_ladder, tmp_sensor);
559 auto hOnlineStrip3CountV =
findHist(tmpname.Data());
560 if (hOnlineStrip3CountV == NULL) {
561 B2INFO(
"OnlineOccupancy3 V histogram not found");
565 Float_t onlineOccV =
getOccupancy(hOnlineStrip3CountV->GetEntries(), tmp_layer, nEvents,
true);
568 for (
int b = 1; b < hOnlineStrip3CountV->GetNbinsX() + 1; b++) {
569 hOnlineStrip3CountV->SetBinContent(b, hOnlineStrip3CountV->GetBinContent(b) / nEvents * 100);
571 hOnlineStrip3CountV->GetYaxis()->SetTitle(
"ZS3 occupancy (%)");
577 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStripCountU", tmp_layer, tmp_ladder, tmp_sensor);
579 auto hOnlineStripCountU =
findHist(tmpname.Data());
580 if (hOnlineStripCountU == NULL) {
581 B2INFO(
"OnlineOccupancy U histogram not found");
585 Float_t onlineOccU =
getOccupancy(hOnlineStripCountU->GetEntries(), tmp_layer, nEvents);
588 for (
int b = 1; b < hOnlineStripCountU->GetNbinsX() + 1; b++) {
589 hOnlineStripCountU->SetBinContent(b, hOnlineStripCountU->GetBinContent(b) / nEvents * 100);
591 hOnlineStripCountU->GetYaxis()->SetTitle(
"ZS3 occupancy (%)");
597 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStrip3CountU", tmp_layer, tmp_ladder, tmp_sensor);
599 auto hOnlineStrip3CountU =
findHist(tmpname.Data());
600 if (hOnlineStrip3CountU == NULL) {
601 B2INFO(
"OnlineOccupancy3 U histogram not found");
605 Float_t onlineOccU =
getOccupancy(hOnlineStrip3CountU->GetEntries(), tmp_layer, nEvents);
608 for (
int b = 1; b < hOnlineStrip3CountU->GetNbinsX() + 1; b++) {
609 hOnlineStrip3CountU->SetBinContent(b, hOnlineStrip3CountU->GetBinContent(b) / nEvents * 100);
611 hOnlineStrip3CountU->GetYaxis()->SetTitle(
"ZS3 occupancy (%)");
623 if (i == 0 || i == 1) {
676 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: endRun called");
682 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: terminate called");
725 for (
int module = 0;
module < m_sensors;
module++) {
726 delete m_cStripOccupancyU[module];
729 delete m_cStripOccupancyU;
730 delete m_cStripOccupancyV;
736 if (tmp_layer != 3 && sideV)
739 return (entries / nStrips / nEvents * 100);
744 if (histoType == kOnline) {
746 occupancyStatus = std::max(
noStat, occupancyStatus);
748 occupancyStatus = std::max(
lowStat, occupancyStatus);
749 }
else if (occupancy < m_onlineOccWarning && occupancy >=
m_onlineOccEmpty) {
750 occupancyStatus = std::max(
good, occupancyStatus);
752 occupancyStatus = std::max(
warning, occupancyStatus);
754 occupancyStatus = std::max(
error, occupancyStatus);
756 }
else if (histoType == kOffline) {
758 occupancyStatus = std::max(
noStat, occupancyStatus);
760 occupancyStatus = std::max(
lowStat, occupancyStatus);
761 }
else if (occupancy < m_occWarning && occupancy >=
m_occEmpty) {
762 occupancyStatus = std::max(
good, occupancyStatus);
764 occupancyStatus = std::max(
warning, occupancyStatus);
766 occupancyStatus = std::max(
error, occupancyStatus);
768 }
else if (histoType == kGroupIDs) {
770 occupancyStatus = std::max(
noStat, occupancyStatus);
772 occupancyStatus = std::max(
lowStat, occupancyStatus);
774 occupancyStatus = std::max(
good, occupancyStatus);
776 occupancyStatus = std::max(
warning, occupancyStatus);
778 occupancyStatus = std::max(
error, occupancyStatus);
int registerEpicsPV(const std::string &pvname, const std::string &keyname="")
EPICS related Functions.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
bool requestLimitsFromEpicsPVs(chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
Get Alarm Limits from EPICS PV.
TPaveText * m_legOnlineNormal
onlineOccupancy plot legend, normal
static TString getHistoNameFromCanvas(TString cName, TString view="", TString cPrefix="c_", TString hPrefix="")
get histogram name from Canvas name
TPaveText * m_legEmpty
plot legend, empty
TPaveText * m_legGroupIDsProblem
Group IDs Occupancy plot legend, problem.
void updateCanvases(SVDSummaryPlots *histo, TCanvas *canvas, TCanvas *canvasRPhi, svdStatus status, bool isU, int histoType=kOffline)
update canvases
TPaveText * m_legLowStat
plot legend, low stats
TPaveText * m_legWarning
plot legend, warning
TPaveText * m_legGroupIDsWarning
Group IDs Occupancy plot legend, warning.
TPaveText * m_legNormal
plot legend, normal
TPaveText * m_legProblem
plot legend, problem
TPaveText * m_legOnlineProblem
onlineOccupancy plot legend, problem
TPaveText * m_legOnlineWarning
onlineOccupancy plot legend, warning
DQMHistAnalysisSVDModule(bool panelTop=false, bool online=false, bool groupIDs=false)
Constructor.
TPaveText * m_legGroupIDsNormal
Group IDs Occupancy plot legend, normal.
TCanvas * m_cOnlineOccupancyU
online occupancy U histo canvas
TCanvas * m_cOccupancyV
occupancy V histo canvas
void initialize() override final
Initializer.
svdStatus m_onlineOccV3Samples
0 = good, 4 = empty, 1 = warning, 2 = error for 3 sampes
svdStatus m_occVstatus
0 = good, 4 = empty, 1 = warning, 2 = error
TCanvas * m_cOccupancyU
occupancy U histo canvas
TCanvas * m_cOccupancyRPhiViewVGroupId0
occupancy V histo canvas for cluster time group Id = 0
DQMHistAnalysisSVDOccupancyModule()
Constructor.
TCanvas * m_cOccupancyRPhiViewV3Samples
occupancy V plot canvas for 3 samples
TCanvas * m_cOnlineOccupancyRPhiViewU3Samples
occupancy U plot canvas for 3 samples
int m_sensors
number of sensors to considired
TCanvas ** m_cStripOccupancyV
u-side strip chart occupancy canvas
svdStatus m_occVGroupId0
0 = good, 4 = empty, 1 = warning, 2 = error for 3 sampels
std::vector< VxdID > m_SVDModules
IDs of all SVD Modules to iterate over.
double m_onlineOccError
error level of the onlineOccupancy
TCanvas * m_cOccupancyRPhiViewUGroupId0
occupancy U histo canvas for cluster time group Id = 0
TCanvas * m_cOccupancyVGroupId0
occupancy V histo canvas for cluster time group Id = 0
SVDSummaryPlots * m_hOccupancy3Samples
occupancy histos for 3 samples
svdStatus m_occU3Samples
0 = good, 4 = empty, 1 = warning, 2 = error for 3 samples
double m_onlineOccEmpty
empty level of the occupancy
svdStatus m_onlineOccUstatus
0 = good, 4 = empty, 1 = warning, 2 = error
SVDSummaryPlots * m_hOnlineOccupancy3Samples
online occupancy histos for 3 sampels
SVDSummaryPlots * m_hOccupancy
occupancy histos
std::string m_pvPrefix
string prefix for EPICS PVs
TCanvas * m_cOnlineOccupancyRPhiViewV
online occupancy V plot canvas
double m_occWarning
warning level of the occupancy
svdStatus m_occUGroupId0
0 = good, 4 = empty, 1 = warning, 2 = error for 3 samples
void terminate() override final
This method is called at the end of the event processing.
TCanvas * m_cOccupancyU3Samples
occupancy U histo canvas for 3 sampes
SVDSummaryPlots * m_hOccupancyGroupId0
occupancy histos for cluster time group id=0
TCanvas * m_cOnlineOccupancyV3Samples
online Occupancy V histo canvas for 3 samples
TCanvas * m_cOccupancyChartChip
occupancy chart histo canvas
double m_groupIDsOccError
error level of the group IDs occupancy
void event() override final
This method is called for each event.
bool m_printCanvas
Parameters accesible from basf2 scripts.
TH1F m_hOccupancyChartChip
occupancy chart histo
TCanvas * m_cOnlineOccupancyRPhiViewV3Samples
occupancy V plot canvas for 3 samples
TCanvas ** m_cStripOccupancyU
u-side strip chart occupancy canvas
TH1F m_hStripOccupancyV[172]
u-side strip chart occupancy histos
static Float_t getOccupancy(float entries, int tmp_layer, int nEvents, bool sideV=false)
get occupancy value
svdStatus m_occV3Samples
0 = good, 4 = empty, 1 = warning, 2 = error for 3 sampels
double m_groupIDsOccWarning
warning level of the group IDs occupancy
bool m_RPhiView
RPhi plots flag.
bool m_3Samples
if true enable 3 samples histograms analysis
svdStatus m_onlineOccVstatus
0 = good, 4 = empty, 1 = warning, 2 = error
svdStatus m_onlineOccU3Samples
0 = good, 4 = empty, 1 = warning, 2 = error for 3 sample
void endRun() override final
This method is called if the current run ends.
TCanvas * m_cOccupancyRPhiViewU3Samples
occupancy U plot canvas for 3 samples
bool m_RPhiViewId0
additional plots flag
void beginRun() override final
Called when entering a new run.
SVDSummaryPlots * m_hOnlineOccupancy
online occupancy histos
bool m_additionalPlots
additional plots flag
TCanvas * m_cOccupancyRPhiViewU
occupancy U plot canvas
double m_groupIDsOccEmpty
empty level of the IDs occupancy
TCanvas * m_cOnlineOccupancyRPhiViewU
online occupancy U plot canvas
double m_occEmpty
empty level of the occupancy
TCanvas * m_cOnlineOccupancyV
online Occupancy V histo canvas
TCanvas * m_cOccupancyUGroupId0
occupancy U histo canvas for cluster time group Id = 0
TCanvas * m_cOccupancyV3Samples
occupancy V histo canvas for 3 samples
double m_onlineOccWarning
warning level of the onlineOccupancy
double m_occError
error level of the occupancy
TCanvas * m_cOnlineOccupancyU3Samples
online occupancy U histo canvas for 3 samples
svdStatus m_occUstatus
0 = good, 4 = empty, 1 = warning, 2 = error
TCanvas * m_cOccupancyRPhiViewV
occupancy V plot canvas
TH1F m_hStripOccupancyU[172]
u-side strip chart occupancy histos
void setOccStatus(float occ, svdStatus &occupancyStatus, int histoType=kOffline)
set occupancy status
void setDescription(const std::string &description)
Sets the description of the module.
class to summarize SVD quantities per sensor and side
Class to facilitate easy access to sensor information of the VXD like coordinate transformations or p...
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a reference to the SensorInfo of a given SensorID.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Base class to provide Sensor Information for PXD and SVD.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.