CMS 3D CMS Logo

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&);
36  ~HLTLevel1Pattern() override;
37  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
38  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") ),
75  m_daqPartitions( config.getParameter<unsigned int> ("daqPartitions") ),
76  m_triggerNumber( 0 ),
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 void
97  desc.add<edm::InputTag>("L1GtReadoutRecordTag",edm::InputTag("hltGtDigis"));
98  desc.add<std::string>("triggerBit","L1Tech_RPC_TTU_pointing_Cosmics.v0");
99  {
100  std::vector<int> temp1;
101  temp1.reserve(5);
102  temp1.push_back(-2);
103  temp1.push_back(-1);
104  temp1.push_back(0);
105  temp1.push_back(1);
106  temp1.push_back(2);
107  desc.add<std::vector<int> >("bunchCrossings",temp1);
108  }
109  desc.add<unsigned int>("daqPartitions",1);
110  desc.add<bool>("ignoreL1Mask",false);
111  desc.add<bool>("invert",false);
112  desc.add<bool>("throw",true);
113  {
114  std::vector<int> temp1;
115  temp1.reserve(5);
116  temp1.push_back(1);
117  temp1.push_back(1);
118  temp1.push_back(1);
119  temp1.push_back(0);
120  temp1.push_back(0);
121  desc.add<std::vector<int> >("triggerPattern",temp1);
122  }
123  descriptions.add("hltLevel1Pattern",desc);
124 }
125 
126 //
127 // member functions
128 //
129 
130 // ------------ method called to produce the data ------------
131 bool
133 {
134  // determine the L1 algo or tech bit to use
135  if (m_watchL1Menu.check(setup)) {
137  setup.get<L1GtTriggerMenuRcd>().get(h_menu);
138 
139  // look for an Algo L1 bit
140  const AlgorithmMap & algoMap = h_menu->gtAlgorithmAliasMap();
141  const AlgorithmMap & techMap = h_menu->gtTechnicalTriggerMap();
142  AlgorithmMap::const_iterator entry;
143  if ((entry = algoMap.find(m_triggerBit)) != algoMap.end()) {
144  m_triggerAlgo = true;
145  m_triggerNumber = entry->second.algoBitNumber();
146  } else
147  if ((entry = techMap.find(m_triggerBit)) != techMap.end()) {
148  m_triggerAlgo = false;
149  m_triggerNumber = entry->second.algoBitNumber();
150  } else {
151  if (m_throw) {
152  throw cms::Exception("Configuration") << "requested L1 trigger \"" << m_triggerBit << "\" does not exist in the current L1 menu";
153  } else {
154  return m_invert;
155  }
156  }
157  }
158 
159  if (m_triggerAlgo) {
160  // check the L1 algorithms mask
161  // - mask & partition == part. --> fully masked
162  // - mask & partition == 0x00 --> fully unmasked
163  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
164  if (m_watchPhysicsMask.check(setup)) {
166  setup.get<L1GtTriggerMaskAlgoTrigRcd>().get(h_mask);
168  }
169  } else {
170  // check the L1 technical triggers mask
171  // - mask & partition == part. --> fully masked
172  // - mask & partition == 0x00 --> fully unmasked
173  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
174  if (m_watchTechnicalMask.check(setup)) {
176  setup.get<L1GtTriggerMaskTechTrigRcd>().get(h_mask);
178  }
179  }
180 
181  // is the L1 trigger masked ?
182  if (not m_ignoreL1Mask and m_triggerMasked)
183  return m_invert;
184 
185  // access the L1 decisions
187  event.getByToken(m_gtReadoutRecordToken, h_gtReadoutRecord);
188 
189  // check the L1 algorithms results
190  for (unsigned int i = 0; i < m_bunchCrossings.size(); ++i) {
191  int bx = m_bunchCrossings[i];
192  const std::vector<bool> & word = (m_triggerAlgo) ? h_gtReadoutRecord->decisionWord(bx) : h_gtReadoutRecord->technicalTriggerWord(bx);
193  if (word.empty() or m_triggerNumber >= word.size())
194  // L1 results not available, bail out
195  return m_invert;
196  bool result = word[m_triggerNumber];
197  if (result != m_triggerPattern[i])
198  // comparison failed, bail out
199  return m_invert;
200  }
201 
202  // comparison successful
203  return not m_invert;
204 }
205 
206 // define as a framework plugin
size
Write out results.
T getParameter(std::string const &) const
HLTLevel1Pattern(const edm::ParameterSet &)
std::string m_triggerBit
const TechnicalTriggerWord & technicalTriggerWord(int bxInEventValue) const
bool filter(edm::Event &, const edm::EventSetup &) override
edm::InputTag m_gtReadoutRecord
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::map< std::string, L1GtAlgorithm > AlgorithmMap
map containing the algorithms
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Definition: config.py:1
edm::ESWatcher< L1GtTriggerMaskTechTrigRcd > m_watchTechnicalMask
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< int > m_bunchCrossings
const std::vector< unsigned int > & gtTriggerMask() const
get the trigger mask
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::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
unsigned int m_triggerNumber
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const DecisionWord & decisionWord(int bxInEventValue) const
~HLTLevel1Pattern() override
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutRecordToken
edm::ESWatcher< L1GtTriggerMenuRcd > m_watchL1Menu
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
HLT enums.
T get() const
Definition: EventSetup.h:63
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
edm::ESWatcher< L1GtTriggerMaskAlgoTrigRcd > m_watchPhysicsMask
const AlgorithmMap & gtAlgorithmAliasMap() const
get / set the algorithm map (by alias)
Definition: event.py:1