CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
TauDQMHistEffProducer Class Reference

#include <DQMHistEffProducer.h>

Inheritance diagram for TauDQMHistEffProducer:
DQMEDHarvester edm::one::EDProducer< edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::EndProcessBlockProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources, edm::Accumulator > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  cfgEntryPlot
 

Public Member Functions

void dqmEndJob (DQMStore::IBooker &ibook, DQMStore::IGetter &iget) override
 
 TauDQMHistEffProducer (const edm::ParameterSet &)
 
 ~TauDQMHistEffProducer () override
 
- Public Member Functions inherited from DQMEDHarvester
void accumulate (edm::Event const &ev, edm::EventSetup const &es) final
 
void beginJob () override
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &) final
 
void beginRun (edm::Run const &run, edm::EventSetup const &) override
 
virtual void dqmAnalyze (DQMStore::IBooker &, DQMStore::IGetter &, edm::Event const &, edm::EventSetup const &)
 
 DQMEDHarvester (edm::ParameterSet const &iConfig)
 
 DQMEDHarvester ()
 
virtual void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 
virtual void dqmEndRun (DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &)
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &es) final
 
void endProcessBlockProduce (edm::ProcessBlock &) final
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void endRunProduce (edm::Run &run, edm::EventSetup const &es) final
 
 ~DQMEDHarvester () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::EndProcessBlockProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources, edm::Accumulator >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) 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 Attributes

std::vector< cfgEntryPlotcfgEntryPlot_
 
std::vector< MonitorElement * > histoEfficiencyVector_
 

Additional Inherited Members

- Public Types inherited from DQMEDHarvester
typedef dqm::harvesting::DQMStore DQMStore
 
typedef dqm::harvesting::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- 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)
 
- Protected Attributes inherited from DQMEDHarvester
DQMStoredqmstore_
 
edm::GetterOfProducts< DQMTokenjobmegetter_
 
edm::EDPutTokenT< DQMTokenjobToken_
 
edm::GetterOfProducts< DQMTokenlumimegetter_
 
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::GetterOfProducts< DQMTokenrunmegetter_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Class to produce efficiency histograms by dividing nominator by denominator histograms

Author
Christian Veelken, UC Davis

Definition at line 22 of file DQMHistEffProducer.h.

Constructor & Destructor Documentation

◆ TauDQMHistEffProducer()

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

Definition at line 45 of file DQMHistEffProducer.cc.

References looper::cfg, cfgEntryPlot_, bTagMiniDQMDeepCSV::denominator, L1TObjectsTimingClient_cff::efficiency, edm::ParameterSet::getParameter(), bTagMiniDQMDeepCSV::numerator, pfMETsysShiftCorrections_cfi::parameter, parKeyword, L1TEGammaDiff_cfi::plotName, HLTObjectsMonitor_cfi::plots, replace_string(), and AlCaHLTBitMon_QueryRunRegistry::string.

45  {
46  //std::cout << "<TauDQMHistEffProducer::TauDQMHistEffProducer>:" << std::endl;
47 
48  edm::ParameterSet plots = cfg.getParameter<edm::ParameterSet>("plots");
49  std::vector<std::string> plotNames = plots.getParameterNamesForType<edm::ParameterSet>();
50  for (std::vector<std::string>::const_iterator plotName = plotNames.begin(); plotName != plotNames.end(); ++plotName) {
51  edm::ParameterSet plotConfig = plots.getParameter<edm::ParameterSet>(*plotName);
52 
53  typedef std::vector<std::string> vstring;
54  vstring plotParameter = plotConfig.getParameter<vstring>("parameter");
55  if (plotParameter.empty()) {
56  cfgEntryPlot_.push_back(cfgEntryPlot(plotConfig));
57  } else {
58  std::string numerator = plotConfig.getParameter<std::string>("numerator");
59  std::string denominator = plotConfig.getParameter<std::string>("denominator");
60  std::string efficiency = plotConfig.getParameter<std::string>("efficiency");
61  for (vstring::const_iterator parameter = plotParameter.begin(); parameter != plotParameter.end(); ++parameter) {
62  int errorFlag = 0;
63  std::string modNumerator = replace_string(numerator, parKeyword, *parameter, 1, 1, errorFlag);
64  std::string modDenominator = replace_string(denominator, parKeyword, *parameter, 1, 1, errorFlag);
65  std::string modEfficiency = replace_string(efficiency, parKeyword, *parameter, 1, 1, errorFlag);
66 
67  if (!errorFlag) {
68  cfgEntryPlot_.push_back(cfgEntryPlot(modNumerator, modDenominator, modEfficiency));
69  } else {
70  edm::LogError("TauDQMHistEffProducer")
71  << " Failed to decode histogram names for plotName = " << (*plotName) << " --> skipping !!";
72  }
73  }
74  }
75  }
76 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
vector< string > vstring
Definition: ExoticaDQM.cc:8
std::string replace_string(const std::string &src, const std::string &keyword, const std::string &parameter, unsigned minReplacements, unsigned maxReplacements, int &errorFlag)
Log< level::Error, false > LogError
std::vector< cfgEntryPlot > cfgEntryPlot_
const std::string parKeyword

◆ ~TauDQMHistEffProducer()

TauDQMHistEffProducer::~TauDQMHistEffProducer ( )
override

Definition at line 78 of file DQMHistEffProducer.cc.

78  {
79  //--- nothing to be done yet
80 }

Member Function Documentation

◆ dqmEndJob()

void TauDQMHistEffProducer::dqmEndJob ( DQMStore::IBooker ibook,
DQMStore::IGetter iget 
)
overridevirtual

Implements DQMEDHarvester.

Definition at line 82 of file DQMHistEffProducer.cc.

References mps_setup::append, dqm::implementation::IBooker::book1D(), cfgEntryPlot_, gather_cfg::cout, dqm::implementation::IGetter::dirExists(), dqmSeparator, dqm::implementation::IGetter::get(), dqm::legacy::MonitorElement::getTH1(), dqm::legacy::MonitorElement::getTH1F(), histoEfficiencyVector_, plotFactory::plot, separateHistogramFromDirectoryName(), dqm::implementation::NavigatorBase::setCurrentFolder(), and AlCaHLTBitMon_QueryRunRegistry::string.

82  {
83  //std::cout << "<TauDQMHistEffProducer::endJob>:" << std::endl;
84 
85  for (std::vector<cfgEntryPlot>::const_iterator plot = cfgEntryPlot_.begin(); plot != cfgEntryPlot_.end(); ++plot) {
86  //std::cout << "plot->numerator_ = " << plot->numerator_ << std::endl;
87  std::string numeratorHistogramName, numeratorHistogramDirectory;
88  separateHistogramFromDirectoryName(plot->numerator_, numeratorHistogramName, numeratorHistogramDirectory);
89  //std::cout << "numeratorHistogramName = " << numeratorHistogramName << std::endl;
90  //std::cout << "numeratorHistogramDirectory = " << numeratorHistogramDirectory << std::endl;
91  MonitorElement* meNumerator =
92  iget.get(std::string(numeratorHistogramDirectory).append(dqmSeparator).append(numeratorHistogramName));
93  //std::cout << "meNumerator = " << meNumerator << std::endl;
94  TH1* histoNumerator = (meNumerator != nullptr) ? meNumerator->getTH1() : nullptr;
95 
96  //std::cout << "plot->denominator_ = " << plot->denominator_ << std::endl;
97  std::string denominatorHistogramName, denominatorHistogramDirectory;
98  separateHistogramFromDirectoryName(plot->denominator_, denominatorHistogramName, denominatorHistogramDirectory);
99  //std::cout << "denominatorHistogramName = " << denominatorHistogramName << std::endl;
100  //std::cout << "denominatorHistogramDirectory = " << denominatorHistogramDirectory << std::endl;
101  MonitorElement* meDenominator =
102  iget.get(std::string(denominatorHistogramDirectory).append(dqmSeparator).append(denominatorHistogramName));
103  //std::cout << "meDenominator = " << meDenominator << std::endl;
104  TH1* histoDenominator = (meDenominator != nullptr) ? meDenominator->getTH1() : nullptr;
105 
106  if (histoNumerator != nullptr && histoDenominator != nullptr) {
107  if (!histoNumerator->GetSumw2N())
108  histoNumerator->Sumw2();
109  //std::cout << " histoNumerator->GetName = " << histoNumerator->GetName() << std::endl;
110 
111  if (!histoDenominator->GetSumw2N())
112  histoDenominator->Sumw2();
113  //std::cout << " histoDenominator->GetName = " << histoNumerator->GetName() << std::endl;
114 
115  std::string effHistogramName, effHistogramDirectory, dummy;
116  separateHistogramFromDirectoryName(plot->efficiency_, effHistogramName, effHistogramDirectory);
117  //if ( effHistogramDirectory == "" ) separateHistogramFromDirectoryName(numeratorHistogramName, dummy, effHistogramDirectory);
118  if (!effHistogramDirectory.empty()) {
119  if (iget.dirExists(effHistogramDirectory))
120  ibook.setCurrentFolder(effHistogramDirectory);
121  else
122  std::cout << "TauDQMHistEffProducer:: Directory: " << effHistogramDirectory << " does not exist!"
123  << std::endl;
124  }
125 
126  MonitorElement* histoEfficiency = ibook.book1D(effHistogramName,
127  effHistogramName,
128  histoNumerator->GetNbinsX(),
129  histoNumerator->GetXaxis()->GetXmin(),
130  histoNumerator->GetXaxis()->GetXmax());
131 
132  histoEfficiency->getTH1F()->Divide(histoNumerator, histoDenominator, 1., 1., "B");
133 
134  //to avoid the pointer to go out of scope:
135  histoEfficiencyVector_.push_back(histoEfficiency);
136 
137  /* std::vector<std::string> mes = dqmStore.getMEs();
138  std::cout<<dqmStore.pwd()<<std::endl;
139  for(unsigned int i =0; i<mes.size(); i++)
140  std::cout<<mes[i]<<std::endl;
141  */
142  } else {
143  edm::LogError("endRun") << " Failed to produce efficiency histogram = " << plot->efficiency_ << " !!";
144  if (histoNumerator == nullptr)
145  edm::LogError("endRun") << " numerator = " << plot->numerator_ << " does not exist.";
146  if (histoDenominator == nullptr)
147  edm::LogError("endRun") << " denominator = " << plot->denominator_ << " does not exist.";
148  }
149  }
150 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:737
Log< level::Error, false > LogError
std::vector< cfgEntryPlot > cfgEntryPlot_
void separateHistogramFromDirectoryName(const std::string &histogramAndDirectoryName, std::string &histogramName, std::string &directoryName)
virtual TH1F * getTH1F() const
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:680
virtual TH1 * getTH1() const
std::vector< MonitorElement * > histoEfficiencyVector_
const std::string dqmSeparator
Definition: EwkTauDQM.cc:8
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98

Member Data Documentation

◆ cfgEntryPlot_

std::vector<cfgEntryPlot> TauDQMHistEffProducer::cfgEntryPlot_
private

Definition at line 37 of file DQMHistEffProducer.h.

Referenced by dqmEndJob(), and TauDQMHistEffProducer().

◆ histoEfficiencyVector_

std::vector<MonitorElement*> TauDQMHistEffProducer::histoEfficiencyVector_
private

Definition at line 38 of file DQMHistEffProducer.h.

Referenced by dqmEndJob().