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 
27  static int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
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 
46  return data;
47 }
48 
50  unsigned short sector,
51  unsigned short station,
52  unsigned short subsector,
53  unsigned theadd)
54 {
55  if(endcap < 1 || endcap > 2)
56  edm::LogWarning("CSCSectorReceiverMiniLUT")
57  << "+++ Value of endcap, " << endcap
58  << ", is out of bounds, [1, 2] +++\n";
59  if(sector < 1 || sector > 6)
60  edm::LogWarning("CSCSectorReceiverMiniLUT")
61  << "+++ Value of sector, " << sector
62  << ", is out of bounds, [1, 6] +++\n";
63  if(station < 1 || station > 4)
64  edm::LogWarning("CSCSectorReceiverMiniLUT")
65  << "+++ Value of station, " << station
66  << ", is out of bounds, [1, 4] +++\n";
67 
68  gbletadat data(0);
69 
70  unsigned short int cscid = ((theadd >> 15) & 0xf);
71  unsigned short int lclPhi = ((theadd >> 6) & 0x3);
72  unsigned short int WG = ((theadd >> 8) & 0x7f);
73 
74  int eta_temp=999, eta_min=999, eta_max=999;
75 
76  if((cscid > 0) && (cscid <= 9) && (WG < CSCConstants::MAX_NUM_WIRES))
77  {
78  if(station == 1)
79  {
80  eta_temp = (gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][0] +
81  gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][1] *
82  log(gbl_eta_params[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][2] + WG));
83  eta_min = gbl_eta_bounds[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][0];
84  eta_max = gbl_eta_bounds[endcap-1][sector-1][station-1][subsector-1][lclPhi][cscid-1][1];
85  }
86  else
87  {
88  eta_temp = (gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][0] +
89  gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][1] *
90  log(gbl_eta_params[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][2] + WG));
91  eta_min = gbl_eta_bounds[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][0];
92  eta_max = gbl_eta_bounds[endcap-1][sector-1][station-1][0][lclPhi][cscid-1][1];
93  }
94  }
95  else
96  {
97  edm::LogWarning("CSCSectorReceiverMiniLUT")
98  << "+++ Value of cscid, " << cscid
99  << ", is out of bounds, [1, 9] -- or --"
100  << " Value of wire group, " << WG
101  << ", exceeds max allowed, " << CSCConstants::MAX_NUM_WIRES << " +++\n";
102  }
103 
104  // protect from negative numbers. If the value of eta_temp is <0, set global eta to the minimum value
105  if((eta_temp >= eta_min) &&
106  (eta_temp <= eta_max))
107  data.global_eta = eta_temp;
108  else if(eta_temp < eta_min)
109  data.global_eta = eta_min;
110  else
111  data.global_eta = eta_max;
112 
113  data.global_bend = 0;
114 
115  return data;
116 }
117 
119  unsigned short sector,
120  unsigned short station,
121  unsigned short subsector,
122  unsigned theadd)
123 {
124  if(endcap < 1 || endcap > 2)
125  edm::LogWarning("CSCSectorReceiverMiniLUT")
126  << "+++ Value of endcap, " << endcap
127  << ", is out of bounds, [1, 2] +++\n";
128  if(sector < 1 || sector > 6)
129  edm::LogWarning("CSCSectorReceiverMiniLUT")
130  << "+++ Value of sector, " << sector
131  << ", is out of bounds, [1, 6] +++\n";
132  if(station < 1 || station > 4)
133  edm::LogWarning("CSCSectorReceiverMiniLUT")
134  << "+++ Value of station, " << station
135  << ", is out of bounds, [1, 4] +++\n";
136 
137  gblphidat data(0);
138 
139  unsigned short int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
140  unsigned short int maxPhiG = 1<<CSCBitWidths::kGlobalPhiDataBitWidth;
141  unsigned short int cscid = ((theadd >> 15)&0xf);
142  unsigned short int lclPhi = (theadd & 0x3ff);
143 
144  // 12/11/09
145  // GP et DA: how to identify the strip number and isolate and shift the localPhi value
146  const double binPhiL = static_cast<double>(maxPhiL)/(2*CSCConstants::MAX_NUM_STRIPS);
147 
148  int strip = static_cast<int>(lclPhi/binPhiL);
149  // edm::LogWarning("GP Input") << " CSCID " << cscid << " strip:" << strip << " lclPhi: " << lclPhi << "theadd: " << theadd;
150  if (station == 1 && (cscid <= 3) && (strip >= 127 && strip < 160)){
151  //edm::LogWarning("GP Input") << " -> Matched Selection Criteria";
152 
153  // in this case need to redefine lclPhi in order to
154  // place local phi in the middle of the 5th CFEB
155  // and not on the first third of the CFEB as default
156  lclPhi = (strip-127+31)*(4*binPhiL/3);
157  }
158  // end GP et DA
159 
160  if(station == 1 && ((cscid <= 3) || (cscid >= 7))) {
161  //if ( (strip >= 127 && strip < 160) || (cscid >= 10) ) // VK: the || (cscid >= 10) for unganged ME1a
162  // 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
163  //else
164  maxPhiL = maxPhiL*(64./80); // currently a hack that is in place to handle the different number of strips in ME1/1 and ME1/3
165  }
166 
167  // VK: The the unganged ME1a hack
168  if (station == 1 && (cscid >= 10)) {
169  lclPhi = strip*(4*binPhiL/3);
170  cscid = cscid - 9; // back to normal 1-9 range
171  }
172  // end VK
173 
174  if((cscid > 0) && (cscid <= 9))
175  {
176  if((station == 1) && (lclPhi < maxPhiL))
177  data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][0] +
178  gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][1]*lclPhi);
179  else if((station == 1) && (lclPhi >= maxPhiL))
180  data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][0] +
181  gbl_phi_me_params[endcap-1][sector-1][station-1][subsector-1][cscid-1][1]*(maxPhiL-1));
182  else
183  data.global_phi = (gbl_phi_me_params[endcap-1][sector-1][station-1][0][cscid-1][0] +
184  gbl_phi_me_params[endcap-1][sector-1][station-1][0][cscid-1][1]*lclPhi);
185  }
186  else
187  edm::LogWarning("CSCSectorReceiverMiniLUT")
188  << "+++ Value of cscid, " << cscid
189  << ", is out of bounds, [1, 9] +++\n";
190 
191  if(data.global_phi >= maxPhiG)
192  edm::LogWarning("CSCSectorReceiverMiniLUT")
193  << "+++ Value of global_phi, " << data.global_phi
194  << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
195 
196  return data;
197 }
198 
200  unsigned short sector,
201  unsigned short subsector,
202  unsigned theadd)
203 {
204  if(endcap < 1 || endcap > 2)
205  edm::LogWarning("CSCSectorReceiverMiniLUT")
206  << "+++ Value of endcap, " << endcap
207  << ", is out of bounds, [1, 2] +++\n";
208  if(sector < 1 || sector > 6)
209  edm::LogWarning("CSCSectorReceiverMiniLUT")
210  << "+++ Value of sector, " << sector
211  << ", is out of bounds, [1, 6] +++\n";
212 
213  gblphidat data(0);
214 
215  unsigned short int maxPhiL = 1<<CSCBitWidths::kLocalPhiDataBitWidth;
216  unsigned short int maxPhiG = 1<<CSCBitWidths::kGlobalPhiDataBitWidth;
217  unsigned short int cscid = ((theadd >> 15)&0xf);
218  unsigned short int lclPhi = (theadd & 0x3ff);
219 
220  if((cscid <= 3) || (cscid >= 7))
221  maxPhiL = maxPhiL*(64./80); // currently a hack that is in place to handle the different number of strips in ME1/1 and ME1/3
222 
223  if((cscid > 0) && (cscid <= 9))
224  {
225  if(lclPhi < maxPhiL)
226  data.global_phi = (gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][0] +
227  gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][1]*lclPhi);
228  else
229  data.global_phi = (gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][0] +
230  gbl_phi_mb_params[endcap-1][sector-1][subsector-1][cscid-1][1]*(maxPhiL-1));
231  }
232  else
233  edm::LogWarning("CSCSectorReceiverMiniLUT")
234  << "+++ Value of cscid, " << cscid
235  << ", is out of bounds, [1, 9] +++\n";
236 
237  if(data.global_phi >= maxPhiG)
238  edm::LogWarning("CSCSectorReceiverMiniLUT")
239  << "+++ Value of global_phi, " << data.global_phi
240  << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
241 
242  if(data.global_phi >= maxPhiG)
243  edm::LogWarning("CSCSectorReceiverMiniLUT")
244  << "+++ Value of global_phi, " << data.global_phi
245  << ", exceeds max allowed, " << maxPhiG-1 << " +++\n";
246 
247  return data;
248 }
void strip(std::string &input, const std::string &blanks=" \n\t")
Definition: stringTools.cc:16
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 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)
Log< T >::type log(const T &t)
Definition: Log.h:22
class global_phi_data gblphidat
class local_phi_data lclphidat
Data Types.
static const float gbl_phi_mb_params[2][6][2][9][2]
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)