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")) {
50 usesResource(
"DQMStore");
63 lat::Regexp*
rx =
nullptr;
65 rx =
new lat::Regexp(
expr, 0, lat::Regexp::Wildcard);
69 <<
"Invalid regular expression '" <<
expr.c_str() <<
"':" <<
e.explain().c_str();
79 edm::LogError(
"endJob") <<
" Failed to access dqmStore --> histograms will NOT be plotted !!";
85 vector<MonitorElement*> allOurMEs =
dqmStore.getAllContents(
"RecoTauV/");
87 vector<lat::Regexp*> toNormRegex;
91 toNormRegex.push_back(
buildRegex(
"*RecoTauV/*/" + *toNorm));
93 map<string, MonitorElement*> refsMap;
94 vector<MonitorElement*> toNormElements;
96 for (vector<MonitorElement*>::const_iterator element = allOurMEs.begin(); element != allOurMEs.end(); ++element) {
97 string pathname = (*element)->getFullname();
103 if (refsMap.find(
dir) != refsMap.end()) {
105 <<
"DQMHistNormalizer::endRun: Warning! found multiple normalizing references for dir: " <<
dir <<
"!";
106 edm::LogInfo(
"DQMHistNormalizer") <<
" " << (refsMap[
dir])->getFullname();
109 refsMap[
dir] = *element;
114 for (vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg) {
117 toNormElements.push_back(*element);
124 for (vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg)
127 for (vector<MonitorElement*>::const_iterator matchingElement = toNormElements.begin();
128 matchingElement != toNormElements.end();
130 string meName = (*matchingElement)->getFullname();
131 string dir = meName.substr(0, meName.rfind(
'/'));
133 if (refsMap.find(
dir) == refsMap.end()) {
134 edm::LogInfo(
"DQMHistNormalizer") <<
"DQMHistNormalizer::endRun: Error! normalizing references for " << meName
135 <<
" not found! Skipping...";
139 float norm = refsMap[
dir]->getTH1()->GetEntries();
140 TH1*
hist = (*matchingElement)->getTH1();
142 if (!
hist->GetSumw2N())
144 hist->Scale(1 / norm);
146 edm::LogInfo(
"DQMHistNormalizer") <<
"DQMHistNormalizer::endRun: Error! Normalization failed in " 147 <<
hist->GetTitle() <<
"!";
edm::ErrorSummaryEntry Error
~DQMHistNormalizer() override
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
#define DEFINE_FWK_MODULE(type)
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
void beginRun(const edm::Run &r, const edm::EventSetup &c) override