CMS 3D CMS Logo

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