Belle II Software development
DQMHistAnalysisECLOutOfTimeDigits.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9//THIS MODULE
10#include <dqm/analysis/modules/DQMHistAnalysisECLOutOfTimeDigits.h>
11
12//ROOT
13#include <TF1.h>
14#include <TH1F.h>
15
16using namespace Belle2;
17
18REG_MODULE(DQMHistAnalysisECLOutOfTimeDigits);
19
22{
23 B2DEBUG(20, "DQMHistAnalysisECLOutOfTimeDigits: Constructor done.");
24 setDescription("Module to collect and process 'out of time' ECL digits");
25 addParam("pvPrefix", m_pvPrefix, "Prefix to use for PVs registered by this module",
26 std::string("ECL:out_of_time_digits:"));
27 addParam("onlyIfUpdated", m_onlyIfUpdated, "If true (default), update EPICS PVs only if there histograms were updated.",
28 true);
29}
30
31
33{
34 // Register EPICS PVs
35 for (const auto& event_type : {"rand", "dphy", "physics"}) {
36 for (const auto& ecl_part : {"All", "FWDEndcap", "Barrel", "BWDEndcap"}) {
37 std::string pv_name = event_type + std::string(":") + ecl_part;
38 registerEpicsPV(m_pvPrefix + pv_name, pv_name);
39 }
40 }
41
43
44 B2DEBUG(20, "DQMHistAnalysisECLOutOfTimeDigits: initialized.");
45}
46
48{
49 //== Get DQM info
50 for (const auto& event_type : {"rand", "dphy", "physics"}) {
51 for (const auto& ecl_part : {"All", "FWDEndcap", "Barrel", "BWDEndcap"}) {
52 std::string pv_name = event_type + std::string(":") + ecl_part;
53 std::string var_name = pv_name;
54 std::replace(var_name.begin(), var_name.end(), ':', '_');
55
56 m_out_of_time_digits[pv_name] = 0;
57
58 auto hist = (TH1F*)findHist("ECL", "out_of_time_" + var_name, m_onlyIfUpdated);
59
60 if (!hist) continue;
61
62 m_out_of_time_digits[pv_name] = hist->GetMean();
63
64 //== Set EPICS PVs
65
66 double selected_value = m_out_of_time_digits[pv_name];
67 setEpicsPV(pv_name, selected_value);
68 }
69 }
70}
71
73{
74 B2DEBUG(20, "DQMHistAnalysisECLOutOfTimeDigits: endRun called");
75
76 auto main_hist = (TH1F*)findHist("ECL/out_of_time_physics_All");
77
78 if (main_hist == nullptr) {
79 m_monObj->setVariable("comment_out_of_time_digits", "No ECL out-of-time ECLCalDigits histograms available");
80 B2INFO("Histogram named ECL/out_of_time_physics_All is not found.");
81 return;
82 }
83
84 TF1 gaus("fit_func", "gaus");
85
86 for (const auto& event_type : {"rand", "dphy", "physics"}) {
87 for (const auto& ecl_part : {"All", "FWDEndcap", "Barrel", "BWDEndcap"}) {
88 std::string pv_name = event_type + std::string(":") + ecl_part;
89 std::string hist_name = "ECL/out_of_time_" + pv_name;
90 std::string var_name = "out_of_time_digits_" + pv_name;
91
92 std::replace(hist_name.begin(), hist_name.end(), ':', '_');
93 std::replace(var_name.begin(), var_name.end(), ':', '_');
94
95 // Use simple mean from the histogram
96 m_monObj->setVariable(var_name, m_out_of_time_digits[pv_name]);
97 m_monObj->setVariable(var_name + "_stddev", 0);
98 }
99 }
100}
101
102
std::map< std::string, double > m_out_of_time_digits
Out-of-time ECLCalDigits for several cases.
DQMHistAnalysisECLOutOfTimeDigitsModule()
< derived from DQMHistAnalysisModule class.
std::string m_pvPrefix
Prefix to use for PVs registered by this module.
bool m_onlyIfUpdated
If true (default), update EPICS PVs only if there were changes in the histograms.
int registerEpicsPV(const std::string &pvname, const std::string &keyname="")
EPICS related Functions.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
DQMHistAnalysisModule()
Constructor / Destructor.
void setEpicsPV(const std::string &keyname, double value)
Write value to a EPICS PV.
static TH1 * findHist(const std::string &dirname, const std::string &histname="", bool onlyIfUpdated=false)
Find histogram.
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.