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&, const edm::EventSetup&) override;
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 
62 #include <boost/foreach.hpp>
63 
68 
69 //
70 // constructors and destructor
71 //
73  m_gtReadoutRecordTag( config.getParameter<edm::InputTag> ("L1GtReadoutRecordTag") ),
74  m_gtReadoutRecordToken(consumes<L1GlobalTriggerReadoutRecord>(m_gtReadoutRecordTag)),
75  m_bunchCrossings( config.getParameter<std::vector<int> > ("bunchCrossings") ),
76  m_selectPhysics( PHYSICS_BITS_SIZE ),
77  m_selectTechnical( TECHNICAL_BITS_SIZE ),
78  m_maskedPhysics( PHYSICS_BITS_SIZE ),
79  m_maskedTechnical( TECHNICAL_BITS_SIZE ),
80  m_daqPartitions( config.getParameter<unsigned int> ("daqPartitions") ),
81  m_ignoreL1Mask( config.getParameter<bool> ("ignoreL1Mask") ),
82  m_invert( config.getParameter<bool> ("invert") )
83 {
84  unsigned long long low = config.getParameter<unsigned long long>("physicsLoBits");
85  unsigned long long high = config.getParameter<unsigned long long>("physicsHiBits");
86  unsigned long long tech = config.getParameter<unsigned long long>("technicalBits");
87  for (unsigned int i = 0; i < 64; i++) {
88  m_selectPhysics[i] = low & (0x01ULL << (unsigned long long) i);
89  m_maskedPhysics[i] = low & (0x01ULL << (unsigned long long) i);
90  }
91  for (unsigned int i = 0; i < 64; i++) {
92  m_selectPhysics[i+64] = high & (0x01ULL << (unsigned long long) i);
93  m_maskedPhysics[i+64] = high & (0x01ULL << (unsigned long long) i);
94  }
95  for (unsigned int i = 0; i < 64; i++) {
96  m_selectTechnical[i] = tech & (0x01ULL << (unsigned long long) i);
97  m_maskedTechnical[i] = tech & (0x01ULL << (unsigned long long) i);
98  }
99 }
100 
102 {
103 }
104 
105 void
108  desc.add<edm::InputTag>("L1GtReadoutRecordTag",edm::InputTag("hltGtDigis"));
109  {
110  std::vector<int> temp1;
111  temp1.reserve(3);
112  temp1.push_back(0);
113  temp1.push_back(-1);
114  temp1.push_back(1);
115  desc.add<std::vector<int> >("bunchCrossings",temp1);
116  }
117  desc.add<unsigned int>("daqPartitions",1);
118  desc.add<bool>("ignoreL1Mask",false);
119  desc.add<bool>("invert",false);
120  desc.add<unsigned long long int>("physicsLoBits",1);
121  desc.add<unsigned long long int>("physicsHiBits",262144);
122  desc.add<unsigned long long int>("technicalBits",1);
123  descriptions.add("hltLevel1Activity",desc);
124 }
125 
126 //
127 // member functions
128 //
129 
130 // ------------ method called to produce the data ------------
131 bool
133 {
134  // apply L1 mask to the physics bits
135  // - mask & partition == part. --> fully masked
136  // - mask & partition == 0x00 --> fully unmasked
137  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
138  if (not m_ignoreL1Mask and m_watchPhysicsMask.check(setup)) {
140  setup.get<L1GtTriggerMaskAlgoTrigRcd>().get(h_mask);
141  const std::vector<unsigned int> & mask = h_mask->gtTriggerMask();
142  for (unsigned int i = 0; i < PHYSICS_BITS_SIZE; ++i)
143  m_maskedPhysics[i] = m_selectPhysics[i] and ((mask[i] & m_daqPartitions) != m_daqPartitions);
144  }
145 
146  // apply L1 mask to the technical bits
147  // - mask & partition == part. --> fully masked
148  // - mask & partition == 0x00 --> fully unmasked
149  // - mask & partition != part. --> unmasked in some partitions, consider as unmasked
150  if (not m_ignoreL1Mask and m_watchTechnicalMask.check(setup)) {
152  setup.get<L1GtTriggerMaskTechTrigRcd>().get(h_mask);
153  const std::vector<unsigned int> & mask = h_mask->gtTriggerMask();
154  for (unsigned int i = 0; i < TECHNICAL_BITS_SIZE; ++i)
155  m_maskedTechnical[i] = m_selectTechnical[i] and ((mask[i] & m_daqPartitions) != m_daqPartitions);
156  }
157 
158  // access the L1 decisions
160  event.getByToken(m_gtReadoutRecordToken, h_gtReadoutRecord);
161 
162  // compare the results with the requested bits, and return true as soon as the first match is found
163  BOOST_FOREACH(int bx, m_bunchCrossings) {
164  const std::vector<bool> & physics = h_gtReadoutRecord->decisionWord(bx);
165  if (physics.size() != PHYSICS_BITS_SIZE)
166  // error in L1 results
167  return m_invert;
168  for (unsigned int i = 0; i < PHYSICS_BITS_SIZE; ++i)
169  if (m_maskedPhysics[i] and physics[i])
170  return not m_invert;
171  const std::vector<bool> & technical = h_gtReadoutRecord->technicalTriggerWord(bx);
172  if (technical.size() != TECHNICAL_BITS_SIZE)
173  // error in L1 results
174  return m_invert;
175  for (unsigned int i = 0; i < TECHNICAL_BITS_SIZE; ++i)
176  if (m_maskedTechnical[i] and technical[i])
177  return not m_invert;
178  }
179 
180  return m_invert;
181 }
182 
183 // 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
virtual bool filter(edm::Event &, const edm::EventSetup &) override
#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
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