CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
edm::service::PrescaleService Class Reference

#include <PrescaleService.h>

Inheritance diagram for edm::service::PrescaleService:
edm::serviceregistry::SaveConfiguration

Public Types

typedef std::map< std::string, std::vector< unsigned int > > PrescaleTable_t
 
typedef std::vector< std::string > VString_t
 

Public Member Functions

unsigned int getLvl1IndexDefault () const
 
const VString_tgetLvl1Labels () const
 
unsigned int getPrescale (std::string const &prescaledPath) const
 
unsigned int getPrescale (unsigned int lvl1Index, std::string const &prescaledPath) const
 
const PrescaleTable_tgetPrescaleTable () const
 
 PrescaleService (ParameterSet const &, ActivityRegistry &)
 
 ~PrescaleService ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
static unsigned int findDefaultIndex (std::string const &label, std::vector< std::string > const &labels)
 

Private Member Functions

void postBeginJob ()
 
void preBeginJob (PathsAndConsumesOfModulesBase const &, ProcessContext const &)
 

Private Attributes

const bool forceDefault_
 
const unsigned int lvl1Default_
 
const VString_t lvl1Labels_
 
PrescaleTable_t prescaleTable_
 
ParameterSetID processParameterSetID_
 
const std::vector< ParameterSetvpsetPrescales_
 

Detailed Description

Definition at line 20 of file PrescaleService.h.

Member Typedef Documentation

◆ PrescaleTable_t

typedef std::map<std::string, std::vector<unsigned int> > edm::service::PrescaleService::PrescaleTable_t

Definition at line 37 of file PrescaleService.h.

◆ VString_t

typedef std::vector<std::string> edm::service::PrescaleService::VString_t

Definition at line 36 of file PrescaleService.h.

Constructor & Destructor Documentation

◆ PrescaleService()

edm::service::PrescaleService::PrescaleService ( ParameterSet const &  iPS,
ActivityRegistry iReg 
)

Definition at line 23 of file PrescaleService.cc.

References Exception, edm::ParameterSet::getParameter(), lvl1Default_, lvl1Labels_, hltMonBTagIPClient_cfi::pathName, postBeginJob(), preBeginJob(), hltrates_dqm_sourceclient-live_cfg::prescales, prescaleTable_, AlCaHLTBitMon_QueryRunRegistry::string, vpsetPrescales_, edm::ActivityRegistry::watchPostBeginJob(), and edm::ActivityRegistry::watchPreBeginJob().

24  : forceDefault_(iPS.getParameter<bool>("forceDefault")),
25  lvl1Labels_(iPS.getParameter<std::vector<std::string> >("lvl1Labels")),
26  lvl1Default_(findDefaultIndex(iPS.getParameter<std::string>("lvl1DefaultLabel"), lvl1Labels_)),
27  vpsetPrescales_(iPS.getParameterSetVector("prescaleTable")),
28  prescaleTable_() {
29  iReg.watchPreBeginJob(this, &PrescaleService::preBeginJob);
30  iReg.watchPostBeginJob(this, &PrescaleService::postBeginJob);
31 
32  // Sanity check
33  if (lvl1Default_ >= lvl1Labels_.size()) {
34  throw cms::Exception("InvalidLvl1Index")
35  << "lvl1Default_ '" << lvl1Default_ << "' exceeds number of prescale columns " << lvl1Labels_.size() << "!";
36  }
37 
38  // Check and store Prescale Table
39  for (unsigned int iVPSet = 0; iVPSet < vpsetPrescales_.size(); ++iVPSet) {
40  const ParameterSet& psetPrescales = vpsetPrescales_[iVPSet];
41  const std::string pathName = psetPrescales.getParameter<std::string>("pathName");
42  if (prescaleTable_.find(pathName) != prescaleTable_.end()) {
43  throw cms::Exception("PrescaleServiceConfigError") << " Path '" << pathName << "' found more than once!";
44  }
45  std::vector<unsigned int> prescales = psetPrescales.getParameter<std::vector<unsigned int> >("prescales");
46  if (prescales.size() != lvl1Labels_.size()) {
47  throw cms::Exception("PrescaleServiceConfigError")
48  << " Path '" << pathName << "' has " << prescales.size() << " prescales, instead of expected "
49  << lvl1Labels_.size() << "!";
50  }
52  }
53  }
void preBeginJob(PathsAndConsumesOfModulesBase const &, ProcessContext const &)
const unsigned int lvl1Default_
const std::vector< ParameterSet > vpsetPrescales_
static unsigned int findDefaultIndex(std::string const &label, std::vector< std::string > const &labels)

◆ ~PrescaleService()

edm::service::PrescaleService::~PrescaleService ( )

Definition at line 56 of file PrescaleService.cc.

56 {}

Member Function Documentation

◆ fillDescriptions()

void edm::service::PrescaleService::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 161 of file PrescaleService.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSet::addParameter(), submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

161  {
163 
164  std::vector<std::string> defaultVector;
165  defaultVector.push_back(std::string("default"));
166  desc.add<std::vector<std::string> >("lvl1Labels", defaultVector);
167 
168  // This default vector<ParameterSet> will be used when
169  // the configuration does not include this parameter and
170  // it also gets written into the generated cfi file.
171  std::vector<edm::ParameterSet> defaultVPSet;
172  edm::ParameterSet pset0;
173  pset0.addParameter<std::string>("pathName", std::string("HLTPath"));
174  std::vector<unsigned> defaultVectorU;
175  defaultVectorU.push_back(1u);
176  pset0.addParameter<std::vector<unsigned> >("prescales", defaultVectorU);
177  defaultVPSet.push_back(pset0);
178 
180  validator.add<std::string>("pathName");
181  validator.add<std::vector<unsigned int> >("prescales");
182 
183  desc.addVPSet("prescaleTable", validator, defaultVPSet);
184 
185  desc.add<std::string>("lvl1DefaultLabel", std::string("default"));
186  desc.add<bool>("forceDefault", false);
187 
188  descriptions.add("PrescaleService", desc);
189  }
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:136
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void add(std::string const &label, ParameterSetDescription const &psetDescription)

◆ findDefaultIndex()

unsigned int edm::service::PrescaleService::findDefaultIndex ( std::string const &  label,
std::vector< std::string > const &  labels 
)
static

Definition at line 151 of file PrescaleService.cc.

References mps_fire::i, label, and SummaryClient_cfi::labels.

151  {
152  for (unsigned int i = 0; i < labels.size(); ++i) {
153  if (labels[i] == label) {
154  return i;
155  }
156  }
157  return labels.size();
158  }
char const * label

◆ getLvl1IndexDefault()

unsigned int edm::service::PrescaleService::getLvl1IndexDefault ( ) const
inline

Definition at line 38 of file PrescaleService.h.

References lvl1Default_.

Referenced by HLTPrescaleRecorder::beginLuminosityBlock(), and HLTPrescaleRecorder::beginRun().

38 { return lvl1Default_; }
const unsigned int lvl1Default_

◆ getLvl1Labels()

const VString_t& edm::service::PrescaleService::getLvl1Labels ( ) const
inline

◆ getPrescale() [1/2]

unsigned int edm::service::PrescaleService::getPrescale ( std::string const &  prescaledPath) const

Definition at line 133 of file PrescaleService.cc.

References lvl1Default_.

Referenced by HLTPrescaler::filter().

133  {
134  return getPrescale(lvl1Default_, prescaledPath);
135  }
const unsigned int lvl1Default_
unsigned int getPrescale(std::string const &prescaledPath) const

◆ getPrescale() [2/2]

unsigned int edm::service::PrescaleService::getPrescale ( unsigned int  lvl1Index,
std::string const &  prescaledPath 
) const

Definition at line 138 of file PrescaleService.cc.

References Exception, forceDefault_, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, lvl1Default_, lvl1Labels_, and prescaleTable_.

138  {
139  if (forceDefault_)
140  lvl1Index = lvl1Default_;
141 
142  if (lvl1Index >= lvl1Labels_.size()) {
143  throw cms::Exception("InvalidLvl1Index")
144  << "lvl1Index '" << lvl1Index << "' exceeds number of prescale columns " << lvl1Labels_.size() << "!";
145  }
146  PrescaleTable_t::const_iterator it = prescaleTable_.find(prescaledPath);
147  return (it == prescaleTable_.end()) ? 1 : it->second[lvl1Index];
148  }
const unsigned int lvl1Default_

◆ getPrescaleTable()

const PrescaleTable_t& edm::service::PrescaleService::getPrescaleTable ( ) const
inline

Definition at line 40 of file PrescaleService.h.

References prescaleTable_.

Referenced by HLTPrescaleRecorder::beginLuminosityBlock(), and HLTPrescaleRecorder::beginRun().

40 { return prescaleTable_; }

◆ postBeginJob()

void edm::service::PrescaleService::postBeginJob ( )
private

Definition at line 66 of file PrescaleService.cc.

References edmTracerLogToSimpleConfig::allModules, mutracking_dqm_sourceclient-live_cfg::allPaths, relativeConstraints::empty, Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), edm::getParameterSet(), mps_fire::i, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, genParticles_cff::map, HerwigMaxPtPartonFilter_cfi::moduleLabel, hltMonBTagIPClient_cfi::pathName, prescaleTable_, processParameterSetID_, muonDTDigis_cfi::pset, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by PrescaleService().

66  {
67  // Acess to Process ParameterSet needed - can't be done in c'tor
69  // Label of HLTPrescaler on each path, keyed on pathName
70  std::map<std::string, std::string> path2module;
71  // Name of path for each HLTPrescaler, keyed on moduleLabel
72  std::map<std::string, std::string> module2path;
73 
74  // Check process config:
75  // * each path contains at most one HLTPrescaler instance
76  // * each HLTPrescaler instance is part of at most one path
77  // * each HLTPrescaler instance is part of at least one ptah
78 
79  // Find all HLTPrescaler instances
80  const std::vector<std::string> allModules = prcPS.getParameter<std::vector<std::string> >("@all_modules");
81  for (unsigned int i = 0; i < allModules.size(); ++i) {
82  ParameterSet const& pset = prcPS.getParameterSet(allModules[i]);
83  const std::string moduleLabel = pset.getParameter<std::string>("@module_label");
84  const std::string moduleType = pset.getParameter<std::string>("@module_type");
85  if (moduleType == "HLTPrescaler")
86  module2path[moduleLabel] = "";
87  }
88  // Check all modules on all paths
89  const std::vector<std::string> allPaths = prcPS.getParameter<std::vector<std::string> >("@paths");
90  for (unsigned int iP = 0; iP < allPaths.size(); ++iP) {
91  const std::string& pathName = allPaths[iP];
92  std::vector<std::string> modules = prcPS.getParameter<std::vector<std::string> >(pathName);
93  for (unsigned int iM = 0; iM < modules.size(); ++iM) {
94  const std::string& moduleLabel = modules[iM];
95  if (module2path.find(moduleLabel) != module2path.end()) {
96  if (path2module.find(pathName) == path2module.end()) {
97  path2module[pathName] = moduleLabel;
98  } else {
99  throw cms::Exception("PrescaleServiceConfigError")
100  << "Path '" << pathName << "' with (>1) HLTPrescalers: " << path2module[pathName] << "+"
101  << moduleLabel << "!";
102  }
103  if (module2path[moduleLabel].empty()) {
104  module2path[moduleLabel] = pathName;
105  } else {
106  throw cms::Exception("PrescaleServiceConfigError")
107  << " HLTPrescaler '" << moduleLabel << "' on (>1) Paths: " << module2path[moduleLabel] << "+"
108  << pathName << "!";
109  }
110  }
111  }
112  }
113  // Check all HLTPrescaler instances are on a path
114  for (std::map<std::string, std::string>::const_iterator it = module2path.begin(); it != module2path.end(); ++it) {
115  if (it->second.empty()) {
116  throw cms::Exception("PrescaleServiceConfigError")
117  << " HLTPrescaler '" << it->first << "' not found on any path!";
118  }
119  }
120 
121  // Check paths stored Prescale Table: each path is actually in the process config
122  for (std::map<std::string, std::vector<unsigned int> >::const_iterator it = prescaleTable_.begin();
123  it != prescaleTable_.end();
124  ++it) {
125  if (path2module.find(it->first) == path2module.end()) {
126  throw cms::Exception("PrescaleServiceConfigError")
127  << " Path '" << it->first << "' is unknown or does not contain any HLTPrescaler!";
128  }
129  }
130  }
ParameterSet const & getParameterSet(ParameterSetID const &id)
ParameterSetID processParameterSetID_

◆ preBeginJob()

void edm::service::PrescaleService::preBeginJob ( PathsAndConsumesOfModulesBase const &  ,
ProcessContext const &  processContext 
)
private

Definition at line 60 of file PrescaleService.cc.

References edm::Hash< I >::isValid(), edm::ProcessContext::parameterSetID(), and processParameterSetID_.

Referenced by PrescaleService().

60  {
62  processParameterSetID_ = processContext.parameterSetID();
63  }
64  }
bool isValid() const
Definition: Hash.h:141
ParameterSetID processParameterSetID_

Member Data Documentation

◆ forceDefault_

const bool edm::service::PrescaleService::forceDefault_
private

Definition at line 55 of file PrescaleService.h.

Referenced by getPrescale().

◆ lvl1Default_

const unsigned int edm::service::PrescaleService::lvl1Default_
private

Definition at line 57 of file PrescaleService.h.

Referenced by getLvl1IndexDefault(), getPrescale(), and PrescaleService().

◆ lvl1Labels_

const VString_t edm::service::PrescaleService::lvl1Labels_
private

Definition at line 56 of file PrescaleService.h.

Referenced by getLvl1Labels(), getPrescale(), and PrescaleService().

◆ prescaleTable_

PrescaleTable_t edm::service::PrescaleService::prescaleTable_
private

Definition at line 59 of file PrescaleService.h.

Referenced by getPrescale(), getPrescaleTable(), postBeginJob(), and PrescaleService().

◆ processParameterSetID_

ParameterSetID edm::service::PrescaleService::processParameterSetID_
private

Definition at line 60 of file PrescaleService.h.

Referenced by postBeginJob(), and preBeginJob().

◆ vpsetPrescales_

const std::vector<ParameterSet> edm::service::PrescaleService::vpsetPrescales_
private

Definition at line 58 of file PrescaleService.h.

Referenced by PrescaleService().