27 #include "classlib/utils/RegexpMatch.h"
28 #include "classlib/utils/Regexp.h"
49 lat::Regexp* buildRegex(
const string & expr);
55 plotNamesToNormalize_(cfg.getParameter< std::vector<string> >(
"plotNamesToNormalize")),
56 reference_(cfg.getParameter< string >(
"reference"))
76 rx =
new lat::Regexp(expr, 0, lat::Regexp::Wildcard);
81 raiseDQMError(
"DQMStore",
"Invalid regular expression '%s': %s",
82 expr.c_str(), e.explain().c_str());
93 edm::LogError (
"endJob") <<
" Failed to access dqmStore --> histograms will NOT be plotted !!";
99 vector<MonitorElement *> allOurMEs = dqmStore.
getAllContents(
"RecoTauV/");
101 vector<lat::Regexp*> toNormRegex;
103 toNormRegex.push_back(
buildRegex(
"*RecoTauV/*/" + *toNorm) );
105 map<string, MonitorElement *> refsMap;
106 vector<MonitorElement *> toNormElements;
108 for(vector<MonitorElement *>::const_iterator element = allOurMEs.begin(); element != allOurMEs.end(); ++element){
109 string pathname = (*element)->getFullname();
112 if(refregex->match(pathname)){
114 string dir = pathname.substr(0, pathname.rfind(
"/"));
115 if(refsMap.find(dir) != refsMap.end()){
116 edm::LogInfo(
"DQMHistNormalizer")<<
"DQMHistNormalizer::endRun: Warning! found multiple normalizing references for dir: "<<dir<<
"!";
117 edm::LogInfo(
"DQMHistNormalizer")<<
" " << (refsMap[
dir])->getFullname();
121 refsMap[
dir] = *element;
126 for(vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg){
127 if((*reg)->match(pathname)){
129 toNormElements.push_back(*element);
136 for(vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg)
139 for(vector<MonitorElement *>::const_iterator matchingElement = toNormElements.begin(); matchingElement != toNormElements.end(); ++matchingElement){
140 string meName = (*matchingElement)->getFullname();
141 string dir = meName.substr(0, meName.rfind(
"/"));
143 if(refsMap.find(dir) == refsMap.end()){
144 edm::LogInfo(
"DQMHistNormalizer")<<
"DQMHistNormalizer::endRun: Error! normalizing references for "<<meName<<
" not found! Skipping...";
148 float norm = refsMap[
dir]->getTH1()->GetEntries();
149 TH1*
hist = (*matchingElement)->getTH1();
151 if( !hist->GetSumw2N() ) hist->Sumw2();
154 edm::LogInfo(
"DQMHistNormalizer")<<
"DQMHistNormalizer::endRun: Error! Normalization failed in "<<hist->GetTitle()<<
"!";
#define DEFINE_FWK_MODULE(type)
vector< string > plotNamesToNormalize_
std::vector< MonitorElement * > getAllContents(const std::string &path) const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
virtual ~DQMHistNormalizer()
lat::Regexp * buildRegex(const string &expr)
virtual void endRun(const edm::Run &r, const edm::EventSetup &c)
DQMHistNormalizer(const edm::ParameterSet &)
void raiseDQMError(const char *context, const char *fmt,...)