CMS 3D CMS Logo

L1GTPrescaler.cc
Go to the documentation of this file.
1 #include <array>
2 #include <cassert>
3 #include <memory>
4 #include <vector>
5 
12 
14 public:
16 
17  bool filter(edm::Event &event, edm::EventSetup const &setup) override;
18 
19  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
20 
21 private:
23  const std::array<double, 128> m_algoPrescales;
24  const std::array<double, 64> m_techPrescales;
25  std::array<unsigned int, 128> m_algoCounters;
26  std::array<unsigned int, 64> m_techCounters;
27 };
28 
30  : m_l1ResultsToken(consumes<L1GlobalTriggerReadoutRecord>(config.getParameter<edm::InputTag>("l1Results"))),
31  m_algoPrescales(config.getParameter<std::array<double, 128>>("l1AlgoPrescales")),
32  m_techPrescales(config.getParameter<std::array<double, 64>>("l1TechPrescales")) {
33  m_algoCounters.fill(0);
34  m_techCounters.fill(0);
35  produces<L1GlobalTriggerReadoutRecord>();
36 }
37 
40  event.getByToken(m_l1ResultsToken, handle);
41  auto algoWord = handle->decisionWord(); // make a copy of the L1 algo results
42  auto techWord = handle->technicalTriggerWord(); // make a copy of the L1 tech results
43  bool finalOr = false;
44 
45  for (unsigned int i = 0; i < 128; ++i) {
46  if (m_algoPrescales[i] == 0) {
47  // mask this trigger: reset the bit
48  algoWord[i] = false;
49  } else if (algoWord[i]) {
50  // prescale this trigger
51  ++m_algoCounters[i];
52  if (std::fmod(m_algoCounters[i], m_algoPrescales[i]) < 1)
53  // the prescale is successful, keep the bit set
54  finalOr = true;
55  else
56  // the prescale failed, reset the bit
57  algoWord[i] = false;
58  }
59  }
60  for (unsigned int i = 0; i < 64; ++i) {
61  if (m_techPrescales[i] == 0) {
62  // mask this trigger: reset the bit
63  techWord[i] = false;
64  } else if (techWord[i]) {
65  ++m_techCounters[i];
66  if (std::fmod(m_techCounters[i], m_techPrescales[i]) < 1)
67  // the prescale is successful, keep the bit set
68  finalOr = true;
69  else
70  // the prescale failed, reset the bit
71  techWord[i] = false;
72  }
73  }
74 
75  // make a copy of the L1GlobalTriggerReadoutRecord, and set the new decisions
76  std::unique_ptr<L1GlobalTriggerReadoutRecord> result(new L1GlobalTriggerReadoutRecord(*handle));
77  result->setDecisionWord(algoWord);
78  result->setTechnicalTriggerWord(techWord);
79  result->setDecision(finalOr);
80  event.put(std::move(result));
81 
82  return finalOr;
83 }
84 
87  desc.add<edm::InputTag>("l1Results", edm::InputTag("gtDigis"));
88  desc.add<std::vector<double>>("l1AlgoPrescales", std::vector<double>(128, 1));
89  desc.add<std::vector<double>>("l1TechPrescales", std::vector<double>(64, 1));
90  descriptions.add("l1GTPrescaler", desc);
91 }
92 
93 // register as a framework plugin
const std::array< double, 64 > m_techPrescales
L1GTPrescaler(edm::ParameterSet const &config)
Definition: config.py:1
std::array< unsigned int, 64 > m_techCounters
const std::array< double, 128 > m_algoPrescales
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::array< unsigned int, 128 > m_algoCounters
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
bool filter(edm::Event &event, edm::EventSetup const &setup) override
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
const edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1ResultsToken
def move(src, dest)
Definition: eostools.py:511
Definition: event.py:1