25 #include "classlib/utils/RegexpMatch.h" 26 #include "classlib/utils/Regexp.h" 47 lat::Regexp* buildRegex(
const string & expr);
53 plotNamesToNormalize_(cfg.getParameter<
std::vector<
string> >(
"plotNamesToNormalize")),
54 reference_(cfg.getParameter<
string >(
"reference"))
74 rx =
new lat::Regexp(expr, 0, lat::Regexp::Wildcard);
79 raiseDQMError(
"DQMStore",
"Invalid regular expression '%s': %s",
80 expr.c_str(), e.explain().c_str());
91 edm::LogError (
"endJob") <<
" Failed to access dqmStore --> histograms will NOT be plotted !!";
97 vector<MonitorElement *> allOurMEs = dqmStore.getAllContents(
"RecoTauV/");
99 vector<lat::Regexp*> toNormRegex;
101 toNormRegex.push_back(
buildRegex(
"*RecoTauV/*/" + *toNorm) );
103 map<string, MonitorElement *> refsMap;
104 vector<MonitorElement *> toNormElements;
106 for(vector<MonitorElement *>::const_iterator element = allOurMEs.begin(); element != allOurMEs.end(); ++element){
107 string pathname = (*element)->getFullname();
110 if(refregex->match(pathname)){
112 string dir = pathname.substr(0, pathname.rfind(
"/"));
113 if(refsMap.find(dir) != refsMap.end()){
114 edm::LogInfo(
"DQMHistNormalizer")<<
"DQMHistNormalizer::endRun: Warning! found multiple normalizing references for dir: "<<dir<<
"!";
115 edm::LogInfo(
"DQMHistNormalizer")<<
" " << (refsMap[
dir])->getFullname();
119 refsMap[
dir] = *element;
124 for(vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg){
125 if((*reg)->match(pathname)){
127 toNormElements.push_back(*element);
134 for(vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg)
137 for(vector<MonitorElement *>::const_iterator matchingElement = toNormElements.begin(); matchingElement != toNormElements.end(); ++matchingElement){
138 string meName = (*matchingElement)->getFullname();
139 string dir = meName.substr(0, meName.rfind(
"/"));
141 if(refsMap.find(dir) == refsMap.end()){
142 edm::LogInfo(
"DQMHistNormalizer")<<
"DQMHistNormalizer::endRun: Error! normalizing references for "<<meName<<
" not found! Skipping...";
146 float norm = refsMap[
dir]->getTH1()->GetEntries();
147 TH1*
hist = (*matchingElement)->getTH1();
149 if( !hist->GetSumw2N() ) hist->Sumw2();
152 edm::LogInfo(
"DQMHistNormalizer")<<
"DQMHistNormalizer::endRun: Error! Normalization failed in "<<hist->GetTitle()<<
"!";
virtual void endJob() override
def analyze(function, filename, filter=None)
#define DEFINE_FWK_MODULE(type)
virtual void endRun(const edm::Run &r, const edm::EventSetup &c) override
vector< string > plotNamesToNormalize_
virtual ~DQMHistNormalizer()
lat::Regexp * buildRegex(const string &expr)
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
DQMHistNormalizer(const edm::ParameterSet &)
void raiseDQMError(const char *context, const char *fmt,...)