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