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