CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GTPrescaler.cc
Go to the documentation of this file.
1 #include <vector>
2 #include <array>
3 #include <memory>
4 #include <cassert>
5 
6 template <class T, std::size_t N>
7 std::array<T, N> make_array(std::vector<T> const & values) {
8  assert(N == values.size());
9  std::array<T, N> ret;
10  std::copy(values.begin(), values.end(), ret.begin());
11  return ret;
12 }
13 
14 
21 
23 public:
25 
26  virtual bool filter(edm::Event& event, edm::EventSetup const& setup) override;
27 
28  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
29 
30 private:
32  const std::array<double, 128> m_algoPrescales;
33  const std::array<double, 64> m_techPrescales;
34  std::array<unsigned int, 128> m_algoCounters;
35  std::array<unsigned int, 64> m_techCounters;
36 
37 };
38 
40  m_l1ResultsToken( consumes<L1GlobalTriggerReadoutRecord>(config.getParameter<edm::InputTag>("l1Results")) ),
41  m_algoPrescales( make_array<double, 128>(config.getParameter<std::vector<double>>("l1AlgoPrescales")) ),
42  m_techPrescales( make_array<double, 64>(config.getParameter<std::vector<double>>("l1TechPrescales")) )
43 {
44  m_algoCounters.fill(0);
45  m_techCounters.fill(0);
46  produces<L1GlobalTriggerReadoutRecord>();
47 }
48 
51  event.getByToken(m_l1ResultsToken, handle);
52  auto algoWord = handle->decisionWord(); // make a copy of the L1 algo results
53  auto techWord = handle->technicalTriggerWord(); // make a copy of the L1 tech results
54  bool finalOr = false;
55 
56  for (unsigned int i = 0; i < 128; ++i) {
57  if (m_algoPrescales[i] == 0) {
58  // mask this trigger: reset the bit
59  algoWord[i] = 0;
60  } else if (algoWord[i]) {
61  // prescale this trigger
62  ++m_algoCounters[i];
63  if (std::fmod(m_algoCounters[i], m_algoPrescales[i]) < 1)
64  // the prescale is successful, keep the bit set
65  finalOr = true;
66  else
67  // the prescale failed, reset the bit
68  algoWord[i] = 0;
69  }
70  }
71  for (unsigned int i = 0; i < 64; ++i) {
72  if (m_techPrescales[i] == 0) {
73  // mask this trigger: reset the bit
74  techWord[i] = 0;
75  } else if (techWord[i]) {
76  ++m_techCounters[i];
77  if (std::fmod(m_techCounters[i], m_techPrescales[i]) < 1)
78  // the prescale is successful, keep the bit set
79  finalOr = true;
80  else
81  // the prescale failed, reset the bit
82  techWord[i] = 0;
83  }
84  }
85 
86  // make a copy of the L1GlobalTriggerReadoutRecord, and set the new decisions
87  std::unique_ptr<L1GlobalTriggerReadoutRecord> result(new L1GlobalTriggerReadoutRecord(*handle));
88  result->setDecisionWord(algoWord);
89  result->setTechnicalTriggerWord(techWord);
90  result->setDecision(finalOr);
91  event.put(std::move(result));
92 
93  return finalOr;
94 }
95 
98  desc.add<edm::InputTag>("l1Results", edm::InputTag("gtDigis"));
99  desc.add<std::vector<double>>("l1AlgoPrescales", std::vector<double>(128, 1));
100  desc.add<std::vector<double>>("l1TechPrescales", std::vector<double>( 64, 1));
101  descriptions.add("l1GTPrescaler", desc);
102 }
103 
104 
105 // register as a framework plugin
int i
Definition: DBlmapReader.cc:9
tuple ret
prodAgent to be discontinued
const std::array< double, 64 > m_techPrescales
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
L1GTPrescaler(edm::ParameterSet const &config)
assert(m_qm.get())
std::array< unsigned int, 64 > m_techCounters
tuple result
Definition: mps_fire.py:83
const std::array< double, 128 > m_algoPrescales
def move
Definition: eostools.py:510
tuple handle
Definition: patZpeak.py:22
std::array< unsigned int, 128 > m_algoCounters
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
#define N
Definition: blowfish.cc:9
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual bool filter(edm::Event &event, edm::EventSetup const &setup) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1ResultsToken
std::array< T, N > make_array(std::vector< T > const &values)
Definition: L1GTPrescaler.cc:7