CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes
GEMDQMEfficiencyClientBase Class Reference

#include <GEMDQMEfficiencyClientBase.h>

Inheritance diagram for GEMDQMEfficiencyClientBase:
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 GEMEffByGEMCSCSegmentClient GEMEfficiencyHarvester

Public Types

using MEPair = std::pair< const MonitorElement *, const MonitorElement * >
 
- 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
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
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
 

Public Member Functions

void bookEfficiencyAuto (DQMStore::IBooker &, DQMStore::IGetter &, const std::string &)
 
bool checkConsistency (const TH1 &, const TH1 &)
 
 GEMDQMEfficiencyClientBase (const edm::ParameterSet &)
 
TH1F * makeEfficiency (const TH1F *, const TH1F *, const char *name=nullptr, const char *title=nullptr)
 
TH2F * makeEfficiency (const TH2F *, const TH2F *, const char *name=nullptr, const char *title=nullptr)
 
std::map< std::string, MEPairmakeEfficiencySourcePair (DQMStore::IBooker &, DQMStore::IGetter &, const std::string &, const std::string prefix="")
 
std::tuple< bool, std::string, std::string, bool > parseEfficiencySourceName (std::string)
 
GEMDetId parseGEMLabel (const std::string, const std::string delimiter="-")
 
TH1F * projectHistogram (const TH2F *, const unsigned int)
 
void setBins (TH1F *, const TAxis *)
 
- 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 dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &)=0
 
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
 
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)
 

Public Attributes

const double kConfidenceLevel_
 
const std::string kLogCategory_
 

Additional Inherited Members

- 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 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

Author
Seungjin Yang seung.nosp@m.jin..nosp@m.yang@.nosp@m.cern.nosp@m..ch

Definition at line 14 of file GEMDQMEfficiencyClientBase.h.

Member Typedef Documentation

◆ MEPair

Definition at line 16 of file GEMDQMEfficiencyClientBase.h.

Constructor & Destructor Documentation

◆ GEMDQMEfficiencyClientBase()

GEMDQMEfficiencyClientBase::GEMDQMEfficiencyClientBase ( const edm::ParameterSet ps)

Definition at line 10 of file GEMDQMEfficiencyClientBase.cc.

11  : kConfidenceLevel_(ps.getUntrackedParameter<double>("confidenceLevel")),
12  kLogCategory_(ps.getUntrackedParameter<std::string>("logCategory")) {}
T getUntrackedParameter(std::string const &, T const &) const

Member Function Documentation

◆ bookEfficiencyAuto()

void GEMDQMEfficiencyClientBase::bookEfficiencyAuto ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  folder 
)

Definition at line 357 of file GEMDQMEfficiencyClientBase.cc.

References dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::book2D(), printsummarytable::folder, dqm::legacy::MonitorElement::getTH2F(), crabWrapper::key, kLogCategory_, makeEfficiency(), makeEfficiencySourcePair(), MonitorElementData::TH1F, MonitorElementData::TH2F, and relativeConstraints::value.

Referenced by GEMEfficiencyHarvester::dqmEndJob(), and GEMEffByGEMCSCSegmentClient::dqmEndLuminosityBlock().

359  {
360  const std::map<std::string, MEPair> me_pairs = makeEfficiencySourcePair(ibooker, igetter, folder);
361 
362  for (auto& [key, value] : me_pairs) {
363  const auto& [me_numerator, me_denominator] = value;
364 
365  const MonitorElement::Kind me_kind = me_numerator->kind();
366  if (me_kind == MonitorElement::Kind::TH1F) {
367  TH1F* h_numerator = me_numerator->getTH1F();
368  if (h_numerator == nullptr) {
369  edm::LogError(kLogCategory_) << "failed to get TH1F from h_numerator " << key;
370  continue;
371  }
372 
373  TH1F* h_denominator = me_denominator->getTH1F();
374  if (h_denominator == nullptr) {
375  edm::LogError(kLogCategory_) << "failed to get TH1F from h_denominator" << key;
376  continue;
377  }
378 
379  if (TH1F* eff = makeEfficiency(h_numerator, h_denominator)) {
380  ibooker.book1D(eff->GetName(), eff);
381 
382  } else {
383  // makeEfficiency will report the error.
384  continue;
385  }
386 
387  } else if (me_kind == MonitorElement::Kind::TH2F) {
388  TH2F* h_numerator = me_numerator->getTH2F();
389  if (h_numerator == nullptr) {
390  edm::LogError(kLogCategory_) << "failed to get TH1F from h_numerator " << key;
391  continue;
392  }
393 
394  TH2F* h_denominator = me_denominator->getTH2F();
395  if (h_denominator == nullptr) {
396  edm::LogError(kLogCategory_) << "failed to get TH1F from h_denominator" << key;
397  continue;
398  }
399 
400  if (TH2F* eff = makeEfficiency(h_numerator, h_denominator)) {
401  ibooker.book2D(eff->GetName(), eff);
402 
403  } else {
404  // makeEfficiency will report the error.
405  continue;
406  }
407 
408  } else {
409  edm::LogError(kLogCategory_) << "got an unepxected MonitorElement::Kind "
410  << "0x" << std::hex << static_cast<int>(me_kind);
411  continue;
412  }
413 
414  } // me_pairs
415 }
TH1F * makeEfficiency(const TH1F *, const TH1F *, const char *name=nullptr, const char *title=nullptr)
Log< level::Error, false > LogError
virtual TH2F * getTH2F() const
Definition: value.py:1
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
std::map< std::string, MEPair > makeEfficiencySourcePair(DQMStore::IBooker &, DQMStore::IGetter &, const std::string &, const std::string prefix="")

◆ checkConsistency()

bool GEMDQMEfficiencyClientBase::checkConsistency ( const TH1 &  pass,
const TH1 &  total 
)

Definition at line 201 of file GEMDQMEfficiencyClientBase.cc.

References kLogCategory_, and dqmMemoryStats::total.

Referenced by makeEfficiency().

201  {
202  if (pass.GetDimension() != total.GetDimension()) {
203  edm::LogError(kLogCategory_) << "numerator and denominator have different dimensions: " << pass.GetName() << " & "
204  << total.GetName();
205  return false;
206  }
207 
208  if (not TEfficiency::CheckBinning(pass, total)) {
209  edm::LogError(kLogCategory_) << "numerator and denominator have different binning: " << pass.GetName() << " & "
210  << total.GetName();
211  return false;
212  }
213 
214  if (not TEfficiency::CheckEntries(pass, total)) {
215  edm::LogError(kLogCategory_) << "numerator and denominator do not have consistent bin contents " << pass.GetName()
216  << " & " << total.GetName();
217  return false;
218  }
219 
220  return true;
221 }
Log< level::Error, false > LogError

◆ makeEfficiency() [1/2]

TH1F * GEMDQMEfficiencyClientBase::makeEfficiency ( const TH1F *  h_numerator,
const TH1F *  h_denominator,
const char *  name = nullptr,
const char *  title = nullptr 
)

Definition at line 224 of file GEMDQMEfficiencyClientBase.cc.

References newFWLiteAna::bin, checkConsistency(), L1TObjectsTimingClient_cff::efficiency, relativeConstraints::error, kConfidenceLevel_, kLogCategory_, SiStripPI::max, Skims_PA_cff::name, LaserClient_cfi::nbins, TriggerAnalyzer::passed, setBins(), runGCPTkAlMap::title, and dqmMemoryStats::total.

Referenced by GEMEfficiencyHarvester::bookDetector1DEfficiency(), and bookEfficiencyAuto().

227  {
228  if (h_numerator == nullptr) {
229  edm::LogError(kLogCategory_) << "numerator is nullptr";
230  return nullptr;
231  }
232 
233  if (h_denominator == nullptr) {
234  edm::LogError(kLogCategory_) << "denominator is nulpptr";
235  return nullptr;
236  }
237 
238  if (not checkConsistency(*h_numerator, *h_denominator)) {
239  return nullptr;
240  }
241 
242  if (name == nullptr) {
243  name = Form("eff_%s", h_denominator->GetName());
244  }
245 
246  if (title == nullptr) {
247  title = h_denominator->GetTitle();
248  }
249 
250  const TAxis* x_axis = h_denominator->GetXaxis();
251 
252  // create an empty TProfile for storing efficiencies and uncertainties.
253  TH1F* h_eff = new TH1F();
254  h_eff->SetName(name);
255  h_eff->SetTitle(title);
256  h_eff->GetXaxis()->SetTitle(x_axis->GetTitle());
257  h_eff->GetYaxis()->SetTitle("Efficiency");
258  setBins(h_eff, h_denominator->GetXaxis());
259 
260  // efficiency calculation
261  const int nbins = x_axis->GetNbins();
262  for (int bin = 1; bin <= nbins; bin++) {
263  const double passed = h_numerator->GetBinContent(bin);
264  const double total = h_denominator->GetBinContent(bin);
265 
266  if (total < 1) {
267  continue;
268  }
269 
270  const double efficiency = passed / total;
271  const double lower_boundary = TEfficiency::ClopperPearson(total, passed, kConfidenceLevel_, false);
272  const double upper_boundary = TEfficiency::ClopperPearson(total, passed, kConfidenceLevel_, true);
273  const double error = std::max(efficiency - lower_boundary, upper_boundary - efficiency);
274 
275  h_eff->SetBinContent(bin, efficiency);
276  h_eff->SetBinError(bin, error);
277  }
278 
279  return h_eff;
280 }
void setBins(TH1F *, const TAxis *)
Log< level::Error, false > LogError
bool checkConsistency(const TH1 &, const TH1 &)

◆ makeEfficiency() [2/2]

TH2F * GEMDQMEfficiencyClientBase::makeEfficiency ( const TH2F *  h_numerator,
const TH2F *  h_denominator,
const char *  name = nullptr,
const char *  title = nullptr 
)

Definition at line 283 of file GEMDQMEfficiencyClientBase.cc.

References checkConsistency(), kLogCategory_, Skims_PA_cff::name, and runGCPTkAlMap::title.

286  {
287  if (h_numerator == nullptr) {
288  edm::LogError(kLogCategory_) << "numerator is nullptr";
289  return nullptr;
290  }
291 
292  if (h_denominator == nullptr) {
293  edm::LogError(kLogCategory_) << "denominator is nulpptr";
294  return nullptr;
295  }
296 
297  if (not checkConsistency(*h_numerator, *h_denominator)) {
298  return nullptr;
299  }
300 
301  if (name == nullptr) {
302  name = Form("eff_%s", h_denominator->GetName());
303  }
304 
305  if (title == nullptr) {
306  title = h_denominator->GetTitle();
307  }
308 
309  TEfficiency eff(*h_numerator, *h_denominator);
310  auto h_eff = dynamic_cast<TH2F*>(eff.CreateHistogram());
311  h_eff->SetName(name);
312  h_eff->SetTitle(title);
313 
314  return h_eff;
315 }
Log< level::Error, false > LogError
bool checkConsistency(const TH1 &, const TH1 &)

◆ makeEfficiencySourcePair()

std::map< std::string, GEMDQMEfficiencyClientBase::MEPair > GEMDQMEfficiencyClientBase::makeEfficiencySourcePair ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  folder,
const std::string  prefix = "" 
)

Definition at line 100 of file GEMDQMEfficiencyClientBase.cc.

References printsummarytable::folder, reco_skim_cfg_mod::fullpath, dqm::implementation::IGetter::get(), dqm::implementation::IGetter::getMEs(), crabWrapper::key, kLogCategory_, hlt_dqm_clientPB-live_cfg::me, Skims_PA_cff::name, parseEfficiencySourceName(), hcallasereventfilter2012_cfi::prefix, dqm::implementation::NavigatorBase::setCurrentFolder(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by GEMEfficiencyHarvester::bookDetector1DEfficiency(), and bookEfficiencyAuto().

101  {
102  ibooker.setCurrentFolder(folder);
103  igetter.setCurrentFolder(folder);
104 
105  std::map<std::string, MEPair> me_pairs;
106 
107  for (const std::string& name : igetter.getMEs()) {
108  // If name doesn't start with prefix
109  // The default prefix is empty string.
110  if (name.rfind(prefix, 0) != 0) {
111  // TODO LogDebug
112  continue;
113  }
114 
115  const std::string fullpath = folder + "/" + name;
116  const MonitorElement* me = igetter.get(fullpath);
117  if (me == nullptr) {
118  edm::LogError(kLogCategory_) << "failed to get " << fullpath;
119  continue;
120  }
121 
122  const auto [parsing_success, var_name, gem_name, is_matched] = parseEfficiencySourceName(name);
123  if (not parsing_success) {
124  // TODO LogDebug
125  continue;
126  }
127 
128  const std::string key = var_name + "_" + gem_name;
129 
130  if (me_pairs.find(key) == me_pairs.end()) {
131  me_pairs[key] = {nullptr, nullptr};
132  }
133 
134  if (is_matched)
135  me_pairs[key].first = me;
136  else
137  me_pairs[key].second = me;
138  }
139 
140  // remove invalid pairs
141  for (auto it = me_pairs.cbegin(); it != me_pairs.cend();) {
142  auto [me_numerator, me_denominator] = (*it).second;
143 
144  bool okay = true;
145  if (me_numerator == nullptr) {
146  okay = false;
147 
148  } else if (me_denominator == nullptr) {
149  okay = false;
150 
151  } else if (me_numerator->kind() != me_denominator->kind()) {
152  okay = false;
153  }
154 
155  // anyways, move on to the next one
156  if (okay) {
157  it++;
158 
159  } else {
160  it = me_pairs.erase(it);
161  }
162  }
163 
164  return me_pairs;
165 }
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
virtual std::vector< std::string > getMEs() const
Definition: DQMStore.cc:759
Log< level::Error, false > LogError
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:712
std::tuple< bool, std::string, std::string, bool > parseEfficiencySourceName(std::string)

◆ parseEfficiencySourceName()

std::tuple< bool, std::string, std::string, bool > GEMDQMEfficiencyClientBase::parseEfficiencySourceName ( std::string  name)

Definition at line 19 of file GEMDQMEfficiencyClientBase.cc.

References Skims_PA_cff::name, AlCaHLTBitMon_QueryRunRegistry::string, and summarizeEdmComparisonLogfiles::success.

Referenced by GEMEfficiencyHarvester::bookDetector1DEfficiency(), and makeEfficiencySourcePair().

20  {
21  // NOTE This expression must be consistent with TODO
22  // TODO use regex
23  const bool success = TPRegexp("\\w+(?:_match)?_GE\\d1-(P|M)[0-9\\-]*").MatchB(name);
24  if (not success) {
25  return std::make_tuple(success, "", "", false);
26  }
27 
28  const std::string numerator_pattern = "_match";
29  const auto numerator_pattern_start = name.find(numerator_pattern);
30  const bool is_numerator = numerator_pattern_start != std::string::npos;
31  if (is_numerator) {
32  // keep a delimiter between a variable name and a GEM name
33  // e.g. 'muon_pt_matched_GE11-L1' --> 'muon_pt_GE11-L1'
34  name.erase(numerator_pattern_start, numerator_pattern.length());
35  }
36  // find the position of the delimiter.
37  // Because variable name can has "_", find the last one.
38  // NOTE The GEM name must not contains "_"
39  const unsigned long last_pos = name.find_last_of('_');
40 
41  // "muon_pt"
42  const std::string var_name = name.substr(0, last_pos);
43 
44  // "GE11-L1"
45  const std::string gem_name = name.substr(last_pos + 1);
46  return std::make_tuple(success, var_name, gem_name, is_numerator);
47 }

◆ parseGEMLabel()

GEMDetId GEMDQMEfficiencyClientBase::parseGEMLabel ( const std::string  gem_label,
const std::string  delimiter = "-" 
)

Definition at line 49 of file GEMDQMEfficiencyClientBase.cc.

References relativeConstraints::chamber, makeHLTPrescaleTable::delimiter, l1ctLayer2EG_cff::id, hcalRecHitTable_cff::ieta, kLogCategory_, nano_mu_digi_cff::layer, or, nano_mu_digi_cff::region, relativeConstraints::station, AlCaHLTBitMon_QueryRunRegistry::string, and unpackBuffers-CaloStage2::token.

49  {
50  // GE11-P
51  // GE11-P-L1
52  // GE11-P-E1
53 
54  int region = 0;
55  int station = 0;
56  int layer = 0;
57  int chamber = 0;
58  int ieta = 0;
59 
60  std::vector<std::string> tokens;
61 
62  // static const?
63  const std::regex re_station{"GE\\d1"};
64  const std::regex re_region{"(P|M)"};
65  const std::regex re_layer{"L\\d"};
66  const std::regex re_chamber_layer{"\\d+L\\d"};
67  const std::regex re_ieta{"E\\d+"};
68 
69  std::string::size_type last_pos = gem_label.find_first_not_of(delimiter, 0);
70  std::string::size_type pos = gem_label.find_first_of(delimiter, last_pos);
71  while ((pos != std::string::npos) or (last_pos != std::string::npos)) {
72  const std::string token = gem_label.substr(last_pos, pos - last_pos);
73 
74  if (std::regex_match(token, re_region)) {
75  region = (token == "P") ? 1 : -1;
76 
77  } else if (std::regex_match(token, re_station)) {
78  station = std::stoi(token.substr(2, 1));
79 
80  } else if (std::regex_match(token, re_layer)) {
81  layer = std::stoi(token.substr(1));
82 
83  } else if (std::regex_match(token, re_chamber_layer)) {
84  const unsigned long layer_prefix_pos = token.find('L');
85  chamber = std::stoi(token.substr(0, layer_prefix_pos));
86  layer = std::stoi(token.substr(layer_prefix_pos + 1));
87 
88  } else if (std::regex_match(token, re_ieta)) {
89  ieta = std::stoi(token.substr(1));
90 
91  } else {
92  edm::LogError(kLogCategory_) << "unknown pattern: " << gem_label << " --> " << token;
93  }
94  }
95 
96  const GEMDetId id{region, 1, station, layer, chamber, ieta};
97  return id;
98 }
Log< level::Error, false > LogError
uint16_t size_type
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12

◆ projectHistogram()

TH1F * GEMDQMEfficiencyClientBase::projectHistogram ( const TH2F *  h_2d,
const unsigned int  on_which_axis 
)

Definition at line 318 of file GEMDQMEfficiencyClientBase.cc.

References kLogCategory_, Skims_PA_cff::name, hcallasereventfilter2012_cfi::prefix, setBins(), and runGCPTkAlMap::title.

Referenced by GEMEfficiencyHarvester::bookDetector1DEfficiency().

318  {
319  if ((on_which_axis != TH1::kXaxis) and (on_which_axis != TH1::kYaxis)) {
320  edm::LogError(kLogCategory_) << "invalid choice: " << on_which_axis << "."
321  << " choose from [TH1::kXaxis (=1), TH1::kYaxis (=2)]";
322  return nullptr;
323  }
324 
325  const bool on_x_axis = (on_which_axis == TH1::kXaxis);
326 
327  // on which axis is the histogram projected?
328  const TAxis* src_proj_axis = on_x_axis ? h_2d->GetXaxis() : h_2d->GetYaxis();
329  // along which axis do the entries accumulate?
330  const TAxis* src_accum_axis = on_x_axis ? h_2d->GetYaxis() : h_2d->GetXaxis();
331 
332  const TString prefix = on_x_axis ? "_proj_on_x" : "_proj_on_y";
333  const TString name = h_2d->GetName() + prefix;
334  const TString title = h_2d->GetTitle();
335 
336  TH1F* h_proj = new TH1F();
337  h_proj->SetName(name);
338  h_proj->SetTitle(title);
339  h_proj->GetXaxis()->SetTitle(src_proj_axis->GetTitle());
340  setBins(h_proj, src_proj_axis);
341 
342  for (int proj_bin = 1; proj_bin <= src_proj_axis->GetNbins(); proj_bin++) {
343  double cumsum = 0.0;
344  for (int accum_bin = 1; accum_bin <= src_accum_axis->GetNbins(); accum_bin++) {
345  if (on_x_axis) {
346  cumsum += h_2d->GetBinContent(proj_bin, accum_bin);
347  } else {
348  cumsum += h_2d->GetBinContent(accum_bin, proj_bin);
349  }
350  }
351  h_proj->SetBinContent(proj_bin, cumsum);
352  }
353  h_proj->Sumw2();
354  return h_proj;
355 }
void setBins(TH1F *, const TAxis *)
Log< level::Error, false > LogError

◆ setBins()

void GEMDQMEfficiencyClientBase::setBins ( TH1F *  dst_hist,
const TAxis *  src_axis 
)

Definition at line 167 of file GEMDQMEfficiencyClientBase.cc.

References newFWLiteAna::bin, SelectiveReadoutTask_cfi::edges, label, and LaserClient_cfi::nbins.

Referenced by makeEfficiency(), and projectHistogram().

167  {
168  const int nbins = src_axis->GetNbins();
169  if (src_axis->IsVariableBinSize()) {
170  std::vector<double> edges;
171  edges.reserve(nbins + 1);
172 
173  for (int bin = 1; bin <= nbins; bin++) {
174  edges.push_back(src_axis->GetBinLowEdge(bin));
175  }
176  edges.push_back(src_axis->GetBinUpEdge(nbins));
177 
178  dst_hist->SetBins(nbins, &edges[0]);
179 
180  } else {
181  const double xlow = src_axis->GetBinLowEdge(1);
182  const double xup = src_axis->GetBinUpEdge(nbins);
183 
184  dst_hist->SetBins(nbins, xlow, xup);
185  }
186 
187  for (int bin = 1; bin <= nbins; bin++) {
188  const TString label{src_axis->GetBinLabel(bin)};
189  if (label.Length() > 0) {
190  dst_hist->GetXaxis()->SetBinLabel(bin, label);
191  }
192  }
193 }
char const * label

Member Data Documentation

◆ kConfidenceLevel_

const double GEMDQMEfficiencyClientBase::kConfidenceLevel_

Definition at line 34 of file GEMDQMEfficiencyClientBase.h.

Referenced by makeEfficiency().

◆ kLogCategory_

const std::string GEMDQMEfficiencyClientBase::kLogCategory_