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::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns > edm::one::EDAnalyzerBase edm::EDConsumerBase

Public Types

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

Public Member Functions

void analyze (const edm::Event &, const edm::EventSetup &) override
 
void beginRun (const edm::Run &r, const edm::EventSetup &c) override
 
 DQMHistNormalizer (const edm::ParameterSet &)
 
void endRun (const edm::Run &r, const edm::EventSetup &c) override
 
 ~DQMHistNormalizer () override
 
- Public Member Functions inherited from edm::one::EDAnalyzer< edm::one::SharedResources, edm::one::WatchRuns >
 EDAnalyzer ()=default
 
 EDAnalyzer (const EDAnalyzer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
const EDAnalyzeroperator= (const EDAnalyzer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDAnalyzerBase () 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESResolverIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESResolverIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (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::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProductResolverIndices 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::one::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
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)
 
void resetItemsToGetFrom (BranchType iType)
 

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  usesResource("DQMStore");
51  //std::cout << "<DQMHistNormalizer::DQMHistNormalizer>:" << std::endl;
52 }
vector< string > plotNamesToNormalize_

◆ ~DQMHistNormalizer()

DQMHistNormalizer::~DQMHistNormalizer ( )
override

Definition at line 54 of file DQMHistNormalizer.cc.

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

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 58 of file DQMHistNormalizer.cc.

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

◆ beginRun()

void DQMHistNormalizer::beginRun ( const edm::Run r,
const edm::EventSetup c 
)
inlineoverride

Definition at line 38 of file DQMHistNormalizer.cc.

38 {}

◆ buildRegex()

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

Definition at line 62 of file DQMHistNormalizer.cc.

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

Referenced by endRun().

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

◆ endRun()

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

Definition at line 74 of file DQMHistNormalizer.cc.

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

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

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().