CMS 3D CMS Logo

CSCSectorReceiverMiniLUT.cc
Go to the documentation of this file.
6 
10 
12 
14 
15 #include <fstream>
16 #include <cmath>
18 
20  // This method is ripped from CSCSectorReceverLUT.cc with minor changes
21 
23 
25  unsigned short int pattern = ((theadd >> 8) & 0xf);
26  unsigned short int strip = (theadd & 0xff);
27 
28  if (strip < 2 * (CSCConstants::MAX_NUM_STRIPS * 7 / 5) &&
29  pattern <
31  NUM_CLCT_PATTERNS) { // MDG, DA and RW, for ME1 we have 7CFEBs and not just 5, so the num_strips can go up to 16 * 7 but only for ME1
32  data.phi_local = gangedME1a ? static_cast<unsigned>((lcl_phi_param0[pattern] + strip) * lcl_phi_param1)
33  : static_cast<unsigned>((lcl_phi_param0[pattern] + strip) * 0.625 * lcl_phi_param1);
34  //DA and MDG, rescale range of local phi so ME1/1b fits in 0-511
35  } else
36  edm::LogWarning("CSCSectorReceiverMiniLUT") << "+++ Value of strip, " << strip << ", exceeds max allowed, "
37  << 2 * CSCConstants::MAX_NUM_STRIPS - 1 << " +++\n";
38 
39  if (data.phi_local >= maxPhiL)
40  edm::LogWarning("CSCSectorReceiverMiniLUT")
41  << "+++ Value of phi_local, " << data.phi_local << ", exceeds max allowed, "
42  << CSCConstants::NUM_CLCT_PATTERNS - 1 << " +++\n";
43 
44  // data.phi_bend_local = 0;
45  // Just pass through all bits of pattern as bend angle (so 2 MSB unfilled)
46  data.phi_bend_local = pattern & 0x3F;
47 
48  return data;
49 }
50 
52  unsigned short sector,
53  unsigned short station,
54  unsigned short subsector,
55  unsigned theadd,
56  const bool gangedME1a) {
57  if (endcap < 1 || endcap > 2)
58  edm::LogWarning("CSCSectorReceiverMiniLUT")
59  << "+++ Value of endcap, " << endcap << ", is out of bounds, [1, 2] +++\n";
60  if (sector < 1 || sector > 6)
61  edm::LogWarning("CSCSectorReceiverMiniLUT")
62  << "+++ Value of sector, " << sector << ", is out of bounds, [1, 6] +++\n";
63  if (station < 1 || station > 4)
64  edm::LogWarning("CSCSectorReceiverMiniLUT")
65  << "+++ Value of station, " << station << ", is out of bounds, [1, 4] +++\n";
66 
67  gbletadat data(0);
68 
69  unsigned short int tcscid = ((theadd >> 15) & 0xf);
70  unsigned short int lclPhi = ((theadd >> 6) & 0x3);
71  unsigned short int WG = ((theadd >> 8) & 0x7f);
72  unsigned short int bend = ((theadd)&0x3f);
73 
74  int eta_temp = 999, eta_min = 999, eta_max = 999;
75 
76  if ((tcscid > 0) && (tcscid <= 12) && (WG < CSCConstants::MAX_NUM_WIRES)) {
77  unsigned short int cscid = (tcscid > 9) ? tcscid - 9 : tcscid;
78  if (station == 1) {
79  unsigned short int lclPhip = 0;
80  if (lclPhi == 1 || lclPhi == 3)
81  lclPhip = 2;
82  // use only eta correction for first and last third of ME1/1 chamber since local phi scaling changed
83  if (gangedME1a) {
84  eta_temp =
85  (gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhi][cscid - 1][0] +
86  gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhi][cscid - 1][1] *
87  log(gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhi][cscid - 1][2] + WG));
88  eta_min = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhi][cscid - 1][0];
89  eta_max = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhi][cscid - 1][1];
90  } else { // DA and MDG, if unganged replace "lclPhi" index with "lclPhip"
91  eta_temp =
92  (gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhip][cscid - 1][0] +
93  gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhip][cscid - 1][1] *
94  log(gbl_eta_params[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhip][cscid - 1][2] + WG));
95  eta_min = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhip][cscid - 1][0];
96  eta_max = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][subsector - 1][lclPhip][cscid - 1][1];
97  }
98 
99  // add offset to ME+11a, subtract for ME-11a (wire tilt and strip direction)1
100  // only is ganged
101  if (gangedME1a && (tcscid < 4) && (lclPhi == 3)) {
102  if (endcap == 1)
103  eta_temp += 3;
104  else
105  eta_temp -= 3;
106  }
107  } else {
108  eta_temp = (gbl_eta_params[endcap - 1][sector - 1][station - 1][0][lclPhi][cscid - 1][0] +
109  gbl_eta_params[endcap - 1][sector - 1][station - 1][0][lclPhi][cscid - 1][1] *
110  log(gbl_eta_params[endcap - 1][sector - 1][station - 1][0][lclPhi][cscid - 1][2] + WG));
111  eta_min = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][0][lclPhi][cscid - 1][0];
112  eta_max = gbl_eta_bounds[endcap - 1][sector - 1][station - 1][0][lclPhi][cscid - 1][1];
113  }
114  } else {
115  edm::LogWarning("CSCSectorReceiverMiniLUT")
116  << "+++ Value of cscid, " << tcscid << ", is out of bounds, [1, 9] -- or --"
117  << " Value of wire group, " << WG << ", exceeds max allowed, " << CSCConstants::MAX_NUM_WIRES << " +++\n";
118  }
119 
120  // protect from negative numbers. If the value of eta_temp is <0, set global eta to the minimum value
121  if ((eta_temp >= eta_min) && (eta_temp <= eta_max))
122  data.global_eta = eta_temp;
123  else if (eta_temp < eta_min)
124  data.global_eta = eta_min;
125  else
126  data.global_eta = eta_max;
127 
128  // data.global_bend = 0;
129  // Just pass through lowest 5 bits of local bend (drop 1 MSB)
130  data.global_bend = bend & 0x1F;
131 
132  return data;
133 }
134 
136  unsigned short sector,
137  unsigned short station,
138  unsigned short subsector,
139  unsigned theadd,
140  const bool gangedME1a) {
141  if (endcap < 1 || endcap > 2)
142  edm::LogWarning("CSCSectorReceiverMiniLUT")
143  << "+++ Value of endcap, " << endcap << ", is out of bounds, [1, 2] +++\n";
144  if (sector < 1 || sector > 6)
145  edm::LogWarning("CSCSectorReceiverMiniLUT")
146  << "+++ Value of sector, " << sector << ", is out of bounds, [1, 6] +++\n";
147  if (station < 1 || station > 4)
148  edm::LogWarning("CSCSectorReceiverMiniLUT")
149  << "+++ Value of station, " << station << ", is out of bounds, [1, 4] +++\n";
150 
151  gblphidat data(0);
152 
153  unsigned short int maxPhiL = 1 << CSCBitWidths::kLocalPhiDataBitWidth;
154  unsigned short int maxPhiG = 1 << CSCBitWidths::kGlobalPhiDataBitWidth;
155  unsigned short int cscid = ((theadd >> 15) & 0xf);
156  unsigned short int lclPhi = (theadd & 0x3ff);
157  if (!gangedME1a)
158  lclPhi = lclPhi / 0.625; // DA and MDG recover old scaling of local phi
159 
160  // 12/11/09
161  // GP et DA: how to identify the strip number and isolate and shift the localPhi value
162  const double binPhiL = static_cast<double>(maxPhiL) / (2 * CSCConstants::MAX_NUM_STRIPS);
163 
164  int strip = static_cast<int>(lclPhi / binPhiL);
165  if (station == 1 && (cscid <= 3) &&
166  (strip >= 127 && strip < 224)) { // 160 --> 224, change range for ME1/1a acceptance, DA and MDG
167  // in this case need to redefine lclPhi in order to
168  // place local phi in the middle of the 5th CFEB
169  // and not on the first third of the CFEB as default
170 
171  gangedME1a
172  ? lclPhi = (strip - 127 + 31) * (4 * binPhiL / 3)
173  : lclPhi =
174  (strip - 127) *
175  (4 * binPhiL /
176  3); //DA and MDG remove offset to center of ME1/1a (no ganging), and reset ME1/1a strip number to start from 0, and scale 48 strips to match ME1/1b 64 strips
177  }
178  // end GP et DA
179 
180  if (station == 1 && ((cscid <= 3) || (cscid >= 7))) {
181  //if ( (strip >= 127 && strip < 160) || (cscid >= 10) ) // VK: the || (cscid >= 10) for unganged ME1a
182  // maxPhiL = maxPhiL*(48./80); // GP et DA: currently a hack that is in place to handle the different number of strips in ME1/1a and ME1/3
183  //else
184  maxPhiL =
185  maxPhiL *
186  (64. / 80); // currently a hack that is in place to handle the different number of strips in ME1/1 and ME1/3
187  }
188 
189  // VK: The the unganged ME1a hack
190  if (station == 1 && (cscid >= 10)) {
191  lclPhi = strip * (4 * binPhiL / 3);
192  cscid = cscid - 9; // back to normal 1-9 range
193  }
194  // end VK
195 
196  if ((cscid > 0) && (cscid <= 9)) {
197  if ((station == 1) && (lclPhi < maxPhiL))
198  data.global_phi = (gbl_phi_me_params[endcap - 1][sector - 1][station - 1][subsector - 1][cscid - 1][0] +
199  gbl_phi_me_params[endcap - 1][sector - 1][station - 1][subsector - 1][cscid - 1][1] * lclPhi);
200  else if ((station == 1) && (lclPhi >= maxPhiL))
201  data.global_phi =
202  (gbl_phi_me_params[endcap - 1][sector - 1][station - 1][subsector - 1][cscid - 1][0] +
203  gbl_phi_me_params[endcap - 1][sector - 1][station - 1][subsector - 1][cscid - 1][1] * (maxPhiL - 1));
204  else
205  data.global_phi = (gbl_phi_me_params[endcap - 1][sector - 1][station - 1][0][cscid - 1][0] +
206  gbl_phi_me_params[endcap - 1][sector - 1][station - 1][0][cscid - 1][1] * lclPhi);
207  } else
208  edm::LogWarning("CSCSectorReceiverMiniLUT")
209  << "+++ Value of cscid, " << cscid << ", is out of bounds, [1, 9] +++\n";
210 
211  if (data.global_phi >= maxPhiG)
212  edm::LogWarning("CSCSectorReceiverMiniLUT")
213  << "+++ Value of global_phi, " << data.global_phi << ", exceeds max allowed, " << maxPhiG - 1 << " +++\n";
214 
215  return data;
216 }
217 
219  unsigned short endcap, unsigned short sector, unsigned short subsector, unsigned theadd, const bool gangedME1a) {
220  if (endcap < 1 || endcap > 2)
221  edm::LogWarning("CSCSectorReceiverMiniLUT")
222  << "+++ Value of endcap, " << endcap << ", is out of bounds, [1, 2] +++\n";
223  if (sector < 1 || sector > 6)
224  edm::LogWarning("CSCSectorReceiverMiniLUT")
225  << "+++ Value of sector, " << sector << ", is out of bounds, [1, 6] +++\n";
226 
227  gblphidat data(0);
228 
229  unsigned short int maxPhiL = 1 << CSCBitWidths::kLocalPhiDataBitWidth;
230  unsigned short int maxPhiG = 1 << CSCBitWidths::kGlobalPhiDataBitWidth;
231  unsigned short int cscid = ((theadd >> 15) & 0xf);
232  unsigned short int lclPhi = (theadd & 0x3ff);
233  if (!gangedME1a)
234  lclPhi = lclPhi / 0.625; // DA and MDG, recover old scaling of local phi
235 
236  if ((cscid <= 3) || (cscid >= 7))
237  maxPhiL =
238  maxPhiL *
239  (64. / 80); // currently a hack that is in place to handle the different number of strips in ME1/1 and ME1/3
240 
241  if ((cscid > 0) && (cscid <= 9)) {
242  if (lclPhi < maxPhiL)
243  data.global_phi = (gbl_phi_mb_params[endcap - 1][sector - 1][subsector - 1][cscid - 1][0] +
244  gbl_phi_mb_params[endcap - 1][sector - 1][subsector - 1][cscid - 1][1] * lclPhi);
245  else
246  data.global_phi = (gbl_phi_mb_params[endcap - 1][sector - 1][subsector - 1][cscid - 1][0] +
247  gbl_phi_mb_params[endcap - 1][sector - 1][subsector - 1][cscid - 1][1] * (maxPhiL - 1));
248  } else
249  edm::LogWarning("CSCSectorReceiverMiniLUT")
250  << "+++ Value of cscid, " << cscid << ", is out of bounds, [1, 9] +++\n";
251 
252  if (data.global_phi >= maxPhiG)
253  edm::LogWarning("CSCSectorReceiverMiniLUT")
254  << "+++ Value of global_phi, " << data.global_phi << ", exceeds max allowed, " << maxPhiG - 1 << " +++\n";
255 
256  if (data.global_phi >= maxPhiG)
257  edm::LogWarning("CSCSectorReceiverMiniLUT")
258  << "+++ Value of global_phi, " << data.global_phi << ", exceeds max allowed, " << maxPhiG - 1 << " +++\n";
259 
260  return data;
261 }
static global_phi_data calcGlobalPhiMEMini(unsigned short endcap, unsigned short sector, unsigned short station, unsigned short subsector, unsigned theadd, const bool gangedME1a)
static const unsigned short int gbl_eta_bounds[2][6][4][2][4][9][2]
static const float gbl_eta_params[2][6][4][2][4][9][3]
static const float lcl_phi_param0[1<< 4]
static lclphidat calcLocalPhiMini(unsigned theadd, const bool gangedME1a)
static global_phi_data calcGlobalPhiMBMini(unsigned short endcap, unsigned short sector, unsigned short subsector, unsigned theadd, const bool gangedME1a)
class global_phi_data gblphidat
class local_phi_data lclphidat
Data Types.
static const float gbl_phi_mb_params[2][6][2][9][2]
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
static const float gbl_phi_me_params[2][6][4][2][9][2]
class global_eta_data gbletadat
static global_eta_data calcGlobalEtaMEMini(unsigned short endcap, unsigned short sector, unsigned short station, unsigned short subsector, unsigned theadd, const bool gangedME1a)
#define constexpr