CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTLevel1Pattern.cc
Go to the documentation of this file.
1 
13 #include <vector>
14 
28 
29 //
30 // class declaration
31 //
32 
34 public:
35  explicit HLTLevel1Pattern(const edm::ParameterSet&);
37  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
38  virtual bool filter(edm::Event&, const edm::EventSetup&) override;
39 
40 private:
44  std::vector<int> m_bunchCrossings;
45  std::vector<int> m_triggerPattern;
46  unsigned int m_daqPartitions;
47  unsigned int m_triggerNumber;
51  bool m_invert;
52  bool m_throw;
53 
57 };
58 
59 #include <boost/foreach.hpp>
60 
66 
67 //
68 // constructors and destructor
69 //
71  m_gtReadoutRecord( config.getParameter<edm::InputTag> ("L1GtReadoutRecordTag") ),
72  m_triggerBit( config.getParameter<std::string> ("triggerBit") ),
73  m_bunchCrossings( config.getParameter<std::vector<int> > ("bunchCrossings") ),
74  m_triggerPattern( m_bunchCrossings.size(), false ),
75  m_daqPartitions( config.getParameter<unsigned int> ("daqPartitions") ),
76  m_triggerNumber( 0 ),
77  m_triggerAlgo( true ),
78  m_triggerMasked( false ),
79  m_ignoreL1Mask( config.getParameter<bool> ("ignoreL1Mask") ),
80  m_invert( config.getParameter<bool> ("invert") ),
81  m_throw ( config.getParameter<bool> ("throw" ) )
82 {
83  m_gtReadoutRecordToken = consumes<L1GlobalTriggerReadoutRecord>(m_gtReadoutRecord);
84  std::vector<int> pattern( config.getParameter<std::vector<int> > ("triggerPattern") );
85  if (pattern.size() != m_bunchCrossings.size())
86  throw cms::Exception("Configuration") << "\"bunchCrossings\" and \"triggerPattern\" parameters do not match";
87 
88  for (unsigned int i = 0; i < pattern.size(); ++i)
89  m_triggerPattern[i] = (bool) pattern[i];
90 }
91 
93 {
94 }
95 
96 void
99  desc.add<edm::InputTag>("L1GtReadoutRecordTag",edm::InputTag("hltGtDigis"));
100  desc.add<std::string>("triggerBit","L1Tech_RPC_TTU_pointing_Cosmics.v0");
101  {
102  std::vector<int> temp1;
103  temp1.reserve(5);
104  temp1.push_back(-2);
105  temp1.push_back(-1);
106  temp1.push_back(0);
107  temp1.push_back(1);
108  temp1.push_back(2);
109  desc.add<std::vector<int> >("bunchCrossings",temp1);
110  }
111  desc.add<unsigned int>("daqPartitions",1);
112  desc.add<bool>("ignoreL1Mask",false);
113  desc.add<bool>("invert",false);
114  desc.add<bool>("throw",true);
115  {
116  std::vector<int> temp1;
117  temp1.reserve(5);
118  temp1.push_back(1);
119  temp1.push_back(1);
120  temp1.push_back(1);
121  temp1.push_back(0);
122  temp1.push_back(0);
123  desc.add<std::vector<int> >("triggerPattern",temp1);
124  }
125  descriptions.add("hltLevel1Pattern",desc);
126 }
127 
128 //
129 // member functions
130 //
131 
132 // ------------ method called to produce the data ------------
133 bool
135 {
136  // determine the L1 algo or tech bit to use
137  if (m_watchL1Menu.check(setup)) {
139  setup.get<L1GtTriggerMenuRcd>().get(h_menu);
140 
141  // look for an Algo L1 bit
142  const AlgorithmMap & algoMap = h_menu->gtAlgorithmAliasMap();
143  const AlgorithmMap & techMap = h_menu->gtTechnicalTriggerMap();
144  AlgorithmMap::const_iterator entry;
145  if ((entry = algoMap.find(m_triggerBit)) != algoMap.end()) {
146  m_triggerAlgo = true;
147  m_triggerNumber = entry->second.algoBitNumber();
148  } else
149  if ((entry = techMap.find(m_triggerBit)) != techMap.end()) {
150  m_triggerAlgo = false;
151  m_triggerNumber = entry->second.algoBitNumber();
152  } else {
153  if (m_throw) {
154  throw cms::Exception("Configuration") << "requested L1 trigger \"" << m_triggerBit << "\" does not exist in the current L1 menu";
155  } else {
156  return m_invert;
157  }
158  }
159  }
160 
161  if (m_triggerAlgo) {
162  // check the L1 algorithms mask
163  // - mask & partition == part. --> fully masked
164  // - mask & partition == 0x00 --> fully unmasked
165  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
166  if (m_watchPhysicsMask.check(setup)) {
168  setup.get<L1GtTriggerMaskAlgoTrigRcd>().get(h_mask);
169  m_triggerMasked = ((h_mask->gtTriggerMask()[m_triggerNumber] & m_daqPartitions) == m_daqPartitions);
170  }
171  } else {
172  // check the L1 technical triggers mask
173  // - mask & partition == part. --> fully masked
174  // - mask & partition == 0x00 --> fully unmasked
175  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
176  if (m_watchTechnicalMask.check(setup)) {
178  setup.get<L1GtTriggerMaskTechTrigRcd>().get(h_mask);
179  m_triggerMasked = ((h_mask->gtTriggerMask()[m_triggerNumber] & m_daqPartitions) == m_daqPartitions);
180  }
181  }
182 
183  // is the L1 trigger masked ?
184  if (not m_ignoreL1Mask and m_triggerMasked)
185  return m_invert;
186 
187  // access the L1 decisions
189  event.getByToken(m_gtReadoutRecordToken, h_gtReadoutRecord);
190 
191  // check the L1 algorithms results
192  for (unsigned int i = 0; i < m_bunchCrossings.size(); ++i) {
193  int bx = m_bunchCrossings[i];
194  const std::vector<bool> & word = (m_triggerAlgo) ? h_gtReadoutRecord->decisionWord(bx) : h_gtReadoutRecord->technicalTriggerWord(bx);
195  if (word.empty() or m_triggerNumber >= word.size())
196  // L1 results not available, bail out
197  return m_invert;
198  bool result = word[m_triggerNumber];
199  if (result != m_triggerPattern[i])
200  // comparison failed, bail out
201  return m_invert;
202  }
203 
204  // comparison successful
205  return not m_invert;
206 }
207 
208 // define as a framework plugin
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
HLTLevel1Pattern(const edm::ParameterSet &)
std::string m_triggerBit
virtual bool filter(edm::Event &, const edm::EventSetup &) override
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventIDconst &, edm::Timestampconst & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
edm::InputTag m_gtReadoutRecord
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
edm::ESWatcher< L1GtTriggerMaskTechTrigRcd > m_watchTechnicalMask
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
tuple result
Definition: mps_fire.py:95
std::vector< int > m_bunchCrossings
unsigned int m_triggerNumber
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
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutRecordToken
edm::ESWatcher< L1GtTriggerMenuRcd > m_watchL1Menu
const T & get() const
Definition: EventSetup.h:56
unsigned int m_daqPartitions
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< int > m_triggerPattern
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
list entry
Definition: mps_splice.py:62
edm::ESWatcher< L1GtTriggerMaskAlgoTrigRcd > m_watchPhysicsMask
volatile std::atomic< bool > shutdown_flag false
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
tuple size
Write out results.