CMS 3D CMS Logo

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