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 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 const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > 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
 
bool registeredToConsumeMany (TypeID const &, 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::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 wantsInputProcessBlocks ()
 
static bool wantsProcessBlocks ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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 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)
 
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 46 of file DQMHistNormalizer.cc.

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

◆ ~DQMHistNormalizer()

DQMHistNormalizer::~DQMHistNormalizer ( )
override

Definition at line 52 of file DQMHistNormalizer.cc.

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

Member Function Documentation

◆ analyze()

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

Implements edm::EDAnalyzer.

Definition at line 56 of file DQMHistNormalizer.cc.

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

◆ buildRegex()

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

Definition at line 60 of file DQMHistNormalizer.cc.

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

Referenced by endRun().

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

◆ endRun()

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

Reimplemented from edm::EDAnalyzer.

Definition at line 72 of file DQMHistNormalizer.cc.

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

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

Member Data Documentation

◆ plotNamesToNormalize_

vector<string> DQMHistNormalizer::plotNamesToNormalize_
private

Definition at line 42 of file DQMHistNormalizer.cc.

Referenced by endRun().

◆ reference_

string DQMHistNormalizer::reference_
private

Definition at line 43 of file DQMHistNormalizer.cc.

Referenced by endRun().