CMS 3D CMS Logo

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