CMS 3D CMS Logo

L1MuGMTPSB.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
3 // Class: L1MuGMTPSB
4 //
5 // Description: Pipelined Synchronising Buffer module
6 //
7 //
8 //
9 // Author :
10 // N. Neumeister CERN EP
11 //
12 // Migrated to CMSSW:
13 // I. Mikulec
14 //
15 //--------------------------------------------------
16 
17 //-----------------------
18 // This Class's Header --
19 //-----------------------
20 
22 
23 //---------------
24 // C++ Headers --
25 //---------------
26 
27 #include <iostream>
28 #include <iomanip>
29 #include <vector>
30 
31 //-------------------------------
32 // Collaborating Class Headers --
33 //-------------------------------
34 
39 
42 
44 
45 // --------------------------------
46 // class L1MuGMTPSB
47 //---------------------------------
48 
49 //----------------
50 // Constructors --
51 //----------------
53  : m_gmt(gmt),
54  m_RpcMuons(L1MuGMTConfig::MAXRPC),
55  m_DtbxMuons(L1MuGMTConfig::MAXDTBX),
56  m_CscMuons(L1MuGMTConfig::MAXCSC),
57  m_Isol(14, 18, false),
58  m_Mip(14, 18, false) {
62  iC.consumes<std::vector<L1MuRegionalCand> >(L1MuGMTConfig::getDTInputTag());
63  iC.consumes<std::vector<L1MuRegionalCand> >(L1MuGMTConfig::getCSCInputTag());
64  iC.consumes<std::vector<L1MuRegionalCand> >(L1MuGMTConfig::getRPCbInputTag());
65  iC.consumes<std::vector<L1MuRegionalCand> >(L1MuGMTConfig::getRPCfInputTag());
67 }
68 
69 //--------------
70 // Destructor --
71 //--------------
73  reset();
74  m_RpcMuons.clear();
75  m_DtbxMuons.clear();
76  m_CscMuons.clear();
77 }
78 
79 //--------------
80 // Operations --
81 //--------------
82 
83 //
84 // receive data
85 //
88 
90 
91  const L1MuGMTChannelMask* theChannelMask = L1MuGMTConfig::getGMTChanMask();
92  unsigned mask = theChannelMask->getSubsystemMask();
93 
94  if ((L1MuGMTConfig::getDTInputTag()).label() != "none" && !(mask & 1)) {
95  e.getByLabel(L1MuGMTConfig::getDTInputTag(), rc_handle);
96  if (rc_handle.isValid()) {
97  getDTBX(rc_handle.product(), bx);
98  } else {
99  if (L1MuGMTConfig::Debug(1)) {
100  edm::LogWarning("GlobalMuonTrigger")
101  << "\nWarning: GlobalMuonTrigger: input tag " << L1MuGMTConfig::getDTInputTag()
102  << "\nrequested, but not found in the event." << std::endl;
103  }
104  }
105  }
106  if ((L1MuGMTConfig::getCSCInputTag()).label() != "none" && !(mask & 4)) {
107  e.getByLabel(L1MuGMTConfig::getCSCInputTag(), rc_handle);
108  if (rc_handle.isValid()) {
109  getCSC(rc_handle.product(), bx);
110  } else {
111  if (L1MuGMTConfig::Debug(1)) {
112  edm::LogWarning("GlobalMuonTrigger")
113  << "\nWarning: GlobalMuonTrigger: input tag " << L1MuGMTConfig::getCSCInputTag()
114  << "\nrequested, but not found in the event." << std::endl;
115  }
116  }
117  }
118  if ((L1MuGMTConfig::getRPCbInputTag()).label() != "none" && !(mask & 2)) {
119  e.getByLabel(L1MuGMTConfig::getRPCbInputTag(), rc_handle);
120  if (rc_handle.isValid()) {
121  getRPCb(rc_handle.product(), bx);
122  } else {
123  if (L1MuGMTConfig::Debug(1)) {
124  edm::LogWarning("GlobalMuonTrigger")
125  << "\nWarning: GlobalMuonTrigger: input tag " << L1MuGMTConfig::getRPCbInputTag()
126  << "\nrequested, but not found in the event." << std::endl;
127  }
128  }
129  }
130  if ((L1MuGMTConfig::getRPCfInputTag()).label() != "none" && !(mask & 8)) {
131  e.getByLabel(L1MuGMTConfig::getRPCfInputTag(), rc_handle);
132  if (rc_handle.isValid()) {
133  getRPCf(rc_handle.product(), bx);
134  } else {
135  if (L1MuGMTConfig::Debug(1)) {
136  edm::LogWarning("GlobalMuonTrigger")
137  << "\nWarning: GlobalMuonTrigger: input tag " << L1MuGMTConfig::getRPCfInputTag()
138  << "\nrequested, but not found in the event." << std::endl;
139  }
140  }
141  }
142 
144 
145  const L1MuTriggerScales* theTriggerScales = L1MuGMTConfig::getTriggerScales();
146  const L1MuTriggerPtScale* theTriggerPtScale = L1MuGMTConfig::getTriggerPtScale();
147 
148  // store data in readout record
149  for (int i = 0; i < 4; i++) {
151  cand->setPhiValue(theTriggerScales->getPhiScale()->getLowEdge(cand->phi_packed()));
152  cand->setEtaValue(theTriggerScales->getRegionalEtaScale(cand->type_idx())->getCenter(cand->eta_packed()));
153  cand->setPtValue(theTriggerPtScale->getPtScale()->getLowEdge(cand->pt_packed()));
154  // cand->setPtValue( theTriggerScales->getPtScale()->getLowEdge(cand->pt_packed()) );
156  }
157  for (int i = 0; i < 4; i++) {
159  cand->setPhiValue(theTriggerScales->getPhiScale()->getLowEdge(cand->phi_packed()));
160  cand->setEtaValue(theTriggerScales->getRegionalEtaScale(cand->type_idx())->getCenter(cand->eta_packed()));
161  cand->setPtValue(theTriggerPtScale->getPtScale()->getLowEdge(cand->pt_packed()));
162  // cand->setPtValue( theTriggerScales->getPtScale()->getLowEdge(cand->pt_packed()) );
164  }
165  for (int i = 0; i < 4; i++) {
167  cand->setPhiValue(theTriggerScales->getPhiScale()->getLowEdge(cand->phi_packed()));
168  cand->setEtaValue(theTriggerScales->getRegionalEtaScale(cand->type_idx())->getCenter(cand->eta_packed()));
169  cand->setPtValue(theTriggerPtScale->getPtScale()->getLowEdge(cand->pt_packed()));
170  // cand->setPtValue( theTriggerScales->getPtScale()->getLowEdge(cand->pt_packed()) );
172  }
173  for (int i = 0; i < 4; i++) {
174  L1MuRegionalCand* cand = &(m_RpcMuons[i + 4]);
175  cand->setPhiValue(theTriggerScales->getPhiScale()->getLowEdge(cand->phi_packed()));
176  cand->setEtaValue(theTriggerScales->getRegionalEtaScale(cand->type_idx())->getCenter(cand->eta_packed()));
177  cand->setPtValue(theTriggerPtScale->getPtScale()->getLowEdge(cand->pt_packed()));
178  // cand->setPtValue( theTriggerScales->getPtScale()->getLowEdge(cand->pt_packed()) );
180  }
181 
182  // if there is at least one muon start the calorimeter trigger
183 
185  getCalo(e);
186 }
187 
188 //
189 // clear PSB
190 //
192  std::vector<L1MuRegionalCand>::iterator iter;
193  iter = m_RpcMuons.begin();
194  while (iter != m_RpcMuons.end())
195  (*(iter++)).reset();
196 
197  iter = m_DtbxMuons.begin();
198  while (iter != m_DtbxMuons.end())
199  (*(iter++)).reset();
200 
201  iter = m_CscMuons.begin();
202  while (iter != m_CscMuons.end())
203  (*(iter++)).reset();
204 
205  m_Isol.reset(false);
206  m_Mip.reset(false);
207 }
208 
209 //
210 // print muons
211 //
212 void L1MuGMTPSB::print() const {
213  edm::LogVerbatim("GMT_PSB_info") << " ";
214  printDTBX();
215  printRPCbarrel();
216  printCSC();
217  printRPCendcap();
218  edm::LogVerbatim("GMT_PSB_info") << " ";
219 }
220 
221 //
222 // return RPC muon
223 //
225  return (index < (int)L1MuGMTConfig::MAXRPC && index >= 0) ? &(m_RpcMuons[index]) : nullptr;
226 }
227 
228 //
229 // return DTBX muon
230 //
232  return (index < (int)L1MuGMTConfig::MAXDTBX && index >= 0) ? &(m_DtbxMuons[index]) : nullptr;
233 }
234 
235 //
236 // return CSC muon
237 //
239  return (index < (int)L1MuGMTConfig::MAXCSC && index >= 0) ? &(m_CscMuons[index]) : nullptr;
240 }
241 
242 //
243 // count number of non empty RPC muons
244 //
246  int count = 0;
247  std::vector<L1MuRegionalCand>::const_iterator iter = m_RpcMuons.begin();
248  while (iter != m_RpcMuons.end()) {
249  if (!(*iter).empty())
250  count++;
251  iter++;
252  }
253  return count;
254 }
255 
256 //
257 // count number of non empty DT muons
258 //
260  int count = 0;
261  std::vector<L1MuRegionalCand>::const_iterator iter = m_DtbxMuons.begin();
262  while (iter != m_DtbxMuons.end()) {
263  if (!(*iter).empty())
264  count++;
265  iter++;
266  }
267  return count;
268 }
269 
270 //
271 // count number of non empty CSC muons
272 //
274  int count = 0;
275  std::vector<L1MuRegionalCand>::const_iterator iter = m_CscMuons.begin();
276  while (iter != m_CscMuons.end()) {
277  if (!(*iter).empty())
278  count++;
279  iter++;
280  }
281  return count;
282 }
283 
284 //
285 // are there any data in the PSB
286 //
287 bool L1MuGMTPSB::empty() const {
288  int number = numberRPC() + numberDTBX() + numberCSC();
289 
290  return (number == 0);
291 }
292 
293 //
294 // get muons from RPCb Trigger
295 //
296 void L1MuGMTPSB::getRPCb(std::vector<L1MuRegionalCand> const* data, int bx) {
297  int irpcb = 0;
298  std::vector<L1MuRegionalCand>::const_iterator iter;
299  for (iter = data->begin(); iter != data->end(); iter++) {
300  if ((*iter).bx() != bx)
301  continue;
302  if (irpcb < (int)L1MuGMTConfig::MAXRPCbarrel) {
303  if (!(*iter).empty())
304  m_RpcMuons[irpcb] = (*iter);
305  irpcb++;
306  }
307  }
308 }
309 
310 //
311 // get muons from RPCf Trigger
312 //
313 void L1MuGMTPSB::getRPCf(std::vector<L1MuRegionalCand> const* data, int bx) {
314  int irpcf = 0;
315  std::vector<L1MuRegionalCand>::const_iterator iter;
316  for (iter = data->begin(); iter != data->end(); iter++) {
317  if ((*iter).bx() != bx)
318  continue;
319  if (irpcf < (int)L1MuGMTConfig::MAXRPCendcap) {
320  if (!(*iter).empty())
321  m_RpcMuons[irpcf + 4] = (*iter);
322  irpcf++;
323  }
324  }
325 }
326 
327 //
328 // get muons from barrel Muon Trigger Track Finder
329 //
330 void L1MuGMTPSB::getDTBX(std::vector<L1MuRegionalCand> const* data, int bx) {
331  // temporary hack with bxoffset - to be removed, trigger bx should be 0
332  int bxoffset = 0;
333  int idtbx = 0;
334  std::vector<L1MuRegionalCand>::const_iterator iter;
335  for (iter = data->begin(); iter != data->end(); iter++) {
336  if (L1MuGMTConfig::Debug(2))
337  edm::LogVerbatim("") << "DTTF BX: " << (*iter).bx() << " my bx: " << bx;
338  if ((*iter).bx() > 10)
339  bxoffset = 16;
340  if ((*iter).bx() != bx + bxoffset)
341  continue;
342  if (idtbx < (int)L1MuGMTConfig::MAXDTBX) {
343  m_DtbxMuons[idtbx] = (*iter);
344  m_DtbxMuons[idtbx].setBx(bx);
345  idtbx++;
346  }
347  }
348 }
349 
350 //
351 // get muons from CSC Track Finder
352 //
353 void L1MuGMTPSB::getCSC(std::vector<L1MuRegionalCand> const* data, int bx) {
354  int icsc = 0;
355  std::vector<L1MuRegionalCand>::const_iterator iter;
356  for (iter = data->begin(); iter != data->end(); iter++) {
357  if ((*iter).bx() != bx)
358  continue;
359  if (icsc < (int)L1MuGMTConfig::MAXCSC) {
360  m_CscMuons[icsc] = (*iter);
361  icsc++;
362  }
363  }
364 }
365 
366 //
367 // print barrel RPC muons
368 //
370  edm::LogVerbatim("GMT_PSB_info") << "RPC barrel muons received by the GMT :";
371 
372  for (unsigned i = 0; i < L1MuGMTConfig::MAXRPCbarrel; i++) {
373  if (!m_RpcMuons[i].empty())
374  m_RpcMuons[i].print();
375  }
376 }
377 
378 //
379 // print endcap RPC muons
380 //
382  edm::LogVerbatim("GMT_PSB_info") << "RPC endcap muons received by the GMT :";
383 
384  for (unsigned i = 0; i < L1MuGMTConfig::MAXRPCendcap; i++) {
385  if (!m_RpcMuons[i + 4].empty())
386  m_RpcMuons[i + 4].print();
387  }
388 }
389 
390 //
391 // print DTBX muons
392 //
393 void L1MuGMTPSB::printDTBX() const {
394  edm::LogVerbatim("GMT_PSB_info") << "DTBX muons received by the GMT :";
395 
396  for (unsigned i = 0; i < L1MuGMTConfig::MAXDTBX; i++) {
397  if (!m_DtbxMuons[i].empty())
398  m_DtbxMuons[i].print();
399  }
400 }
401 
402 //
403 // print CSC muons
404 //
405 void L1MuGMTPSB::printCSC() const {
406  edm::LogVerbatim("GMT_PSB_info") << "CSC muons received by the GMT :";
407 
408  for (unsigned i = 0; i < L1MuGMTConfig::MAXCSC; i++) {
409  if (!m_CscMuons[i].empty())
410  m_CscMuons[i].print();
411  }
412 }
413 
414 //
415 // get data from regional calorimeter trigger
416 //
419  e.getByLabel(L1MuGMTConfig::getMipIsoInputTag(), calocoll_h);
420  if (calocoll_h.isValid()) {
421  L1CaloRegionCollection const* regions = calocoll_h.product();
422  L1CaloRegionCollection::const_iterator iter;
423 
424  // edm::LogVerbatim("GMT_PSB_info") << "MIP/QUIET bits rceived by the GMT :";
425 
426  for (iter = regions->begin(); iter != regions->end(); iter++) {
427  if ((*iter).id().ieta() < 4 || (*iter).id().ieta() > 17 || (*iter).id().iphi() > 17)
428  continue;
429  m_Isol.set((*iter).id().ieta() - 4, (*iter).id().iphi(), (*iter).quiet());
430  m_Mip.set((*iter).id().ieta() - 4, (*iter).id().iphi(), (*iter).mip());
431 
432  if ((*iter).quiet())
433  m_gmt.currentReadoutRecord()->setQuietbit((*iter).id().ieta() - 4, (*iter).id().iphi());
434 
435  if ((*iter).mip())
436  m_gmt.currentReadoutRecord()->setMIPbit((*iter).id().ieta() - 4, (*iter).id().iphi());
437 
438  // edm::LogVerbatim("GMT_PSB_info") << (*iter).id().ieta()-4 << " "
439  // << (*iter).id().iphi() << " "
440  // << (*iter).quiet() << " "
441  // << (*iter).mip();
442  }
443  } else {
444  if (L1MuGMTConfig::Debug(1)) {
445  edm::LogWarning("GlobalMuonTrigger")
446  << "\nWarning: GlobalMuonTrigger: input tag " << L1MuGMTConfig::getMipIsoInputTag()
447  << "\nrequested, but not found in the event." << std::endl;
448  }
449  }
450 }
Log< level::Info, true > LogVerbatim
void getRPCf(std::vector< L1MuRegionalCand > const *data, int bx)
get muons from RPCf Trigger
Definition: L1MuGMTPSB.cc:313
void getCSC(std::vector< L1MuRegionalCand > const *data, int bx)
get muons from endcap Muon Trigger Track Finder
Definition: L1MuGMTPSB.cc:353
int numberDTBX() const
return number of non-empty DTBX muons
Definition: L1MuGMTPSB.cc:259
static edm::InputTag getRPCfInputTag()
Definition: L1MuGMTConfig.h:98
static edm::InputTag getRPCbInputTag()
Definition: L1MuGMTConfig.h:97
static bool getCaloTrigger()
void set(int r, int c, T v)
set matrix element
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
T const * product() const
Definition: Handle.h:70
int numberRPC() const
return number of non-empty RPC muons
Definition: L1MuGMTPSB.cc:245
const L1MuRegionalCand * RPCMuon(int index) const
get RPC muon
Definition: L1MuGMTPSB.cc:224
void setInputCand(int nr, unsigned data)
set Input muon
void getCalo(edm::Event &e)
get Calorimeter Trigger data
Definition: L1MuGMTPSB.cc:417
void printRPCbarrel() const
print barrel RPC muons
Definition: L1MuGMTPSB.cc:369
const L1MuGlobalMuonTrigger & m_gmt
Definition: L1MuGMTPSB.h:122
void print() const
print PSB
Definition: L1MuGMTPSB.cc:212
void reset()
clear PSB
Definition: L1MuGMTPSB.cc:191
const L1MuScale * getPhiScale() const
get the phi scale
const L1MuScale * getPtScale() const
get the Pt scale
constexpr uint32_t mask
Definition: gpuClustering.h:24
L1MuGMTPSB(const L1MuGlobalMuonTrigger &gmt, edm::ConsumesCollector &&iC)
constructor
Definition: L1MuGMTPSB.cc:52
void setQuietbit(int eta, int phi)
set Quiet bit
const L1MuRegionalCand * DTBXMuon(int index) const
get DTBX muon
Definition: L1MuGMTPSB.cc:231
const L1MuRegionalCand * CSCMuon(int index) const
get CSC muon
Definition: L1MuGMTPSB.cc:238
char const * label
void setMIPbit(int eta, int phi)
set MIP bit
static bool Debug()
const L1MuScale * getRegionalEtaScale(int isys) const
get the regioanl muon trigger eta scale, isys = 0(DT), 1(bRPC), 2(CSC), 3(fwdRPC) ...
void reset(T v)
reset all elements
unsigned getSubsystemMask() const
static const L1MuGMTChannelMask * getGMTChanMask()
static const unsigned int MAXCSC
Definition: L1MuGMTConfig.h:85
static const unsigned int MAXDTBX
Definition: L1MuGMTConfig.h:85
static const unsigned int MAXRPCendcap
Definition: L1MuGMTConfig.h:85
virtual ~L1MuGMTPSB()
destructor
Definition: L1MuGMTPSB.cc:72
std::vector< L1MuRegionalCand > m_CscMuons
Definition: L1MuGMTPSB.h:126
L1MuGMTReadoutRecord * currentReadoutRecord() const
return a reference to the current record in the ring buffer
static const L1MuTriggerPtScale * getTriggerPtScale()
L1MuGMTMatrix< bool > m_Isol
Definition: L1MuGMTPSB.h:128
void printCSC() const
print CSC muons
Definition: L1MuGMTPSB.cc:405
int numberCSC() const
return number of non-empty CSC muons
Definition: L1MuGMTPSB.cc:273
static const L1MuTriggerScales * getTriggerScales()
void getRPCb(std::vector< L1MuRegionalCand > const *data, int bx)
get muons from RPCb Trigger
Definition: L1MuGMTPSB.cc:296
bool isValid() const
Definition: HandleBase.h:70
bool empty() const
are there any data in the PSB
Definition: L1MuGMTPSB.cc:287
void receiveData(edm::Event &e, int bx)
receive muon candidates
Definition: L1MuGMTPSB.cc:86
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
static edm::InputTag getMipIsoInputTag()
Definition: L1MuGMTConfig.h:99
void getDTBX(std::vector< L1MuRegionalCand > const *data, int bx)
get muons from barrel Muon Trigger Track Finder
Definition: L1MuGMTPSB.cc:330
L1MuGMTMatrix< bool > m_Mip
Definition: L1MuGMTPSB.h:129
static const unsigned int MAXRPCbarrel
Definition: L1MuGMTConfig.h:85
void printDTBX() const
print DTBX muons
Definition: L1MuGMTPSB.cc:393
std::vector< L1CaloRegion > L1CaloRegionCollection
std::vector< L1MuRegionalCand > m_RpcMuons
Definition: L1MuGMTPSB.h:124
Log< level::Warning, false > LogWarning
std::vector< L1MuRegionalCand > m_DtbxMuons
Definition: L1MuGMTPSB.h:125
static edm::InputTag getDTInputTag()
Definition: L1MuGMTConfig.h:95
static const unsigned int MAXRPC
Definition: L1MuGMTConfig.h:85
void printRPCendcap() const
print endcap RPC muons
Definition: L1MuGMTPSB.cc:381
static edm::InputTag getCSCInputTag()
Definition: L1MuGMTConfig.h:96