CMS 3D CMS Logo

L1MuGMTReadoutRecord.cc
Go to the documentation of this file.
1 //-------------------------------------------------
2 //
10 //
11 //
12 // Author :
13 // H. Sakulin HEPHY Vienna
14 //
15 // Migrated to CMSSW:
16 // I. Mikulec
17 //
18 //--------------------------------------------------
19 
20 //-----------------------
21 // This Class's Header --
22 //-----------------------
23 
25 
26 //---------------
27 // C++ Headers --
28 //---------------
29 
30 #include <iostream>
31 #include <iomanip>
32 #include <cmath>
33 #include <algorithm>
34 
35 //-------------------------------
36 // Collaborating Class Headers --
37 //-------------------------------
38 
39 using namespace std;
40 
41 //--------------------------------------
42 // class L1MuGMTReadoutRecord
43 //--------------------------------------
44 
45 //----------------
46 // Constructors --
47 //----------------
48 
50  m_BarrelCands(4), m_ForwardCands(4), m_GMTCands(4) {
51  reset();
52 }
53 
56  reset();
57  m_BxInEvent = bxie;
58 }
59 
60 //--------------
61 // Destructor --
62 //--------------
64 }
65 
66 //--------------
67 // Operations --
68 //--------------
69 
72 
73  m_BxNr = 0;
74  m_BxInEvent = 0;
75  m_EvNr = 0;
76  m_BCERR = 0;
77 
78  std::vector<L1MuRegionalCand>::iterator itr;
79  for(itr = m_InputCands.begin(); itr != m_InputCands.end(); itr++) (*itr).reset();
80 
81  std::vector<L1MuGMTExtendedCand>::iterator itg;
82  for(itg = m_BarrelCands.begin(); itg != m_BarrelCands.end(); itg++) (*itg).reset();
83  for(itg = m_ForwardCands.begin(); itg != m_ForwardCands.end(); itg++) (*itg).reset();
84  for(itg = m_GMTCands.begin(); itg != m_GMTCands.end(); itg++) (*itg).reset();
85  for(int i=0;i<8;i++) {
86  m_MIPbits[i]=0;
87  m_Quietbits[i]=0;
88  }
89 }
90 
92 vector<L1MuGMTExtendedCand> L1MuGMTReadoutRecord::getGMTCands() const {
93 
94  vector<L1MuGMTExtendedCand> cands;
95 
96  std::vector<L1MuGMTExtendedCand>::const_iterator it;
97  for(it = m_BarrelCands.begin(); it != m_BarrelCands.end(); it++) {
98  if((*it).getDataWord()!=0) cands.push_back(*it);
99  }
100  for(it = m_ForwardCands.begin(); it != m_ForwardCands.end(); it++) {
101  if((*it).getDataWord()!=0) cands.push_back(*it);
102  }
103 
104  // sort by rank
105  stable_sort( cands.begin(), cands.end(), L1MuGMTExtendedCand::rankRef );
106 
107 
108  return cands;
109 }
110 
112 vector<L1MuGMTExtendedCand>& L1MuGMTReadoutRecord::getGMTCandsData() {
113 
114  return m_GMTCands;
115 
116 }
117 
119 vector<L1MuGMTExtendedCand> L1MuGMTReadoutRecord::getGMTBrlCands() const {
120 
121  vector<L1MuGMTExtendedCand> cands;
122  std::vector<L1MuGMTExtendedCand>::const_iterator it;
123  for(it = m_BarrelCands.begin(); it != m_BarrelCands.end(); it++) {
124  if((*it).getDataWord()!=0) cands.push_back(*it);
125  }
126 
127  return cands;
128 
129 }
130 
132 vector<L1MuGMTExtendedCand> L1MuGMTReadoutRecord::getGMTFwdCands() const {
133 
134  vector<L1MuGMTExtendedCand> cands;
135  std::vector<L1MuGMTExtendedCand>::const_iterator it;
136  for(it = m_ForwardCands.begin(); it != m_ForwardCands.end(); it++) {
137  if((*it).getDataWord()!=0) cands.push_back(*it);
138  }
139 
140  return cands;
141 
142 }
143 
145 vector<L1MuRegionalCand> L1MuGMTReadoutRecord::getDTBXCands() const {
146 
147  vector<L1MuRegionalCand> cands;
148 
149  for (int i=0; i<4; i++)
150  if(m_InputCands[i].getDataWord() != 0)
151  cands.push_back( m_InputCands[i] );
152 
153 
154  return cands;
155 }
156 
157 
159 vector<L1MuRegionalCand> L1MuGMTReadoutRecord::getCSCCands() const {
160 
161  vector<L1MuRegionalCand> cands;
162 
163  for (int i=0; i<4; i++)
164  if(m_InputCands[i+8].getDataWord() != 0)
165  cands.push_back( m_InputCands[i+8] );
166 
167  return cands;
168 }
169 
171 vector<L1MuRegionalCand> L1MuGMTReadoutRecord::getBrlRPCCands() const {
172 
173  vector<L1MuRegionalCand> cands;
174 
175  for (int i=0; i<4; i++)
176  if(m_InputCands[i+4].getDataWord() != 0)
177  cands.push_back( m_InputCands[i+4] );
178 
179  return cands;
180 }
181 
183 vector<L1MuRegionalCand> L1MuGMTReadoutRecord::getFwdRPCCands() const {
184 
185  vector<L1MuRegionalCand> cands;
186 
187  for (int i=0; i<4; i++)
188  if(m_InputCands[i+12].getDataWord() != 0)
189  cands.push_back( m_InputCands[i+12] );
190 
191  return cands;
192 }
193 
195 unsigned L1MuGMTReadoutRecord::getMIPbit(int eta, int phi) const {
196 
197  if (phi<0 || phi > 17 || eta < 0 || eta > 13) return 0;
198 
199  int idx = eta * 18 + phi;
200  int idx_word = idx / 32;
201  int idx_bit = idx % 32;
202 
203  unsigned mask = 1 << (idx_bit-1);
204 
205  return( m_MIPbits[idx_word] & mask) ? 1 : 0;
206 
207 }
208 
209 
211 unsigned L1MuGMTReadoutRecord::getQuietbit(int eta, int phi) const {
212 
213  if (phi<0 || phi > 17 || eta < 0 || eta > 13) return 0;
214 
215  int idx = eta * 18 + phi;
216  int idx_word = idx / 32;
217  int idx_bit = idx % 32;
218 
219  unsigned mask = 1 << (idx_bit-1);
220 
221  return( m_Quietbits[idx_word] & mask) ? 1 : 0;
222 
223 }
224 
225 
226 
227 //
228 // Setters
229 //
230 
233  if (nr>=0 && nr < 16) {
234  m_InputCands[nr] = cand;
235  }
236 }
237 
239 void L1MuGMTReadoutRecord::setInputCand(int nr, unsigned data) {
240  if (nr>=0 && nr < 16) {
242  }
243 }
244 
247  if (nr>=0 && nr<4) {
248  m_BarrelCands[nr] = cand;
249  }
250 }
251 
253 void L1MuGMTReadoutRecord::setGMTBrlCand(int nr, unsigned data, unsigned rank) {
254  if (nr>=0 && nr<4) {
256  }
257 }
258 
261  if (nr>=0 && nr<4) {
262  m_ForwardCands[nr] = cand;
263  }
264 }
265 
267 void L1MuGMTReadoutRecord::setGMTFwdCand(int nr, unsigned data, unsigned rank) {
268  if (nr>=0 && nr<4) {
270  }
271 }
272 
275  if (nr>=0 && nr<4) {
276  m_GMTCands[nr] = cand;
277  }
278 }
279 
281 void L1MuGMTReadoutRecord::setGMTCand(int nr, unsigned data) {
282  if (nr>=0 && nr<4) {
284  }
285 }
286 
287 
288 
290 unsigned L1MuGMTReadoutRecord::getBrlRank(int i) const {
291 
292  return m_BarrelCands[i].rank();
293 
294 }
295 
296 
298 unsigned L1MuGMTReadoutRecord::getFwdRank(int i) const {
299 
300  return m_ForwardCands[i].rank();
301 
302 }
303 
306 
307  if (i>=0 && i<4) {
308  m_BarrelCands[i].setRank(value);
309  }
310 
311 }
312 
313 
316 
317  if (i>=0 && i<4) {
318  m_ForwardCands[i].setRank(value);
319  }
320 
321 }
322 
325 
326  if (phi<0 || phi > 17 || eta < 0 || eta > 13) return;
327 
328  int idx = eta * 18 + phi;
329  int idx_word = idx / 32;
330  int idx_bit = idx % 32;
331 
332  unsigned mask = 1 << (idx_bit-1);
333 
334  m_MIPbits[idx_word] |= mask;
335 
336 }
337 
338 
341 
342  if (phi<0 || phi > 17 || eta < 0 || eta > 13) return;
343 
344  int idx = eta * 18 + phi;
345  int idx_word = idx / 32;
346  int idx_bit = idx % 32;
347 
348  unsigned mask = 1 << (idx_bit-1);
349 
350  m_Quietbits[idx_word] |= mask;
351 
352 }
std::vector< L1MuGMTExtendedCand > & getGMTCandsData()
get GMT candidates vector as stored in data (no rank info)
std::vector< L1MuGMTExtendedCand > getGMTCands() const
get GMT candidates vector
std::vector< L1MuRegionalCand > m_InputCands
void setFwdRank(int i, unsigned value)
set rank of fwd cand i
L1MuGMTReadoutRecord()
constructors
void setBrlRank(int i, unsigned value)
set rank of brl cand i
void setGMTBrlCand(int nr, L1MuGMTExtendedCand const &cand)
set GMT barrel candidate
std::vector< L1MuGMTExtendedCand > m_BarrelCands
void setGMTFwdCand(int nr, L1MuGMTExtendedCand const &cand)
set GMT forward candidate
void setInputCand(int nr, unsigned data)
set Input muon
unsigned getQuietbit(int eta, int phi) const
get Quiet bit
std::vector< L1MuRegionalCand > getBrlRPCCands() const
get barrel RPC candidates vector
void setQuietbit(int eta, int phi)
set Quiet bit
void reset()
reset the record
std::vector< L1MuRegionalCand > getFwdRPCCands() const
get forward RPC candidates vector
void setMIPbit(int eta, int phi)
set MIP bit
std::vector< L1MuRegionalCand > getCSCCands() const
get CSC candidates vector
Definition: value.py:1
std::vector< L1MuGMTExtendedCand > getGMTBrlCands() const
get GMT barrel candidates vector
std::vector< L1MuRegionalCand > getDTBXCands() const
get DT candidates vector
static bool rankRef(const L1MuGMTExtendedCand &first, const L1MuGMTExtendedCand &second)
define a rank for muon candidates
unsigned getMIPbit(int eta, int phi) const
get MIP bit
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
std::vector< L1MuGMTExtendedCand > getGMTFwdCands() const
get GMT forward candidates vector
void setGMTCand(int nr, L1MuGMTExtendedCand const &cand)
set GMT candidate (does not store rank)
std::vector< L1MuGMTExtendedCand > m_GMTCands
virtual ~L1MuGMTReadoutRecord()
destructor
std::vector< L1MuGMTExtendedCand > m_ForwardCands
unsigned getFwdRank(int i) const
get rank of fwd cand i
unsigned getBrlRank(int i) const
get rank of brl cand i