CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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;
177 }
178 #endif //_STAND_ALONE
179 //---------------------------------------------------------------------------
180 
181 unsigned int RPCTBMuon::toBits(RPCTBMuon::MuonBitsType muonBitsType) const {
182  if (muonBitsType == mbtPACOut) {
183  return PACOut::toBits(*this);
184  } else if (muonBitsType == mbtTBSortOut) {
185  return TBOut::toBits(*this);
186  } else if (muonBitsType == mbtTCSortOut) {
187  return TCOut::toBits(*this);
188  } else if (muonBitsType == mbtHSBOut) {
189  return HSBOut::toBits(*this);
190  } else if (muonBitsType == mbtFSBOut) {
191  return FSBOut::toBits(*this);
192  } else {
193  throw RPCException("unknown value of muonBitsType");
194  //edm::LogError("RPCTrigger")<<"unknown value of where: " + where;
195  }
196  return 0;
197 }
198 
199 void RPCTBMuon::fromBits(RPCTBMuon::MuonBitsType muonBitsType, unsigned int value) {
200  if (muonBitsType == mbtPACOut) {
201  PACOut::fromBits(*this, value);
202  } else if (muonBitsType == mbtTBSortOut) {
203  TBOut::fromBits(*this, value);
204  } else if (muonBitsType == mbtTCSortOut) {
205  TCOut::fromBits(*this, value);
206  } else if (muonBitsType == mbtHSBOut) {
207  HSBOut::fromBits(*this, value);
208  } else if (muonBitsType == mbtFSBOut) {
209  FSBOut::fromBits(*this, value);
210  } else {
211  RPCException("unknown value of muonBitsType");
212  //edm::LogError("RPCTrigger")<< "unknown value of where: " + where;
213  }
214 }
215 
217  unsigned int shift = 0;
218  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
219  shift += m_signBitsCnt;
220  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
221  shift += m_ptBitsCnt;
222  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
223  shift += m_qualBitsCnt;
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  shift += m_qualBitsCnt;
235 
236  return value;
237 }
238 
239 //-----------------------
241  unsigned int shift = 0;
242  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
243  shift += m_signBitsCnt;
244  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
245  shift += m_ptBitsCnt;
246  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
247  shift += m_qualBitsCnt;
248  muon.m_PhiAddress = (value & (m_phiBitsMask << shift)) >> shift;
249  shift += m_phiBitsCnt;
250  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
251  shift += m_etaBitsCnt;
252  muon.m_GBData = (value & (m_gbDataBitsMask << shift)) >> shift;
253  shift += m_gbDataBitsCnt;
254 }
255 
257  unsigned int value = 0;
258  unsigned int shift = 0;
259  value = (muon.m_Sign << shift);
260  shift += m_signBitsCnt;
261  value = value | (muon.m_PtCode << shift);
262  shift += m_ptBitsCnt;
263  value = value | (muon.m_Quality << shift);
264  shift += m_qualBitsCnt;
265  value = value | (muon.m_PhiAddress << shift);
266  shift += m_phiBitsCnt;
267  value = value | (muon.m_EtaAddress << shift);
268  shift += m_etaBitsCnt;
269  value = value | (muon.m_GBData << shift);
270  shift += m_gbDataBitsCnt;
271  return value;
272 }
273 
274 //-----------------------
276  unsigned int shift = 0;
277  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
278  shift += m_signBitsCnt;
279  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
280  shift += m_ptBitsCnt;
281  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
282  shift += m_qualBitsCnt;
283  muon.m_PhiAddress = (value & (m_phiBitsMask << shift)) >> shift;
284  shift += m_phiBitsCnt;
285  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
286  shift += m_etaBitsCnt;
287  muon.m_GBData = (value & (m_gbDataBitsMask << shift)) >> shift;
288  shift += m_gbDataBitsCnt;
289 }
290 
292  unsigned int value = 0;
293  unsigned int shift = 0;
294  value = (muon.m_Sign << shift);
295  shift += m_signBitsCnt;
296  value = value | (muon.m_PtCode << shift);
297  shift += m_ptBitsCnt;
298  value = value | (muon.m_Quality << shift);
299  shift += m_qualBitsCnt;
300  value = value | (muon.m_PhiAddress << shift);
301  shift += m_phiBitsCnt;
302  value = value | (muon.m_EtaAddress << shift);
303  shift += m_etaBitsCnt;
304  value = value | (muon.m_GBData << shift);
305  shift += m_gbDataBitsCnt;
306  return value;
307 }
308 //-------------------------------
309 
311  unsigned int value = 0;
312 
313  unsigned int shift = 0;
314  value = value | (muon.m_Sign << shift);
315  shift += m_signBitsCnt;
316  // value = (muon.m_Sign<<shift); shift += m_signBitsCnt;
317  value = value | (muon.m_PtCode << shift);
318  shift += m_ptBitsCnt;
319  value = value | (muon.m_Quality << shift);
320  shift += m_qualBitsCnt;
321  value = value | (muon.m_PhiAddress << shift);
322  shift += m_phiBitsCnt;
323  value = value | (muon.m_EtaAddress << shift);
324  shift += m_etaBitsCnt;
325 
326  return value;
327 }
328 
330  unsigned int shift = 0;
331  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
332  shift += m_signBitsCnt;
333  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
334  shift += m_ptBitsCnt;
335  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
336  shift += m_qualBitsCnt;
337  muon.m_PhiAddress = (value & (m_phiBitsMask << shift)) >> shift;
338  shift += m_phiBitsCnt;
339  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
340  shift += m_etaBitsCnt;
341 }
342 
344  unsigned int value = 0;
345 
346  unsigned int shift = 0;
347  //bita are reversed, to be zero when cable not connected
348  unsigned int ptCode = (~(muon.m_PtCode)) & m_ptBitsMask;
349  unsigned int quality = (~(muon.m_Quality)) & m_qualBitsMask;
350 
351  value = value | muon.m_PhiAddress;
352  shift += m_phiBitsCnt;
353  value = value | (ptCode << shift);
354  shift += m_ptBitsCnt;
355  value = value | (quality << shift);
356  shift += m_qualBitsCnt;
357 
358  //+1 beacouse H/F bits, unused in RPC:
359  value = value | (muon.m_EtaAddress << shift);
360  shift += m_etaBitsCnt + 1;
361  value = value | (muon.m_Sign << shift);
362  shift += m_signBitsCnt;
363 
364  return value;
365 }
366 
368  unsigned int shift = 0;
369  muon.m_PhiAddress = value & m_phiBitsMask;
370  shift += m_phiBitsCnt;
371  muon.m_PtCode = (value & (m_ptBitsMask << shift)) >> shift;
372  shift += m_ptBitsCnt;
373  muon.m_Quality = (value & (m_qualBitsMask << shift)) >> shift;
374  shift += m_qualBitsCnt;
375 
376  //+1 beacouse H/F bits, unused in RPC:
377  muon.m_EtaAddress = (value & (m_etaBitsMask << shift)) >> shift;
378  shift += m_etaBitsCnt + 1;
379  muon.m_Sign = (value & (m_signBitsMask << shift)) >> shift;
380  shift += m_signBitsCnt;
381 
382  muon.m_PtCode = (~(muon.m_PtCode)) & m_ptBitsMask;
383  muon.m_Quality = (~(muon.m_Quality)) & m_qualBitsMask;
384 }
385 
387  ostringstream ostr;
388  if (format == 0) {
389  ostr << "qu " << m_Quality << ", pt " << setw(2) << m_PtCode << ", sig " << m_Sign << ", phi " << setw(3)
390  << m_PhiAddress << ", eta " << setw(2) << m_EtaAddress;
391  } else if (format == 1) {
392  ostr << " " << m_Quality << " " << setw(2) << m_PtCode << " " << m_Sign << " " << setw(3) << m_PhiAddress << " "
393  << setw(2) << m_EtaAddress;
394  } else if (format == 2) {
395  ostr << " " << m_Quality << " " << setw(2) << m_PtCode << " " << m_Sign;
396  }
397 
398  return ostr.str();
399 }
bool gBDataKilledLast() const
Definition: RPCTBMuon.cc:145
static const int m_ptBitsCnt
Definition: RPCTBMuon.h:124
static const int m_qualBitsCnt
Definition: RPCTBMuon.h:122
unsigned int m_GBData
Definition: RPCTBMuon.h:113
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:367
int getQuality() const
Definition: RPCMuon.cc:69
uint32_t const *__restrict__ Quality * quality
int getPtCode() const
Definition: RPCMuon.cc:65
std::string getGBDataBitStr() const
Definition: RPCTBMuon.cc:128
std::string toString(int format) const
Definition: RPCTBMuon.cc:386
double sign(double x)
int getSegmentAddr() const
Definition: RPCTBMuon.cc:110
unsigned int m_PhiAddress
Definition: RPCTBMuon.h:106
unsigned int toBits() const
Definition: RPCTBMuon.h:95
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
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:310
bool isLive() const
Definition: RPCTBMuon.cc:161
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:329
void setGBData(unsigned int gbData)
Definition: RPCTBMuon.cc:104
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:240
static unsigned int toBits(const RPCTBMuon &muon)
Definition: RPCTBMuon.cc:226
int getSectorAddr() const
Definition: RPCTBMuon.cc:112
int getLogSector() const
Definition: RPCMuon.cc:59
int getLogSegment() const
Definition: RPCMuon.cc:61
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:291
void setEtaAddr(int etaAddr)
Definition: RPCTBMuon.cc:92
void setCodeAndPhiAddr(int code, int phiAddr)
Definition: RPCTBMuon.cc:116
int getContinSegmAddr() const
Definition: RPCTBMuon.cc:114
int getTower() const
Definition: RPCMuon.cc:57
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:275
std::string printDebugInfo(int debugFormat) const
Gives debuging info in human readable format (1) or technicall format (2)
Definition: RPCTBMuon.cc:55
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
int getEtaAddr() const
Definition: RPCTBMuon.cc:106
void fromBits(MuonBitsType muonBitsType, unsigned int value)
Definition: RPCTBMuon.cc:199
int getGBData() const
Definition: RPCTBMuon.cc:126
int getPhiAddr() const
Definition: RPCTBMuon.cc:108
MuonBitsType m_muonBitsType
Definition: RPCTBMuon.h:102
bool wasKilled() const
Definition: RPCTBMuon.cc:152
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
static unsigned int toBits(const RPCTBMuon &muon)
Definition: RPCTBMuon.cc:256
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
int getSign() const
Definition: RPCMuon.cc:73
static void fromBits(RPCTBMuon &muon, unsigned int value)
Definition: RPCTBMuon.cc:216
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:343