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::Accumulator, edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources > 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 beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void beginRun (edm::Run const &, edm::EventSetup const &) override
 
 DQMEDHarvester ()
 
virtual void dqmEndLuminosityBlock (DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &)
 
void endJob () final
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) final
 
void endLuminosityBlockProduce (edm::LuminosityBlock &, edm::EventSetup const &) final
 
void endRun (edm::Run const &, edm::EventSetup const &) override
 
void endRunProduce (edm::Run &run, edm::EventSetup const &setup) override
 
 ~DQMEDHarvester () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::Accumulator, edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns, edm::one::SharedResources >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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)
 
 ~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
 
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
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Private Attributes

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

Additional Inherited Members

- 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::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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<typename ESProduct , Transition Tr = Transition::Event>
auto esConsumes (eventsetup::EventSetupRecordKey const &, ESInputTag const &tag)
 
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)
 
- Protected Attributes inherited from DQMEDHarvester
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Detailed Description

Class to produce efficiency histograms by dividing nominator by denominator histograms

Author
Christian Veelken, UC Davis

Definition at line 23 of file DQMHistEffProducer.h.

Constructor & Destructor Documentation

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

Definition at line 46 of file DQMHistEffProducer.cc.

References TauDQMHistEffProducer::cfgEntryPlot::cfgEntryPlot(), cfgEntryPlot_, pfDeepCMVADiscriminatorsJetTags_cfi::denominator, PostProcessor_cff::efficiency, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNamesForType(), pfDeepCMVADiscriminatorsJetTags_cfi::numerator, ValidateTausOnQCD_cff::parameter, parKeyword, nanoDQM_cff::plots, replace_string(), and AlCaHLTBitMon_QueryRunRegistry::string.

47 {
48  //std::cout << "<TauDQMHistEffProducer::TauDQMHistEffProducer>:" << std::endl;
49 
51  std::vector<std::string> plotNames = plots.getParameterNamesForType<edm::ParameterSet>();
52  for ( std::vector<std::string>::const_iterator plotName = plotNames.begin(); plotName != plotNames.end(); ++plotName ) {
53  edm::ParameterSet plotConfig = plots.getParameter<edm::ParameterSet>(*plotName);
54 
55  typedef std::vector<std::string> vstring;
56  vstring plotParameter = plotConfig.getParameter<vstring>("parameter");
57  if ( plotParameter.empty() ) {
58  cfgEntryPlot_.push_back(cfgEntryPlot(plotConfig));
59  } else {
60  std::string numerator = plotConfig.getParameter<std::string>("numerator");
61  std::string denominator = plotConfig.getParameter<std::string>("denominator");
62  std::string efficiency = plotConfig.getParameter<std::string>("efficiency");
63  for ( vstring::const_iterator parameter = plotParameter.begin(); parameter != plotParameter.end(); ++parameter ) {
64  int errorFlag = 0;
65  std::string modNumerator = replace_string(numerator, parKeyword, *parameter, 1, 1, errorFlag);
66  std::string modDenominator = replace_string(denominator, parKeyword, *parameter, 1, 1, errorFlag);
67  std::string modEfficiency = replace_string(efficiency, parKeyword, *parameter, 1, 1, errorFlag);
68 
69  if ( !errorFlag ) {
70  cfgEntryPlot_.push_back(cfgEntryPlot(modNumerator, modDenominator, modEfficiency));
71  } else {
72  edm::LogError("TauDQMHistEffProducer") << " Failed to decode histogram names for plotName = " << (*plotName)
73  << " --> skipping !!";
74  }
75  }
76  }
77  }
78 }
T getParameter(std::string const &) const
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)
std::vector< std::string > getParameterNamesForType(bool trackiness=true) const
Definition: ParameterSet.h:193
std::vector< cfgEntryPlot > cfgEntryPlot_
const std::string parKeyword
TauDQMHistEffProducer::~TauDQMHistEffProducer ( )
override

Definition at line 80 of file DQMHistEffProducer.cc.

81 {
82 //--- nothing to be done yet
83 }

Member Function Documentation

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

Implements DQMEDHarvester.

Definition at line 85 of file DQMHistEffProducer.cc.

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

86 {
87  //std::cout << "<TauDQMHistEffProducer::endJob>:" << std::endl;
88 
89  for ( std::vector<cfgEntryPlot>::const_iterator plot = cfgEntryPlot_.begin(); plot != cfgEntryPlot_.end(); ++plot ) {
90  //std::cout << "plot->numerator_ = " << plot->numerator_ << std::endl;
91  std::string numeratorHistogramName, numeratorHistogramDirectory;
92  separateHistogramFromDirectoryName(plot->numerator_, numeratorHistogramName, numeratorHistogramDirectory);
93  //std::cout << "numeratorHistogramName = " << numeratorHistogramName << std::endl;
94  //std::cout << "numeratorHistogramDirectory = " << numeratorHistogramDirectory << std::endl;
95  MonitorElement* meNumerator = iget.get(std::string(numeratorHistogramDirectory).append(dqmSeparator).append(numeratorHistogramName));
96  //std::cout << "meNumerator = " << meNumerator << std::endl;
97  TH1* histoNumerator = ( meNumerator != nullptr ) ? meNumerator->getTH1() : nullptr;
98 
99  //std::cout << "plot->denominator_ = " << plot->denominator_ << std::endl;
100  std::string denominatorHistogramName, denominatorHistogramDirectory;
101  separateHistogramFromDirectoryName(plot->denominator_, denominatorHistogramName, denominatorHistogramDirectory);
102  //std::cout << "denominatorHistogramName = " << denominatorHistogramName << std::endl;
103  //std::cout << "denominatorHistogramDirectory = " << denominatorHistogramDirectory << std::endl;
104  MonitorElement* meDenominator = iget.get(std::string(denominatorHistogramDirectory).append(dqmSeparator).append(denominatorHistogramName));
105  //std::cout << "meDenominator = " << meDenominator << std::endl;
106  TH1* histoDenominator = ( meDenominator != nullptr ) ? meDenominator->getTH1() : nullptr;
107 
108  if ( histoNumerator != nullptr && histoDenominator != nullptr ) {
109  if ( !histoNumerator->GetSumw2N() ) histoNumerator->Sumw2();
110  //std::cout << " histoNumerator->GetName = " << histoNumerator->GetName() << std::endl;
111 
112  if ( !histoDenominator->GetSumw2N() ) 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  {
120  if(iget.dirExists(effHistogramDirectory))
121  ibook.setCurrentFolder(effHistogramDirectory);
122  else
123  std::cout<<"TauDQMHistEffProducer:: Directory: "<<effHistogramDirectory<<" does not exist!"<<std::endl;
124  }
125 
126  MonitorElement* histoEfficiency = ibook.book1D(effHistogramName, effHistogramName,
127  histoNumerator->GetNbinsX(), histoNumerator->GetXaxis()->GetXmin(), histoNumerator->GetXaxis()->GetXmax());
128 
129  histoEfficiency->getTH1F()->Divide(histoNumerator, histoDenominator, 1., 1., "B");
130 
131  //to avoid the pointer to go out of scope:
132  histoEfficiencyVector_.push_back(histoEfficiency);
133 
134  /* std::vector<std::string> mes = dqmStore.getMEs();
135  std::cout<<dqmStore.pwd()<<std::endl;
136  for(unsigned int i =0; i<mes.size(); i++)
137  std::cout<<mes[i]<<std::endl;
138  */
139  } else {
140  edm::LogError("endRun") << " Failed to produce efficiency histogram = " << plot->efficiency_ << " !!";
141  if ( histoNumerator == nullptr ) edm::LogError("endRun") << " numerator = " << plot->numerator_ << " does not exist.";
142  if ( histoDenominator == nullptr ) edm::LogError("endRun") << " denominator = " << plot->denominator_ << " does not exist.";
143  }
144  }
145 }
TH1F * getTH1F() const
TH1 * getTH1() const
#define nullptr
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
std::vector< cfgEntryPlot > cfgEntryPlot_
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
void separateHistogramFromDirectoryName(const std::string &histogramAndDirectoryName, std::string &histogramName, std::string &directoryName)
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:303
bool dirExists(std::string const &path)
Definition: DQMStore.cc:343
std::vector< MonitorElement * > histoEfficiencyVector_
const std::string dqmSeparator
Definition: EwkTauDQM.cc:8

Member Data Documentation

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

Definition at line 40 of file DQMHistEffProducer.h.

Referenced by dqmEndJob(), and TauDQMHistEffProducer().

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

Definition at line 41 of file DQMHistEffProducer.h.

Referenced by dqmEndJob().