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 
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 
32  data.phi_local = static_cast<unsigned>((lcl_phi_param0[pattern] + strip)*lcl_phi_param1);
33  else
34  edm::LogWarning("CSCSectorReceiverMiniLUT")
35  << "+++ Value of strip, " << strip
36  << ", exceeds max allowed, " << 2*CSCConstants::MAX_NUM_STRIPS-1
37  << " +++\n";
38 
39  if(data.phi_local >= maxPhiL)
40  edm::LogWarning("CSCSectorReceiverMiniLUT")
41  << "+++ Value of phi_local, " << data.phi_local
42  << ", exceeds max allowed, " << 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 {
57  if(endcap < 1 || endcap > 2)
58  edm::LogWarning("CSCSectorReceiverMiniLUT")
59  << "+++ Value of endcap, " << endcap
60  << ", is out of bounds, [1, 2] +++\n";
61  if(sector < 1 || sector > 6)
62  edm::LogWarning("CSCSectorReceiverMiniLUT")
63  << "+++ Value of sector, " << sector
64  << ", is out of bounds, [1, 6] +++\n";
65  if(station < 1 || station > 4)
66  edm::LogWarning("CSCSectorReceiverMiniLUT")
67  << "+++ Value of station, " << station
68  << ", is out of bounds, [1, 4] +++\n";
69 
70  gbletadat data(0);
71 
72  unsigned short int cscid = ((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  int eta_temp=999, eta_min=999, eta_max=999;
78 
79  if((cscid > 0) && (cscid <= 9) && (WG < CSCConstants::MAX_NUM_WIRES))
80  {
81  if(station == 1)
82  {
83  eta_temp = (gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][0] +
84  gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][1] *
85  log(gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][2] + WG));
86  eta_min = gbl_eta_bounds[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][0];
87  eta_max = gbl_eta_bounds[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][1];
88 
89  // add offset to ME+11a, subtract for ME-11a (wire tilt and strip direction)1
90  if ( (cscid < 4)&&(lclPhi == 3) ) {
91  if (endcap == 1)
92  eta_temp += 3;
93  else
94  eta_temp -= 3;
95  }
96  }
97  else
98  {
99  eta_temp = (gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][0] +
100  gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][1] *
101  log(gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][2] + WG));
102  eta_min = gbl_eta_bounds[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][0];
103  eta_max = gbl_eta_bounds[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][1];
104  }
105  }
106  else
107  {
108  edm::LogWarning("CSCSectorReceiverMiniLUT")
109  << "+++ Value of cscid, " << cscid
110  << ", is out of bounds, [1, 9] -- or --"
111  << " Value of wire group, " << WG
112  << ", exceeds max allowed, " << CSCConstants::MAX_NUM_WIRES << " +++\n";
113  }
114 
115  // protect from negative numbers. If the value of eta_temp is <0, set global eta to the minimum value
116  if((eta_temp >= eta_min) &&
117  (eta_temp <= eta_max))
118  data.global_eta = eta_temp;
119  else if(eta_temp < eta_min)
120  data.global_eta = eta_min;
121  else
122  data.global_eta = eta_max;
123 
124 // data.global_bend = 0;
125 // Just pass through lowest 5 bits of local bend (drop 1 MSB)
126  data.global_bend = bend & 0x1F;
127 
128  return data;
129 }
130 
132  unsigned short sector,
133  unsigned short station,
134  unsigned short subsector,
135  unsigned theadd)
136 {
137  if(endcap < 1 || endcap > 2)
138  edm::LogWarning("CSCSectorReceiverMiniLUT")
139  << "+++ Value of endcap, " << endcap
140  << ", is out of bounds, [1, 2] +++\n";
141  if(sector < 1 || sector > 6)
142  edm::LogWarning("CSCSectorReceiverMiniLUT")
143  << "+++ Value of sector, " << sector
144  << ", is out of bounds, [1, 6] +++\n";
145  if(station < 1 || station > 4)
146  edm::LogWarning("CSCSectorReceiverMiniLUT")
147  << "+++ Value of station, " << station
148  << ", 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 
157  // 12/11/09
158  // GP et DA: how to identify the strip number and isolate and shift the localPhi value
159  const double binPhiL = static_cast<double>(maxPhiL)/(2*CSCConstants::MAX_NUM_STRIPS);
160 
161  int strip = static_cast<int>(lclPhi/binPhiL);
162  // edm::LogWarning("GP Input") << " CSCID " << cscid << " strip:" << strip << " lclPhi: " << lclPhi << "theadd: " << theadd;
163  if (station == 1 && (cscid <= 3) && (strip >= 127 && strip < 160)){
164  //edm::LogWarning("GP Input") << " -> Matched Selection Criteria";
165 
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  lclPhi = (strip-127+31)*(4*binPhiL/3);
170  }
171  // end GP et DA
172 
173  if(station == 1 && ((cscid <= 3) || (cscid >= 7))) {
174  //if ( (strip >= 127 && strip < 160) || (cscid >= 10) ) // VK: the || (cscid >= 10) for unganged ME1a
175  // 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
176  //else
177  maxPhiL = maxPhiL*(64./80); // currently a hack that is in place to handle the different number of strips in ME1/1 and ME1/3
178  }
179 
180  // VK: The the unganged ME1a hack
181  if (station == 1 && (cscid >= 10)) {
182  lclPhi = strip*(4*binPhiL/3);
183  cscid = cscid - 9; // back to normal 1-9 range
184  }
185  // end VK
186 
187  if((cscid > 0) && (cscid <= 9))
188  {
189  if((station == 1) && (lclPhi < maxPhiL))
190  data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][0] +
191  gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][1]*lclPhi);
192  else if((station == 1) && (lclPhi >= maxPhiL))
193  data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][0] +
194  gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][1]*(maxPhiL-1));
195  else
196  data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][0][cscid-1][0] +
197  gbl_phi_me_params[endcap-1][sector-1][station-1][0][cscid-1][1]*lclPhi);
198  }
199  else
200  edm::LogWarning("CSCSectorReceiverMiniLUT")
201  << "+++ Value of cscid, " << cscid
202  << ", is out of bounds, [1, 9] +++\n";
203 
204  if(data.global_phi >= maxPhiG)
205  edm::LogWarning("CSCSectorReceiverMiniLUT")
206  << "+++ Value of global_phi, " << data.global_phi
207  << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
208 
209  return data;
210 }
211 
213  unsigned short sector,
214  unsigned short subsector,
215  unsigned theadd)
216 {
217  if(endcap < 1 || endcap > 2)
218  edm::LogWarning("CSCSectorReceiverMiniLUT")
219  << "+++ Value of endcap, " << endcap
220  << ", is out of bounds, [1, 2] +++\n";
221  if(sector < 1 || sector > 6)
222  edm::LogWarning("CSCSectorReceiverMiniLUT")
223  << "+++ Value of sector, " << sector
224  << ", 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 
233  if((cscid <= 3) || (cscid >= 7))
234  maxPhiL = maxPhiL*(64./80); // currently a hack that is in place to handle the different number of strips in ME1/1 and ME1/3
235 
236  if((cscid > 0) && (cscid <= 9))
237  {
238  if(lclPhi < maxPhiL)
239  data.global_phi = (gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][0] +
240  gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][1]*lclPhi);
241  else
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]*(maxPhiL-1));
244  }
245  else
246  edm::LogWarning("CSCSectorReceiverMiniLUT")
247  << "+++ Value of cscid, " << cscid
248  << ", is out of bounds, [1, 9] +++\n";
249 
250  if(data.global_phi >= maxPhiG)
251  edm::LogWarning("CSCSectorReceiverMiniLUT")
252  << "+++ Value of global_phi, " << data.global_phi
253  << ", 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
258  << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
259 
260  return data;
261 }
static std::vector< std::string > checklist log
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 global_phi_data calcGlobalPhiMEMini(unsigned short endcap, unsigned short sector, unsigned short station, unsigned short subsector, unsigned theadd)
static global_phi_data calcGlobalPhiMBMini(unsigned short endcap, unsigned short sector, unsigned short subsector, unsigned theadd)
static const float lcl_phi_param0[1<< 4]
static lclphidat calcLocalPhiMini(unsigned theadd)
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)