21 #include "classlib/utils/RegexpMatch.h"
22 #include "classlib/utils/Regexp.h"
41 lat::Regexp* buildRegex(
const string& expr);
47 : plotNamesToNormalize_(cfg.getParameter<std::
vector<
string> >(
"plotNamesToNormalize")),
48 reference_(cfg.getParameter<
string>(
"reference")) {
61 lat::Regexp*
rx =
nullptr;
63 rx =
new lat::Regexp(expr, 0, lat::Regexp::Wildcard);
67 <<
"Invalid regular expression '" << expr.c_str() <<
"':" << e.explain().c_str();
77 edm::LogError(
"endJob") <<
" Failed to access dqmStore --> histograms will NOT be plotted !!";
83 vector<MonitorElement*> allOurMEs = dqmStore.
getAllContents(
"RecoTauV/");
85 vector<lat::Regexp*> toNormRegex;
89 toNormRegex.push_back(
buildRegex(
"*RecoTauV/*/" + *toNorm));
91 map<string, MonitorElement*> refsMap;
92 vector<MonitorElement*> toNormElements;
94 for (vector<MonitorElement*>::const_iterator element = allOurMEs.begin(); element != allOurMEs.end(); ++element) {
95 string pathname = (*element)->getFullname();
98 if (refregex->match(pathname)) {
100 string dir = pathname.substr(0, pathname.rfind(
'/'));
101 if (refsMap.find(dir) != refsMap.end()) {
103 <<
"DQMHistNormalizer::endRun: Warning! found multiple normalizing references for dir: " << dir <<
"!";
104 edm::LogInfo(
"DQMHistNormalizer") <<
" " << (refsMap[
dir])->getFullname();
107 refsMap[
dir] = *element;
112 for (vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg) {
113 if ((*reg)->match(pathname)) {
115 toNormElements.push_back(*element);
122 for (vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg)
125 for (vector<MonitorElement*>::const_iterator matchingElement = toNormElements.begin();
126 matchingElement != toNormElements.end();
128 string meName = (*matchingElement)->getFullname();
129 string dir = meName.substr(0, meName.rfind(
'/'));
131 if (refsMap.find(dir) == refsMap.end()) {
132 edm::LogInfo(
"DQMHistNormalizer") <<
"DQMHistNormalizer::endRun: Error! normalizing references for " << meName
133 <<
" not found! Skipping...";
137 float norm = refsMap[
dir]->getTH1()->GetEntries();
138 TH1*
hist = (*matchingElement)->getTH1();
140 if (!hist->GetSumw2N())
142 hist->Scale(1 / norm);
144 edm::LogInfo(
"DQMHistNormalizer") <<
"DQMHistNormalizer::endRun: Error! Normalization failed in "
145 << hist->GetTitle() <<
"!";
edm::ErrorSummaryEntry Error
const edm::EventSetup & c
~DQMHistNormalizer() override
#define DEFINE_FWK_MODULE(type)
void endRun(const edm::Run &r, const edm::EventSetup &c) override
vector< string > plotNamesToNormalize_
Log< level::Error, false > LogError
example_stream void analyze(const edm::Event &, const edm::EventSetup &) override
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
lat::Regexp * buildRegex(const string &expr)
Log< level::Info, false > LogInfo
void analyze(const edm::Event &, const edm::EventSetup &) override
DQMHistNormalizer(const edm::ParameterSet &)
dqm::legacy::MonitorElement MonitorElement
dqm::legacy::DQMStore DQMStore