CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Member Functions | Private Attributes
DQMHistNormalizer Class Reference
Inheritance diagram for DQMHistNormalizer:
edm::EDAnalyzer edm::EDConsumerBase

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
 DQMHistNormalizer (const edm::ParameterSet &)
 
void endJob () override
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
 ~DQMHistNormalizer () override
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase &&)=default
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Member Functions

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

Private Attributes

vector< string > plotNamesToNormalize_
 
string reference_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (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 30 of file DQMHistNormalizer.cc.

Member Typedef Documentation

◆ DQMStore

Definition at line 32 of file DQMHistNormalizer.cc.

◆ MonitorElement

Definition at line 33 of file DQMHistNormalizer.cc.

Constructor & Destructor Documentation

◆ DQMHistNormalizer()

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

Definition at line 47 of file DQMHistNormalizer.cc.

48  : plotNamesToNormalize_(cfg.getParameter<std::vector<string> >("plotNamesToNormalize")),
49  reference_(cfg.getParameter<string>("reference")) {
50  //std::cout << "<DQMHistNormalizer::DQMHistNormalizer>:" << std::endl;
51 }

◆ ~DQMHistNormalizer()

DQMHistNormalizer::~DQMHistNormalizer ( )
override

Definition at line 53 of file DQMHistNormalizer.cc.

53  {
54  //--- nothing to be done yet
55 }

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 57 of file DQMHistNormalizer.cc.

57  {
58  //--- nothing to be done yet
59 }

◆ buildRegex()

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

Definition at line 61 of file DQMHistNormalizer.cc.

61  {
62  lat::Regexp* rx = nullptr;
63  try {
64  rx = new lat::Regexp(expr, 0, lat::Regexp::Wildcard);
65  rx->study();
66  } catch (lat::Error& e) {
67  throw cms::Exception("DQMHistNormalizer")
68  << "Invalid regular expression '" << expr.c_str() << "':" << e.explain().c_str();
69  }
70  return rx;
71 }

References MillePedeFileConverter_cfg::e, Exception, jets_cff::expr, and corrVsCorr::rx.

Referenced by endRun().

◆ endJob()

void DQMHistNormalizer::endJob ( void  )
inlineoverridevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 38 of file DQMHistNormalizer.cc.

38 {}

◆ endRun()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 73 of file DQMHistNormalizer.cc.

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

References buildRegex(), DeadROC_duringRun::dir, L1TBPTX_cfi::dqmStore, compare::hist, BTVHLTOfflineSource_cfi::pathname, plotNamesToNormalize_, and reference_.

Member Data Documentation

◆ plotNamesToNormalize_

vector<string> DQMHistNormalizer::plotNamesToNormalize_
private

Definition at line 43 of file DQMHistNormalizer.cc.

Referenced by endRun().

◆ reference_

string DQMHistNormalizer::reference_
private

Definition at line 44 of file DQMHistNormalizer.cc.

Referenced by endRun().

DQMHistNormalizer::DQMStore
dqm::legacy::DQMStore DQMStore
Definition: DQMHistNormalizer.cc:32
BTVHLTOfflineSource_cfi.pathname
pathname
Definition: BTVHLTOfflineSource_cfi.py:28
edm::LogInfo
Definition: MessageLogger.h:254
DQMHistNormalizer::plotNamesToNormalize_
vector< string > plotNamesToNormalize_
Definition: DQMHistNormalizer.cc:43
compare.hist
hist
Definition: compare.py:376
DQMHistNormalizer::reference_
string reference_
Definition: DQMHistNormalizer.cc:44
DQMHistNormalizer::buildRegex
lat::Regexp * buildRegex(const string &expr)
Definition: DQMHistNormalizer.cc:61
L1TBPTX_cfi.dqmStore
dqmStore
Definition: L1TBPTX_cfi.py:6
edm::LogError
Definition: MessageLogger.h:183
leef::Error
edm::ErrorSummaryEntry Error
Definition: LogErrorEventFilter.cc:29
edm::Service
Definition: Service.h:30
corrVsCorr.rx
rx
Definition: corrVsCorr.py:103
looper.cfg
cfg
Definition: looper.py:297
jets_cff.expr
expr
Definition: jets_cff.py:449
Exception
Definition: hltDiff.cc:246
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37