CMS 3D CMS Logo

GenericTriggerEventFlag.h
Go to the documentation of this file.
1 #ifndef GenericTriggerEventFlag_H
2 #define GenericTriggerEventFlag_H
3 
4 
5 // -*- C++ -*-
6 //
7 // Package: CommonTools/TriggerUtils
8 // Class: GenericTriggerEventFlag
9 //
10 // $Id: GenericTriggerEventFlag.h,v 1.5 2012/01/19 20:17:34 vadler Exp $
11 //
36 
37 #include <memory>
38 #include <string>
39 
40 
42 
43  // Utility classes
44  std::unique_ptr<edm::ESWatcher< AlCaRecoTriggerBitsRcd > > watchDB_;
45  std::unique_ptr<L1GtUtils> l1Gt_;
46  std::unique_ptr<l1t::L1TGlobalUtil> l1uGt_;
49  // Configuration parameters
50  bool andOr_;
52  unsigned verbose_;
53  bool andOrDcs_;
56  std::vector< int > dcsPartitions_;
58  bool andOrGt_;
64  std::vector< std::string > gtLogicalExpressions_;
66  bool andOrL1_;
67  bool stage2_;
70  std::vector< std::string > l1LogicalExpressionsCache_;
71  std::vector< std::string > l1LogicalExpressions_;
73  bool andOrHlt_;
77  std::vector< std::string > hltLogicalExpressionsCache_;
78  std::vector< std::string > hltLogicalExpressions_;
80  // Switches
81  bool on_;
82  bool onDcs_;
83  bool onGt_;
84  bool onL1_;
85  bool onHlt_;
86  // Member constants
89 
90  public:
91  //so passing in the owning EDProducer is a pain for me (S. Harper)
92  //and its only needed for legacy/stage1 L1 info which is mostly obsolete now
93  //defined a new constructor which doesnt allow for the use of legacy/stage 1 L1, only stage2
94  //so you no longer have to pass in the EDProducer
95  //however I set things up such that its an error to try and configure the stage-1 L1 here
96  //hence the extra private constructor
97  //tldr: use these constructors, not the other two if unsure, if you get it wrong, there'll be an error
99  GenericTriggerEventFlag(config,iC){}
101 
102  // Constructors must be called from the ED module's c'tor
103  template <typename T>
105 
106  template <typename T>
107  GenericTriggerEventFlag( const edm::ParameterSet & config, edm::ConsumesCollector & iC, T& module );
108 
109 
110  // Public methods
111  bool on() { return on_ ; }
112  bool off() { return ( ! on_ ); }
113  void initRun( const edm::Run & run, const edm::EventSetup & setup ); // To be called from beginRun() methods
114  bool accept( const edm::Event & event, const edm::EventSetup & setup ); // To be called from analyze/filter() methods
115 
116  private:
117  GenericTriggerEventFlag( const edm::ParameterSet & config, edm::ConsumesCollector & iC, bool stage1Valid );
118  // Private methods
119 
120  // DCS
121  bool acceptDcs( const edm::Event & event );
122  bool acceptDcsPartition( const edm::Handle< DcsStatusCollection > & dcsStatus, int dcsPartition ) const;
123 
124  // GT status bits
125  bool acceptGt( const edm::Event & event );
126  bool acceptGtLogicalExpression( const edm::Event & event, std::string gtLogicalExpression );
127 
128  // L1
129  bool acceptL1( const edm::Event & event, const edm::EventSetup & setup );
130  bool acceptL1LogicalExpression( const edm::Event & event, const edm::EventSetup & setup, std::string l1LogicalExpression );
131 
132  // HLT
133  bool acceptHlt( const edm::Event & event );
134  bool acceptHltLogicalExpression( const edm::Handle< edm::TriggerResults > & hltTriggerResults, std::string hltLogicalExpression ) const;
135 
136  // Algos
137  std::string expandLogicalExpression( const std::vector< std::string > & target, const std::string & expr, bool useAnd = false ) const;
138  bool negate( std::string & word ) const;
139 
140  public:
141 
142  // Methods for expert analysis
143 
144  std::string gtDBKey() { return gtDBKey_ ; } // can be empty
145  std::string l1DBKey() { return l1DBKey_ ; } // can be empty
146  std::string hltDBKey() { return hltDBKey_; } // can be empty
147 
148  std::vector< std::string > expressionsFromDB( const std::string & key, const edm::EventSetup & setup );
149 
150 };
151 
152 template <typename T>
154  GenericTriggerEventFlag(config, iC, module) {
155 }
156 
157 template <typename T>
159  GenericTriggerEventFlag(config, iC,true) {
160  if ( config.exists( "andOrL1" ) ) {
161  if (stage2_){
162  l1uGt_ = std::make_unique<l1t::L1TGlobalUtil>(config, iC);
163  }else{
164  l1Gt_ = std::make_unique<L1GtUtils>(config, iC, false, module);
165  }
166  }
167  //these pointers are already null so no need to reset them to a nullptr
168  //if andOrL1 doesnt exist
169 }
170 
171 
172 #endif
bool negate(std::string &word) const
Checks for negated words.
std::vector< int > dcsPartitions_
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > gtInputToken_
std::vector< std::string > gtLogicalExpressions_
std::vector< std::string > hltLogicalExpressions_
bool exists(std::string const &parameterName) const
checks if a parameter exists
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:2
edm::EDGetTokenT< edm::TriggerResults > hltInputToken_
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
Definition: config.py:1
std::unique_ptr< L1GtUtils > l1Gt_
std::vector< std::string > l1LogicalExpressionsCache_
bool acceptHlt(const edm::Event &event)
Was this event accepted by the configured HLT logical expression combination?
bool acceptDcsPartition(const edm::Handle< DcsStatusCollection > &dcsStatus, int dcsPartition) const
edm::EDGetTokenT< DcsStatusCollection > dcsInputToken_
config
Definition: looper.py:291
std::vector< std::string > expressionsFromDB(const std::string &key, const edm::EventSetup &setup)
Reads and returns logical expressions from DB.
std::unique_ptr< edm::ESWatcher< AlCaRecoTriggerBitsRcd > > watchDB_
bool accept(const edm::Event &event, const edm::EventSetup &setup)
To be called from analyze/filter() methods.
bool acceptGtLogicalExpression(const edm::Event &event, std::string gtLogicalExpression)
Does this event fulfill this particular GT status bits&#39; logical expression?
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > gtEvmInputToken_
bool acceptDcs(const edm::Event &event)
std::vector< std::string > hltLogicalExpressionsCache_
bool acceptL1LogicalExpression(const edm::Event &event, const edm::EventSetup &setup, std::string l1LogicalExpression)
Was this event accepted by this particular L1 algorithms&#39; logical expression?
std::vector< std::string > l1LogicalExpressions_
GenericTriggerEventFlag(const edm::ParameterSet &config, edm::ConsumesCollector &&iC)
void initRun(const edm::Run &run, const edm::EventSetup &setup)
To be called from beginRun() methods.
std::string expandLogicalExpression(const std::vector< std::string > &target, const std::string &expr, bool useAnd=false) const
Expand wild-carded logical expressions, giving version postfixes priority.
long double T
Definition: vlib.h:208
std::unique_ptr< l1t::L1TGlobalUtil > l1uGt_
Definition: event.py:1
Definition: Run.h:45
bool acceptHltLogicalExpression(const edm::Handle< edm::TriggerResults > &hltTriggerResults, std::string hltLogicalExpression) const
Was this event accepted by this particular HLT paths&#39; logical expression?
bool acceptL1(const edm::Event &event, const edm::EventSetup &setup)
Was this event accepted by the configured L1 logical expression combination?
bool acceptGt(const edm::Event &event)
Does this event fulfill the configured GT status logical expression combination?