Skip to content

Commit

Permalink
TriggerResultFilters: accept arbitrary Path names
Browse files Browse the repository at this point in the history
  - accept arbitrary Path names
  - rename the internal classes for consistency
  - update test files for the new functionality
  - prevent segfault if an L1 trigger is used in the expression without
    passing the L1 results collection
  • Loading branch information
fwyzard committed Jan 9, 2015
1 parent ebaa900 commit f126e8b
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HLTrigger_HLTfilters_TriggerExpressionL1Reader_h
#define HLTrigger_HLTfilters_TriggerExpressionL1Reader_h
#ifndef HLTrigger_HLTfilters_TriggerExpressionL1AlgoReader_h
#define HLTrigger_HLTfilters_TriggerExpressionL1AlgoReader_h

#include <vector>
#include <string>
Expand All @@ -8,15 +8,15 @@

namespace triggerExpression {

class L1Reader : public Evaluator {
class L1AlgoReader : public Evaluator {
public:
L1Reader(const std::string & pattern) :
L1AlgoReader(const std::string & pattern) :
m_pattern(pattern),
m_triggers()
{ }

bool operator()(const Data & data) const;

void init(const Data & data);

void dump(std::ostream & out) const;
Expand All @@ -28,4 +28,4 @@ class L1Reader : public Evaluator {

} // namespace triggerExpression

#endif // HLTrigger_HLTfilters_TriggerExpressionL1Reader_h
#endif // HLTrigger_HLTfilters_TriggerExpressionL1AlgoReader_h
41 changes: 14 additions & 27 deletions HLTrigger/HLTcore/interface/TriggerExpressionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>

#include "HLTrigger/HLTcore/interface/TriggerExpressionHLTReader.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionL1Reader.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionPathReader.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionL1AlgoReader.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionL1TechReader.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionOperators.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionPrescaler.h"
Expand All @@ -24,26 +24,18 @@ template <typename Iterator>
class Parser : public qi::grammar<Iterator, Evaluator*(), ascii::space_type>
{
public:
Parser() :
Parser() :
Parser::base_type(expression)
{
token_hlt %= qi::raw[qi::lexeme["HLT_" >> +(qi::char_("a-zA-Z0-9_*?"))]];
token_alca %= qi::raw[qi::lexeme["AlCa_" >> +(qi::char_("a-zA-Z0-9_*?"))]];
token_dqm %= qi::raw[qi::lexeme["DQM_" >> +(qi::char_("a-zA-Z0-9_*?"))]];
token_dst %= qi::raw[qi::lexeme["DST_" >> +(qi::char_("a-zA-Z0-9_*?"))]];
token_step %= qi::raw[qi::lexeme["generation_step"]];
token_l1 %= qi::raw[qi::lexeme["L1_" >> +(qi::char_("a-zA-Z0-9_*?"))]];
token_l1algo %= qi::raw[qi::lexeme["L1_" >> +(qi::char_("a-zA-Z0-9_*?"))]];
token_l1tech %= qi::raw[qi::lexeme["L1Tech_" >> +(qi::char_("a-zA-Z0-9_*?"))]];
token_path %= qi::raw[qi::lexeme[ +(qi::char_("a-zA-Z0-9_*?"))]];

token = ( token_hlt [qi::_val = new_<HLTReader>(qi::_1)]
| token_alca [qi::_val = new_<HLTReader>(qi::_1)]
| token_dqm [qi::_val = new_<HLTReader>(qi::_1)]
| token_dst [qi::_val = new_<HLTReader>(qi::_1)]
| token_step [qi::_val = new_<HLTReader>(qi::_1)]
| token_l1 [qi::_val = new_<L1Reader>(qi::_1)]
| token_l1tech [qi::_val = new_<L1TechReader>(qi::_1)]
| qi::lit("TRUE") [qi::_val = new_<Constant>(true)]
token = ( qi::lit("TRUE") [qi::_val = new_<Constant>(true)]
| qi::lit("FALSE") [qi::_val = new_<Constant>(false)]
| token_l1algo [qi::_val = new_<L1AlgoReader>(qi::_1)]
| token_l1tech [qi::_val = new_<L1TechReader>(qi::_1)]
| token_path [qi::_val = new_<PathReader>(qi::_1)]
);

parenthesis %= ('(' >> expression >> ')');
Expand All @@ -58,25 +50,20 @@ class Parser : public qi::grammar<Iterator, Evaluator*(), ascii::space_type>
| (qi::lit("NOT") >> operand) [qi::_val = new_<OperatorNot> (qi::_1)]
);

expression = unary [qi::_val = qi::_1]
expression = unary [qi::_val = qi::_1]
>> *(
(qi::lit("AND") >> unary) [qi::_val = new_<OperatorAnd> (qi::_val, qi::_1)]
| (qi::lit("OR") >> unary) [qi::_val = new_<OperatorOr> (qi::_val, qi::_1)]
(qi::lit("AND") >> unary) [qi::_val = new_<OperatorAnd> (qi::_val, qi::_1)]
| (qi::lit("OR") >> unary) [qi::_val = new_<OperatorOr> (qi::_val, qi::_1)]
);
}

private:
typedef qi::rule<Iterator, unused_type(), ascii::space_type> void_rule;
typedef qi::rule<Iterator, std::string(), ascii::space_type> name_rule;
typedef qi::rule<Iterator, Evaluator*(), ascii::space_type> rule;

name_rule token_hlt;
name_rule token_alca;
name_rule token_dqm;
name_rule token_dst;
name_rule token_step;
name_rule token_l1;
name_rule token_l1algo;
name_rule token_l1tech;
name_rule token_path;

rule token;
rule parenthesis;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef HLTrigger_HLTfilters_TriggerExpressionHLTReader_h
#define HLTrigger_HLTfilters_TriggerExpressionHLTReader_h
#ifndef HLTrigger_HLTfilters_TriggerExpressionPathReader_h
#define HLTrigger_HLTfilters_TriggerExpressionPathReader_h

#include <vector>
#include <string>
Expand All @@ -8,15 +8,15 @@

namespace triggerExpression {

class HLTReader : public Evaluator {
class PathReader : public Evaluator {
public:
HLTReader(const std::string & pattern) :
PathReader(const std::string & pattern) :
m_pattern(pattern),
m_triggers()
{ }

bool operator()(const Data & data) const;

void init(const Data & data);

void dump(std::ostream & out) const;
Expand All @@ -28,4 +28,4 @@ class HLTReader : public Evaluator {

} // namespace triggerExpression

#endif // HLTrigger_HLTfilters_TriggerExpressionHLTReader_h
#endif // HLTrigger_HLTfilters_TriggerExpressionPathReader_h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#include "CondFormats/L1TObjects/interface/L1GtTriggerMenuFwd.h"
#include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutRecord.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionData.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionL1Reader.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionL1AlgoReader.h"

namespace triggerExpression {

// define the result of the module from the L1 reults
bool L1Reader::operator()(const Data & data) const {
bool L1AlgoReader::operator()(const Data & data) const {
if (not data.hasL1T())
return false;

Expand All @@ -30,7 +30,7 @@ bool L1Reader::operator()(const Data & data) const {
return false;
}

void L1Reader::dump(std::ostream & out) const {
void L1AlgoReader::dump(std::ostream & out) const {
if (m_triggers.size() == 0) {
out << "FALSE";
} else if (m_triggers.size() == 1) {
Expand All @@ -43,14 +43,17 @@ void L1Reader::dump(std::ostream & out) const {
}
}

void L1Reader::init(const Data & data) {
void L1AlgoReader::init(const Data & data) {
if (not data.hasL1T())
return;

const L1GtTriggerMenu & menu = data.l1tMenu();
const L1GtTriggerMask & mask = data.l1tAlgoMask();

// clear the previous configuration
m_triggers.clear();

// check if the pattern has is a glob expression, or a single trigger name
// check if the pattern has is a glob expression, or a single trigger name
if (not edm::is_glob(m_pattern)) {
// no wildcard expression
const AlgorithmMap & triggerMap = menu.gtAlgorithmAliasMap();
Expand All @@ -65,7 +68,7 @@ void L1Reader::init(const Data & data) {
else
edm::LogWarning("Configuration") << "requested L1 trigger \"" << m_pattern << "\" does not exist in the current L1 menu";
} else {
// expand wildcards in the pattern
// expand wildcards in the pattern
bool match = false;
boost::regex re(edm::glob2reg(m_pattern));
const AlgorithmMap & triggerMap = menu.gtAlgorithmAliasMap();
Expand Down
3 changes: 3 additions & 0 deletions HLTrigger/HLTcore/src/TriggerExpressionL1TechReader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ void L1TechReader::dump(std::ostream & out) const {
}

void L1TechReader::init(const Data & data) {
if (not data.hasL1T())
return;

const L1GtTriggerMenu & menu = data.l1tMenu();
const L1GtTriggerMask & mask = data.l1tTechMask();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@
#include "FWCore/Utilities/interface/RegexMatch.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "DataFormats/Common/interface/TriggerResults.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionHLTReader.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionPathReader.h"
#include "HLTrigger/HLTcore/interface/TriggerExpressionData.h"

namespace triggerExpression {

// define the result of the module from the HLT reults
bool HLTReader::operator()(const Data & data) const {
bool PathReader::operator()(const Data & data) const {
if (not data.hasHLT())
return false;

typedef std::pair<std::string, unsigned int> value_type;
BOOST_FOREACH(const value_type & trigger, m_triggers)
if (data.hltResults().accept(trigger.second))
return true;

return false;
}

void HLTReader::dump(std::ostream & out) const {
void PathReader::dump(std::ostream & out) const {
if (m_triggers.size() == 0) {
out << "FALSE";
} else if (m_triggers.size() == 1) {
Expand All @@ -38,7 +38,7 @@ void HLTReader::dump(std::ostream & out) const {
}

// (re)initialize the module
void HLTReader::init(const Data & data) {
void PathReader::init(const Data & data) {
// clear the previous configuration
m_triggers.clear();

Expand Down
Loading

0 comments on commit f126e8b

Please sign in to comment.