9 #include <boost/algorithm/string.hpp> 19 : geometryInterface(geo),
23 top_folder_name(iconfig.getParameter<
std::
string>(
"topFolderName")),
29 range_x_nbins(iconfig.getParameter<
int>(
"range_nbins")),
30 range_x_min(iconfig.getParameter<double>(
"range_min")),
31 range_x_max(iconfig.getParameter<double>(
"range_max")),
33 range_y_min(iconfig.getParameter<double>(
"range_y_min")),
34 range_y_max(iconfig.getParameter<double>(
"range_y_max")),
37 for (
const auto& spec : spec_configs) {
41 if (!conf.getParameter<
bool>(
"enabled"))
48 specs.push_back(spec);
79 if (sourceModule == this->
iq.
sourceModule && sourceEvent == this->iq.sourceEvent) {
83 for (
unsigned int i = 0;
i <
specs.size();
i++) {
93 <<
"name " <<
tables[
i].begin()->second.th1->GetName() <<
"\n";
94 assert(!
"Histogram not booked! Probably inconsistent geometry description.");
114 fill(x, 0.0, sourceModule, sourceEvent,
col, row);
118 fill(0.0, 0.0, sourceModule, sourceEvent,
col, row);
125 std::vector<SummationStep>::iterator
first,
126 std::vector<SummationStep>::iterator
last,
128 double fx = 0,
fy = 0, fz = 0;
129 int tot_parameters = n_parameters;
138 if (
it->arg[0] ==
'1' && n_parameters >= 1)
140 if (
it->arg[0] ==
'2' && n_parameters >= 2)
144 if (
it->arg[0] ==
'1' && n_parameters >= 1)
146 if (
it->arg[0] ==
'2' && n_parameters >= 2)
150 if (
it->arg[0] ==
'1' && n_parameters >= 1)
152 if (
it->arg[0] ==
'2' && n_parameters >= 2)
166 assert(!
"illegal step in STAGE1!");
170 switch (tot_parameters) {
181 edm::LogError(
"HistogramManager") <<
"got " << tot_parameters <<
" dimensions\n" 182 <<
"name " <<
dest.th1->GetName() <<
"\n";
183 assert(!
"More than 3 dimensions should never occur.");
192 for (
unsigned int i = 0;
i <
specs.size();
i++) {
199 !
"Incomplete spec (but this cannot be caught in Python)");
205 auto iq =
e.second.iq_sample;
215 <<
"name " <<
t.begin()->second.th1->GetName() <<
"\n" 218 assert(!
"Histogram not booked! (per-event) Probably inconsistent geometry description.");
229 std::ostringstream
dir(
"");
289 double range_z_min = 1e12;
290 double range_z_max = -1e12;
293 int range_z_nbins = 0;
297 bool do_profile =
false;
301 std::map<GeometryInterface::Values, MEInfo> toBeBooked;
303 for (
unsigned int i = 0;
i <
specs.size();
i++) {
308 bool bookCounters =
false;
310 auto firststep =
s.steps.begin();
319 auto laststep = std::find_if(
343 if (
histo == toBeBooked.end()) {
346 mei.title = this->
title;
355 int tot_parameters = n_parameters;
357 #define SET_AXIS(to, from) \ 358 mei.to##label = from##label; \ 359 mei.range_##to##_min = ((it->nbins == -1) ? this->range_##from##_min : it->xmin); \ 360 mei.range_##to##_max = ((it->nbins == -1) ? this->range_##from##_max : it->xmax); \ 361 mei.range_##to##_nbins = ((it->nbins == -1) ? this->range_##from##_nbins : it->nbins) 363 for (
auto it = firststep + 1;
it != laststep; ++
it) {
366 if (
it->arg[0] ==
'1' && n_parameters >= 1) {
369 if (
it->arg[0] ==
'2' && n_parameters >= 2) {
374 if (
it->arg[0] ==
'1' && n_parameters >= 1) {
377 if (
it->arg[0] ==
'2' && n_parameters >= 2) {
382 if (
it->arg[0] ==
'1' && n_parameters >= 1) {
385 if (
it->arg[0] ==
'2' && n_parameters >= 2) {
390 assert(mei.range_x_nbins == 0);
391 auto col =
it->columns[0];
393 mei.title = mei.title +
" by " + mei.xlabel;
402 auto col =
it->columns[0];
404 mei.title = mei.title +
" by " + mei.ylabel;
413 mei.do_profile =
true;
416 assert(!
"illegal step in STAGE1! (booking)");
419 mei.dimensions = tot_parameters;
421 mei.title =
"Profile of " + mei.title;
422 if (!mei.zlabel.empty())
423 mei.title = mei.title +
" (Z: " + mei.zlabel +
")";
429 for (
auto it = firststep + 1;
it != laststep; ++
it) {
452 for (
auto&
e : toBeBooked) {
454 MEInfo& mei =
e.second;
462 if (mei.binwidth_x != 0) {
463 double range = (mei.range_x_max - mei.range_x_min) / mei.binwidth_x;
465 mei.range_x_min -= mei.binwidth_x / 2;
466 mei.range_x_max += mei.binwidth_x / 2;
468 mei.range_x_min = std::floor(mei.range_x_min / mei.binwidth_x) * mei.binwidth_x;
469 mei.range_x_max =
std::ceil(mei.range_x_max / mei.binwidth_x) * mei.binwidth_x;
471 mei.range_x_nbins =
int((mei.range_x_max - mei.range_x_min) / mei.binwidth_x);
473 if (mei.binwidth_y != 0) {
474 double range = (mei.range_y_max - mei.range_y_min) / mei.binwidth_y;
476 mei.range_y_min -= mei.binwidth_y / 2;
477 mei.range_y_max += mei.binwidth_y / 2;
479 mei.range_y_min = std::floor(mei.range_y_min / mei.binwidth_y) * mei.binwidth_y;
480 mei.range_y_max =
std::ceil(mei.range_y_max / mei.binwidth_y) * mei.binwidth_y;
482 mei.range_y_nbins =
int((mei.range_y_max - mei.range_y_min) / mei.binwidth_y);
485 if (mei.dimensions == 1) {
487 name.second, (mei.title +
";" + mei.xlabel).c_str(), mei.range_x_nbins, mei.range_x_min, mei.range_x_max);
488 }
else if (mei.dimensions == 2 && !mei.do_profile) {
490 (mei.title +
";" + mei.xlabel +
";" + mei.ylabel).c_str(),
497 }
else if (mei.dimensions == 2 && mei.do_profile) {
499 (mei.title +
";" + mei.xlabel +
";" + mei.ylabel).c_str(),
506 }
else if (mei.dimensions == 3 && mei.do_profile) {
508 (mei.title +
";" + mei.xlabel +
";" + mei.ylabel).c_str(),
519 <<
"name " <<
name.second <<
"\n" 520 <<
"dim " << mei.dimensions <<
" profile " << mei.do_profile <<
"\n";
521 assert(!
"Illegal Histogram kind.");
523 h.th1 =
h.me->getTH1();
524 h.me->setStatOverflows(mei.statsOverflows);
550 auto firststep =
s.steps.begin();
553 auto laststep = std::find_if(
586 TH1* th1 =
e.second.th1;
592 if (dynamic_cast<TH1F*>(th1))
594 else if (dynamic_cast<TH2F*>(th1))
596 else if (dynamic_cast<TProfile*>(th1))
598 else if (dynamic_cast<TProfile2D*>(th1))
601 assert(!
"No idea how to book this.");
605 new_histo.
th1->Add(th1);
619 std::map<GeometryInterface::Values, int>
nbins;
625 std::map<GeometryInterface::Values, std::string> separators;
632 assert(
e.second.th1 || !
"invalid histogram");
634 int bins = !reduce_type.empty() ? 1 :
e.second.th1->GetXaxis()->GetNbins();
639 for (
auto&
e : separators)
640 e.second =
"(" +
e.second +
")/";
645 TH1* th1 =
e.second.th1;
658 (!reduce_type.empty() ? th1->GetYaxis()->GetTitle() : th1->GetXaxis()->GetTitle()) +
";" +
659 (!reduce_type.empty() ? reduce_type +
" of " + th1->GetXaxis()->GetTitle() : th1->GetYaxis()->GetTitle());
662 if (th1->GetDimension() == 1) {
666 assert(!
"2D extend not implemented in harvesting.");
675 if (new_histo.
th1->GetDimension() == 1) {
676 if (reduce_type.empty()) {
677 for (
int i = 1;
i <= th1->GetXaxis()->GetNbins();
i++) {
678 new_histo.
th1->SetBinContent(new_histo.
count, th1->GetBinContent(
i));
679 new_histo.
th1->SetBinError(new_histo.
count, th1->GetBinError(
i));
680 new_histo.
count += 1;
682 }
else if (reduce_type ==
"MEAN") {
683 new_histo.
th1->SetBinContent(new_histo.
count, th1->GetMean());
684 new_histo.
th1->SetBinError(new_histo.
count, th1->GetMeanError());
685 new_histo.
count += 1;
687 assert(!
"Reduction type not supported");
691 assert(!
"2D extend not implemented in harvesting.");
703 log <<
"Specs for " <<
name <<
" ";
707 for (
unsigned int i = 0;
i <
specs.size();
i++) {
726 reduce_type =
step.arg;
733 assert(!
"EXTEND_Y currently not supported in harvesting.");
736 assert(!
"Operation not supported in harvesting.");
void executeHarvesting(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter)
constexpr int32_t ceil(float num)
T getParameter(std::string const &) const
void fill(DetId sourceModule, const edm::Event *sourceEvent=nullptr, int col=0, int row=0)
GeometryInterface::InterestingQuantities iq_sample
MonitorElement * bookProfile2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, double lowZ, double highZ, char const *option="s", FUNC onbooking=NOOP())
void addSpec(SummationSpecification spec)
virtual void setCurrentFolder(std::string const &fullpath)
void executePerLumiHarvesting(DQMStore::IBooker &iBooker, DQMStore::IGetter &iGetter, edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &iSetup)
std::vector< ParameterSet > VParameterSet
std::string pretty(Column col)
void executeGroupBy(SummationStep const &step, Table &t, DQMStore::IBooker &iBooker, SummationSpecification const &s)
std::string formatValue(Column, Value)
std::vector< SummationSpecification > specs
std::pair< std::string, std::string > makePathName(SummationSpecification const &s, GeometryInterface::Values const &, SummationStep const *upto)
std::string to_lower(const std::string &s)
Log< level::Error, false > LogError
std::string top_folder_name
static std::string to_string(const XMLCh *ch)
void fillInternal(double x, double y, int n_parameters, GeometryInterface::InterestingQuantities const &iq, std::vector< SummationStep >::iterator first, std::vector< SummationStep >::iterator last, AbstractHistogram &dest)
void executeExtend(SummationStep const &step, Table &t, std::string const &reduction, DQMStore::IBooker &iBooker, SummationSpecification const &s)
void loadFromDQMStore(SummationSpecification &s, Table &t, DQMStore::IGetter &iGetter)
void load(edm::EventSetup const &iSetup)
void extractColumns(std::vector< Column > const &names, InterestingQuantities const &iq, Values &out)
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
static const Value UNDEFINED
std::vector< std::pair< Column, Value > > Values
std::vector< AbstractHistogram * > fastpath
std::vector< GeometryInterface::Values > significantvalues
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
std::map< GeometryInterface::Values, AbstractHistogram > Table
virtual DQM_DEPRECATED void setStatOverflows(bool value)
virtual MonitorElement * get(std::string const &fullpath) const
HistogramManager(const edm::ParameterSet &iConfig, GeometryInterface &geo)
virtual TH1 * getTH1() const
std::vector< Table > tables
edm::LuminosityBlock const * lumisection
std::pair< Column, Value > extract(Column const &col, InterestingQuantities const &iq)
std::vector< Table > counters
dqm::legacy::MonitorElement * me
std::vector< InterestingQuantities > const & allModules()
const edm::Event * sourceEvent
void executePerEventHarvesting(edm::Event const *ev)
void book(DQMStore::IBooker &iBooker, edm::EventSetup const &iSetup)
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
GeometryInterface::InterestingQuantities iq
if(threadIdxLocalY==0 &&threadIdxLocalX==0)
#define SET_AXIS(to, from)
GeometryInterface & geometryInterface