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)
 

Private Member Functions

void configure ()
 

Private Attributes

bool configured_
 
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 edm::ParameterSet::getUntrackedParameter(), i, iLvl1IndexDefault_, lvl1Labels_, 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  , lvl1Labels_(iPS.getParameter<std::vector<std::string> >("lvl1Labels"))
32  , nLvl1Index_(lvl1Labels_.size())
34  , vpsetPrescales_(iPS.getParameterSetVector("prescaleTable"))
35  , prescaleTable_()
36  {
37  std::string lvl1DefaultLabel=
38  iPS.getUntrackedParameter<std::string>("lvl1DefaultLabel","");
39  for (unsigned int i = 0; i < lvl1Labels_.size(); ++i) {
40  if (lvl1Labels_[i] == lvl1DefaultLabel) iLvl1IndexDefault_ = i;
41  }
42 
43  iReg.watchPostBeginJob(this, &PrescaleService::postBeginJob);
44  iReg.watchPostEndJob(this, &PrescaleService::postEndJob);
45 
46  iReg.watchPreProcessEvent(this, &PrescaleService::preEventProcessing);
47  iReg.watchPostProcessEvent(this, &PrescaleService::postEventProcessing);
48 
49  iReg.watchPreModule(this, &PrescaleService::preModule);
50  iReg.watchPostModule(this, &PrescaleService::postModule);
51  }
int i
Definition: DBlmapReader.cc:9
std::vector< ParameterSet > vpsetPrescales_
void preEventProcessing(EventID const &, Timestamp const &)
void postModule(ModuleDescription const &)
void postEventProcessing(Event const &, EventSetup const &)
void preModule(ModuleDescription const &)
edm::service::PrescaleService::~PrescaleService ( )

Definition at line 54 of file PrescaleService.cc.

54  {
55  }

Member Function Documentation

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

Definition at line 83 of file PrescaleService.cc.

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

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

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

Definition at line 164 of file PrescaleService.cc.

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

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

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

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

149  {
150  if (lvl1Index >= nLvl1Index_) {
151  throw cms::Exception("InvalidLvl1Index")
152  <<"lvl1Index '"<<lvl1Index<<"' exceeds number of prescale columns";
153  }
154 
155  if (!configured_) {
156  configure();
157  }
158 
159  PrescaleTable_t::const_iterator it = prescaleTable_.find(prescaledPath);
160  return (it == prescaleTable_.end()) ? 1 : it->second[lvl1Index];
161  }
unsigned int edm::service::PrescaleService::getPrescale ( std::string const &  prescaledPath)

Definition at line 141 of file PrescaleService.cc.

References getPrescale(), and iLvl1IndexDefault_.

142  {
143  return getPrescale(iLvl1IndexDefault_, prescaledPath);
144  }
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 76 of file PrescaleService.cc.

References configure(), and configured_.

Referenced by PrescaleService().

76  {
77  if (!configured_) {
78  configure();
79  }
80  }
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 61 of file PrescaleService.cc.

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

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

61  {
62  vpsetPrescales_.clear();
63  prescaleTable_.clear();
65  lvl1Labels_ = iPS.getParameter<std::vector<std::string> >("lvl1Labels");
66  nLvl1Index_ = lvl1Labels_.size();
67  vpsetPrescales_ = iPS.getParameterSetVector("prescaleTable");
68  std::string lvl1DefaultLabel=
69  iPS.getUntrackedParameter<std::string>("lvl1DefaultLabel");
70  for (unsigned int i=0; i < lvl1Labels_.size(); ++i) {
71  if (lvl1Labels_[i] == lvl1DefaultLabel) iLvl1IndexDefault_ = i;
72  }
73  configure();
74  }
int i
Definition: DBlmapReader.cc:9
std::vector< ParameterSet > vpsetPrescales_
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 71 of file PrescaleService.h.

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

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

Definition at line 72 of file PrescaleService.h.

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

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

Definition at line 73 of file PrescaleService.h.

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

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

Definition at line 76 of file PrescaleService.h.

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

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

Definition at line 75 of file PrescaleService.h.

Referenced by configure(), and reconfigure().