CMS 3D CMS Logo

TriggerPath.h
Go to the documentation of this file.
1 #ifndef DataFormats_PatCandidates_TriggerPath_h
2 #define DataFormats_PatCandidates_TriggerPath_h
3 
4 // -*- C++ -*-
5 //
6 // Package: PatCandidates
7 // Class: pat::TriggerPath
8 //
9 //
10 /*
11  \class pat::TriggerPath TriggerPath.h "DataFormats/PatCandidates/interface/TriggerPath.h"
12  \brief Analysis-level HLTrigger path class
13 
14  TriggerPath implements a container for trigger paths' information within the 'pat' namespace.
15  For detailed information, consult
16  https://twiki.cern.ch/twiki/bin/view/CMS/SWGuidePATTrigger#TriggerPath
17 
18  \author Volker Adler
19 */
20 
21 #include <string>
22 #include <vector>
23 #include <type_traits>
24 
29 
30 namespace pat {
31 
33  typedef std::pair<bool, std::string> L1Seed;
35  typedef std::vector<L1Seed> L1SeedCollection;
36 
37  class TriggerPath {
39 
43  unsigned index_;
45  double prescale_;
47  bool run_;
49  bool accept_;
51  bool error_;
56  std::vector<std::string> modules_;
61  std::vector<unsigned> filterIndices_;
66  unsigned l3Filters_;
69 
70  public:
72 
74  TriggerPath();
79  unsigned index,
80  double prescale,
81  bool run,
82  bool accept,
83  bool error,
84  unsigned lastActiveFilterSlot,
85  unsigned l3Filters = 0);
86 
88  virtual ~TriggerPath() = default;
89 
91 
93  void setName(const std::string& name) { name_ = name; };
95  void setIndex(unsigned index) { index_ = index; };
97  void setPrescale(double prescale) { prescale_ = prescale; };
99  void setRun(bool run) { run_ = run; };
101  void setAccept(bool accept) { accept_ = accept; };
103  void setError(bool error) { error_ = error; };
109  void addModule(const std::string& name) { modules_.push_back(name); };
111  void addFilterIndex(const unsigned index) { filterIndices_.push_back(index); };
113  void addL1Seed(const L1Seed& seed) { l1Seeds_.push_back(seed); };
114  void addL1Seed(bool decision, const std::string& expression) { l1Seeds_.push_back(L1Seed(decision, expression)); };
116  const std::string& name() const { return name_; };
118  unsigned index() const { return index_; };
120  template <typename T = unsigned int>
121  T prescale() const {
122  static_assert(std::is_same_v<T, double>,
123  "\n\tPlease use prescale<double>"
124  "\n\t(other types for prescales are not supported anymore by pat::TriggerPath");
125  return prescale_;
126  };
128  bool wasRun() const { return run_; };
130  bool wasAccept() const { return accept_; };
132  bool wasError() const { return error_; };
134  unsigned lastActiveFilterSlot() const { return lastActiveFilterSlot_; };
137  unsigned l3Filters() const { return l3Filters_; };
140  bool xTrigger() const { return (l3Filters_ > 2); };
142  const std::vector<std::string>& modules() const { return modules_; };
144  const std::vector<unsigned>& filterIndices() const { return filterIndices_; };
148  int indexModule(const std::string& name) const;
150  const L1SeedCollection& l1Seeds() const { return l1Seeds_; };
152  std::vector<std::string> l1Seeds(const bool decision) const;
154  std::vector<std::string> acceptedL1Seeds() const { return l1Seeds(true); };
156  std::vector<std::string> failedL1Seeds() const { return l1Seeds(false); };
157  };
158 
160  typedef std::vector<TriggerPath> TriggerPathCollection;
169 
170 } // namespace pat
171 
172 #endif
bool xTrigger() const
Definition: TriggerPath.h:140
void setIndex(unsigned index)
Set the path index.
Definition: TriggerPath.h:95
std::vector< unsigned > filterIndices_
Definition: TriggerPath.h:61
std::vector< L1Seed > L1SeedCollection
Collection of L1Seed.
Definition: TriggerPath.h:35
T prescale() const
Get the path pre-scale.
Definition: TriggerPath.h:121
edm::RefVector< TriggerPathCollection > TriggerPathRefVector
Vector of persistent references to items in the same TriggerPathCollection.
Definition: TriggerPath.h:166
const std::string & name() const
Get the path name.
Definition: TriggerPath.h:116
edm::Ref< TriggerPathCollection > TriggerPathRef
Persistent reference to an item in a TriggerPathCollection.
Definition: TriggerPath.h:162
edm::RefProd< TriggerPathCollection > TriggerPathRefProd
Persistent reference to a TriggerPathCollection product.
Definition: TriggerPath.h:164
std::vector< std::string > failedL1Seeds() const
Get names of all failing L1 seeds.
Definition: TriggerPath.h:156
bool accept_
Did path succeed?
Definition: TriggerPath.h:49
TriggerPath()
Constructors and Desctructor.
Definition: TriggerPath.cc:6
std::vector< std::string > modules_
Definition: TriggerPath.h:56
bool run_
Was path run?
Definition: TriggerPath.h:47
unsigned index() const
Get the path index.
Definition: TriggerPath.h:118
const L1SeedCollection & l1Seeds() const
Get all L1 seeds.
Definition: TriggerPath.h:150
bool accept(const edm::Event &event, const edm::TriggerResults &triggerTable, const std::string &triggerPath)
Definition: TopDQMHelpers.h:31
std::string name_
Data Members.
Definition: TriggerPath.h:41
unsigned l3Filters() const
Definition: TriggerPath.h:137
edm::RefVectorIterator< TriggerPathCollection > TriggerPathRefVectorIterator
Const iterator over vector of persistent references to items in the same TriggerPathCollection.
Definition: TriggerPath.h:168
Definition: HeavyIon.h:7
const std::vector< std::string > & modules() const
Get all module labels.
Definition: TriggerPath.h:142
const std::vector< unsigned > & filterIndices() const
Get all trigger fillter collection indeces.
Definition: TriggerPath.h:144
unsigned l3Filters_
Definition: TriggerPath.h:66
void setL3Filters(unsigned l3Filters)
Set the number of modules identified as L3 filter.
Definition: TriggerPath.h:107
void setRun(bool run)
Set the run flag.
Definition: TriggerPath.h:99
std::pair< bool, std::string > L1Seed
Pair to store decision and name of L1 seeds.
Definition: TriggerPath.h:33
void setName(const std::string &name)
Methods.
Definition: TriggerPath.h:93
void addL1Seed(bool decision, const std::string &expression)
Definition: TriggerPath.h:114
void addL1Seed(const L1Seed &seed)
Add a new L1 seed.
Definition: TriggerPath.h:113
int indexModule(const std::string &name) const
Definition: TriggerPath.cc:43
L1SeedCollection l1Seeds_
List of L1 seeds and their decisions.
Definition: TriggerPath.h:68
void setError(bool error)
Set the error flag.
Definition: TriggerPath.h:103
void setLastActiveFilterSlot(unsigned lastActiveFilterSlot)
Set the index of the last active filter.
Definition: TriggerPath.h:105
virtual ~TriggerPath()=default
Destructor.
double prescale_
Pre-scale.
Definition: TriggerPath.h:45
bool wasError() const
Get the error flag.
Definition: TriggerPath.h:132
std::vector< TriggerPath > TriggerPathCollection
Collection of TriggerPath.
Definition: TriggerPath.h:160
void setAccept(bool accept)
Set the success flag.
Definition: TriggerPath.h:101
void setPrescale(double prescale)
Set the path pre-scale.
Definition: TriggerPath.h:97
bool wasAccept() const
Get the success flag.
Definition: TriggerPath.h:130
bool error_
Was path in error?
Definition: TriggerPath.h:51
void addFilterIndex(const unsigned index)
Add a new trigger fillter collection index.
Definition: TriggerPath.h:111
unsigned lastActiveFilterSlot() const
Get the index of the last active filter.
Definition: TriggerPath.h:134
unsigned lastActiveFilterSlot_
Index of the last active filter in the list of modules.
Definition: TriggerPath.h:63
bool wasRun() const
Get the run flag.
Definition: TriggerPath.h:128
long double T
void addModule(const std::string &name)
Add a new module label.
Definition: TriggerPath.h:109
unsigned index_
Path index in trigger table.
Definition: TriggerPath.h:43
std::vector< std::string > acceptedL1Seeds() const
Get names of all succeeding L1 seeds.
Definition: TriggerPath.h:154