CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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&);
43  static void fillDescriptions(edm::ConfigurationDescriptions & descriptions);
44  virtual bool filter(edm::Event &, edm::EventSetup const &) override 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") ),
72  m_gtReadoutRecordToken(consumes<L1GlobalTriggerReadoutRecord>(m_gtReadoutRecordTag)),
73  m_bunchCrossings( config.getParameter<std::vector<int>> ("bunchCrossings") ),
74  m_selectPhysics( PHYSICS_BITS_SIZE ),
75  m_selectTechnical( TECHNICAL_BITS_SIZE ),
76  m_maskedPhysics( PHYSICS_BITS_SIZE ),
77  m_maskedTechnical( TECHNICAL_BITS_SIZE ),
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 }
102 
103 void
106  desc.add<edm::InputTag>("L1GtReadoutRecordTag", edm::InputTag("hltGtDigis"));
107  desc.add<std::vector<int>>("bunchCrossings", {0, -1, 1});
108  desc.add<unsigned int>("daqPartitions", 1);
109  desc.add<bool>("ignoreL1Mask", false);
110  desc.add<bool>("invert", false);
111  desc.add<unsigned long long int>("physicsLoBits", 0x0000000000000001LL); // bit 0
112  desc.add<unsigned long long int>("physicsHiBits", 0x0000000000040000LL); // bit 64 + 18 = 82
113  desc.add<unsigned long long int>("technicalBits", 0x0000000000000001LL); // bit 0
114  descriptions.add("hltLevel1Activity", desc);
115 }
116 
117 //
118 // member functions
119 //
120 
121 // ------------ method called to produce the data ------------
122 bool
124 {
125  // apply L1 mask to the physics bits
126  // - mask & partition == part. --> fully masked
127  // - mask & partition == 0x00 --> fully unmasked
128  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
129  if (not m_ignoreL1Mask and m_watchPhysicsMask.check(setup)) {
131  setup.get<L1GtTriggerMaskAlgoTrigRcd>().get(h_mask);
132  const std::vector<unsigned int> & mask = h_mask->gtTriggerMask();
133  for (unsigned int i = 0; i < PHYSICS_BITS_SIZE; ++i)
134  m_maskedPhysics[i] = m_selectPhysics[i] and ((mask[i] & m_daqPartitions) != m_daqPartitions);
135  }
136 
137  // apply L1 mask to the technical bits
138  // - mask & partition == part. --> fully masked
139  // - mask & partition == 0x00 --> fully unmasked
140  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
141  if (not m_ignoreL1Mask and m_watchTechnicalMask.check(setup)) {
143  setup.get<L1GtTriggerMaskTechTrigRcd>().get(h_mask);
144  const std::vector<unsigned int> & mask = h_mask->gtTriggerMask();
145  for (unsigned int i = 0; i < TECHNICAL_BITS_SIZE; ++i)
146  m_maskedTechnical[i] = m_selectTechnical[i] and ((mask[i] & m_daqPartitions) != m_daqPartitions);
147  }
148 
149  // access the L1 decisions
151  event.getByToken(m_gtReadoutRecordToken, h_gtReadoutRecord);
152 
153  // compare the results with the requested bits, and return true as soon as the first match is found
154  for (int bx : m_bunchCrossings) {
155  const std::vector<bool> & physics = h_gtReadoutRecord->decisionWord(bx);
156  if (physics.size() != PHYSICS_BITS_SIZE)
157  // error in L1 results
158  return m_invert;
159  for (unsigned int i = 0; i < PHYSICS_BITS_SIZE; ++i)
160  if (m_maskedPhysics[i] and physics[i])
161  return not m_invert;
162  const std::vector<bool> & technical = h_gtReadoutRecord->technicalTriggerWord(bx);
163  if (technical.size() != TECHNICAL_BITS_SIZE)
164  // error in L1 results
165  return m_invert;
166  for (unsigned int i = 0; i < TECHNICAL_BITS_SIZE; ++i)
167  if (m_maskedTechnical[i] and technical[i])
168  return not m_invert;
169  }
170 
171  return m_invert;
172 }
173 
174 // define as a framework plugin
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
unsigned int m_daqPartitions
edm::ESWatcher< L1GtTriggerMaskAlgoTrigRcd > m_watchPhysicsMask
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
std::vector< bool > m_selectTechnical
#define TECHNICAL_BITS_SIZE
std::vector< bool > m_selectPhysics
edm::InputTag m_gtReadoutRecordTag
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
std::vector< bool > m_maskedPhysics
virtual bool filter(edm::Event &, edm::EventSetup const &) overridefinal
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutRecordToken
#define PHYSICS_BITS_SIZE
const T & get() const
Definition: EventSetup.h:55
HLTLevel1Activity(const edm::ParameterSet &)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool check(const edm::EventSetup &iSetup)
Definition: ESWatcher.h:57
std::vector< int > m_bunchCrossings
edm::ESWatcher< L1GtTriggerMaskTechTrigRcd > m_watchTechnicalMask
void setup(std::vector< TH2F > &depth, std::string name, std::string units="")
std::vector< bool > m_maskedTechnical