CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (unsigned int lvl1Index, std::string const &prescaledPath)
 
unsigned int getPrescale (std::string const &prescaledPath)
 
const PrescaleTable_tgetPrescaleTable () const
 
void postBeginJob ()
 
void postEndJob ()
 
void postEventProcessing (Event const &, EventSetup const &)
 
void postModule (ModuleDescription const &)
 
void preEventProcessing (EventID const &, Timestamp const &)
 
void preModule (ModuleDescription const &)
 
 PrescaleService (ParameterSet const &, ActivityRegistry &)
 
void reconfigure (ParameterSet const &ps)
 
void setIndex (unsigned int lvl1Index)
 
 ~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 configure ()
 

Private Attributes

bool configured_
 
bool forceDefault_
 
unsigned int iLvl1IndexDefault_
 
VString_t lvl1Labels_
 
unsigned int nLvl1Index_
 
PrescaleTable_t prescaleTable_
 
std::vector< ParameterSetvpsetPrescales_
 

Detailed Description

Definition at line 25 of file PrescaleService.h.

Member Typedef Documentation

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

Definition at line 54 of file PrescaleService.h.

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

Definition at line 53 of file PrescaleService.h.

Constructor & Destructor Documentation

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

Definition at line 29 of file PrescaleService.cc.

References postBeginJob(), postEndJob(), postEventProcessing(), postModule(), preEventProcessing(), preModule(), edm::ActivityRegistry::watchPostBeginJob(), edm::ActivityRegistry::watchPostEndJob(), edm::ActivityRegistry::watchPostModule(), edm::ActivityRegistry::watchPostProcessEvent(), edm::ActivityRegistry::watchPreModule(), and edm::ActivityRegistry::watchPreProcessEvent().

30  : configured_(false)
31  , forceDefault_(iPS.getParameter<bool>("forceDefault"))
32  , lvl1Labels_(iPS.getParameter<std::vector<std::string> >("lvl1Labels"))
33  , nLvl1Index_(lvl1Labels_.size())
34  , iLvl1IndexDefault_(findDefaultIndex(iPS.getParameter<std::string>("lvl1DefaultLabel"), lvl1Labels_))
35  , vpsetPrescales_(iPS.getParameterSetVector("prescaleTable"))
36  , prescaleTable_()
37  {
38  iReg.watchPostBeginJob(this, &PrescaleService::postBeginJob);
39  iReg.watchPostEndJob(this, &PrescaleService::postEndJob);
40 
41  iReg.watchPreProcessEvent(this, &PrescaleService::preEventProcessing);
42  iReg.watchPostProcessEvent(this, &PrescaleService::postEventProcessing);
43 
44  iReg.watchPreModule(this, &PrescaleService::preModule);
45  iReg.watchPostModule(this, &PrescaleService::postModule);
46  }
std::vector< ParameterSet > vpsetPrescales_
void preEventProcessing(EventID const &, Timestamp const &)
void postModule(ModuleDescription const &)
void postEventProcessing(Event const &, EventSetup const &)
void preModule(ModuleDescription const &)
static unsigned int findDefaultIndex(std::string const &label, std::vector< std::string > const &labels)
edm::service::PrescaleService::~PrescaleService ( )

Definition at line 49 of file PrescaleService.cc.

49  {
50  }

Member Function Documentation

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

Definition at line 73 of file PrescaleService.cc.

References configured_, edm::hlt::Exception, edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSet(), edm::getProcessParameterSet(), i, nLvl1Index_, EgammaValidation_cff::pathName, makeHLTPrescaleTable::prescales, prescaleTable_, and vpsetPrescales_.

Referenced by getPrescale(), postBeginJob(), and reconfigure().

74  {
75  configured_ = true;
76 
78 
79  // find all HLTPrescaler modules
80  std::set<std::string> prescalerModules;
81  std::vector<std::string> allModules=prcPS.getParameter<std::vector<std::string> >("@all_modules");
82  for(unsigned int i = 0; i < allModules.size(); ++i) {
83  ParameterSet const& pset = prcPS.getParameterSet(allModules[i]);
84  std::string moduleLabel = pset.getParameter<std::string>("@module_label");
85  std::string moduleType = pset.getParameter<std::string>("@module_type");
86  if (moduleType == "HLTPrescaler") prescalerModules.insert(moduleLabel);
87  }
88 
89  // find all paths with an HLTPrescaler and check for <=1
90  std::set<std::string> prescaledPathSet;
91  std::vector<std::string> allPaths = prcPS.getParameter<std::vector<std::string> >("@paths");
92  for (unsigned int iP = 0; iP < allPaths.size(); ++iP) {
93  std::string pathName = allPaths[iP];
94  std::vector<std::string> modules = prcPS.getParameter<std::vector<std::string> >(pathName);
95  for (unsigned int iM = 0; iM < modules.size(); ++iM) {
96  std::string moduleLabel = modules[iM];
97  if (prescalerModules.erase(moduleLabel)>0) {
98  std::set<std::string>::const_iterator itPath=prescaledPathSet.find(pathName);
99  if (itPath==prescaledPathSet.end()) {
100  prescaledPathSet.insert(pathName);
101  } else {
102  throw cms::Exception("DuplicatePrescaler")
103  <<"path '"<<pathName<<"' has more than one HLTPrescaler!";
104  }
105  }
106  }
107  }
108 
109  std::vector<std::string> prescaledPaths;
110  for (unsigned int iVPSet=0; iVPSet < vpsetPrescales_.size(); ++iVPSet) {
111  ParameterSet psetPrescales = vpsetPrescales_[iVPSet];
112  std::string pathName = psetPrescales.getParameter<std::string>("pathName");
113  if (prescaledPathSet.erase(pathName) > 0) {
114  std::vector<unsigned int> prescales =
115  psetPrescales.getParameter<std::vector<unsigned int> >("prescales");
116  if (prescales.size()!=nLvl1Index_) {
117  throw cms::Exception("PrescaleTableMismatch")
118  << "path '" << pathName << "' has unexpected number of prescales";
119  }
121  }
122  else {
123  throw cms::Exception("PrescaleTableUnknownPath")
124  <<"path '"<<pathName<<"' is invalid or does not "
125  <<"contain any HLTPrescaler";
126  }
127  }
128  }
int i
Definition: DBlmapReader.cc:9
std::vector< ParameterSet > vpsetPrescales_
ParameterSet const & getProcessParameterSet()
Definition: Registry.cc:34
void edm::service::PrescaleService::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 168 of file PrescaleService.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::add(), edm::ParameterSet::addParameter(), and edm::ParameterSetDescription::addVPSet().

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

Definition at line 157 of file PrescaleService.cc.

References i.

Referenced by reconfigure().

157  {
158  for (unsigned int i = 0; i < labels.size(); ++i) {
159  if (labels[i] == label) {
160  return i;
161  }
162  }
163  // FIXME add a LogWarning if the default is not found ?
164  return 0;
165  }
int i
Definition: DBlmapReader.cc:9
unsigned int edm::service::PrescaleService::getLvl1IndexDefault ( ) const
inline
const VString_t& edm::service::PrescaleService::getLvl1Labels ( ) const
inline
unsigned int edm::service::PrescaleService::getPrescale ( unsigned int  lvl1Index,
std::string const &  prescaledPath 
)

Definition at line 137 of file PrescaleService.cc.

References configure(), configured_, edm::hlt::Exception, forceDefault_, iLvl1IndexDefault_, nLvl1Index_, and prescaleTable_.

Referenced by HLTPrescaler::filter(), getPrescale(), and evf::FWEPWrapper::taskWebPage().

139  {
140  if (forceDefault_)
141  lvl1Index = iLvl1IndexDefault_;
142 
143  if (lvl1Index >= nLvl1Index_) {
144  throw cms::Exception("InvalidLvl1Index")
145  <<"lvl1Index '"<<lvl1Index<<"' exceeds number of prescale columns";
146  }
147 
148  if (!configured_) {
149  configure();
150  }
151 
152  PrescaleTable_t::const_iterator it = prescaleTable_.find(prescaledPath);
153  return (it == prescaleTable_.end()) ? 1 : it->second[lvl1Index];
154  }
unsigned int edm::service::PrescaleService::getPrescale ( std::string const &  prescaledPath)

Definition at line 131 of file PrescaleService.cc.

References getPrescale(), and iLvl1IndexDefault_.

132  {
133  return getPrescale(iLvl1IndexDefault_, prescaledPath);
134  }
unsigned int getPrescale(unsigned int lvl1Index, std::string const &prescaledPath)
const PrescaleTable_t& edm::service::PrescaleService::getPrescaleTable ( ) const
inline

Definition at line 57 of file PrescaleService.h.

References prescaleTable_.

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

57 {return prescaleTable_;}
void edm::service::PrescaleService::postBeginJob ( )

Definition at line 66 of file PrescaleService.cc.

References configure(), and configured_.

Referenced by PrescaleService().

66  {
67  if (!configured_) {
68  configure();
69  }
70  }
void edm::service::PrescaleService::postEndJob ( )
inline

Definition at line 47 of file PrescaleService.h.

Referenced by PrescaleService().

47 {}
void edm::service::PrescaleService::postEventProcessing ( Event const &  ,
EventSetup const &   
)
inline

Definition at line 49 of file PrescaleService.h.

Referenced by PrescaleService().

49 {}
void edm::service::PrescaleService::postModule ( ModuleDescription const &  )
inline

Definition at line 51 of file PrescaleService.h.

Referenced by PrescaleService().

51 {}
void edm::service::PrescaleService::preEventProcessing ( EventID const &  ,
Timestamp const &   
)
inline

Definition at line 48 of file PrescaleService.h.

Referenced by PrescaleService().

48 {}
void edm::service::PrescaleService::preModule ( ModuleDescription const &  )
inline

Definition at line 50 of file PrescaleService.h.

Referenced by PrescaleService().

50 {}
void edm::service::PrescaleService::reconfigure ( ParameterSet const &  ps)

Definition at line 56 of file PrescaleService.cc.

References configure(), findDefaultIndex(), edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterSetVector(), iLvl1IndexDefault_, lvl1Labels_, nLvl1Index_, prescaleTable_, and vpsetPrescales_.

Referenced by evf::FWEPWrapper::init().

56  {
57  vpsetPrescales_.clear();
58  prescaleTable_.clear();
59  lvl1Labels_ = iPS.getParameter<std::vector<std::string> >("lvl1Labels");
60  nLvl1Index_ = lvl1Labels_.size();
61  iLvl1IndexDefault_ = findDefaultIndex(iPS.getParameter<std::string>("lvl1DefaultLabel"), lvl1Labels_);
62  vpsetPrescales_ = iPS.getParameterSetVector("prescaleTable");
63  configure();
64  }
std::vector< ParameterSet > vpsetPrescales_
static unsigned int findDefaultIndex(std::string const &label, std::vector< std::string > const &labels)
void edm::service::PrescaleService::setIndex ( unsigned int  lvl1Index)
inline

Definition at line 45 of file PrescaleService.h.

References iLvl1IndexDefault_.

Referenced by evf::FWEPWrapper::getTriggerReport().

45 {iLvl1IndexDefault_ = lvl1Index;}

Member Data Documentation

bool edm::service::PrescaleService::configured_
private

Definition at line 73 of file PrescaleService.h.

Referenced by configure(), getPrescale(), and postBeginJob().

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

Definition at line 74 of file PrescaleService.h.

Referenced by getPrescale().

unsigned int edm::service::PrescaleService::iLvl1IndexDefault_
private

Definition at line 77 of file PrescaleService.h.

Referenced by getLvl1IndexDefault(), getPrescale(), reconfigure(), and setIndex().

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

Definition at line 75 of file PrescaleService.h.

Referenced by getLvl1Labels(), and reconfigure().

unsigned int edm::service::PrescaleService::nLvl1Index_
private

Definition at line 76 of file PrescaleService.h.

Referenced by configure(), getPrescale(), and reconfigure().

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

Definition at line 79 of file PrescaleService.h.

Referenced by configure(), getPrescale(), getPrescaleTable(), and reconfigure().

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

Definition at line 78 of file PrescaleService.h.

Referenced by configure(), and reconfigure().