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")),
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  unsigned long long low = config.getParameter<unsigned long long>("physicsLoBits");
82  unsigned long long high = config.getParameter<unsigned long long>("physicsHiBits");
83  unsigned long long tech = config.getParameter<unsigned long long>("technicalBits");
84  for (unsigned int i = 0; i < 64; i++) {
85  m_selectPhysics[i] = low & (0x01ULL << (unsigned long long)i);
86  m_maskedPhysics[i] = low & (0x01ULL << (unsigned long long)i);
87  }
88  for (unsigned int i = 0; i < 64; i++) {
89  m_selectPhysics[i + 64] = high & (0x01ULL << (unsigned long long)i);
90  m_maskedPhysics[i + 64] = high & (0x01ULL << (unsigned long long)i);
91  }
92  for (unsigned int i = 0; i < 64; i++) {
93  m_selectTechnical[i] = tech & (0x01ULL << (unsigned long long)i);
94  m_maskedTechnical[i] = tech & (0x01ULL << (unsigned long long)i);
95  }
96 }
97 
99 
102  desc.add<edm::InputTag>("L1GtReadoutRecordTag", edm::InputTag("hltGtDigis"));
103  desc.add<std::vector<int>>("bunchCrossings", {0, -1, 1});
104  desc.add<unsigned int>("daqPartitions", 1);
105  desc.add<bool>("ignoreL1Mask", false);
106  desc.add<bool>("invert", false);
107  desc.add<unsigned long long int>("physicsLoBits", 0x0000000000000001LL); // bit 0
108  desc.add<unsigned long long int>("physicsHiBits", 0x0000000000040000LL); // bit 64 + 18 = 82
109  desc.add<unsigned long long int>("technicalBits", 0x0000000000000001LL); // bit 0
110  descriptions.add("hltLevel1Activity", desc);
111 }
112 
113 //
114 // member functions
115 //
116 
117 // ------------ method called to produce the data ------------
119  /*
120  // apply L1 mask to the physics bits
121  // - mask & partition == part. --> fully masked
122  // - mask & partition == 0x00 --> fully unmasked
123  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
124  if (not m_ignoreL1Mask and m_watchPhysicsMask.check(setup)) {
125  edm::ESHandle<L1GtTriggerMask> h_mask;
126  setup.get<L1GtTriggerMaskAlgoTrigRcd>().get(h_mask);
127  const std::vector<unsigned int> & mask = h_mask->gtTriggerMask();
128  for (unsigned int i = 0; i < PHYSICS_BITS_SIZE; ++i)
129  m_maskedPhysics[i] = m_selectPhysics[i] and ((mask[i] & m_daqPartitions) != m_daqPartitions);
130  }
131 
132  // apply L1 mask to the technical bits
133  // - mask & partition == part. --> fully masked
134  // - mask & partition == 0x00 --> fully unmasked
135  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
136  if (not m_ignoreL1Mask and m_watchTechnicalMask.check(setup)) {
137  edm::ESHandle<L1GtTriggerMask> h_mask;
138  setup.get<L1GtTriggerMaskTechTrigRcd>().get(h_mask);
139  const std::vector<unsigned int> & mask = h_mask->gtTriggerMask();
140  for (unsigned int i = 0; i < TECHNICAL_BITS_SIZE; ++i)
141  m_maskedTechnical[i] = m_selectTechnical[i] and ((mask[i] & m_daqPartitions) != m_daqPartitions);
142  }
143 
144  // access the L1 decisions
145  edm::Handle<L1GlobalTriggerReadoutRecord> h_gtReadoutRecord;
146  event.getByToken(m_gtReadoutRecordToken, h_gtReadoutRecord);
147 
148  // compare the results with the requested bits, and return true as soon as the first match is found
149  for (int bx : m_bunchCrossings) {
150  const std::vector<bool> & physics = h_gtReadoutRecord->decisionWord(bx);
151  if (physics.size() != PHYSICS_BITS_SIZE)
152  // error in L1 results
153  return m_invert;
154  for (unsigned int i = 0; i < PHYSICS_BITS_SIZE; ++i)
155  if (m_maskedPhysics[i] and physics[i])
156  return not m_invert;
157  const std::vector<bool> & technical = h_gtReadoutRecord->technicalTriggerWord(bx);
158  if (technical.size() != TECHNICAL_BITS_SIZE)
159  // error in L1 results
160  return m_invert;
161  for (unsigned int i = 0; i < TECHNICAL_BITS_SIZE; ++i)
162  if (m_maskedTechnical[i] and technical[i])
163  return not m_invert;
164  }
165 
166  return m_invert;
167  */
168  return false;
169 }
170 
171 // define as a framework plugin
ConfigurationDescriptions.h
electrons_cff.bool
bool
Definition: electrons_cff.py:372
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
MessageLogger.h
L1GtTriggerMaskAlgoTrigRcd.h
L1GtTriggerMask.h
edm::ESWatcher< L1GtTriggerMaskAlgoTrigRcd >
ESHandle.h
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord >
HLTLevel1Activity::m_selectTechnical
std::vector< bool > m_selectTechnical
Definition: HLTLevel1Activity.cc:51
edm
HLT enums.
Definition: AlignableModifier.h:19
HLTLevel1Activity
Definition: HLTLevel1Activity.cc:39
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
L1GtTriggerMaskTechTrigRcd.h
HLTLevel1Activity::m_daqPartitions
unsigned int m_daqPartitions
Definition: HLTLevel1Activity.cc:54
PHYSICS_BITS_SIZE
#define PHYSICS_BITS_SIZE
Definition: HLTLevel1Activity.cc:32
HLTLevel1Activity::m_gtReadoutRecordTag
edm::InputTag m_gtReadoutRecordTag
Definition: HLTLevel1Activity.cc:47
L1GlobalTriggerReadoutRecord
Definition: L1GlobalTriggerReadoutRecord.h:46
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
HLTLevel1Activity::m_watchPhysicsMask
edm::ESWatcher< L1GtTriggerMaskAlgoTrigRcd > m_watchPhysicsMask
Definition: HLTLevel1Activity.cc:58
HLTLevel1Activity::m_gtReadoutRecordToken
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_gtReadoutRecordToken
Definition: HLTLevel1Activity.cc:48
config
Definition: config.py:1
MakerMacros.h
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
HLTLevel1Activity::m_maskedPhysics
std::vector< bool > m_maskedPhysics
Definition: HLTLevel1Activity.cc:52
ParameterSetDescription.h
HLTLevel1Activity::HLTLevel1Activity
HLTLevel1Activity(const edm::ParameterSet &)
Definition: HLTLevel1Activity.cc:70
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
HLTLevel1Activity::m_bunchCrossings
std::vector< int > m_bunchCrossings
Definition: HLTLevel1Activity.cc:49
createfilelist.int
int
Definition: createfilelist.py:10
edm::EventSetup
Definition: EventSetup.h:57
HLTLevel1Activity::m_selectPhysics
std::vector< bool > m_selectPhysics
Definition: HLTLevel1Activity.cc:50
HLTLevel1Activity::m_invert
bool m_invert
Definition: HLTLevel1Activity.cc:56
InputTag.h
HLTLevel1Activity::m_ignoreL1Mask
bool m_ignoreL1Mask
Definition: HLTLevel1Activity.cc:55
HLTLevel1Activity::filter
bool filter(edm::Event &, edm::EventSetup const &) final
Definition: HLTLevel1Activity.cc:118
L1DTConfigBti_cff.LL
LL
Definition: L1DTConfigBti_cff.py:25
HLTLevel1Activity::m_maskedTechnical
std::vector< bool > m_maskedTechnical
Definition: HLTLevel1Activity.cc:53
LaserClient_cfi.high
high
Definition: LaserClient_cfi.py:50
std
Definition: JetResolutionObject.h:76
Frameworkfwd.h
ESWatcher.h
EventSetup.h
TECHNICAL_BITS_SIZE
#define TECHNICAL_BITS_SIZE
Definition: HLTLevel1Activity.cc:33
HLTLevel1Activity::~HLTLevel1Activity
~HLTLevel1Activity() override
EDFilter.h
ParameterSet.h
HLTLevel1Activity::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: HLTLevel1Activity.cc:100
event
Definition: event.py:1
edm::stream::EDFilter
Definition: EDFilter.h:38
edm::Event
Definition: Event.h:73
HLTLevel1Activity::m_watchTechnicalMask
edm::ESWatcher< L1GtTriggerMaskTechTrigRcd > m_watchTechnicalMask
Definition: HLTLevel1Activity.cc:59
LaserClient_cfi.low
low
Definition: LaserClient_cfi.py:52
edm::InputTag
Definition: InputTag.h:15
L1GlobalTriggerReadoutRecord.h