14#include <dqm/analysis/modules/DQMHistAnalysisPXDCM.h>
18#include <vxd/geometry/GeoCache.h>
19#include <framework/core/ModuleParam.templateDetails.h>
53 B2DEBUG(99,
"DQMHistAnalysisPXDCM: Constructor done.");
63 for (
VxdID& aVxdID : sensors) {
74 B2WARNING(
"No PXDModules in Geometry found! Use hard-coded setup.");
75 std::vector <string> mod = {
76 "1.1.1",
"1.1.2",
"1.2.1",
"1.2.2",
"1.3.1",
"1.3.2",
"1.4.1",
"1.4.2",
77 "1.5.1",
"1.5.2",
"1.6.1",
"1.6.2",
"1.7.1",
"1.7.2",
"1.8.1",
"1.8.2",
78 "2.1.1",
"2.1.2",
"2.2.1",
"2.2.2",
"2.3.1",
"2.3.2",
"2.4.1",
"2.4.2",
79 "2.5.1",
"2.5.2",
"2.6.1",
"2.6.2",
"2.7.1",
"2.7.2",
"2.8.1",
"2.8.2",
80 "2.9.1",
"2.9.2",
"2.10.1",
"2.10.2",
"2.11.1",
"2.11.2",
"2.12.1",
"2.12.2"
103 B2FATAL(
"Parameter list need same length");
129 auto buff = (std::string)aPXDModule;
130 replace(buff.begin(), buff.end(),
'.',
'_');
131 registerEpicsPV(
"PXD:CommonMode:Mean:" + buff, (std::string)aPXDModule);
133 B2DEBUG(99,
"DQMHistAnalysisPXDCM: initialized.");
138 B2DEBUG(99,
"DQMHistAnalysisPXDCM: beginRun called.");
149 double all_outside = 0.0, all = 0.0;
151 bool error_flag =
false;
152 bool warn_flag =
false;
153 bool anyupdate =
false;
155 static TPaveText* leg =
nullptr;
157 if (leg ==
nullptr) {
158 leg =
new TPaveText(0.1, 0.6, 0.90, 0.95,
"NDC");
159 leg->SetFillStyle(0);
160 leg->SetBorderSize(0);
165 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
167 std::string name =
"PXDDAQCM_" + modname;
172 auto scale = hh1->GetBinContent(0);
175 if (scale > 0) scale = 1.0 / scale;
181 for (
int bin = 1; bin <= 64; bin++) {
184 for (
int gate = 0; gate < 192; gate++) {
186 if (std::find(gm.begin(), gm.end(), gate) == gm.end()) {
187 v += hh1->GetBinContent(hh1->GetBin(gate + 1 + 192 * 0, bin)) +
188 hh1->GetBinContent(hh1->GetBin(gate + 1 + 192 * 1, bin)) +
189 hh1->GetBinContent(hh1->GetBin(gate + 1 + 192 * 2, bin)) +
190 hh1->GetBinContent(hh1->GetBin(gate + 1 + 192 * 3, bin));
211 Double_t entries = 0.;
212 Double_t outside = 0.;
219 mean += v * (cm_y + 1);
228 if (entries > 0 and scale < 1e-3) {
231 auto warn_tmp_m = fabs(10.0 - mean) >
m_warnMean;
236 warn_flag |= warn_tmp_m or warn_tmp_os;
237 error_flag |= err_tmp_m or err_tmp_os;
239 if (warn_tmp_m or err_tmp_m) {
241 tmp.Form(
"%s: Mean %f", modname.c_str(), mean);
243 B2INFO(name <<
" Mean " << mean <<
" " << warn_tmp_m << err_tmp_m);
245 if (warn_tmp_os or err_tmp_os) {
247 tmp.Form(
"%s: Outside %f %%", modname.c_str(), 100. * outside / entries);
249 B2INFO(name <<
" Outside " << outside / entries <<
" (" << outside <<
"/" << entries <<
") " << warn_tmp_os
261 auto status =
makeStatus(all >= 10000, warn_flag, error_flag);
267 double dataoutside = all > 0 ? (all_outside / all) : 0;
268 double datacm = all > 0 ? (all_cm / all) : 0;
279 static std::map <int, TLatex*> ltmap;
282 tt =
new TLatex(it + 0.5, 0, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
283 tt->SetTextSize(0.035);
284 tt->SetTextAngle(90);
285 tt->SetTextAlign(12);
299 B2DEBUG(99,
"DQMHistAnalysisPXDCM: terminate called");
The base class for the histogram analysis module.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
void addDeltaPar(const std::string &dirname, const std::string &histname, HistDelta::EDeltaType t, int p, unsigned int a=1)
Add Delta histogram parameters.
void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
TH1 * getDelta(const std::string &fullname, int n=0, bool onlyIfUpdated=true)
Get Delta histogram.
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
EStatus makeStatus(bool enough, bool warn_flag, bool error_flag)
Helper function to judge the status for coloring and EPICS.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
void UpdateCanvas(std::string name, bool updated=true)
Mark canvas as updated (or not)
void terminate(void) override final
This method is called at the end of the event processing.
int m_minEntries
Update entry interval.
TLine * m_line10
Line in the Canvas to guide the eye, target CM.
double m_warnOutside
warn level for outside fraction
TCanvas * m_cCommonModeDelta
Final Canvas.
int m_upperLine
threshold level/line for outside fraction
void initialize(void) override final
Initializer.
TLine * m_lineOutside
Line in the Canvas to guide the eye, outside boundary.
MonitoringObject * m_monObj
Monitoring Object.
TH2D * m_hCommonModeDelta
histogram covering all modules
std::vector< VxdID > m_PXDModules
IDs of all PXD Modules to iterate over.
std::string m_histogramDirectoryName
name of histogram directory
double m_errorOutside
error level for outside fraction
double m_errorMean
error level for mean
DQMHistAnalysisPXDCMModule()
Constructor.
std::map< VxdID, std::vector< int > > m_maskedGates
Module wise gate masking in CM plot and alarm.
double m_warnMean
warn level for mean
std::vector< std::vector< int > > m_parGateList
Gate list for masking.
std::vector< int > m_excluded
Indizes of excluded PXD Modules.
void beginRun(void) override final
Called when entering a new run.
void event(void) override final
This method is called for each event.
std::vector< std::string > m_parModuleList
Module list for masking.
void setDescription(const std::string &description)
Sets the description of the module.
void setVariable(const std::string &var, float val, float upErr=-1., float dwErr=-1)
set value to float variable (new variable is made if not yet existing)
void addCanvas(TCanvas *canv)
Add Canvas to monitoring object.
Class to faciliate easy access to sensor information of the VXD like coordinate transformations or pi...
const std::vector< VxdID > getListOfSensors() const
Get list of all sensors.
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne 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.
Class to uniquely identify a any structure of the 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.