CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TriggerResultsFilter.cc
Go to the documentation of this file.
1 
10 #include <vector>
11 #include <string>
12 #include <sstream>
13 #include <iostream>
14 #include <iomanip>
15 #include <boost/foreach.hpp>
16 
23 
27 
28 //
29 // constructors and destructor
30 //
32  m_expression(0),
33  m_eventCache(config, consumesCollector())
34 {
35  const std::vector<std::string> & expressions = config.getParameter<std::vector<std::string> >("triggerConditions");
36  parse( expressions );
37 }
38 
40 {
41  delete m_expression;
42 }
43 
44 void
47  // # HLT results - set to empty to ignore HLT
48  desc.add<edm::InputTag>("hltResults",edm::InputTag("TriggerResults"));
49  // # L1 GT results - set to empty to ignore L1T
50  desc.add<edm::InputTag>("l1tResults",edm::InputTag("hltGtDigis"));
51  // # use L1 mask
52  desc.add<bool>("l1tIgnoreMask",false);
53  // # read L1 technical bits from PSB#9, bypassing the prescales
54  desc.add<bool>("l1techIgnorePrescales",false);
55  // # used by the definition of the L1 mask
56  desc.add<unsigned int>("daqPartitions",0x01);
57  // # throw exception on unknown trigger names
58  desc.add<bool>("throw",true);
59  // # trigger conditions
60  std::vector<std::string> triggerConditions(1,"HLT_*");
61  desc.add<std::vector<std::string> >("triggerConditions",triggerConditions);
62  descriptions.add("triggerResultsFilter", desc);
63 }
64 
65 void TriggerResultsFilter::parse(const std::vector<std::string> & expressions) {
66  // parse the logical expressions into functionals
67  if (expressions.size() == 0) {
68  edm::LogWarning("Configuration") << "Empty trigger results expression";
69  } else if (expressions.size() == 1) {
70  parse( expressions[0] );
71  } else {
72  std::stringstream expression;
73  expression << "(" << expressions[0] << ")";
74  for (unsigned int i = 1; i < expressions.size(); ++i)
75  expression << " OR (" << expressions[i] << ")";
76  parse( expression.str() );
77  }
78 }
79 
80 void TriggerResultsFilter::parse(const std::string & expression) {
81  // parse the logical expressions into functionals
82  m_expression = triggerExpression::parse( expression );
83 
84  // check if the expressions were parsed correctly
85  if (not m_expression)
86  edm::LogWarning("Configuration") << "Couldn't parse trigger results expression \"" << expression << "\"";
87 }
88 
90 {
91  if (not m_expression)
92  // no valid expression has been parsed
93  return false;
94 
95  if (not m_eventCache.setEvent(event, setup))
96  // couldn't properly access all information from the Event
97  return false;
98 
99  // if the L1 or HLT configurations have changed, (re)initialize the filters (including during the first event)
101  m_expression->init(m_eventCache);
102 
103  // log the expanded configuration
104  edm::LogInfo("Configuration") << "TriggerResultsFilter configuration updated: " << *m_expression;
105  }
106 
107  // run the trigger results filter
108  return (*m_expression)(m_eventCache);
109 }
110 
111 // register as framework plugin
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
void parse(const std::string &expression)
parse the logical expression into functionals
Evaluator * parse(const T &text)
triggerExpression::Data m_eventCache
cache some data from the Event for faster access by the m_expression
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
tuple triggerConditions
TriggerResultsFilter(const edm::ParameterSet &)
triggerExpression::Evaluator * m_expression
evaluator for the trigger condition
ParameterDescriptionBase * add(U const &iLabel, T const &value)
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
bool setEvent(const edm::Event &event, const edm::EventSetup &setup)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
bool filter(edm::Event &, const edm::EventSetup &) override