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 
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 
20 
22 public:
24 
25  bool filter(edm::Event &event, edm::EventSetup const &setup) override;
26 
27  static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);
28 
29 private:
31  const std::array<double, 128> m_algoPrescales;
32  const std::array<double, 64> m_techPrescales;
33  std::array<unsigned int, 128> m_algoCounters;
34  std::array<unsigned int, 64> m_techCounters;
35 };
36 
38  : m_l1ResultsToken(consumes<L1GlobalTriggerReadoutRecord>(config.getParameter<edm::InputTag>("l1Results"))),
39  m_algoPrescales(make_array<double, 128>(config.getParameter<std::vector<double>>("l1AlgoPrescales"))),
40  m_techPrescales(make_array<double, 64>(config.getParameter<std::vector<double>>("l1TechPrescales"))) {
41  m_algoCounters.fill(0);
42  m_techCounters.fill(0);
43  produces<L1GlobalTriggerReadoutRecord>();
44 }
45 
48  event.getByToken(m_l1ResultsToken, handle);
49  auto algoWord = handle->decisionWord(); // make a copy of the L1 algo results
50  auto techWord = handle->technicalTriggerWord(); // make a copy of the L1 tech results
51  bool finalOr = false;
52 
53  for (unsigned int i = 0; i < 128; ++i) {
54  if (m_algoPrescales[i] == 0) {
55  // mask this trigger: reset the bit
56  algoWord[i] = false;
57  } else if (algoWord[i]) {
58  // prescale this trigger
59  ++m_algoCounters[i];
60  if (std::fmod(m_algoCounters[i], m_algoPrescales[i]) < 1)
61  // the prescale is successful, keep the bit set
62  finalOr = true;
63  else
64  // the prescale failed, reset the bit
65  algoWord[i] = false;
66  }
67  }
68  for (unsigned int i = 0; i < 64; ++i) {
69  if (m_techPrescales[i] == 0) {
70  // mask this trigger: reset the bit
71  techWord[i] = false;
72  } else if (techWord[i]) {
73  ++m_techCounters[i];
74  if (std::fmod(m_techCounters[i], m_techPrescales[i]) < 1)
75  // the prescale is successful, keep the bit set
76  finalOr = true;
77  else
78  // the prescale failed, reset the bit
79  techWord[i] = false;
80  }
81  }
82 
83  // make a copy of the L1GlobalTriggerReadoutRecord, and set the new decisions
84  std::unique_ptr<L1GlobalTriggerReadoutRecord> result(new L1GlobalTriggerReadoutRecord(*handle));
85  result->setDecisionWord(algoWord);
86  result->setTechnicalTriggerWord(techWord);
87  result->setDecision(finalOr);
88  event.put(std::move(result));
89 
90  return finalOr;
91 }
92 
95  desc.add<edm::InputTag>("l1Results", edm::InputTag("gtDigis"));
96  desc.add<std::vector<double>>("l1AlgoPrescales", std::vector<double>(128, 1));
97  desc.add<std::vector<double>>("l1TechPrescales", std::vector<double>(64, 1));
98  descriptions.add("l1GTPrescaler", desc);
99 }
100 
101 // register as a framework plugin
ConfigurationDescriptions.h
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:367
mps_fire.i
i
Definition: mps_fire.py:428
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
patZpeak.handle
handle
Definition: patZpeak.py:23
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord >
L1GTPrescaler::L1GTPrescaler
L1GTPrescaler(edm::ParameterSet const &config)
Definition: L1GTPrescaler.cc:37
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89353
L1GTPrescaler
Definition: L1GTPrescaler.cc:21
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
cms::cuda::assert
assert(be >=bs)
L1GTPrescaler::m_algoCounters
std::array< unsigned int, 128 > m_algoCounters
Definition: L1GTPrescaler.cc:33
L1GTPrescaler::m_techPrescales
const std::array< double, 64 > m_techPrescales
Definition: L1GTPrescaler.cc:32
edm::Handle
Definition: AssociativeIterator.h:50
L1GlobalTriggerReadoutRecord
Definition: L1GlobalTriggerReadoutRecord.h:46
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
EDFilter.h
config
Definition: config.py:1
MakerMacros.h
L1GTPrescaler::m_algoPrescales
const std::array< double, 128 > m_algoPrescales
Definition: L1GTPrescaler.cc:31
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
N
#define N
Definition: blowfish.cc:9
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
L1GTPrescaler::filter
bool filter(edm::Event &event, edm::EventSetup const &setup) override
Definition: L1GTPrescaler.cc:46
edm::EventSetup
Definition: EventSetup.h:57
L1GTPrescaler::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: L1GTPrescaler.cc:93
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
edm::one::EDFilter
Definition: EDFilter.h:30
L1GTPrescaler::m_techCounters
std::array< unsigned int, 64 > m_techCounters
Definition: L1GTPrescaler.cc:34
make_array
std::array< T, N > make_array(std::vector< T > const &values)
Definition: L1GTPrescaler.cc:7
mps_fire.result
result
Definition: mps_fire.py:311
ParameterSet.h
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
edm::InputTag
Definition: InputTag.h:15
L1GlobalTriggerReadoutRecord.h
L1GTPrescaler::m_l1ResultsToken
const edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1ResultsToken
Definition: L1GTPrescaler.cc:30