21 #include "classlib/utils/RegexpMatch.h"
22 #include "classlib/utils/Regexp.h"
42 lat::Regexp* buildRegex(
const string&
expr);
48 : plotNamesToNormalize_(
cfg.getParameter<
std::vector<
string> >(
"plotNamesToNormalize")),
49 reference_(
cfg.getParameter<
string>(
"reference")) {
62 lat::Regexp*
rx =
nullptr;
64 rx =
new lat::Regexp(
expr, 0, lat::Regexp::Wildcard);
68 <<
"Invalid regular expression '" <<
expr.c_str() <<
"':" <<
e.explain().c_str();
78 edm::LogError(
"endJob") <<
" Failed to access dqmStore --> histograms will NOT be plotted !!";
84 vector<MonitorElement*> allOurMEs =
dqmStore.getAllContents(
"RecoTauV/");
86 vector<lat::Regexp*> toNormRegex;
90 toNormRegex.push_back(
buildRegex(
"*RecoTauV/*/" + *toNorm));
92 map<string, MonitorElement*> refsMap;
93 vector<MonitorElement*> toNormElements;
95 for (vector<MonitorElement*>::const_iterator element = allOurMEs.begin(); element != allOurMEs.end(); ++element) {
96 string pathname = (*element)->getFullname();
102 if (refsMap.find(
dir) != refsMap.end()) {
104 <<
"DQMHistNormalizer::endRun: Warning! found multiple normalizing references for dir: " <<
dir <<
"!";
105 edm::LogInfo(
"DQMHistNormalizer") <<
" " << (refsMap[
dir])->getFullname();
108 refsMap[
dir] = *element;
113 for (vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg) {
116 toNormElements.push_back(*element);
123 for (vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg)
126 for (vector<MonitorElement*>::const_iterator matchingElement = toNormElements.begin();
127 matchingElement != toNormElements.end();
129 string meName = (*matchingElement)->getFullname();
130 string dir = meName.substr(0, meName.rfind(
"/"));
132 if (refsMap.find(
dir) == refsMap.end()) {
133 edm::LogInfo(
"DQMHistNormalizer") <<
"DQMHistNormalizer::endRun: Error! normalizing references for " << meName
134 <<
" not found! Skipping...";
138 float norm = refsMap[
dir]->getTH1()->GetEntries();
139 TH1*
hist = (*matchingElement)->getTH1();
141 if (!
hist->GetSumw2N())
143 hist->Scale(1 / norm);
145 edm::LogInfo(
"DQMHistNormalizer") <<
"DQMHistNormalizer::endRun: Error! Normalization failed in "
146 <<
hist->GetTitle() <<
"!";