14#include <dqm/analysis/modules/DQMHistAnalysisInputTest.h>
16#include <boost/property_tree/ptree.hpp>
17#include <boost/property_tree/json_parser.hpp>
23using namespace boost::property_tree;
37 setDescription(
"Testing input file functionality for DQMHistAnalysisModules");
44 B2DEBUG(1,
"DQMHistAnalysisInputTest: Constructor done.");
50 B2DEBUG(20,
"DQMHistAnalysisInputTest: initialized.");
55 json_parser::read_json(cf, tree);
57 ptree pt = tree.get_child(
"HistogramList");
58 for (
auto pair : pt) {
62 unsigned int dtype = 0;
63 unsigned int parameter = 0;
64 unsigned int amount = 0;
65 unsigned int fill = 0;
66 unsigned int underflow = 0;
68 std::vector<double> fitparm;
69 std::vector<double> histparm;
70 for (
auto pair2 : pair.second) {
71 if (pair2.first ==
"Name") {
72 name = pair2.second.get_value<std::string>();
73 }
else if (pair2.first ==
"Dir") {
74 dir = pair2.second.get_value<std::string>();
75 }
else if (pair2.first ==
"Delta") {
76 for (
auto pair3 : pair2.second) {
77 if (pair3.first ==
"Type") {
78 dtype = pair3.second.get_value<
unsigned int>();
79 }
else if (pair3.first ==
"Parameter") {
80 parameter = pair3.second.get_value<
unsigned int>();
81 }
else if (pair3.first ==
"Amount") {
82 amount = pair3.second.get_value<
unsigned int>();
84 std::cout << pair3.first <<
" is unknown parameter -> parse error" << std::endl;
87 }
else if (pair2.first ==
"Simulation") {
88 for (
auto pair3 : pair2.second) {
89 if (pair3.first ==
"Function") {
90 fitfunc = pair3.second.get_value<std::string>();
91 }
else if (pair3.first ==
"Fill") {
92 fill = pair3.second.get_value<
unsigned int>();
93 }
else if (pair3.first ==
"Underflow") {
94 underflow = pair3.second.get_value<
unsigned int>();
95 }
else if (pair3.first ==
"FPar") {
96 for (
auto pair4 : pair3.second) {
97 fitparm.push_back(pair4.second.get_value<
double>());
99 }
else if (pair3.first ==
"HPar") {
100 for (
auto pair4 : pair3.second) {
101 histparm.push_back(pair4.second.get_value<
double>());
105 }
else if (pair2.first ==
"Analysis") {
107 }
else if (pair2.first ==
"EPICS") {
110 std::cout << pair2.first <<
" is unknown parameter -> parse error" << std::endl;
114 if (dir ==
"" or name ==
"") {
115 std::cout <<
"Both Dir and Name must be given. -> parse error" << std::endl;
120 m_testHisto.push_back((TH1*)
new TH1F(name.data(),
"test Histo", histparm.at(0), histparm.at(1), histparm.at(2)));
122 auto func =
new TF1(TString(name) +
"_func", fitfunc.data(), fitparm.at(0), fitparm.at(1));
128 m_fpar.push_back(fitparm);
141 B2INFO(
"DQMHistAnalysisInputTest: beginRun called. Run: " <<
m_runno);
153 B2INFO(
"DQMHistAnalysisInputTest: event called.");
160 B2INFO(
"DQMHistAnalysisInputTest: max event number reached, set EndOfData");
167 for (
int p = 0; p <
m_fpar[i].at(2); p++) {
172 h->SetBinContent(0, h->GetBinContent(0) +
m_underflow[i]);
179 addHist(
"test", h->GetName(), (TH1*)h->Clone());
200 B2INFO(
"DQMHistAnalysisInputTest: event finished. count: " <<
m_count);
211 B2INFO(a.first <<
" " << a.second.m_type <<
" " << a.second.m_parameter
212 <<
" " << a.second.m_amountDeltas <<
" " << a.second.m_deltaHists.size());
217 std::string name =
"test/" + n;
218 auto c =
new TCanvas();
222 if (h) h->Draw(
"hist");
229 h = it->second.m_lastHist.get();
230 if (h) h->Draw(
"hist");
232 for (
unsigned int i = 0; i < it->second.m_amountDeltas; i++) {
234 auto hist = it->second.getDelta(i);
241 hist->SetLineColor(i + 2);
245 if (i + 4 == 9)
break;
252 fn.Form(
"%s_Delta_%d.png", n.data(),
m_count);
260 B2INFO(
"DQMHistAnalysisInputTest: endRun called. Run: " <<
m_runno);
262 B2INFO(
"DQMHistAnalysisInputTest: endRun: Histos");
268 B2INFO(
"DQMHistAnalysisInputTest: endRun: done");
274 B2INFO(
"DQMHistAnalysisInputTest: terminate called. Run: " <<
m_runno);
The base class for the histogram analysis module.
void addDeltaPar(const std::string &dirname, const std::string &histname, HistDelta::EDeltaType t, int p, unsigned int a=1)
Add Delta histogram parameters.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
void clearlist(void)
Clear all static global lists.
static void clearHistList(void)
Clears the list of histograms.
void setRunType(std::string &t)
Set the Run Type.
void setEventProcessed(int e)
Set the number of processed events.
static bool addHist(const std::string &dirname, const std::string &histname, TH1 *h)
Add histogram.
static HistList & getHistList()
Get the list of the histograms.
static void initHistListBeforeEvent(void)
Reset the list of histograms.
static const DeltaList & getDeltaList()
Get the list of the delta histograms.
EDeltaType
enum definition for delta algo Disabled: nothing Entries: use nr histogram entries Underflow: use ent...
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.
Abstract base class for different kinds of events.