CMS 3D CMS Logo

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