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).");
38 std::string pv_name = (boost::format(
"logic_check:crate%02d") %
42 for (
auto part_id : {
"fw",
"br",
"bw",
"al"}) {
43 std::string pv_name =
"pedwidth:max_";
47 pv_name =
"pedwidth:avg_";
57 B2DEBUG(20,
"DQMHistAnalysisECLShapers: initialized.");
62 B2DEBUG(20,
"DQMHistAnalysisECLShapers: beginRun called.");
67 TH1* h_fail_crateid =
findHist(
"ECL/fail_crateid");
68 TProfile* h_pedrms_cellid = (TProfile*)
findHist(
"ECL/pedrms_cellid");
70 if (h_pedrms_cellid != NULL) {
71 double pedwidth_sum = 0;
74 std::multiset<double> barrel_pedwidth;
75 std::multiset<double> bwd_pedwidth;
76 std::multiset<double> fwd_pedwidth;
79 const int cellid = i + 1;
80 if (h_pedrms_cellid->GetBinEntries(cellid) < 100)
continue;
81 double pedrms = h_pedrms_cellid->GetBinContent(cellid);
82 pedwidth_sum += pedrms;
84 fwd_pedwidth.insert(pedrms);
85 }
else if (cellid < 7777) {
86 barrel_pedwidth.insert(pedrms);
88 bwd_pedwidth.insert(pedrms);
94 const double adc_to_mev = 0.05;
102 auto sum = [](std::multiset<double> x) {
return std::accumulate(x.begin(), x.end(), 0.0); };
104 m_pedwidth_avg[0] = sum(fwd_pedwidth) / fwd_pedwidth.size() * adc_to_mev;
105 m_pedwidth_avg[1] = sum(barrel_pedwidth) / barrel_pedwidth.size() * adc_to_mev;
106 m_pedwidth_avg[2] = sum(bwd_pedwidth) / bwd_pedwidth.size() * adc_to_mev;
109 for (
int i = 0; i < 4; i++) {
117 if (h_fail_crateid != NULL) {
120 std::string pv_name = (boost::format(
"logic_check:crate%02d") %
122 int errors_count = h_fail_crateid->GetBinContent(i + 1);
126 static const char* part_id[] = {
"fw",
"br",
"bw",
"al"};
127 for (
int i = 0; i < 4; i++) {
129 std::string pv_name =
"pedwidth:max_";
130 pv_name += part_id[i];
133 for (
int i = 0; i < 4; i++) {
135 std::string pv_name =
"pedwidth:avg_";
136 pv_name += part_id[i];
144 B2DEBUG(20,
"DQMHistAnalysisECLShapers: endRun called");
149 TProfile* h_pedrms_cellid = (TProfile*)
findHist(
"ECL/pedrms_cellid");
150 if (h_pedrms_cellid ==
nullptr) {
151 m_monObj->setVariable(
"comment",
"No ECL pedestal width histograms available");
152 B2INFO(
"Histogram named ECL/pedrms_cellid is not found.");
157 h_pedrms_cellid->Draw();
174 int len = values.size();
180 auto end_iter = std::prev(values.end(), len * 0.1);
void initialize() override final
Initialize the module.
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)
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)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
DQMHistAnalysisModule()
Constructor / Destructor.
void setEpicsPV(const std::string &keyname, double value)
Write value to a EPICS PV.
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.