10#include <dqm/analysis/modules/DQMHistAnalysisECLShapers.h>
16#include "boost/format.hpp"
28 B2DEBUG(20,
"DQMHistAnalysisECLShapers: Constructor done.");
29 setDescription(
"Processes information involving ECL pedestals (widths and rms).");
41 std::string pv_name = (boost::format(
"logic_check:crate%02d") %
45 for (
auto part_id : {
"fw",
"br",
"bw",
"al"}) {
46 std::string pv_name =
"pedwidth:max_";
50 pv_name =
"pedwidth:avg_";
60 B2DEBUG(20,
"DQMHistAnalysisECLShapers: initialized.");
65 B2DEBUG(20,
"DQMHistAnalysisECLShapers: beginRun called.");
70 TH1* h_fail_crateid =
findHist(
"ECL/fail_crateid");
71 TProfile* h_pedrms_cellid = (TProfile*)
findHist(
"ECL/pedrms_cellid");
73 if (h_pedrms_cellid != NULL) {
74 double pedwidth_sum = 0;
77 std::multiset<double> barrel_pedwidth;
78 std::multiset<double> bwd_pedwidth;
79 std::multiset<double> fwd_pedwidth;
82 const int cellid = i + 1;
83 if (h_pedrms_cellid->GetBinEntries(cellid) < 100)
continue;
84 double pedrms = h_pedrms_cellid->GetBinContent(cellid);
85 pedwidth_sum += pedrms;
87 fwd_pedwidth.insert(pedrms);
88 }
else if (cellid < 7777) {
89 barrel_pedwidth.insert(pedrms);
91 bwd_pedwidth.insert(pedrms);
97 const double adc_to_mev = 0.05;
105 auto sum = [](std::multiset<double> x) {
return std::accumulate(x.begin(), x.end(), 0.0); };
107 m_pedwidth_avg[0] = sum(fwd_pedwidth) / fwd_pedwidth.size() * adc_to_mev;
108 m_pedwidth_avg[1] = sum(barrel_pedwidth) / barrel_pedwidth.size() * adc_to_mev;
109 m_pedwidth_avg[2] = sum(bwd_pedwidth) / bwd_pedwidth.size() * adc_to_mev;
112 for (
int i = 0; i < 4; i++) {
120 if (h_fail_crateid != NULL) {
123 std::string pv_name = (boost::format(
"logic_check:crate%02d") %
125 int errors_count = h_fail_crateid->GetBinContent(i + 1);
129 static const char* part_id[] = {
"fw",
"br",
"bw",
"al"};
130 for (
int i = 0; i < 4; i++) {
132 std::string pv_name =
"pedwidth:max_";
133 pv_name += part_id[i];
136 for (
int i = 0; i < 4; i++) {
138 std::string pv_name =
"pedwidth:avg_";
139 pv_name += part_id[i];
147 B2DEBUG(20,
"DQMHistAnalysisECLShapers: endRun called");
152 TProfile* h_pedrms_cellid = (TProfile*)
findHist(
"ECL/pedrms_cellid");
153 if (h_pedrms_cellid ==
nullptr) {
154 m_monObj->setVariable(
"comment",
"No ECL pedestal width histograms available");
155 B2INFO(
"Histogram named ECL/pedrms_cellid is not found.");
160 h_pedrms_cellid->Draw();
177 int len = values.size();
183 auto end_iter = std::prev(values.end(), len * 0.1);
void initialize() override final
Initialize the module.
~DQMHistAnalysisECLShapersModule()
Destructor.
double m_pedwidth_avg[4]
Average pedestal width array See m_pedwidth_max for the details.
DQMHistAnalysisECLShapersModule()
< derived from DQMHistAnalysisModule class.
std::string m_pvPrefix
Prefix to use for PVs registered by this module.
MonitoringObject * m_monObj
monitoring object
double robust_max(std::multiset< double > values)
Remove upper 10% of the values, return the maximum in the remaining 90%.
double m_pedwidth_max[4]
Max pedestal width array [0] -> Max pedestal width in FWD endcap [1] -> Max pedestal width in barrel ...
void event() override final
Event processor.
TCanvas * m_c_main
main panel for monitoring object
void endRun() override final
Call when a run ends.
void beginRun() override final
Call when a run begins.
static const int c_collector_count
Number of ECLCollector modules (normally 52)
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
DQMHistAnalysisModule()
Constructor / Destructor.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
void setDescription(const std::string &description)
Sets the description of the module.
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.
const int c_NCrystals
Number of crystals.
Abstract base class for different kinds of events.