CMS 3D CMS Logo

RPCTBMuon.cc
Go to the documentation of this file.
1 //---------------------------------------------------------------------------
3 #ifndef _STAND_ALONE
5 #endif // _STAND_ALONE
7 
8 #include <sstream>
9 #include <iomanip>
10 #include <iostream>
11 
12 using namespace std;
13 //---------------------------------------------------------------------------
15  m_Killed = false;
16 
17  m_GBData = 0;
18 
19  m_EtaAddress = 0;
20  m_PhiAddress = 0;
21 
23 }
24 //---------------------------------------------------------------------------
25 RPCTBMuon::RPCTBMuon(int ptCode, int quality, int sign, int patternNum, unsigned short firedPlanes)
26  : RPCMuon(ptCode, quality, sign, patternNum, firedPlanes) {
27  m_Killed = false;
28 
29  m_GBData = 0;
30 
31  m_EtaAddress = 0;
32  m_PhiAddress = 0;
33 
35 }
36 
37 RPCTBMuon::RPCTBMuon(int ptCode, int quality, int sign, MuonBitsType muonBitsType)
38  : RPCMuon(ptCode, quality, sign, 0, 0) {
39  m_Killed = false;
40 
41  m_GBData = 0;
42 
43  m_EtaAddress = 0;
44  m_PhiAddress = 0;
45 
46  m_muonBitsType = muonBitsType;
47 }
48 
55 std::string RPCTBMuon::printDebugInfo(int debugFormat) const {
56  std::ostringstream sDebugInfo;
57  if (debugFormat == 1) { // Human readable
58 
59  sDebugInfo << "TBMuon: code: " << getPtCode() << " etaAddr: " << getEtaAddr() << " phiAddr: " << getPhiAddr()
60  << " sgAddr: " << getSegmentAddr() << " scAddr: " << getSectorAddr() << " gbData: " << getGBData();
61 
62  } else { //technicall
63  sDebugInfo << "TBMuon pt " << getPtCode() << " ql " << getQuality() << " sgn " << getSign() << " tw " << getTower()
64  << " sc " << getLogSector() << " sg " << getLogSegment() << " phi " << getPhiAddr() << " eta "
65  << getEtaAddr() << " gbD " << getGBData() << " bits " << toBits(mbtFSBOut);
66  }
67 
68  return sDebugInfo.str();
69 }
70 //---------------------------------------------------------------------------
71 // Simple setters and getters
72 
74 int RPCTBMuon::getCode() const {
75  // 1 bit, 0 - negative, 1 - positive.
76  unsigned int signLocal = 0;
77  if (m_Sign == 0)
78  signLocal = 1; // invert
79  return (m_Quality << 6 | m_PtCode << 1 | signLocal);
80 }
81 
83 void RPCTBMuon::setCode(int code) {
84  m_Quality = (code & (3 << 5)) >> 5;
85  m_PtCode = code & 31;
86 }
87 
88 void RPCTBMuon::setPhiAddr(int phiAddr) { m_PhiAddress = phiAddr; }
89 
90 void RPCTBMuon::setSectorAddr(int sectorAddr) { m_PhiAddress = m_PhiAddress | sectorAddr << 4; }
91 
92 void RPCTBMuon::setEtaAddr(int etaAddr) { m_EtaAddress = etaAddr; }
93 
94 void RPCTBMuon::setAddress(int etaAddr, int phiAddr) {
95  m_EtaAddress = etaAddr;
96  m_PhiAddress = phiAddr;
97 }
98 
99 void RPCTBMuon::setAddress(int tbNumber, int tbTower, int phiAddr) {
100  m_EtaAddress = (tbNumber << 2) | tbTower;
101  m_PhiAddress = phiAddr;
102 }
103 
104 void RPCTBMuon::setGBData(unsigned int gbData) { m_GBData = gbData; }
105 
106 int RPCTBMuon::getEtaAddr() const { return m_EtaAddress; }
107 
108 int RPCTBMuon::getPhiAddr() const { return m_PhiAddress; }
109 
110 int RPCTBMuon::getSegmentAddr() const { return m_PhiAddress & 15; }
111 
112 int RPCTBMuon::getSectorAddr() const { return (m_PhiAddress & 0xF0) >> 4; }
113 
115 
116 void RPCTBMuon::setCodeAndPhiAddr(int code, int phiAddr) {
117  setCode(code);
118  m_PhiAddress = phiAddr;
119 }
120 
121 void RPCTBMuon::setCodeAndEtaAddr(int code, int etaAddr) {
122  setCode(code);
123  m_EtaAddress = etaAddr;
124 }
125 
126 int RPCTBMuon::getGBData() const { return m_GBData; }
127 
129  std::string str = "00";
130  if (m_GBData == 1)
131  str = "01";
132  else if (m_GBData == 2)
133  str = "10";
134  else if (m_GBData == 3)
135  str = "11";
136  return str;
137 }
138 
140 
142 
143 bool RPCTBMuon::gBDataKilledFirst() const { return (m_GBData & 1); }
144 
145 bool RPCTBMuon::gBDataKilledLast() const { return (m_GBData & 2); }
146 
147 //---------------------------------------------------------------------------
148 void RPCTBMuon::kill() { m_Killed = true; }
149 
152 bool RPCTBMuon::wasKilled() const {
153  if (m_PtCode > 0 && m_Killed)
154  return true;
155  else
156  return false;
157 }
158 
161 bool RPCTBMuon::isLive() const {
162  if (m_PtCode > 0 && !m_Killed)
163  return true;
164  else
165  return false;
166 }
167 
168 //---------------------------------------------------------------------------
169 #ifndef _STAND_ALONE
170 RPCTBMuon::RPCTBMuon(const RPCPacMuon& pacMuon) : RPCMuon(pacMuon) {
171  m_Killed = false;
172 
173  m_GBData = 0;
174 
175  m_EtaAddress = 0;
176  m_PhiAddress = 0;
178 }
179 #endif //_STAND_ALONE
180 //---------------------------------------------------------------------------
181 
182 unsigned int RPCTBMuon::toBits(RPCTBMuon::MuonBitsType muonBitsType) const {
183  if (muonBitsType == mbtPACOut) {
184  return PACOut::toBits(*this);
185  } else if (muonBitsType == mbtTBSortOut) {
186  return TBOut::toBits(*this);
187  } else if (muonBitsType == mbtTCSortOut) {
188  return TCOut::toBits(*this);
189  } else if (muonBitsType == mbtHSBOut) {
190  return HSBOut::toBits(*this);
191  } else if (muonBitsType == mbtFSBOut) {
192  return FSBOut::toBits(*this);
193  } else {
194  throw RPCException("unknown value of muonBitsType");
195  //edm::LogError("RPCTrigger")<<"unknown value of where: " + where;
196  }
197  return 0;
198 }
199 
200 void RPCTBMuon::fromBits(RPCTBMuon::MuonBitsType muonBitsType, unsigned int value) {
201  if (muonBitsType == mbtPACOut) {
202  PACOut::fromBits(*this, value);
203  } else if (muonBitsType == mbtTBSortOut) {
204  TBOut::fromBits(*this, value);
205  } else if (muonBitsType == mbtTCSortOut) {
206  TCOut::fromBits(*this, value);
207  } else if (muonBitsType == mbtHSBOut) {
208  HSBOut::fromBits(*this, value);
209  } else if (muonBitsType == mbtFSBOut) {
210  FSBOut::fromBits(*this, value);
211  } else {
212  RPCException("unknown value of muonBitsType");
213  //edm::LogError("RPCTrigger")<< "unknown value of where: " + where;
214  }
215 }
216 
218  unsigned int shift = 0;
219  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
220  shift += m_signBitsCnt;
221  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
222  shift += m_ptBitsCnt;
223  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
224  shift += m_qualBitsCnt;
225 }
226 
228  unsigned int value = 0;
229  unsigned int shift = 0;
230  value = (muon.m_Sign << shift);
231  shift += m_signBitsCnt;
232  value = value | (muon.m_PtCode << shift);
233  shift += m_ptBitsCnt;
234  value = value | (muon.m_Quality << shift);
235  shift += m_qualBitsCnt;
236 
237  return value;
238 }
239 
240 //-----------------------
242  unsigned int shift = 0;
243  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
244  shift += m_signBitsCnt;
245  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
246  shift += m_ptBitsCnt;
247  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
248  shift += m_qualBitsCnt;
249  muon.m_PhiAddress = (value & (m_phiBitsMask << shift)) >> shift;
250  shift += m_phiBitsCnt;
251  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
252  shift += m_etaBitsCnt;
253  muon.m_GBData = (value & (m_gbDataBitsMask << shift)) >> shift;
254  shift += m_gbDataBitsCnt;
255 }
256 
258  unsigned int value = 0;
259  unsigned int shift = 0;
260  value = (muon.m_Sign << shift);
261  shift += m_signBitsCnt;
262  value = value | (muon.m_PtCode << shift);
263  shift += m_ptBitsCnt;
264  value = value | (muon.m_Quality << shift);
265  shift += m_qualBitsCnt;
266  value = value | (muon.m_PhiAddress << shift);
267  shift += m_phiBitsCnt;
268  value = value | (muon.m_EtaAddress << shift);
269  shift += m_etaBitsCnt;
270  value = value | (muon.m_GBData << shift);
271  shift += m_gbDataBitsCnt;
272  return value;
273 }
274 
275 //-----------------------
277  unsigned int shift = 0;
278  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
279  shift += m_signBitsCnt;
280  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
281  shift += m_ptBitsCnt;
282  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
283  shift += m_qualBitsCnt;
284  muon.m_PhiAddress = (value & (m_phiBitsMask << shift)) >> shift;
285  shift += m_phiBitsCnt;
286  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
287  shift += m_etaBitsCnt;
288  muon.m_GBData = (value & (m_gbDataBitsMask << shift)) >> shift;
289  shift += m_gbDataBitsCnt;
290 }
291 
293  unsigned int value = 0;
294  unsigned int shift = 0;
295  value = (muon.m_Sign << shift);
296  shift += m_signBitsCnt;
297  value = value | (muon.m_PtCode << shift);
298  shift += m_ptBitsCnt;
299  value = value | (muon.m_Quality << shift);
300  shift += m_qualBitsCnt;
301  value = value | (muon.m_PhiAddress << shift);
302  shift += m_phiBitsCnt;
303  value = value | (muon.m_EtaAddress << shift);
304  shift += m_etaBitsCnt;
305  value = value | (muon.m_GBData << shift);
306  shift += m_gbDataBitsCnt;
307  return value;
308 }
309 //-------------------------------
310 
312  unsigned int value = 0;
313 
314  unsigned int shift = 0;
315  value = value | (muon.m_Sign << shift);
316  shift += m_signBitsCnt;
317  // value = (muon.m_Sign<<shift); shift += m_signBitsCnt;
318  value = value | (muon.m_PtCode << shift);
319  shift += m_ptBitsCnt;
320  value = value | (muon.m_Quality << shift);
321  shift += m_qualBitsCnt;
322  value = value | (muon.m_PhiAddress << shift);
323  shift += m_phiBitsCnt;
324  value = value | (muon.m_EtaAddress << shift);
325  shift += m_etaBitsCnt;
326 
327  return value;
328 }
329 
331  unsigned int shift = 0;
332  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
333  shift += m_signBitsCnt;
334  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
335  shift += m_ptBitsCnt;
336  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
337  shift += m_qualBitsCnt;
338  muon.m_PhiAddress = (value & (m_phiBitsMask << shift)) >> shift;
339  shift += m_phiBitsCnt;
340  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
341  shift += m_etaBitsCnt;
342 }
343 
345  unsigned int value = 0;
346 
347  unsigned int shift = 0;
348  //bita are reversed, to be zero when cable not connected
349  unsigned int ptCode = (~(muon.m_PtCode)) & m_ptBitsMask;
350  unsigned int quality = (~(muon.m_Quality)) & m_qualBitsMask;
351 
352  value = value | muon.m_PhiAddress;
353  shift += m_phiBitsCnt;
354  value = value | (ptCode << shift);
355  shift += m_ptBitsCnt;
356  value = value | (quality << shift);
357  shift += m_qualBitsCnt;
358 
359  //+1 beacouse H/F bits, unused in RPC:
360  value = value | (muon.m_EtaAddress << shift);
361  shift += m_etaBitsCnt + 1;
362  value = value | (muon.m_Sign << shift);
363  shift += m_signBitsCnt;
364 
365  return value;
366 }
367 
369  unsigned int shift = 0;
370  muon.m_PhiAddress = value & m_phiBitsMask;
371  shift += m_phiBitsCnt;
372  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
373  shift += m_ptBitsCnt;
374  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
375  shift += m_qualBitsCnt;
376 
377  //+1 beacouse H/F bits, unused in RPC:
378  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
379  shift += m_etaBitsCnt + 1;
380  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
381  shift += m_signBitsCnt;
382 
383  muon.m_PtCode = (~(muon.m_PtCode)) & m_ptBitsMask;
384  muon.m_Quality = (~(muon.m_Quality)) & m_qualBitsMask;
385 }
386 
388  ostringstream ostr;
389  if (format == 0) {
390  ostr << "qu " << m_Quality << ", pt " << setw(2) << m_PtCode << ", sig " << m_Sign << ", phi " << setw(3)
391  << m_PhiAddress << ", eta " << setw(2) << m_EtaAddress;
392  } else if (format == 1) {
393  ostr << " " << m_Quality << " " << setw(2) << m_PtCode << " " << m_Sign << " " << setw(3) << m_PhiAddress << " "
394  << setw(2) << m_EtaAddress;
395  } else if (format == 2) {
396  ostr << " " << m_Quality << " " << setw(2) << m_PtCode << " " << m_Sign;
397  }
398 
399  return ostr.str();
400 }
static const int m_ptBitsCnt
Definition: RPCTBMuon.h:124
static const int m_qualBitsCnt
Definition: RPCTBMuon.h:122
bool isLive() const
Definition: RPCTBMuon.cc:161
int getPhiAddr() const
Definition: RPCTBMuon.cc:108
unsigned int m_GBData
Definition: RPCTBMuon.h:113
int getEtaAddr() const
Definition: RPCTBMuon.cc:106
int getGBData() const
Definition: RPCTBMuon.cc:126
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:368
std::string getGBDataBitStr() const
Definition: RPCTBMuon.cc:128
unsigned int m_PhiAddress
Definition: RPCTBMuon.h:106
bool wasKilled() const
Definition: RPCTBMuon.cc:152
unsigned int m_PtCode
5 bits, 0-31.
Definition: RPCMuon.h:90
unsigned int m_Sign
1 bit, 0 - negative, 1 - positive.
Definition: RPCMuon.h:96
void setCodeAndEtaAddr(int code, int etaAddr)
Definition: RPCTBMuon.cc:121
void kill()
Definition: RPCTBMuon.cc:148
static unsigned int toBits(const RPCTBMuon &muon)
Definition: RPCTBMuon.cc:311
string quality
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:330
void setGBData(unsigned int gbData)
Definition: RPCTBMuon.cc:104
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:241
static unsigned int toBits(const RPCTBMuon &muon)
Definition: RPCTBMuon.cc:227
int getTower() const
Definition: RPCMuon.cc:57
int getCode() const
Combined quality and ptCode, 8 bits [7...6 m_Quality, 5...1 m_PtCode, 0 sign], used in GhoustBusters...
Definition: RPCTBMuon.cc:74
int getLogSegment() const
Definition: RPCMuon.cc:61
std::string printDebugInfo(int debugFormat) const
Gives debuging info in human readable format (1) or technicall format (2)
Definition: RPCTBMuon.cc:55
void setGBDataKilledFirst()
Definition: RPCTBMuon.cc:139
void setAddress(int etaAddr, int phiAddr)
Definition: RPCTBMuon.cc:94
static unsigned int toBits(const RPCTBMuon &muon)
Definition: RPCTBMuon.cc:292
void setEtaAddr(int etaAddr)
Definition: RPCTBMuon.cc:92
int getSectorAddr() const
Definition: RPCTBMuon.cc:112
Definition: value.py:1
void setCodeAndPhiAddr(int code, int phiAddr)
Definition: RPCTBMuon.cc:116
int getSign() const
Definition: RPCMuon.cc:73
int getContinSegmAddr() const
Definition: RPCTBMuon.cc:114
int getSegmentAddr() const
Definition: RPCTBMuon.cc:110
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:276
int getPtCode() const
Definition: RPCMuon.cc:65
unsigned int toBits() const
Definition: RPCTBMuon.h:95
int getQuality() const
Definition: RPCMuon.cc:69
void setCode(int code)
Sets combined code: 8 bits [7...5 m_Quality, 4...0 m_PtCode].
Definition: RPCTBMuon.cc:83
bool m_Killed
true means that muon was killed during GB
Definition: RPCTBMuon.h:116
void fromBits(MuonBitsType muonBitsType, unsigned int value)
Definition: RPCTBMuon.cc:200
MuonBitsType m_muonBitsType
Definition: RPCTBMuon.h:102
bool gBDataKilledLast() const
Definition: RPCTBMuon.cc:145
std::string toString(int format) const
Definition: RPCTBMuon.cc:387
RPCTBMuon()
Empty muon.
Definition: RPCTBMuon.cc:14
bool gBDataKilledFirst() const
Definition: RPCTBMuon.cc:143
unsigned int m_EtaAddress
Definition: RPCTBMuon.h:104
static unsigned int const shift
int getLogSector() const
Definition: RPCMuon.cc:59
static unsigned int toBits(const RPCTBMuon &muon)
Definition: RPCTBMuon.cc:257
unsigned int m_Quality
3 bits, 0-7.
Definition: RPCMuon.h:93
void setSectorAddr(int sectorAddr)
Definition: RPCTBMuon.cc:90
#define str(s)
void setPhiAddr(int phiAddr)
Definition: RPCTBMuon.cc:88
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:217
void setGBDataKilledLast()
Definition: RPCTBMuon.cc:141
static const int m_signBitsCnt
Definition: RPCTBMuon.h:126
static unsigned int toBits(const RPCTBMuon &muon)
Definition: RPCTBMuon.cc:344