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 }
225 
227  unsigned int value = 0;
228  unsigned int shift = 0;
229  value = (muon.m_Sign << shift);
230  shift += m_signBitsCnt;
231  value = value | (muon.m_PtCode << shift);
232  shift += m_ptBitsCnt;
233  value = value | (muon.m_Quality << shift);
234 
235  return value;
236 }
237 
238 //-----------------------
240  unsigned int shift = 0;
241  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
242  shift += m_signBitsCnt;
243  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
244  shift += m_ptBitsCnt;
245  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
246  shift += m_qualBitsCnt;
247  muon.m_PhiAddress = (value & (m_phiBitsMask << shift)) >> shift;
248  shift += m_phiBitsCnt;
249  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
250  shift += m_etaBitsCnt;
251  muon.m_GBData = (value & (m_gbDataBitsMask << shift)) >> shift;
252 }
253 
255  unsigned int value = 0;
256  unsigned int shift = 0;
257  value = (muon.m_Sign << shift);
258  shift += m_signBitsCnt;
259  value = value | (muon.m_PtCode << shift);
260  shift += m_ptBitsCnt;
261  value = value | (muon.m_Quality << shift);
262  shift += m_qualBitsCnt;
263  value = value | (muon.m_PhiAddress << shift);
264  shift += m_phiBitsCnt;
265  value = value | (muon.m_EtaAddress << shift);
266  shift += m_etaBitsCnt;
267  value = value | (muon.m_GBData << shift);
268  return value;
269 }
270 
271 //-----------------------
273  unsigned int shift = 0;
274  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
275  shift += m_signBitsCnt;
276  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
277  shift += m_ptBitsCnt;
278  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
279  shift += m_qualBitsCnt;
280  muon.m_PhiAddress = (value & (m_phiBitsMask << shift)) >> shift;
281  shift += m_phiBitsCnt;
282  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
283  shift += m_etaBitsCnt;
284  muon.m_GBData = (value & (m_gbDataBitsMask << shift)) >> shift;
285 }
286 
288  unsigned int value = 0;
289  unsigned int shift = 0;
290  value = (muon.m_Sign << shift);
291  shift += m_signBitsCnt;
292  value = value | (muon.m_PtCode << shift);
293  shift += m_ptBitsCnt;
294  value = value | (muon.m_Quality << shift);
295  shift += m_qualBitsCnt;
296  value = value | (muon.m_PhiAddress << shift);
297  shift += m_phiBitsCnt;
298  value = value | (muon.m_EtaAddress << shift);
299  shift += m_etaBitsCnt;
300  value = value | (muon.m_GBData << shift);
301  return value;
302 }
303 //-------------------------------
304 
306  unsigned int value = 0;
307 
308  unsigned int shift = 0;
309  value = value | (muon.m_Sign << shift);
310  shift += m_signBitsCnt;
311  // value = (muon.m_Sign<<shift); shift += m_signBitsCnt;
312  value = value | (muon.m_PtCode << shift);
313  shift += m_ptBitsCnt;
314  value = value | (muon.m_Quality << shift);
315  shift += m_qualBitsCnt;
316  value = value | (muon.m_PhiAddress << shift);
317  shift += m_phiBitsCnt;
318  value = value | (muon.m_EtaAddress << shift);
319 
320  return value;
321 }
322 
324  unsigned int shift = 0;
325  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
326  shift += m_signBitsCnt;
327  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
328  shift += m_ptBitsCnt;
329  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
330  shift += m_qualBitsCnt;
331  muon.m_PhiAddress = (value & (m_phiBitsMask << shift)) >> shift;
332  shift += m_phiBitsCnt;
333  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
334 }
335 
337  unsigned int value = 0;
338 
339  unsigned int shift = 0;
340  //bita are reversed, to be zero when cable not connected
341  unsigned int ptCode = (~(muon.m_PtCode)) & m_ptBitsMask;
342  unsigned int quality = (~(muon.m_Quality)) & m_qualBitsMask;
343 
344  value = value | muon.m_PhiAddress;
345  shift += m_phiBitsCnt;
346  value = value | (ptCode << shift);
347  shift += m_ptBitsCnt;
348  value = value | (quality << shift);
349  shift += m_qualBitsCnt;
350 
351  //+1 beacouse H/F bits, unused in RPC:
352  value = value | (muon.m_EtaAddress << shift);
353  shift += m_etaBitsCnt + 1;
354  value = value | (muon.m_Sign << shift);
355 
356  return value;
357 }
358 
360  unsigned int shift = 0;
361  muon.m_PhiAddress = value & m_phiBitsMask;
362  shift += m_phiBitsCnt;
363  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
364  shift += m_ptBitsCnt;
365  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
366  shift += m_qualBitsCnt;
367 
368  //+1 beacouse H/F bits, unused in RPC:
369  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
370  shift += m_etaBitsCnt + 1;
371  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
372 
373  muon.m_PtCode = (~(muon.m_PtCode)) & m_ptBitsMask;
374  muon.m_Quality = (~(muon.m_Quality)) & m_qualBitsMask;
375 }
376 
378  ostringstream ostr;
379  if (format == 0) {
380  ostr << "qu " << m_Quality << ", pt " << setw(2) << m_PtCode << ", sig " << m_Sign << ", phi " << setw(3)
381  << m_PhiAddress << ", eta " << setw(2) << m_EtaAddress;
382  } else if (format == 1) {
383  ostr << " " << m_Quality << " " << setw(2) << m_PtCode << " " << m_Sign << " " << setw(3) << m_PhiAddress << " "
384  << setw(2) << m_EtaAddress;
385  } else if (format == 2) {
386  ostr << " " << m_Quality << " " << setw(2) << m_PtCode << " " << m_Sign;
387  }
388 
389  return ostr.str();
390 }
static const int m_ptBitsCnt
Definition: RPCTBMuon.h:124
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:359
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:305
string quality
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:323
void setGBData(unsigned int gbData)
Definition: RPCTBMuon.cc:104
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:239
static unsigned int toBits(const RPCTBMuon &muon)
Definition: RPCTBMuon.cc:226
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:287
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:272
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:377
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:254
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:336