CMS 3D CMS Logo

List of all members | Public Types | Public 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 noexcept final
 
bool wantsGlobalRuns () const noexcept final
 
bool wantsInputProcessBlocks () const noexcept final
 
bool wantsProcessBlocks () const noexcept 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 noexcept
 
bool wantsStreamRuns () const noexcept
 
 ~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 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 46 of file DQMHistNormalizer.cc.

Member Typedef Documentation

◆ DQMStore

Definition at line 48 of file DQMHistNormalizer.cc.

◆ MonitorElement

Definition at line 49 of file DQMHistNormalizer.cc.

Constructor & Destructor Documentation

◆ DQMHistNormalizer()

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

Definition at line 62 of file DQMHistNormalizer.cc.

63  : plotNamesToNormalize_(cfg.getParameter<std::vector<string> >("plotNamesToNormalize")),
64  reference_(cfg.getParameter<string>("reference")) {
65  usesResource("DQMStore");
66  //std::cout << "<DQMHistNormalizer::DQMHistNormalizer>:" << std::endl;
67 }
vector< string > plotNamesToNormalize_

◆ ~DQMHistNormalizer()

DQMHistNormalizer::~DQMHistNormalizer ( )
override

Definition at line 69 of file DQMHistNormalizer.cc.

69  {
70  //--- nothing to be done yet
71 }

Member Function Documentation

◆ analyze()

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

Implements edm::one::EDAnalyzerBase.

Definition at line 73 of file DQMHistNormalizer.cc.

73  {
74  //--- nothing to be done yet
75 }

◆ beginRun()

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

Definition at line 54 of file DQMHistNormalizer.cc.

54 {}

◆ endRun()

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

Definition at line 77 of file DQMHistNormalizer.cc.

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

77  {
78  //std::cout << "<DQMHistNormalizer::endJob>:" << std::endl;
79 
80  //--- check that DQMStore service is available
81  if (!edm::Service<DQMStore>().isAvailable()) {
82  edm::LogError("endJob") << " Failed to access dqmStore --> histograms will NOT be plotted !!";
83  return;
84  }
85 
87 
88  vector<MonitorElement*> allOurMEs = dqmStore.getAllContents("RecoTauV/");
89  std::regex refregex = std::regex(".*RecoTauV/.*/" + globToRegex(reference_), std::regex::nosubs);
90  vector<std::regex> toNormRegex;
91  for (std::vector<string>::const_iterator toNorm = plotNamesToNormalize_.begin();
92  toNorm != plotNamesToNormalize_.end();
93  ++toNorm)
94  toNormRegex.emplace_back(".*RecoTauV/.*/" + globToRegex(*toNorm), std::regex::nosubs);
95 
96  map<string, MonitorElement*> refsMap;
97  vector<MonitorElement*> toNormElements;
98  std::smatch path_match;
99 
100  for (vector<MonitorElement*>::const_iterator element = allOurMEs.begin(); element != allOurMEs.end(); ++element) {
101  string pathname = (*element)->getFullname();
102  //cout << pathname << endl;
103  //Matches reference
104  if (std::regex_match(pathname, path_match, refregex)) {
105  //cout << "Matched to ref" << endl;
106  string dir = pathname.substr(0, pathname.rfind('/'));
107  if (refsMap.find(dir) != refsMap.end()) {
108  edm::LogInfo("DQMHistNormalizer")
109  << "DQMHistNormalizer::endRun: Warning! found multiple normalizing references for dir: " << dir << "!";
110  edm::LogInfo("DQMHistNormalizer") << " " << (refsMap[dir])->getFullname();
111  edm::LogInfo("DQMHistNormalizer") << " " << pathname;
112  } else {
113  refsMap[dir] = *element;
114  }
115  }
116 
117  //Matches targets
118  for (const auto& reg : toNormRegex) {
119  if (std::regex_match(pathname, path_match, reg)) {
120  //cout << "Matched to target" << endl;
121  toNormElements.push_back(*element);
122  //cout << "Filled the collection" << endl;
123  }
124  }
125  }
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
Log< level::Info, false > LogInfo

Member Data Documentation

◆ plotNamesToNormalize_

vector<string> DQMHistNormalizer::plotNamesToNormalize_
private

Definition at line 58 of file DQMHistNormalizer.cc.

Referenced by endRun().

◆ reference_

string DQMHistNormalizer::reference_
private

Definition at line 59 of file DQMHistNormalizer.cc.

Referenced by endRun().