22 triggerResultsTag_(
"TriggerResults::HLT"),
23 triggerResultsToken_(iC.mayConsume<edm::TriggerResults>(triggerResultsTag_)),
24 l1GtTriggerMenuLiteTag_(
"l1GtTriggerMenuLite"),
27 if (config.
exists(
"prescaleWeightVerbosityLevel"))
29 if (config.
exists(
"prescaleWeightTriggerResults"))
31 if (config.
exists(
"prescaleWeightL1GtTriggerMenuLite"))
33 if (config.
exists(
"prescaleWeightHltPaths"))
40 edm::LogWarning(
"PrescaleWeightProvider") <<
"Process name not configured via TriggerResults InputTag";
44 edm::LogWarning(
"PrescaleWeightProvider") <<
"TriggerResults label not configured";
48 edm::LogWarning(
"PrescaleWeightProvider") <<
"L1GtTriggerMenuLite label not configured";
52 edm::LogError(
"PrescaleWeightProvider") <<
"HLT paths of interest not configured";
66 edm::LogWarning(
"PrescaleWeightProvider") <<
"Run initialisation failed due to failing configuration";
71 bool hltChanged(
false);
77 }
else if (hltConfig.
size() <= 0) {
79 edm::LogError(
"PrescaleWeightProvider") <<
"HLT config size error";
81 }
else if (hltChanged) {
83 edm::LogInfo(
"PrescaleWeightProvider") <<
"HLT configuration changed";
109 if (!triggerResults.
isValid()) {
116 const int SENTINEL(-1);
122 if (hltIndex == hltConfig.
size()) {
124 edm::LogError(
"PrescaleWeightProvider::prescaleWeight") <<
"HLT path \"" << hltPath <<
"\" does not exist";
127 if (!triggerResults->accept(hltIndex))
130 const std::vector<std::pair<bool, std::string> >& level1Seeds = hltConfig.
hltL1GTSeeds(hltPath);
131 if (level1Seeds.size() != 1) {
134 <<
"HLT path \"" << hltPath <<
"\" provides too many L1 seeds";
141 <<
"Failed to parse L1 seeds for HLT path \"" << hltPath <<
"\"";
145 int l1Prescale(SENTINEL);
147 int l1TempPrescale(SENTINEL);
149 if (level1Seeds.at(0).first) {
154 if (!l1GtUtils.
decision(event, techName, errorCode))
158 l1TempPrescale = l1GtUtils.
prescaleFactor(event, techName, errorCode);
170 if (l1TempPrescale > 0) {
171 if (l1Prescale == SENTINEL || l1Prescale > l1TempPrescale)
172 l1Prescale = l1TempPrescale;
175 if (l1Prescale == SENTINEL) {
178 <<
"Unable to find the L1 prescale for HLT path \"" << hltPath <<
"\"";
184 if (hltPrescale * l1Prescale > 0) {
185 if (weight == SENTINEL || weight > hltPrescale * l1Prescale) {
186 weight = hltPrescale * l1Prescale;
191 if (weight == SENTINEL) {
194 <<
"No valid weight for any requested HLT path, returning default weight of 1";
202 std::stringstream
ss(l1Seeds);
205 while (ss.good() && !ss.eof()) {
207 if (buf[0] ==
'(' || buf[buf.size() - 1] ==
')' || buf ==
"AND" || buf ==
"NOT") {
210 edm::LogWarning(
"PrescaleWeightProvider::parseL1Seeds") <<
"Only supported logical expression is OR";
212 }
else if (buf ==
"OR")
unsigned int size() const
number of trigger paths in trigger table
EDGetTokenT< ProductType > mayConsume(edm::InputTag const &tag)
PrescaleWeightProvider(const edm::ParameterSet &config, edm::ConsumesCollector &&iC, T &module)
int prescaleWeight(const edm::Event &event, const edm::EventSetup &setup)
edm::Handle< L1GtTriggerMenuLite > triggerMenuLite_
bool exists(std::string const ¶meterName) const
checks if a parameter exists
const bool decision(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
edm::InputTag triggerResultsTag_
Log< level::Error, false > LogError
std::vector< std::string > l1SeedPaths_
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::vector< std::string > hltPaths_
std::unique_ptr< HLTPrescaleProvider > hltPrescaleProvider_
void initRun(const edm::Run &run, const edm::EventSetup &setup)
static std::string const triggerResults
edm::EDGetTokenT< L1GtTriggerMenuLite > l1GtTriggerMenuLiteToken_
const std::vector< std::vector< std::pair< bool, std::string > > > & hltL1GTSeeds() const
Log< level::Info, false > LogInfo
T getParameter(std::string const &) const
tuple config
parse the configuration file
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
Log< level::Warning, false > LogWarning
edm::InputTag l1GtTriggerMenuLiteTag_
void parseL1Seeds(const std::string &l1Seeds)
const int prescaleFactor(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
return prescale factor for a given algorithm or technical trigger