35 out.reserve(
s.size());
63 : plotNamesToNormalize_(
cfg.getParameter<
std::
vector<
string> >(
"plotNamesToNormalize")),
64 reference_(
cfg.getParameter<
string>(
"reference")) {
65 usesResource(
"DQMStore");
82 edm::LogError(
"endJob") <<
" Failed to access dqmStore --> histograms will NOT be plotted !!";
88 vector<MonitorElement*> allOurMEs =
dqmStore.getAllContents(
"RecoTauV/");
89 std::regex refregex = std::regex(
".*RecoTauV/.*/" + globToRegex(
reference_), std::regex::nosubs);
90 vector<std::regex> toNormRegex;
94 toNormRegex.emplace_back(
".*RecoTauV/.*/" + globToRegex(*toNorm), std::regex::nosubs);
96 map<string, MonitorElement*> refsMap;
97 vector<MonitorElement*> toNormElements;
98 std::smatch path_match;
100 for (vector<MonitorElement*>::const_iterator element = allOurMEs.begin(); element != allOurMEs.end(); ++element) {
101 string pathname = (*element)->getFullname();
104 if (std::regex_match(
pathname, path_match, refregex)) {
107 if (refsMap.find(
dir) != refsMap.end()) {
109 <<
"DQMHistNormalizer::endRun: Warning! found multiple normalizing references for dir: " <<
dir <<
"!";
110 edm::LogInfo(
"DQMHistNormalizer") <<
" " << (refsMap[
dir])->getFullname();
113 refsMap[
dir] = *element;
118 for (
const auto& reg : toNormRegex) {
119 if (std::regex_match(
pathname, path_match, reg)) {
121 toNormElements.push_back(*element);
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() <<
"!";
~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)
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