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));
67 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: initialized.");
73 for (
const auto& aVxdID : sensors) {
96 m_cStripOccupancyU[i] =
new TCanvas(Form(
"SVDOccupancy/c_StripOccupancyU_%d_%d_%d", tmp_layer, tmp_ladder, tmp_sensor));
97 m_cStripOccupancyV[i] =
new TCanvas(Form(
"SVDOccupancy/c_StripOccupancyV_%d_%d_%d", tmp_layer, tmp_ladder, tmp_sensor));
134 "Average OFFLINE Sensor Occupancy (%), @view/@side Side for cluster time group Id = 0, 1, 2 & 3");
158 "Average ONLINE Sensor Occupancy (%), @view/@side Side for 3 samples");
171 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: beginRun called.");
229 double oocErrorLoOff = 0.;
230 double oocErrorLoOn = 0.;
231 double oocErrorLoIDs = 0.;
233 double occWarningOff = 0.;
234 double occWarningOn = 0.;
235 double occWarningIDs = 0.;
241 B2DEBUG(10,
" SVD occupancy thresholds taken from EPICS configuration file:");
246 " < error with minimum statistics of " <<
m_occEmpty);
250 " < error with minimum statistics of " <<
m_occEmpty);
273 m_legEmpty->AddText(
"at least one sensor is emtpy");
324 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: event called.");
327 TH1* hnEvnts =
findHist(
"SVDExpReco/SVDDQM_nEvents",
true);
328 if (hnEvnts == NULL) {
329 B2INFO(
"no events, nothing to do here");
332 B2DEBUG(10,
"SVDExpReco/SVDDQM_nEvents found");
336 TString tmp = hnEvnts->GetTitle();
337 Int_t pos = tmp.Last(
'~');
338 if (pos == -1) pos = 0;
340 TString runID = tmp(pos, tmp.Length() - pos);
341 B2INFO(
"DQMHistAnalysisSVDOccupancyModule::runID = " << runID);
342 Float_t nEvents = hnEvnts->GetEntries();
345 auto hChart =
findHist(
"SVDExpReco/SVDDQM_StripCountsChip");
347 if (hChart != NULL) {
405 gStyle->SetOptStat(0);
406 gStyle->SetPaintTextFormat(
"2.3f");
409 for (
unsigned int i = 0; i <
m_SVDModules.size(); i++) {
415 TString tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_StripCountU", tmp_layer, tmp_ladder, tmp_sensor);
417 auto hStripCountU =
findHist(tmpname.Data());
418 if (hStripCountU == NULL) {
419 B2INFO(
"Occupancy U histogram not found");
422 Float_t occU =
getOccupancy(hStripCountU->GetEntries(), tmp_layer, nEvents);
431 m_hStripOccupancyU[i].SetName(Form(
"%d_%d_%d_OccupancyU", tmp_layer, tmp_ladder, tmp_sensor));
432 m_hStripOccupancyU[i].SetTitle(Form(
"SVD Sensor %d_%d_%d U-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
433 tmp_sensor, runID.Data()));
435 if (i == 0 || i == 1) {
439 m_hStripOccupancyU[i].SetName(Form(
"%d_%d_%d_OccupancyU", tmp_layer, tmp_ladder, tmp_sensor));
440 m_hStripOccupancyU[i].SetTitle(Form(
"SVD Sensor %d_%d_%d U-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
441 tmp_sensor, runID.Data()));
448 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_Strip3CountU", tmp_layer, tmp_ladder, tmp_sensor);
450 auto hStrip3CountU =
findHist(tmpname.Data());
451 if (hStrip3CountU == NULL) {
452 B2INFO(
"Occupancy U histogram not found for 3 samples");
456 Float_t occU =
getOccupancy(hStrip3CountU->GetEntries(), tmp_layer, nEvents);
463 TString tmpnameGrpId0 = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_StripCountSignalGroupIDsU", tmp_layer, tmp_ladder, tmp_sensor);
464 auto hStripCountGroupIDsU =
findHist(tmpnameGrpId0.Data());
465 if (hStripCountGroupIDsU == NULL) {
466 B2INFO(
"Occupancy U histogram for group Id0 not found");
470 Float_t occU =
getOccupancy(hStripCountGroupIDsU->GetEntries(), tmp_layer, nEvents);
476 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_StripCountV", tmp_layer, tmp_ladder, tmp_sensor);
478 auto hStripCountV =
findHist(tmpname.Data());
479 if (hStripCountV == NULL) {
480 B2INFO(
"Occupancy V histogram not found");
484 Float_t occV =
getOccupancy(hStripCountV->GetEntries(), tmp_layer, nEvents,
true);
493 m_hStripOccupancyV[i].SetName(Form(
"%d_%d_%d_OccupancyV", tmp_layer, tmp_ladder, tmp_sensor));
494 m_hStripOccupancyV[i].SetTitle(Form(
"SVD Sensor %d_%d_%d V-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
495 tmp_sensor, runID.Data()));
501 m_hStripOccupancyV[i].SetName(Form(
"%d_%d_%d_OccupancyV", tmp_layer, tmp_ladder, tmp_sensor));
502 m_hStripOccupancyV[i].SetTitle(Form(
"SVD Sensor %d_%d_%d V-Strip OFFLINE Occupancy vs Strip Number %s", tmp_layer, tmp_ladder,
503 tmp_sensor, runID.Data()));
510 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_Strip3CountV", tmp_layer, tmp_ladder, tmp_sensor);
512 auto hStrip3CountV =
findHist(tmpname.Data());
513 if (hStrip3CountV == NULL) {
514 B2INFO(
"Occupancy V histogram not found");
518 Float_t occV =
getOccupancy(hStrip3CountV->GetEntries(), tmp_layer, nEvents,
true);
525 tmpnameGrpId0 = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_StripCountSignalGroupIDsV", tmp_layer, tmp_ladder, tmp_sensor);
527 auto hStripCountGroupIDsV =
findHist(tmpnameGrpId0.Data());
528 if (hStripCountGroupIDsV == NULL) {
529 B2INFO(
"Occupancy U histogram for group Id0 not found");
533 Float_t occV =
getOccupancy(hStripCountGroupIDsV->GetEntries(), tmp_layer, nEvents,
true);
539 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStripCountV", tmp_layer, tmp_ladder, tmp_sensor);
541 auto hOnlineStripCountV =
findHist(tmpname.Data());
542 if (hOnlineStripCountV == NULL) {
543 B2INFO(
"OnlineOccupancy V histogram not found");
547 Float_t onlineOccV =
getOccupancy(hOnlineStripCountV->GetEntries(), tmp_layer, nEvents,
true);
550 for (
int b = 1; b < hOnlineStripCountV->GetNbinsX() + 1; b++) {
551 hOnlineStripCountV->SetBinContent(b, hOnlineStripCountV->GetBinContent(b) / nEvents * 100);
553 hOnlineStripCountV->GetYaxis()->SetTitle(
"ZS3 occupancy (%)");
559 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStrip3CountV", tmp_layer, tmp_ladder, tmp_sensor);
561 auto hOnlineStrip3CountV =
findHist(tmpname.Data());
562 if (hOnlineStrip3CountV == NULL) {
563 B2INFO(
"OnlineOccupancy3 V histogram not found");
567 Float_t onlineOccV =
getOccupancy(hOnlineStrip3CountV->GetEntries(), tmp_layer, nEvents,
true);
570 for (
int b = 1; b < hOnlineStrip3CountV->GetNbinsX() + 1; b++) {
571 hOnlineStrip3CountV->SetBinContent(b, hOnlineStrip3CountV->GetBinContent(b) / nEvents * 100);
573 hOnlineStrip3CountV->GetYaxis()->SetTitle(
"ZS3 occupancy (%)");
579 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStripCountU", tmp_layer, tmp_ladder, tmp_sensor);
581 auto hOnlineStripCountU =
findHist(tmpname.Data());
582 if (hOnlineStripCountU == NULL) {
583 B2INFO(
"OnlineOccupancy U histogram not found");
587 Float_t onlineOccU =
getOccupancy(hOnlineStripCountU->GetEntries(), tmp_layer, nEvents);
590 for (
int b = 1; b < hOnlineStripCountU->GetNbinsX() + 1; b++) {
591 hOnlineStripCountU->SetBinContent(b, hOnlineStripCountU->GetBinContent(b) / nEvents * 100);
593 hOnlineStripCountU->GetYaxis()->SetTitle(
"ZS3 occupancy (%)");
599 tmpname = Form(
"SVDExpReco/SVDDQM_%d_%d_%d_OnlineZSStrip3CountU", tmp_layer, tmp_ladder, tmp_sensor);
601 auto hOnlineStrip3CountU =
findHist(tmpname.Data());
602 if (hOnlineStrip3CountU == NULL) {
603 B2INFO(
"OnlineOccupancy3 U histogram not found");
607 Float_t onlineOccU =
getOccupancy(hOnlineStrip3CountU->GetEntries(), tmp_layer, nEvents);
610 for (
int b = 1; b < hOnlineStrip3CountU->GetNbinsX() + 1; b++) {
611 hOnlineStrip3CountU->SetBinContent(b, hOnlineStrip3CountU->GetBinContent(b) / nEvents * 100);
613 hOnlineStrip3CountU->GetYaxis()->SetTitle(
"ZS3 occupancy (%)");
625 if (i == 0 || i == 1) {
678 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: endRun called");
684 B2DEBUG(10,
"DQMHistAnalysisSVDOccupancy: terminate called");
727 for (
int module = 0;
module < m_sensors;
module++) {
728 delete m_cStripOccupancyU[module];
731 delete m_cStripOccupancyU;
732 delete m_cStripOccupancyV;
738 if (tmp_layer != 3 && sideV)
741 return (entries / nStrips / nEvents * 100);
746 if (histoType == kOnline) {
748 occupancyStatus = std::max(
noStat, occupancyStatus);
750 occupancyStatus = std::max(
lowStat, occupancyStatus);
751 }
else if (occupancy < m_onlineOccWarning && occupancy >=
m_onlineOccEmpty) {
752 occupancyStatus = std::max(
good, occupancyStatus);
754 occupancyStatus = std::max(
warning, occupancyStatus);
756 occupancyStatus = std::max(
error, occupancyStatus);
758 }
else if (histoType == kOffline) {
760 occupancyStatus = std::max(
noStat, occupancyStatus);
762 occupancyStatus = std::max(
lowStat, occupancyStatus);
763 }
else if (occupancy < m_occWarning && occupancy >=
m_occEmpty) {
764 occupancyStatus = std::max(
good, occupancyStatus);
766 occupancyStatus = std::max(
warning, occupancyStatus);
768 occupancyStatus = std::max(
error, occupancyStatus);
770 }
else if (histoType == kGroupIDs) {
772 occupancyStatus = std::max(
noStat, occupancyStatus);
774 occupancyStatus = std::max(
lowStat, occupancyStatus);
776 occupancyStatus = std::max(
good, occupancyStatus);
778 occupancyStatus = std::max(
warning, occupancyStatus);
780 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
~DQMHistAnalysisSVDOccupancyModule() override
Destructor.
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.