14 #include <dqm/analysis/modules/DQMHistAnalysisPXDCM.h>
17 #include <TPaveText.h>
18 #include <vxd/geometry/GeoCache.h>
19 #include <framework/core/ModuleParam.templateDetails.h>
33 DQMHistAnalysisPXDCMModule::DQMHistAnalysisPXDCMModule()
53 B2DEBUG(99,
"DQMHistAnalysisPXDCM: Constructor done.");
67 for (
VxdID& aVxdID : sensors) {
78 B2WARNING(
"No PXDModules in Geometry found! Use hard-coded setup.");
79 std::vector <string> mod = {
80 "1.1.1",
"1.1.2",
"1.2.1",
"1.2.2",
"1.3.1",
"1.3.2",
"1.4.1",
"1.4.2",
81 "1.5.1",
"1.5.2",
"1.6.1",
"1.6.2",
"1.7.1",
"1.7.2",
"1.8.1",
"1.8.2",
82 "2.1.1",
"2.1.2",
"2.2.1",
"2.2.2",
"2.3.1",
"2.3.2",
"2.4.1",
"2.4.2",
83 "2.5.1",
"2.5.2",
"2.6.1",
"2.6.2",
"2.7.1",
"2.7.2",
"2.8.1",
"2.8.2",
84 "2.9.1",
"2.9.2",
"2.10.1",
"2.10.2",
"2.11.1",
"2.11.2",
"2.12.1",
"2.12.2"
107 B2FATAL(
"Parameter list need same length");
133 auto buff = (std::string)aPXDModule;
134 replace(buff.begin(), buff.end(),
'.',
'_');
135 registerEpicsPV(
"PXD:CommonMode:Mean:" + buff, (std::string)aPXDModule);
137 B2DEBUG(99,
"DQMHistAnalysisPXDCM: initialized.");
142 B2DEBUG(99,
"DQMHistAnalysisPXDCM: beginRun called.");
153 double all_outside = 0.0, all = 0.0;
155 bool error_adhoc_flag =
false;
156 bool warn_adhoc_flag =
false;
157 bool anyupdate =
false;
159 auto leg =
new TPaveText(0.1, 0.6, 0.90, 0.95,
"NDC");
160 leg->SetFillStyle(0);
161 leg->SetBorderSize(0);
163 for (
unsigned int i = 0; i <
m_PXDModules.size(); i++) {
165 std::string name =
"PXDDAQCM_" + modname;
169 auto scale = hh1->GetBinContent(0);
172 if (scale > 0) scale = 1.0 / scale;
178 for (
int bin = 1; bin <= 64; bin++) {
181 for (
int gate = 0; gate < 192; gate++) {
183 if (std::find(gm.begin(), gm.end(), gate) == gm.end()) {
184 v += hh1->GetBinContent(hh1->GetBin(gate + 1 + 192 * 0, bin)) +
185 hh1->GetBinContent(hh1->GetBin(gate + 1 + 192 * 1, bin)) +
186 hh1->GetBinContent(hh1->GetBin(gate + 1 + 192 * 2, bin)) +
187 hh1->GetBinContent(hh1->GetBin(gate + 1 + 192 * 3, bin));
205 Double_t mean_adhoc = 0.;
206 Double_t entries_adhoc = 0.;
207 Double_t outside_adhoc = 0.;
214 mean_adhoc += v * (cm_y + 1);
223 if (entries_adhoc > 0 && scale < 1e-3) {
225 mean_adhoc /= entries_adhoc;
230 warn_adhoc_flag |= warn_tmp_m || warn_tmp_os;
231 error_adhoc_flag |= err_tmp_m || err_tmp_os;
233 if (warn_tmp_m || err_tmp_m) {
235 tmp.Form(
"%s: Mean %f", modname.c_str(), mean_adhoc);
237 B2INFO(name <<
" Mean " << mean_adhoc <<
" " << warn_tmp_m << err_tmp_m);
239 if (warn_tmp_os || err_tmp_os) {
241 tmp.Form(
"%s: Outside %f %%", modname.c_str(), 100. * outside_adhoc / entries_adhoc);
243 B2INFO(name <<
" Outside " << outside_adhoc / entries_adhoc <<
" (" << outside_adhoc <<
"/" << entries_adhoc <<
") " << warn_tmp_os
255 int status_adhoc = 0;
264 if (error_adhoc_flag) {
267 }
else if (warn_adhoc_flag) {
279 double dataoutside = all > 0 ? (all_outside / all) : 0;
280 double datacm = all > 0 ? (all_cm / all) : 0;
293 auto tt =
new TLatex(it + 0.5, 0, (
" " + std::string(
m_PXDModules[it]) +
" Module is excluded, please ignore").c_str());
294 tt->SetTextSize(0.035);
295 tt->SetTextAngle(90);
296 tt->SetTextAlign(12);
309 B2DEBUG(99,
"DQMHistAnalysisPXDCM: terminate called");
The base class for the histogram analysis module.
int registerEpicsPV(std::string pvname, std::string keyname="", bool update_pvs=true)
EPICS related Functions.
void addDeltaPar(const std::string &dirname, const std::string &histname, HistDelta::EDeltaType t, int p, unsigned int a=1)
Add Delta histogram parameters.
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.
void UpdateCanvas(std::string name, bool updated=true)
Mark canvas as updated (or not)
static MonitoringObject * getMonitoringObject(const std::string &histname)
Get MonitoringObject with given name (new object is created if non-existing)
void terminate(void) override final
This method is called at the end of the event processing.
int m_minEntries
Update entry intervall.
double m_warnMeanAdhoc
warn level for mean adhoc plot
~DQMHistAnalysisPXDCMModule()
Destructor.
TCanvas * m_cCommonModeDelta
Final Canvas.
double m_errorMeanAdhoc
error level for mean adhoc plot
void initialize(void) override final
Initializer.
TLine * m_lineA
Line in the Canvas to guide the eye.
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
int m_upperLineAdhoc
threshold level/line for outside fraction
std::map< VxdID, std::vector< int > > m_maskedGates
Module wise gate masking in CM plot and alarm.
double m_errorOutsideAdhoc
error level for outside fraction
TLine * m_line1
Line in the Canvas to guide the eye.
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.
double m_warnOutsideAdhoc
warn level for outside fraction
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.