CMS 3D CMS Logo

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