23 , triggerResultsTag_(
"TriggerResults::HLT" )
24 , triggerResultsToken_( iC.mayConsume<
edm::TriggerResults >( triggerResultsTag_ ) )
25 , l1GtTriggerMenuLiteTag_(
"l1GtTriggerMenuLite" )
33 if ( config.
exists(
"prescaleWeightHltPaths" ) )
hltPaths_ = config.
getParameter< std::vector< std::string > >(
"prescaleWeightHltPaths" );
38 if (
verbosity_ > 0 )
edm::LogWarning(
"PrescaleWeightProvider" ) <<
"Process name not configured via TriggerResults InputTag";
63 if (
verbosity_ > 0 )
edm::LogWarning(
"PrescaleWeightProvider" ) <<
"Run initialisation failed due to failing configuration";
68 bool hltChanged(
false );
72 }
else if ( hltConfig.
size() <= 0 ) {
75 }
else if ( hltChanged ) {
78 if ( !
init_ )
return;
91 if ( !
init_ )
return 1;
101 if( ! triggerResults.
isValid() ) {
106 const int SENTINEL( -1 );
112 if ( hltIndex == hltConfig.
size() ) {
116 if ( ! triggerResults->
accept( hltIndex ) )
continue;
118 const std::vector< std::pair < bool, std::string > >& level1Seeds = hltConfig.
hltL1GTSeeds(
hltPath );
119 if ( level1Seeds.size() != 1 ) {
129 int l1Prescale( SENTINEL );
130 for (
unsigned uj = 0; uj <
l1SeedPaths_.size(); uj++ ) {
131 int l1TempPrescale( SENTINEL );
133 if ( level1Seeds.at( 0 ).first ) {
134 unsigned techBit( atoi(
l1SeedPaths_.at( uj ).c_str() ) );
136 if ( errorCode != 0 )
continue;
137 if ( ! l1GtUtils.
decision( event, techName, errorCode ) )
continue;
138 if ( errorCode != 0 )
continue;
139 l1TempPrescale = l1GtUtils.
prescaleFactor( event, techName, errorCode );
140 if ( errorCode != 0 )
continue;
144 if ( errorCode != 0 )
continue;
146 if ( errorCode != 0 )
continue;
148 if ( l1TempPrescale > 0 ){
149 if ( l1Prescale == SENTINEL || l1Prescale > l1TempPrescale ) l1Prescale = l1TempPrescale;
152 if ( l1Prescale == SENTINEL ){
153 if (
verbosity_ > 0 )
edm::LogError(
"PrescaleWeightProvider::prescaleWeight" ) <<
"Unable to find the L1 prescale for HLT path \"" <<
hltPath <<
"\"";
159 if ( hltPrescale * l1Prescale > 0 ) {
160 if ( weight == SENTINEL || weight > hltPrescale * l1Prescale ) {
161 weight = hltPrescale * l1Prescale;
166 if ( weight == SENTINEL ){
167 if (
verbosity_ > 0 )
edm::LogWarning(
"PrescaleWeightProvider::prescaleWeight" ) <<
"No valid weight for any requested HLT path, returning default weight of 1";
178 std::stringstream ss( l1Seeds );
181 while ( ss.good() && ! ss.eof() ){
183 if ( buf[0] ==
'(' || buf[ buf.size() - 1 ] ==
')' || buf ==
"AND" || buf ==
"NOT" ){
185 if (
verbosity_ > 0 )
edm::LogWarning(
"PrescaleWeightProvider::parseL1Seeds" ) <<
"Only supported logical expression is OR";
188 else if (buf ==
"OR")
continue;
unsigned int size() const
number of trigger paths in trigger table
edm::EDGetTokenT< L1GtTriggerMenuLite > l1GtTriggerMenuLiteToken_
T getParameter(std::string const &) const
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_
std::vector< std::string > l1SeedPaths_
const std::vector< std::vector< std::pair< bool, std::string > > > & hltL1GTSeeds() const
bool accept() const
Has at least one path accepted the event?
bool exists(std::string const ¶meterName) const
checks if a parameter exists
def setup(process, global_tag, zero_tesla=False)
const bool decision(const edm::Event &iEvent, const std::string &nameAlgoTechTrig, int &errorCode) const
edm::InputTag triggerResultsTag_
unsigned int triggerIndex(const std::string &triggerName) const
slot position of trigger path in trigger table (0 to size-1)
std::vector< std::string > hltPaths_
edm::EDGetTokenT< edm::TriggerResults > triggerResultsToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
std::unique_ptr< HLTPrescaleProvider > hltPrescaleProvider_
void initRun(const edm::Run &run, const edm::EventSetup &setup)
static std::string const triggerResults
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