10#include <dqm/analysis/modules/DQMHistAnalysisECL.h>
21#include "boost/format.hpp"
30 B2DEBUG(20,
"DQMHistAnalysisECL: Constructor done.");
34 "Provide a large number of ECL DQM analysis histograms:\n"
35 " 1. Normalize some low-level DQM histograms by the event count.\n"
36 " 2. Display time offsets for each ECL crate.\n"
37 " 3. Display the number of failed fits in each ECL module.");
53 B2DEBUG(20,
"DQMHistAnalysisECL: initialized.");
67 std::string canvas_name = str(boost::format(
"ECL/c_cid_Thr%1%MeV_analysis") %
id);
68 TCanvas* canvas =
new TCanvas(canvas_name.c_str());
74 std::string canvas_name = str(boost::format(
"ECL/c_wf_cid_%1%_analysis") %
id);
75 TCanvas* canvas =
new TCanvas(canvas_name.c_str());
101 h_crate_time_offsets->SetTitle(
"Crate time offset (E > 1 GeV); Crate ID (same as ECLCollector ID); Time offset [ns]");
107 h_logic_summary =
new TH2F(
"logic_summary",
"FPGA <-> C++ fitter inconsistencies count", 52, 1, 53, 12, 1, 13);
108 h_logic_summary->SetTitle(
"FPGA <-> C++ fitter inconsistencies count; ECLCollector ID (same as Crate ID); Shaper ID inside the crate");
111 for (
unsigned short i = 0; i < 52; i++)
h_logic_summary->GetXaxis()->SetBinLabel(i + 1, std::to_string(i + 1).c_str());
112 for (
unsigned short i = 0; i < 12; i++)
h_logic_summary->GetYaxis()->SetBinLabel(i + 1, std::to_string(i + 1).c_str());
118 for (
unsigned short i = 0; i < 52; i++) {
119 auto pv_name = (boost::format(
"time_offset:crate%02d") % (i + 1)).str();
123 auto pv_name = (boost::format(
"wf_frac:%s:min") % wf_option).str();
132 B2DEBUG(20,
"DQMHistAnalysisECL: beginRun called.");
141 for (
unsigned short i = 0; i < h->GetNbinsX(); i++) {
142 Double_t entries = h->GetBinContent(i + 1);
143 Double_t error = h->GetBinError(i + 1);
145 h->SetBinContent(i + 1, entries / weight);
146 h->SetBinError(i + 1, error / weight);
158 B2DEBUG(20,
"DQMHistAnalysisECL: event called");
161 gStyle->SetPalette(1);
168 TH1* h_quality =
findHist(
"ECL/quality");
169 if (h_quality != NULL) {
170 h_quality->SetFillColor(kPink - 4);
171 h_quality->SetDrawOption(
"hist");
172 h_quality->SetMinimum(0.1);
173 h_quality->Draw(
"hist");
183 TH1* h_quality_other =
findHist(
"ECL/quality_other");
184 if (h_quality_other != NULL) {
185 h_quality_other->SetMinimum(0.1);
186 h_quality_other->SetFillColor(kPink - 4);
187 h_quality_other->Draw(
"hist");
194 TH1* h_evtot =
findHist(
"ECL/event");
195 if (h_evtot != NULL) {
196 Double_t events = h_evtot->GetBinContent(1);
204 if (val !=
"psd" && val !=
"other") {
205 TH1* h_evtot_norm =
findHist(str(boost::format(
"ECL/event_%1%") % val));
206 if (h_evtot_norm != NULL) {
207 Double_t events = h_evtot_norm->GetBinContent(1);
209 str(boost::format(
"ECL/wf_cid_%1%") % val), events);
211 }
else if (val ==
"psd") {
214 TH1* h_psd =
findHist(str(boost::format(
"ECL/wf_cid_%1%") % val));
215 TH1* h_psd_norm =
findHist(str(boost::format(
"ECL/%1%_cid") % val));
216 if (h_psd != NULL && h_psd_norm != NULL) {
217 h_psd->Divide(h_psd, h_psd_norm);
232 TH1* h_trigtag1 =
findHist(
"ECL/trigtag1");
233 if (h_trigtag1 != NULL) {
234 h_trigtag1->SetMinimum(0.1);
235 h_trigtag1->Draw(
"hist");
246 TH1* h_adc_hits =
findHist(
"ECL/adc_hits");
247 if (h_adc_hits != NULL) {
248 h_adc_hits->SetMinimum(0.1);
249 h_adc_hits->Draw(
"hist");
261 TH1* h_ampfail_quality =
findHist(
"ECL/ampfail_quality");
262 if (h_ampfail_quality != NULL) {
263 h_ampfail_quality->SetMinimum(0.1);
264 h_ampfail_quality->Draw(
"hist");
265 for (
unsigned short i = 1; i < 5; i++) {
266 if (h_ampfail_quality->GetBinContent(i + 1)) {
282 TH1* h_timefail_quality =
findHist(
"ECL/timefail_quality");
283 if (h_timefail_quality != NULL) {
284 h_timefail_quality->SetMinimum(0.1);
285 h_timefail_quality->Draw(
"hist");
286 for (
unsigned short i = 1; i < 5; i++) {
287 if (h_timefail_quality->GetBinContent(i + 1)) {
303 TH1* h_trigtag2_trigid =
findHist(
"ECL/trigtag2_trigid");
304 if (h_trigtag2_trigid != NULL) {
305 h_trigtag2_trigid->Draw(
"colz");
306 for (
unsigned short i = 0; i < 52; i++) {
307 if (h_trigtag2_trigid->GetBinContent(h_trigtag2_trigid->GetBin(i + 1, 3))) {
325 TH1* h_quality_fit_data =
findHist(
"ECL/quality_fit_data");
326 if (h_quality_fit_data != NULL) {
327 h_quality_fit_data->Draw(
"hist");
328 for (
unsigned short i = 0; i < 4; i++) {
329 for (
unsigned short j = 0; j < 4; j++) {
330 if (h_quality_fit_data->GetBinContent(h_quality_fit_data->GetBin(i + 1, j + 1)) > 0) {
342 bool crates_bad_timing =
false;
347 for (
unsigned short i = 0; i < 52; i++) {
350 std::string h_title =
"ECL/time_crate_" + std::to_string(i + 1) +
"_Thr1GeV";
363 m_low.push_back(i + 1);
366 auto pv_name = (boost::format(
"time_offset:crate%02d") % (i + 1)).str();
380 for (
unsigned short i = 0; i < 52; i++)
h_crate_time_offsets->GetXaxis()->SetBinLabel(i + 1, std::to_string(i + 1).c_str());
386 if (!
m_low.empty()) {
387 auto tg =
new TLatex(5, 40,
"Low statistics");
388 tg->SetTextSize(.06);
389 tg->SetTextAlign(12);
392 if (
m_low.size() < 52) {
393 std::ostringstream sstream;
394 std::copy(
m_low.begin(),
m_low.end() - 1, std::ostream_iterator<short>(sstream,
","));
395 sstream <<
m_low.back();
396 std::string str =
"Crates: " + sstream.str();
397 auto tg1 =
new TLatex(5, 30, str.c_str());
398 tg1->SetTextSize(.03);
399 tg1->SetTextAlign(12);
402 auto tg1 =
new TLatex(5, 30,
"All crates");
403 tg1->SetTextSize(.06);
404 tg1->SetTextAlign(12);
421 TH1* h_fail_crateid =
findHist(
"ECL/fail_crateid");
422 TH1* h_fail_shaperid =
findHist(
"ECL/fail_shaperid");
423 if (h_fail_crateid != NULL && h_fail_shaperid != NULL) {
424 for (
unsigned short i = 0; i < 52; i++) {
425 if (h_fail_crateid->GetBinContent(i + 1)) {
426 for (
unsigned short j = i * 12; j < i * 12 + 12; j++) {
427 if (h_fail_shaperid->GetBinContent(j + 1)) {
428 unsigned short shaper = (j + 1) - 12 * i;
451 if (h_evtot == NULL)
return;
453 Double_t events = h_evtot->GetBinContent(1);
455 m_wf_fraction[wf_option] = std::numeric_limits<double>::quiet_NaN();
457 if (events > 100000) {
458 TH1* hist =
findHist(str(boost::format(
"ECL/wf_cid_%1%") % wf_option));
459 m_wf_fraction[wf_option] = hist->GetBinContent(hist->GetMinimumBin());
461 auto pv_name = (boost::format(
"wf_frac:%s:min") % wf_option).str();
468 B2DEBUG(20,
"DQMHistAnalysisECL: endRun called");
469 for (
unsigned short i = 0; i < 52; i++) {
470 auto var_name = (boost::format(
"time_offset_crate%02d") % (i + 1)).str();
474 auto var_name = (boost::format(
"wf_frac_%s_min") % wf_option).str();
482 B2DEBUG(20,
"terminate called");
std::vector< double > m_HitMapThresholds
Parameters for hit map histograms.
void normalize(TCanvas *, const std::string &, const Double_t &)
Normalize histograms.
void initialize() override final
Initialize the module.
TCanvas * c_bad_quality_analysis
TCanvas for bad_quality .
std::vector< TCanvas * > c_wf_analysis
Vector of TCanvases for waveforms .
TLine * m_lower_boundary_trigtag2
TLine to show lower boundary for 'trigtag2_trigid' histogram.
int m_LogicTestMax
Maximum of fails for logic test.
~DQMHistAnalysisECLModule()
Destructor.
TCanvas * c_crate_time_offsets
TCanvas for time offsets.
TH1 * h_time_crate_Thr1GeV
Histogram showing signal times from ECL crates (Thr.
DQMHistAnalysisECLModule()
< derived from DQMHistAnalysisModule class.
TCanvas * c_quality_fit_data_analysis
TCanvas for quality_fit_data .
TCanvas * c_ampfail_quality_analysis
TCanvas for ampfail_quality .
std::string m_pvPrefix
Prefix to use for PVs registered by this module.
MonitoringObject * m_monObj
MiraBelle monitoring object.
void terminate() override final
Terminate.
double m_crate_time_offsets[52]
Values of crate time offsets.
TLine * m_upper_boundary_time_offsets
TLine to show upper boundary for 'crate_time_offsets' graph.
void event() override final
Event processor.
std::map< std::string, double > m_wf_fraction
Minimum fraction of saved waveforms for each waveform type.
TLine * m_upper_boundary_trigtag2
TLine to show upper boundary for 'trigtag2_trigid' histogram.
std::vector< short > m_low
Vector for crates IDs w/ low statistics.
std::vector< std::string > m_WaveformOption
Options for waveform histograms.
TCanvas * c_quality_analysis
TCanvas for quality .
TH2F * h_logic_summary
Histogram for ECL logic summary.
void endRun() override final
Call when a run ends.
TCanvas * c_adc_hits_analysis
TCanvas for adc_hits .
TCanvas * c_logic_summary
TCanvas for ECL logic summary.
void beginRun() override final
Call when a run begins.
TGraphErrors * h_crate_time_offsets
Graph for time offsets.
TLine * m_lower_boundary_time_offsets
TLine to show lower boundary for 'crate_time_offsets' graph.
TCanvas * c_quality_other_analysis
TCanvas for quality_other .
std::vector< TCanvas * > c_cid_analysis
Vector of TCanvases for hit map .
TCanvas * c_trigtag1_analysis
TCanvas for trigtag1 .
double m_CrateTimeOffsetsMax
Maximum boundary for crate time offsets.
TCanvas * c_trigtag2_analysis
TCanvas for trigtag2 .
TCanvas * c_timefail_quality_analysis
TCanvas for timefail_quality .
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)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
@ c_ColorWarning
Analysis result: Warning, there may be minor issues.
@ c_ColorError
Analysis result: Severe issue found.
@ c_ColorTooFew
Not enough entries/event to judge.
@ c_ColorGood
Analysis result: Good.
@ c_ColorDefault
default for non-coloring
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
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 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.