14#include <framework/core/ModuleParam.templateDetails.h>
15#include <dqm/analysis/modules/DQMHistComparitor.h>
35 "['histname', 'refhistname', 'canvas', 'delta', 'color', 'minentry', 'Chi/KS', 'warnlvl', 'errlvl', 'fitresult_pvname', 'status_pvname'],[...],...");
36 B2DEBUG(1,
"DQMHistComparitor: Constructor done.");
41 gStyle->SetOptStat(0);
42 gStyle->SetStatStyle(1);
43 gStyle->SetOptDate(22);
46 if (it.size() != 11) {
47 B2WARNING(
"Histolist with wrong nr of parameters (" << it.size() <<
"), histo=" << (it.size() > 0 ? it.at(0) : std::string(
"")));
52 n->histName = it.at(0);
53 n->refName = it.at(1) ==
"" ? n->histName : it.at(1) ;
54 n->canvas =
new TCanvas(it.at(2).c_str());
56 n->deltaflag = it.at(3) !=
"";
57 n->colorflag = it.at(4) !=
"";
58 n->min_entries = atoi(it.at(5).c_str());
59 if (it.at(6) ==
"KS") n->algo = 1;
61 n->warning = atof(it.at(7).c_str());
62 n->error = atof(it.at(8).c_str());
66 n->pvstatus = it.at(10);
71 B2DEBUG(20,
"DQMHistComparitor: initialized.");
77 B2DEBUG(20,
"DQMHistComparitor: beginRun called.");
82 gStyle->SetOptStat(0);
83 gStyle->SetStatStyle(0);
84 gStyle->SetOptDate(22);
88 B2DEBUG(20,
"== Search for " << it->histName <<
" with ref " << it->refName <<
"==");
89 if (it->deltaflag) histo =
getDelta(it->histName);
90 if (!histo) histo =
findHist(it->histName,
"",
true);
99 B2DEBUG(20,
"NOT Found " << it->refName);
103 B2DEBUG(20,
"Compare " << it->histName <<
" with ref " << it->refName);
105 it->canvas->UseCurrentStyle();
111 data = histo->KolmogorovTest(refhist,
"");
112 B2DEBUG(20,
"KS: " << data <<
" , " << it->warning <<
" , " << it->error);
114 data = histo->Chi2Test(refhist,
"NORM,UU");
115 B2DEBUG(20,
"Chi: " << data <<
" , " << it->warning <<
" , " << it->error);
120 if (it->pvfit !=
"")
setEpicsPV(it->pvfit, data);
122 refhist->SetLineStyle(3);
123 refhist->SetLineColor(3);
125 refhist->Draw(
"hist");
126 refhist->SetStats(kFALSE);
127 if (refhist->GetMaximum() > histo->GetMaximum())
128 histo->SetMaximum(1.1 * refhist->GetMaximum());
130 refhist->Draw(
"hist,same");
133 auto status_data =
makeStatus(histo->GetEntries() >= it->min_entries, data < it->warning,
135 if (it->pvstatus !=
"")
setEpicsPV(it->pvstatus, status_data);
144 it->canvas->Modified();
145 it->canvas->Update();
151 B2DEBUG(20,
"DQMHistComparitor: endRun called");
156 B2DEBUG(20,
"DQMHistComparitor: terminate called");
int registerEpicsPV(const std::string &pvname, const std::string &keyname="")
EPICS related Functions.
TH1 * getDelta(const std::string &dirname, const std::string &histname="", bool onlyIfUpdated=true, int n=0)
Get Delta histogram.
static void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
DQMHistAnalysisModule()
Constructor / Destructor.
@ c_RefScaleEntries
to number of entries (integral)
static EStatus makeStatus(bool enough, bool warn_flag, bool error_flag)
Helper function to judge the status for coloring and EPICS.
static TH1 * findRefHist(const std::string &dirname, const std::string &histname="", ERefScaling scaling=ERefScaling::c_RefScaleNone, const TH1 *hist=nullptr)
Find reference histogram.
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 initialize() override final
Initializer.
void terminate() override final
This method is called at the end of the event processing.
void event() override final
This method is called for each event.
void endRun() override final
This method is called if the current run ends.
std::vector< std::vector< std::string > > m_histlist
Parameter list for histograms.
void beginRun() override final
Called when entering a new run.
DQMHistComparitorModule()
Constructor.
std::vector< CMPNODE * > m_pnode
Struct for extracted parameters + EPICS PV.
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.
The struct for reference histogram comparison.