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