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.");
45 gStyle->SetOptStat(0);
46 gStyle->SetStatStyle(1);
47 gStyle->SetOptDate(22);
50 if (it.size() != 11) {
51 B2WARNING(
"Histolist with wrong nr of parameters (" << it.size() <<
"), histo=" << (it.size() > 0 ? it.at(0) : std::string(
"")));
56 n->histName = it.at(0);
57 n->refName = it.at(1) ==
"" ? n->histName : it.at(1) ;
58 n->canvas =
new TCanvas(it.at(2).c_str());
60 n->deltaflag = it.at(3) !=
"";
61 n->colorflag = it.at(4) !=
"";
62 n->min_entries = atoi(it.at(5).c_str());
63 if (it.at(6) ==
"KS") n->algo = 1;
65 n->warning = atof(it.at(7).c_str());
66 n->error = atof(it.at(8).c_str());
70 n->pvstatus = it.at(10);
75 B2DEBUG(20,
"DQMHistComparitor: initialized.");
81 B2DEBUG(20,
"DQMHistComparitor: beginRun called.");
86 gStyle->SetOptStat(0);
87 gStyle->SetStatStyle(0);
88 gStyle->SetOptDate(22);
92 B2DEBUG(20,
"== Search for " << it->histName <<
" with ref " << it->refName <<
"==");
93 if (it->deltaflag) histo =
getDelta(it->histName);
94 if (!histo) histo =
findHist(it->histName,
true);
103 B2DEBUG(20,
"NOT Found " << it->refName);
107 B2DEBUG(20,
"Compare " << it->histName <<
" with ref " << it->refName);
109 it->canvas->UseCurrentStyle();
115 data = histo->KolmogorovTest(refhist,
"");
116 B2DEBUG(20,
"KS: " << data <<
" , " << it->warning <<
" , " << it->error);
118 data = histo->Chi2Test(refhist,
"NORM,UU");
119 B2DEBUG(20,
"Chi: " << data <<
" , " << it->warning <<
" , " << it->error);
124 if (it->pvfit !=
"")
setEpicsPV(it->pvfit, data);
126 refhist->SetLineStyle(3);
127 refhist->SetLineColor(3);
142 refhist->Draw(
"hist");
143 refhist->SetStats(kFALSE);
144 if (refhist->GetMaximum() > histo->GetMaximum())
145 histo->SetMaximum(1.1 * refhist->GetMaximum());
147 refhist->Draw(
"hist,same");
150 auto status_data =
makeStatus(histo->GetEntries() >= it->min_entries, data < it->warning,
152 if (it->pvstatus !=
"")
setEpicsPV(it->pvstatus, status_data);
161 it->canvas->Modified();
162 it->canvas->Update();
168 B2DEBUG(20,
"DQMHistComparitor: endRun called");
173 B2DEBUG(20,
"DQMHistComparitor: terminate called");
The base class for the histogram analysis module.
static TH1 * findRefHist(const std::string &histname, ERefScaling scaling=ERefScaling::c_RefScaleNone, const TH1 *hist=nullptr)
Get referencehistogram from list (no other search).
void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
TH1 * getDelta(const std::string &fullname, int n=0, bool onlyIfUpdated=true)
Get Delta histogram.
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
@ c_RefScaleEntries
to number of entries (integral)
EStatus makeStatus(bool enough, bool warn_flag, bool error_flag)
Helper function to judge the status for coloring and EPICS.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
void initialize() override final
Initializer.
~DQMHistComparitorModule()
Destructor.
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.