CMS 3D CMS Logo

HLTLevel1Activity.cc
Go to the documentation of this file.
1 
16 #include <vector>
17 
28 
30 
31 // FIXME: these should come form the L1 configuration at runtime
32 #define PHYSICS_BITS_SIZE 128
33 #define TECHNICAL_BITS_SIZE 64
34 
35 //
36 // class declaration
37 //
38 
40 public:
41  explicit HLTLevel1Activity(const edm::ParameterSet&);
42  ~HLTLevel1Activity() override;
43  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
44  bool filter(edm::Event &, edm::EventSetup const &) final;
45 
46 private:
49  std::vector<int> m_bunchCrossings;
50  std::vector<bool> m_selectPhysics;
51  std::vector<bool> m_selectTechnical;
52  std::vector<bool> m_maskedPhysics;
53  std::vector<bool> m_maskedTechnical;
54  unsigned int m_daqPartitions;
56  bool m_invert;
57 
60 };
61 
66 
67 //
68 // constructors and destructor
69 //
71  m_gtReadoutRecordTag( config.getParameter<edm::InputTag> ("L1GtReadoutRecordTag") ),
73  m_bunchCrossings( config.getParameter<std::vector<int>> ("bunchCrossings") ),
78  m_daqPartitions( config.getParameter<unsigned int> ("daqPartitions") ),
79  m_ignoreL1Mask( config.getParameter<bool> ("ignoreL1Mask") ),
80  m_invert( config.getParameter<bool> ("invert") )
81 {
82  unsigned long long low = config.getParameter<unsigned long long>("physicsLoBits");
83  unsigned long long high = config.getParameter<unsigned long long>("physicsHiBits");
84  unsigned long long tech = config.getParameter<unsigned long long>("technicalBits");
85  for (unsigned int i = 0; i < 64; i++) {
86  m_selectPhysics[i] = low & (0x01ULL << (unsigned long long) i);
87  m_maskedPhysics[i] = low & (0x01ULL << (unsigned long long) i);
88  }
89  for (unsigned int i = 0; i < 64; i++) {
90  m_selectPhysics[i+64] = high & (0x01ULL << (unsigned long long) i);
91  m_maskedPhysics[i+64] = high & (0x01ULL << (unsigned long long) i);
92  }
93  for (unsigned int i = 0; i < 64; i++) {
94  m_selectTechnical[i] = tech & (0x01ULL << (unsigned long long) i);
95  m_maskedTechnical[i] = tech & (0x01ULL << (unsigned long long) i);
96  }
97 }
98 
100 
101 void
104  desc.add<edm::InputTag>("L1GtReadoutRecordTag", edm::InputTag("hltGtDigis"));
105  desc.add<std::vector<int>>("bunchCrossings", {0, -1, 1});
106  desc.add<unsigned int>("daqPartitions", 1);
107  desc.add<bool>("ignoreL1Mask", false);
108  desc.add<bool>("invert", false);
109  desc.add<unsigned long long int>("physicsLoBits", 0x0000000000000001LL); // bit 0
110  desc.add<unsigned long long int>("physicsHiBits", 0x0000000000040000LL); // bit 64 + 18 = 82
111  desc.add<unsigned long long int>("technicalBits", 0x0000000000000001LL); // bit 0
112  descriptions.add("hltLevel1Activity", desc);
113 }
114 
115 //
116 // member functions
117 //
118 
119 // ------------ method called to produce the data ------------
120 bool
122 {
123  /*
124  // apply L1 mask to the physics bits
125  // - mask & partition == part. --> fully masked
126  // - mask & partition == 0x00 --> fully unmasked
127  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
128  if (not m_ignoreL1Mask and m_watchPhysicsMask.check(setup)) {
129  edm::ESHandle<L1GtTriggerMask> h_mask;
130  setup.get<L1GtTriggerMaskAlgoTrigRcd>().get(h_mask);
131  const std::vector<unsigned int> & mask = h_mask->gtTriggerMask();
132  for (unsigned int i = 0; i < PHYSICS_BITS_SIZE; ++i)
133  m_maskedPhysics[i] = m_selectPhysics[i] and ((mask[i] & m_daqPartitions) != m_daqPartitions);
134  }
135 
136  // apply L1 mask to the technical bits
137  // - mask & partition == part. --> fully masked
138  // - mask & partition == 0x00 --> fully unmasked
139  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
140  if (not m_ignoreL1Mask and m_watchTechnicalMask.check(setup)) {
141  edm::ESHandle<L1GtTriggerMask> h_mask;
142  setup.get<L1GtTriggerMaskTechTrigRcd>().get(h_mask);
143  const std::vector<unsigned int> & mask = h_mask->gtTriggerMask();
144  for (unsigned int i = 0; i < TECHNICAL_BITS_SIZE; ++i)
145  m_maskedTechnical[i] = m_selectTechnical[i] and ((mask[i] & m_daqPartitions) != m_daqPartitions);
146  }
147 
148  // access the L1 decisions
149  edm::Handle<L1GlobalTriggerReadoutRecord> h_gtReadoutRecord;
150  event.getByToken(m_gtReadoutRecordToken, h_gtReadoutRecord);
151 
152  // compare the results with the requested bits, and return true as soon as the first match is found
153  for (int bx : m_bunchCrossings) {
154  const std::vector<bool> & physics = h_gtReadoutRecord->decisionWord(bx);
155  if (physics.size() != PHYSICS_BITS_SIZE)
156  // error in L1 results
157  return m_invert;
158  for (unsigned int i = 0; i < PHYSICS_BITS_SIZE; ++i)
159  if (m_maskedPhysics[i] and physics[i])
160  return not m_invert;
161  const std::vector<bool> & technical = h_gtReadoutRecord->technicalTriggerWord(bx);
162  if (technical.size() != TECHNICAL_BITS_SIZE)
163  // error in L1 results
164  return m_invert;
165  for (unsigned int i = 0; i < TECHNICAL_BITS_SIZE; ++i)
166  if (m_maskedTechnical[i] and technical[i])
167  return not m_invert;
168  }
169 
170  return m_invert;
171  */
172  return false;
173 }
174 
175 // define as a framework plugin
T getParameter(std::string const &) const
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned int m_daqPartitions
edm::ESWatcher< L1GtTriggerMaskAlgoTrigRcd > m_watchPhysicsMask
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
def setup(process, global_tag, zero_tesla=False)
Definition: GeneralSetup.py:1
Definition: config.py:1
std::vector< bool > m_selectTechnical
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
#define TECHNICAL_BITS_SIZE
std::vector< bool > m_selectPhysics
edm::InputTag m_gtReadoutRecordTag
ParameterDescriptionBase * add(U const &iLabel, T const &value)
~HLTLevel1Activity() override
std::vector< bool > m_maskedPhysics
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutRecordToken
#define PHYSICS_BITS_SIZE
HLTLevel1Activity(const edm::ParameterSet &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< int > m_bunchCrossings
edm::ESWatcher< L1GtTriggerMaskTechTrigRcd > m_watchTechnicalMask
HLT enums.
bool filter(edm::Event &, edm::EventSetup const &) final
Definition: event.py:1
std::vector< bool > m_maskedTechnical