CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TGlobalPrescaler.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, GlobalAlgBlk::maxPhysicsTriggers> m_prescales;
33  std::array<unsigned int, GlobalAlgBlk::maxPhysicsTriggers> m_counters;
34 
35 };
36 
38  m_l1ResultsToken( consumes<GlobalAlgBlkBxCollection>(config.getParameter<edm::InputTag>("l1tResults")) ),
39  m_prescales( make_array<double, GlobalAlgBlk::maxPhysicsTriggers>(config.getParameter<std::vector<double>>("l1tPrescales")) )
40 {
41  m_counters.fill(0);
42  produces<GlobalAlgBlkBxCollection>();
43 }
44 
47  event.getByToken(m_l1ResultsToken, handle);
48 
49  // if the input collection does not have any information for bx 0,
50  // produce an empty collection, and fail
51  if (handle->isEmpty(0)) {
52  std::unique_ptr<GlobalAlgBlkBxCollection> result(new GlobalAlgBlkBxCollection());
53  event.put(std::move(result));
54  return false;
55  }
56 
57  // make a copy of the GlobalAlgBlk for bx 0
58  GlobalAlgBlk algoBlock = handle->at(0,0);
59 
60  bool finalOr = false;
61 
62  for (unsigned int i = 0; i < GlobalAlgBlk::maxPhysicsTriggers; ++i) {
63  if (m_prescales[i] == 0) {
64  // mask this trigger: reset the bit
65  algoBlock.setAlgoDecisionFinal(i, false);
66  } else if (algoBlock.getAlgoDecisionFinal(i)) {
67  // prescale this trigger
68  ++m_counters[i];
69  if (std::fmod(m_counters[i], m_prescales[i]) < 1)
70  // the prescale is successful, keep the bit set
71  finalOr = true;
72  else
73  // the prescale failed, reset the bit
74  algoBlock.setAlgoDecisionFinal(i, false);
75  }
76  }
77 
78  // set the final OR
79  algoBlock.setFinalORPreVeto(finalOr);
80  if (algoBlock.getFinalORVeto())
81  finalOr = false;
82  algoBlock.setFinalOR(finalOr);
83 
84  // create a new GlobalAlgBlkBxCollection, and set the new prescaled decisions for bx 0
85  std::unique_ptr<GlobalAlgBlkBxCollection> result(new GlobalAlgBlkBxCollection());
86  result->push_back(0, algoBlock);
87  event.put(std::move(result));
88 
89  return finalOr;
90 }
91 
94  desc.add<edm::InputTag>("l1tResults", edm::InputTag("gtStage2Digis"));
95  desc.add<std::vector<double>>("l1tPrescales", std::vector<double>(GlobalAlgBlk::maxPhysicsTriggers, 1.));
96  descriptions.add("l1tGlobalPrescaler", desc);
97 }
98 
99 
100 // register as a framework plugin
int i
Definition: DBlmapReader.cc:9
tuple ret
prodAgent to be discontinued
void setFinalORPreVeto(bool fOR)
Definition: GlobalAlgBlk.h:59
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
assert(m_qm.get())
std::array< unsigned int, GlobalAlgBlk::maxPhysicsTriggers > m_counters
BXVector< GlobalAlgBlk > GlobalAlgBlkBxCollection
Definition: GlobalAlgBlk.h:31
bool getAlgoDecisionFinal(unsigned int bit) const
const bool getFinalORVeto() const
Definition: GlobalAlgBlk.h:69
static const unsigned int maxPhysicsTriggers
Definition: GlobalAlgBlk.h:52
tuple result
Definition: mps_fire.py:83
const std::array< double, GlobalAlgBlk::maxPhysicsTriggers > m_prescales
virtual bool filter(edm::Event &event, edm::EventSetup const &setup) override
def move
Definition: eostools.py:510
tuple handle
Definition: patZpeak.py:22
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
void setFinalOR(bool fOR)
Definition: GlobalAlgBlk.h:60
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define N
Definition: blowfish.cc:9
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1ResultsToken
void setAlgoDecisionFinal(unsigned int bit, bool val)
L1TGlobalPrescaler(edm::ParameterSet const &config)
std::array< T, N > make_array(std::vector< T > const &values)
Definition: L1GTPrescaler.cc:7