CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes
HLTGenValClient Class Reference
Inheritance diagram for HLTGenValClient:
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  EfficOption
 

Public Member Functions

void computeEfficiency (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &dirName, const std::string &efficMEName, const std::string &efficMETitle, const std::string &numeratorMEName, const std::string &denominatorMEName)
 
void dqmEndJob (DQMStore::IBooker &, DQMStore::IGetter &) override
 
void dqmEndLuminosityBlock (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 
void dqmEndRun (DQMStore::IBooker &, DQMStore::IGetter &, edm::Run const &, edm::EventSetup const &) override
 
 HLTGenValClient (const edm::ParameterSet &pset)
 
 ~HLTGenValClient () 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 ()
 
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 Member Functions

void findAllSubdirectories (DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
 
void genericEff (TH1 *denom, TH1 *numer, MonitorElement *efficiencyHist)
 
void makeAllPlots (DQMStore::IBooker &, DQMStore::IGetter &)
 

Private Attributes

std::vector< EfficOptionefficOptions_
 
bool isWildcardUsed_
 
bool makeGlobalEffPlot_
 
TPRegexp metacharacters_
 
TPRegexp nonPerlWildcard_
 
std::string outputFileName_
 
bool runOnEndJob_
 
bool runOnEndLumi_
 
const std::string separator_ = "__"
 
std::vector< std::string > subDirs_
 
DQMStoretheDQM
 
unsigned int verbose_
 

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

Definition at line 36 of file HLTGenValClient.cc.

Constructor & Destructor Documentation

◆ HLTGenValClient()

HLTGenValClient::HLTGenValClient ( const edm::ParameterSet pset)

Definition at line 89 of file HLTGenValClient.cc.

References isWildcardUsed_, makeGlobalEffPlot_, outputFileName_, muonDTDigis_cfi::pset, runOnEndJob_, runOnEndLumi_, AlCaHLTBitMon_QueryRunRegistry::string, subDirs_, and verbose_.

90  : metacharacters_("[\\^\\$\\.\\*\\+\\?\\|\\(\\)\\{\\}\\[\\]]"), nonPerlWildcard_("\\w\\*|^\\*") {
91  boost::escaped_list_separator<char> commonEscapes("\\", " \t", "\'");
92 
93  verbose_ = pset.getUntrackedParameter<unsigned int>("verbose", 0);
94  runOnEndLumi_ = pset.getUntrackedParameter<bool>("runOnEndLumi", false);
95  runOnEndJob_ = pset.getUntrackedParameter<bool>("runOnEndJob", true);
96  makeGlobalEffPlot_ = pset.getUntrackedParameter<bool>("makeGlobalEffienciesPlot", true);
97 
98  outputFileName_ = pset.getUntrackedParameter<std::string>("outputFileName", "");
99  subDirs_ = pset.getUntrackedParameter<std::vector<std::string>>("subDirs");
100 
101  isWildcardUsed_ = false;
102 }
std::vector< std::string > subDirs_
TPRegexp metacharacters_
TPRegexp nonPerlWildcard_
unsigned int verbose_
std::string outputFileName_

◆ ~HLTGenValClient()

HLTGenValClient::~HLTGenValClient ( )
inlineoverride

Definition at line 39 of file HLTGenValClient.cc.

39 {};

Member Function Documentation

◆ computeEfficiency()

void HLTGenValClient::computeEfficiency ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const std::string &  dirName,
const std::string &  efficMEName,
const std::string &  efficMETitle,
const std::string &  numeratorMEName,
const std::string &  denominatorMEName 
)

Definition at line 244 of file HLTGenValClient.cc.

References dqm::implementation::IBooker::book1D(), dqm::implementation::IBooker::book2D(), dqm::implementation::IBooker::book3D(), dqm::implementation::NavigatorBase::cd(), dqm::implementation::IGetter::dirExists(), TrackerOfflineValidation_Dqm_cff::dirName, genericEff(), dqm::implementation::IGetter::get(), dqm::impl::MonitorElement::getEntries(), dqm::legacy::MonitorElement::getTH1(), dqm::legacy::MonitorElement::getTH1F(), isWildcardUsed_, makeGlobalEffPlot_, dqm::implementation::NavigatorBase::setCurrentFolder(), dqm::impl::MonitorElement::setEfficiencyFlag(), dqm::impl::MonitorElement::setEntries(), mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, and verbose_.

Referenced by makeAllPlots().

250  {
251  // checking if directory exists
252  if (!igetter.dirExists(dirName)) {
253  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
254  edm::LogError("HLTGenValClient") << "computeEfficiency() : "
255  << "Cannot find sub-directory " << dirName << std::endl;
256  }
257  return;
258  }
259 
260  ibooker.cd();
261 
262  // getting input MEs
263  HLTGenValClient::MonitorElement* denominatorME = igetter.get(dirName + "/" + denominatorMEName);
264  HLTGenValClient::MonitorElement* numeratorME = igetter.get(dirName + "/" + numeratorMEName);
265 
266  // checking of input MEs exist
267  if (!denominatorME) {
268  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
269  edm::LogError("HLTGenValClient") << "computeEfficiency() : "
270  << "No denominator-ME '" << denominatorMEName << "' found\n";
271  }
272  return;
273  }
274  if (!numeratorME) {
275  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
276  edm::LogError("HLTGenValClient") << "computeEfficiency() : "
277  << "No numerator-ME '" << numeratorMEName << "' found\n";
278  }
279  return;
280  }
281 
282  // Treat everything as the base class, TH1
283  TH1* hDenominator = denominatorME->getTH1();
284  TH1* hNumerator = numeratorME->getTH1();
285 
286  // check if TH1 extraction has succeeded
287  if (!hDenominator || !hNumerator) {
288  if (verbose_ >= 2 || (verbose_ == 1 && !isWildcardUsed_)) {
289  edm::LogError("HLTGenValClient") << "computeEfficiency() : "
290  << "Cannot create TH1 from ME\n";
291  }
292  return;
293  }
294 
295  // preparing efficiency output path and name
296  std::string efficDir = dirName;
297  std::string newEfficMEName = efficMEName;
298  std::string::size_type shiftPos;
299  if (std::string::npos != (shiftPos = efficMEName.rfind('/'))) {
300  efficDir += "/" + efficMEName.substr(0, shiftPos);
301  newEfficMEName.erase(0, shiftPos + 1);
302  }
303  ibooker.setCurrentFolder(efficDir);
304 
305  // creating the efficiency MonitorElement
306  HLTGenValClient::MonitorElement* efficME = nullptr;
307 
308  // We need to know what kind of TH1 we have
309  // That information is obtained from the class name of the hDenominator
310  // Then we use the appropriate booking function
311  TH1* efficHist = static_cast<TH1*>(hDenominator->Clone(newEfficMEName.c_str()));
312  efficHist->SetDirectory(nullptr);
313  efficHist->SetTitle(efficMETitle.c_str());
314  TClass* myHistClass = efficHist->IsA();
315  std::string histClassName = myHistClass->GetName();
316  if (histClassName == "TH1F") {
317  efficME = ibooker.book1D(newEfficMEName, (TH1F*)efficHist);
318  } else if (histClassName == "TH2F") {
319  efficME = ibooker.book2D(newEfficMEName, (TH2F*)efficHist);
320  } else if (histClassName == "TH3F") {
321  efficME = ibooker.book3D(newEfficMEName, (TH3F*)efficHist);
322  }
323  delete efficHist;
324 
325  // checking whether efficME was succesfully created
326  if (!efficME) {
327  edm::LogError("HLTGenValClient") << "computeEfficiency() : "
328  << "Cannot book effic-ME from the DQM\n";
329  return;
330  }
331 
332  // actually calculating the efficiency and filling the ME
333  genericEff(hDenominator, hNumerator, efficME);
334  efficME->setEntries(denominatorME->getEntries());
335 
336  // Putting total efficiency in "GLobal efficiencies" histogram
337  if (makeGlobalEffPlot_) {
338  // getting global efficiency ME
339  HLTGenValClient::MonitorElement* globalEfficME = igetter.get(efficDir + "/globalEfficiencies");
340  if (!globalEfficME) // in case it does not exist yet, we create it
341  globalEfficME = ibooker.book1D("globalEfficiencies", "Global efficiencies", 1, 0, 1);
342  if (!globalEfficME) { // error handling in case creation failed
343  edm::LogError("HLTGenValClient") << "computeEfficiency() : "
344  << "Cannot book globalEffic-ME from the DQM\n";
345  return;
346  }
347  globalEfficME->setEfficiencyFlag();
348 
349  // extracting histogram
350  TH1F* hGlobalEffic = globalEfficME->getTH1F();
351  if (!hGlobalEffic) {
352  edm::LogError("HLTGenValClient") << "computeEfficiency() : "
353  << "Cannot create TH1F from ME, globalEfficME\n";
354  return;
355  }
356 
357  // getting total counts
358  const float nDenominatorAll = hDenominator->GetEntries();
359  const float nNumeratorAll = hNumerator->GetEntries();
360 
361  // calculating total efficiency
362  float efficAll = 0;
363  float errorAll = 0;
364  efficAll = nDenominatorAll ? nNumeratorAll / nDenominatorAll : 0;
365  errorAll = nDenominatorAll && efficAll < 1 ? sqrt(efficAll * (1 - efficAll) / nDenominatorAll) : 0;
366 
367  // Filling the histogram bin
368  const int iBin = hGlobalEffic->Fill(newEfficMEName.c_str(), 0);
369  hGlobalEffic->SetBinContent(iBin, efficAll);
370  hGlobalEffic->SetBinError(iBin, errorAll);
371  }
372 }
void genericEff(TH1 *denom, TH1 *numer, MonitorElement *efficiencyHist)
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
virtual void setEntries(double nentries)
set # of entries
unsigned int verbose_
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:754
Log< level::Error, false > LogError
uint16_t size_type
T sqrt(T t)
Definition: SSEVec.h:19
virtual double getEntries() const
get # of entries
virtual TH1F * getTH1F() const
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
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:697
virtual TH1 * getTH1() const
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * book3D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, int nchZ, double lowZ, double highZ, FUNC onbooking=NOOP())
Definition: DQMStore.h:367

◆ dqmEndJob()

void HLTGenValClient::dqmEndJob ( DQMStore::IBooker ,
DQMStore::IGetter  
)
inlineoverridevirtual

Implements DQMEDHarvester.

Definition at line 46 of file HLTGenValClient.cc.

46 {};

◆ dqmEndLuminosityBlock()

void HLTGenValClient::dqmEndLuminosityBlock ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
overridevirtual

Reimplemented from DQMEDHarvester.

Definition at line 104 of file HLTGenValClient.cc.

References makeAllPlots(), and runOnEndLumi_.

107  {
108  if (runOnEndLumi_) {
109  makeAllPlots(ibooker, igetter);
110  }
111 }
void makeAllPlots(DQMStore::IBooker &, DQMStore::IGetter &)

◆ dqmEndRun()

void HLTGenValClient::dqmEndRun ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
edm::Run const &  ,
edm::EventSetup const &   
)
overridevirtual

Reimplemented from DQMEDHarvester.

Definition at line 113 of file HLTGenValClient.cc.

References makeAllPlots(), Utilities::operator, outputFileName_, runOnEndJob_, dqm::implementation::DQMStore::save(), and theDQM.

116  {
117  // Create new MEs in endRun, even though we are requested to do it in endJob.
118  // This gives the QTests a chance to run, before summaries are created in
119  // endJob. The negative side effect is that we cannot run the GenericClient
120  // for plots produced in Harvesting, but that seems rather rare.
121  //
122  // It is important that this is still save in the presence of multiple runs,
123  // first because in multi-run harvesting, we accumulate statistics over all
124  // runs and have full statistics at the endRun of the last run, and second,
125  // because we set the efficiencyFlag so any further aggregation should produce
126  // correct results. Also, all operations should be idempotent; running them
127  // more than once does no harm.
128 
130 
131  if (runOnEndJob_) {
132  makeAllPlots(ibooker, igetter);
133  }
134 
135  if (!outputFileName_.empty())
137 }
std::string outputFileName_
void makeAllPlots(DQMStore::IBooker &, DQMStore::IGetter &)
DQM_DEPRECATED void save(std::string const &filename, std::string const &path="")
Definition: DQMStore.cc:808

◆ findAllSubdirectories()

void HLTGenValClient::findAllSubdirectories ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter,
std::string  dir,
std::set< std::string > *  myList,
const TString &  pattern = TString("") 
)
private

Definition at line 376 of file HLTGenValClient.cc.

References dqm::implementation::NavigatorBase::cd(), DeadROC_duringRun::dir, dqm::implementation::IGetter::dirExists(), TrackerOfflineValidation_Dqm_cff::dirName, dqm::implementation::IGetter::getSubdirs(), PatBasicFWLiteJetAnalyzer_Selector_cfg::myList, nonPerlWildcard_, and fetchall_from_DQM_v2::regexp.

Referenced by makeAllPlots().

380  {
381  TString patternTmp = _pattern;
382 
383  // checking if directory exists
384  if (!igetter.dirExists(dir)) {
385  edm::LogError("HLTGenValClient") << " HLTGenValClient::findAllSubdirectories ==> Missing folder " << dir << " !!!";
386  return;
387  }
388 
389  // replacing wildcards
390  if (patternTmp != "") {
391  if (patternTmp.Contains(nonPerlWildcard_))
392  patternTmp.ReplaceAll("*", ".*");
393  TPRegexp regexp(patternTmp);
394  ibooker.cd(dir);
395  std::vector<std::string> foundDirs = igetter.getSubdirs();
396  for (const auto& iDir : foundDirs) {
397  TString dirName = iDir.substr(iDir.rfind('/') + 1, iDir.length());
398  if (dirName.Contains(regexp))
399  findAllSubdirectories(ibooker, igetter, iDir, myList);
400  }
401  } else if (igetter.dirExists(dir)) {
402  // we have found a subdirectory - adding it to the list
403  myList->insert(dir);
404 
405  // moving into the found subdirectory and recursively continue
406  ibooker.cd(dir);
407  findAllSubdirectories(ibooker, igetter, dir, myList, "*");
408 
409  } else {
410  // error handling in case found directory does not exist
411  edm::LogError("HLTGenValClient") << "Trying to find sub-directories of " << dir << " failed because " << dir
412  << " does not exist";
413  }
414  return;
415 }
TPRegexp nonPerlWildcard_
virtual bool dirExists(std::string const &path) const
Definition: DQMStore.cc:754
Log< level::Error, false > LogError
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
virtual DQM_DEPRECATED std::vector< std::string > getSubdirs() const
Definition: DQMStore.cc:724

◆ genericEff()

void HLTGenValClient::genericEff ( TH1 *  denom,
TH1 *  numer,
MonitorElement efficiencyHist 
)
private

Definition at line 418 of file HLTGenValClient.cc.

References makePileupJSON::denom, dqm::impl::MonitorElement::setBinContent(), dqm::impl::MonitorElement::setBinError(), dqm::impl::MonitorElement::setEfficiencyFlag(), and mathSSE::sqrt().

Referenced by computeEfficiency().

418  {
419  // looping over all bins. Up to three dimentions can be handled
420  // in case of less dimensions, the inner for loops are excecuted only once
421  for (int iBinX = 1; iBinX < denom->GetNbinsX() + 1; iBinX++) {
422  for (int iBinY = 1; iBinY < denom->GetNbinsY() + 1; iBinY++) {
423  for (int iBinZ = 1; iBinZ < denom->GetNbinsZ() + 1; iBinZ++) {
424  int globalBinNum = denom->GetBin(iBinX, iBinY, iBinZ);
425 
426  // getting numerator and denominator values
427  float numerVal = numer->GetBinContent(globalBinNum);
428  float denomVal = denom->GetBinContent(globalBinNum);
429 
430  // calculating effiency
431  float effVal = 0;
432  effVal = denomVal ? numerVal / denomVal : 0;
433 
434  // calculating error
435  float errVal = 0;
436  errVal = (denomVal && (effVal <= 1)) ? sqrt(effVal * (1 - effVal) / denomVal) : 0;
437 
438  // inserting value into the efficiency histogram
439  efficiencyHist->setBinContent(globalBinNum, effVal);
440  efficiencyHist->setBinError(globalBinNum, errVal);
441  efficiencyHist->setEfficiencyFlag();
442  }
443  }
444  }
445 }
T sqrt(T t)
Definition: SSEVec.h:19
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)

◆ makeAllPlots()

void HLTGenValClient::makeAllPlots ( DQMStore::IBooker ibooker,
DQMStore::IGetter igetter 
)
private

Definition at line 140 of file HLTGenValClient.cc.

References computeEfficiency(), Skims_PA_cff::content, relmon_rootfiles_spy::contents, TrackerOfflineValidation_Dqm_cff::dirName, efficOptions_, findAllSubdirectories(), dqm::implementation::IGetter::getAllContents(), isWildcardUsed_, metacharacters_, Skims_PA_cff::name, runTheMatrix::opt, topSingleLeptonDQM_PU_cfi::pattern, separator_, AlCaHLTBitMon_QueryRunRegistry::string, PostProcessorHcalIsoTrack_cfi::subDir, subDirs_, makeGlobalPositionRcd_cfg::tag, and unpackBuffers-CaloStage2::token.

Referenced by dqmEndLuminosityBlock(), and dqmEndRun().

140  {
141  // Process wildcard in the sub-directory
142  std::set<std::string> subDirSet;
143  for (auto& subDir : subDirs_) {
144  if (subDir[subDir.size() - 1] == '/')
145  subDir.erase(subDir.size() - 1);
146 
147  if (TString(subDir).Contains(metacharacters_)) {
148  isWildcardUsed_ = true;
149 
150  const std::string::size_type shiftPos = subDir.rfind('/');
151  const std::string searchPath = subDir.substr(0, shiftPos);
152  const std::string pattern = subDir.substr(shiftPos + 1, subDir.length());
153 
154  findAllSubdirectories(ibooker, igetter, searchPath, &subDirSet, pattern);
155 
156  } else {
157  subDirSet.insert(subDir);
158  }
159  }
160 
161  // loop through all sub-directories
162  // from the current implementation of the HLTGenValSource, we expect all histograms in a single directory
163  // however, this module is also capable of handling sub-directories, if needed
164  for (std::set<std::string>::const_iterator iSubDir = subDirSet.begin(); iSubDir != subDirSet.end(); ++iSubDir) {
165  const std::string& dirName = *iSubDir;
166 
167  // construct efficiency options automatically from systematically names histograms^
168  const auto contents = igetter.getAllContents(dirName);
169  for (const auto& content : contents) {
170  // splitting the input string
171  std::string name = content->getName();
172  std::vector<std::string> seglist;
173  size_t pos = 0;
175  while ((pos = name.find(separator_)) != std::string::npos) {
176  token = name.substr(0, pos);
177  seglist.push_back(token);
178  name.erase(0, pos + separator_.length());
179  }
180  seglist.push_back(name);
181 
182  if (seglist.size() == 4 ||
183  seglist.size() ==
184  5) { // this should be the only "proper" files we want to look at. 5 means that a custom tag was set!
185  if (seglist.at(2) == "GEN")
186  continue; // this is the "before" hist, we won't create an effiency from this alone
187 
188  // if a fifth entry exists, it is expected to be the custom tag
189  std::string tag = "";
190  if (seglist.size() == 5)
191  tag = seglist.at(4);
192 
193  // first we determing whether we have the 1D or 2D case
194  if (seglist.at(3).rfind("2D", 0) == 0) {
195  // 2D case
196  EfficOption opt;
197  opt.name = seglist.at(0) + separator_ + seglist.at(1) + separator_ + seglist.at(2) + separator_ +
198  seglist.at(3) + separator_ + "eff"; // efficiency histogram name
199  opt.title = seglist.at(0) + " " + seglist.at(1) + " " + seglist.at(2) + " " + seglist.at(3) +
200  " efficiency"; // efficiency histogram title
201  opt.numerator = content->getName(); // numerator histogram (after a filter)
202  opt.denominator = seglist.at(0) + separator_ + seglist.at(1) + separator_ + "GEN" + separator_ +
203  seglist.at(3); // denominator histogram (before all filters)
204 
205  efficOptions_.push_back(opt);
206 
207  } else {
208  // 1D case
209  EfficOption opt;
210  opt.name = seglist.at(0) + separator_ + seglist.at(1) + separator_ + seglist.at(2) + separator_ +
211  seglist.at(3) + separator_ + "eff"; // efficiency histogram name
212  opt.title = seglist.at(0) + " " + seglist.at(1) + " " + seglist.at(2) + " " + seglist.at(3) +
213  " efficiency"; // efficiency histogram title
214  opt.numerator = content->getName(); // numerator histogram (after a filter)
215  opt.denominator = seglist.at(0) + separator_ + seglist.at(1) + separator_ + "GEN" + separator_ +
216  seglist.at(3); // denominator histogram (before all filters)
217 
218  // propagating the custom tag to the efficiency
219  if (!tag.empty()) {
220  opt.name += separator_ + tag;
221  opt.title += " " + tag;
222  opt.denominator += separator_ + tag;
223  }
224 
225  efficOptions_.push_back(opt);
226  }
227  }
228  }
229 
230  // now that we have all EfficOptions, we create the histograms
231  for (const auto& efficOption : efficOptions_) {
232  computeEfficiency(ibooker,
233  igetter,
234  dirName,
235  efficOption.name,
236  efficOption.title,
237  efficOption.numerator,
238  efficOption.denominator);
239  }
240  }
241 }
std::vector< std::string > subDirs_
std::vector< EfficOption > efficOptions_
TPRegexp metacharacters_
void computeEfficiency(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, const std::string &dirName, const std::string &efficMEName, const std::string &efficMETitle, const std::string &numeratorMEName, const std::string &denominatorMEName)
const std::string separator_
uint16_t size_type
void findAllSubdirectories(DQMStore::IBooker &ibooker, DQMStore::IGetter &igetter, std::string dir, std::set< std::string > *myList, const TString &pattern)
virtual std::vector< dqm::harvesting::MonitorElement * > getAllContents(std::string const &path) const
Definition: DQMStore.cc:626

Member Data Documentation

◆ efficOptions_

std::vector<EfficOption> HLTGenValClient::efficOptions_
private

Definition at line 74 of file HLTGenValClient.cc.

Referenced by makeAllPlots().

◆ isWildcardUsed_

bool HLTGenValClient::isWildcardUsed_
private

Definition at line 68 of file HLTGenValClient.cc.

Referenced by computeEfficiency(), HLTGenValClient(), and makeAllPlots().

◆ makeGlobalEffPlot_

bool HLTGenValClient::makeGlobalEffPlot_
private

Definition at line 67 of file HLTGenValClient.cc.

Referenced by computeEfficiency(), and HLTGenValClient().

◆ metacharacters_

TPRegexp HLTGenValClient::metacharacters_
private

Definition at line 62 of file HLTGenValClient.cc.

Referenced by makeAllPlots().

◆ nonPerlWildcard_

TPRegexp HLTGenValClient::nonPerlWildcard_
private

Definition at line 63 of file HLTGenValClient.cc.

Referenced by findAllSubdirectories().

◆ outputFileName_

std::string HLTGenValClient::outputFileName_
private

Definition at line 72 of file HLTGenValClient.cc.

Referenced by dqmEndRun(), and HLTGenValClient().

◆ runOnEndJob_

bool HLTGenValClient::runOnEndJob_
private

Definition at line 66 of file HLTGenValClient.cc.

Referenced by dqmEndRun(), and HLTGenValClient().

◆ runOnEndLumi_

bool HLTGenValClient::runOnEndLumi_
private

Definition at line 65 of file HLTGenValClient.cc.

Referenced by dqmEndLuminosityBlock(), and HLTGenValClient().

◆ separator_

const std::string HLTGenValClient::separator_ = "__"
private

Definition at line 76 of file HLTGenValClient.cc.

Referenced by makeAllPlots().

◆ subDirs_

std::vector<std::string> HLTGenValClient::subDirs_
private

Definition at line 71 of file HLTGenValClient.cc.

Referenced by HLTGenValClient(), and makeAllPlots().

◆ theDQM

DQMStore* HLTGenValClient::theDQM
private

Definition at line 70 of file HLTGenValClient.cc.

Referenced by dqmEndRun().

◆ verbose_

unsigned int HLTGenValClient::verbose_
private

Definition at line 64 of file HLTGenValClient.cc.

Referenced by computeEfficiency(), and HLTGenValClient().