CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
DQMHistNormalizer Class Reference
Inheritance diagram for DQMHistNormalizer:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &) override
 
 DQMHistNormalizer (const edm::ParameterSet &)
 
virtual void endJob () override
 
virtual void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
virtual ~DQMHistNormalizer ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

lat::Regexp * buildRegex (const string &expr)
 

Private Attributes

vector< string > plotNamesToNormalize_
 
string reference_
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Class to produce efficiency histograms by dividing nominator by denominator histograms

Author
Christian Veelken, UC Davis

Definition at line 36 of file DQMHistNormalizer.cc.

Constructor & Destructor Documentation

DQMHistNormalizer::DQMHistNormalizer ( const edm::ParameterSet cfg)
explicit

Definition at line 52 of file DQMHistNormalizer.cc.

52  :
53  plotNamesToNormalize_(cfg.getParameter< std::vector<string> >("plotNamesToNormalize")),
54  reference_(cfg.getParameter< string >("reference"))
55 {
56  //std::cout << "<DQMHistNormalizer::DQMHistNormalizer>:" << std::endl;
57 }
T getParameter(std::string const &) const
vector< string > plotNamesToNormalize_
DQMHistNormalizer::~DQMHistNormalizer ( )
virtual

Definition at line 59 of file DQMHistNormalizer.cc.

60 {
61 //--- nothing to be done yet
62 }

Member Function Documentation

void DQMHistNormalizer::analyze ( const edm::Event ,
const edm::EventSetup  
)
overridevirtual

Implements edm::EDAnalyzer.

Definition at line 64 of file DQMHistNormalizer.cc.

65 {
66 //--- nothing to be done yet
67 }
lat::Regexp * DQMHistNormalizer::buildRegex ( const string &  expr)
private

Definition at line 69 of file DQMHistNormalizer.cc.

References alignCSCRings::e, raiseDQMError(), and corrVsCorr::rx.

Referenced by endRun().

70 {
71  lat::Regexp* rx = 0;
72  try
73  {
74  rx = new lat::Regexp(expr, 0, lat::Regexp::Wildcard);
75  rx->study();
76  }
77  catch (lat::Error &e)
78  {
79  raiseDQMError("DQMStore", "Invalid regular expression '%s': %s",
80  expr.c_str(), e.explain().c_str());
81  }
82  return rx;
83 }
void raiseDQMError(const char *context, const char *fmt,...)
Definition: DQMError.cc:11
virtual void DQMHistNormalizer::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 43 of file DQMHistNormalizer.cc.

43 {}
void DQMHistNormalizer::endRun ( const edm::Run r,
const edm::EventSetup c 
)
overridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 85 of file DQMHistNormalizer.cc.

References buildRegex(), dir, AlcaSiStripGainsAfterAbortGapHarvester_cff::DQMStore, estimatePileup::hist, timingPdfMaker::pathname, plotNamesToNormalize_, and reference_.

86 {
87  //std::cout << "<DQMHistNormalizer::endJob>:" << std::endl;
88 
89 //--- check that DQMStore service is available
90  if ( !edm::Service<DQMStore>().isAvailable() ) {
91  edm::LogError ("endJob") << " Failed to access dqmStore --> histograms will NOT be plotted !!";
92  return;
93  }
94 
95  DQMStore& dqmStore = (*edm::Service<DQMStore>());
96 
97  vector<MonitorElement *> allOurMEs = dqmStore.getAllContents("RecoTauV/");
98  lat::Regexp* refregex = buildRegex("*RecoTauV/*/" + reference_);
99  vector<lat::Regexp*> toNormRegex;
100  for ( std::vector<string>::const_iterator toNorm = plotNamesToNormalize_.begin(); toNorm != plotNamesToNormalize_.end(); ++toNorm )
101  toNormRegex.push_back( buildRegex("*RecoTauV/*/" + *toNorm) );
102 
103  map<string, MonitorElement *> refsMap;
104  vector<MonitorElement *> toNormElements;
105 
106  for(vector<MonitorElement *>::const_iterator element = allOurMEs.begin(); element != allOurMEs.end(); ++element){
107  string pathname = (*element)->getFullname();
108  //cout << pathname << endl;
109  //Matches reference
110  if(refregex->match(pathname)){
111  //cout << "Matched to ref" << endl;
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();
116  edm::LogInfo("DQMHistNormalizer")<<" " << pathname;
117  }
118  else{
119  refsMap[dir] = *element;
120  }
121  }
122 
123  //Matches targets
124  for(vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg){
125  if((*reg)->match(pathname)){
126  //cout << "Matched to target" << endl;
127  toNormElements.push_back(*element);
128  //cout << "Filled the collection" << endl;
129  }
130  }
131  }
132 
133  delete refregex;
134  for(vector<lat::Regexp*>::const_iterator reg = toNormRegex.begin(); reg != toNormRegex.end(); ++reg)
135  delete *reg;
136 
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("/"));
140 
141  if(refsMap.find(dir) == refsMap.end()){
142  edm::LogInfo("DQMHistNormalizer")<<"DQMHistNormalizer::endRun: Error! normalizing references for "<<meName<<" not found! Skipping...";
143  continue;
144  }
145 
146  float norm = refsMap[dir]->getTH1()->GetEntries();
147  TH1* hist = (*matchingElement)->getTH1();
148  if ( norm != 0. ) {
149  if( !hist->GetSumw2N() ) hist->Sumw2();
150  hist->Scale(1/norm);//use option "width" to divide the bin contents and errors by the bin width?
151  }else{
152  edm::LogInfo("DQMHistNormalizer")<<"DQMHistNormalizer::endRun: Error! Normalization failed in "<<hist->GetTitle()<<"!";
153  }
154 
155  }// for(vector<MonitorElement *>::const_iterator matchingElement = matchingElemts.begin(); matchingElement = matchingElemts.end(); ++matchingElement)
156 }
vector< string > plotNamesToNormalize_
lat::Regexp * buildRegex(const string &expr)
dbl *** dir
Definition: mlp_gen.cc:35

Member Data Documentation

vector<string> DQMHistNormalizer::plotNamesToNormalize_
private

Definition at line 48 of file DQMHistNormalizer.cc.

Referenced by endRun().

string DQMHistNormalizer::reference_
private

Definition at line 49 of file DQMHistNormalizer.cc.

Referenced by endRun().