CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCTFPtLUT.cc
Go to the documentation of this file.
1 /*****************************************************
2  * 28/01/2010
3  * GP: added new switch to use the beam start Pt LUTs
4  * if (eta > 2.1) 2 stations tracks have quality 2
5  * 3 stations tracks have quality 3
6  * NB: no matter if the have ME1
7  *
8  * --> by default is set to true
9  *****************************************************/
10 
14 #include <fstream>
15 
18 
23 
24 // info for getPtScale() pt scale in GeV
25 // low edges of pt bins
26 /* const float ptscale[33] = { */
27 /* -1., 0.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, */
28 /* 4.5, 5.0, 6.0, 7.0, 8.0, 10.0, 12.0, 14.0, */
29 /* 16.0, 18.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0, */
30 /* 50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 140.0, 1.E6 }; */
31 
32 /*
33  These arrays were defined such that they take integer dPhi --> dPhi-units which are used by CSCTFPtMethods.
34  The values were defined using:
35 
36  Phi_{i} = Phi_{i-1} + MAX( phi_Unit * alphi^{i}, phi_Unit), where phi_Unit = 62 deg / 4096, and alpha is solved for
37  such that the phi-space is resonably covered. This will be better optimized in the future.
38 
39 */
40 
41 // Array that maps the 5-bit integer dPhi --> dPhi-units. It is assumed that this is used for dPhi23,
42 // which has a maximum value of 3.83 degrees (255 units) in the extrapolation units.
43 const int CSCTFPtLUT::dPhiNLBMap_5bit[32] =
44  { 0 , 1 , 2 , 4 , 5 , 7 , 9 , 11 , 13 , 15 , 18 , 21 , 24 , 28 , 32 , 37 , 41 , 47 , 53 , 60 , 67 , 75 , 84 , 94 , 105 , 117 , 131 , 145 , 162 , 180 , 200 , 222};
45 
46 // Array that maps the 7-bit integer dPhi --> dPhi-units. It is assumed that this is used for dPhi12,
47 // which has a maximum value of 7.67 degrees (511 units) in the extrapolation units.
48 const int CSCTFPtLUT::dPhiNLBMap_7bit[128] =
49  { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 8 , 9 , 10 , 11 , 12 , 14 , 15 , 16 , 17 , 19 , 20 , 21 , 23 , 24 , 26 , 27 , 29 , 30 , 32 , 33 , 35 , 37 , 38 , 40 , 42 , 44 , 45 , 47 , 49 , 51 , 53 , 55 , 57 , 59 , 61 , 63 , 65 , 67 , 70 , 72 , 74 , 77 , 79 , 81 , 84 , 86 , 89 , 92 , 94 , 97 , 100 , 103 , 105 , 108 , 111 , 114 , 117 , 121 , 124 , 127 , 130 , 134 , 137 , 141 , 144 , 148 , 151 , 155 , 159 , 163 , 167 , 171 , 175 , 179 , 183 , 188 , 192 , 197 , 201 , 206 , 210 , 215 , 220 , 225 , 230 , 235 , 241 , 246 , 251 , 257 , 263 , 268 , 274 , 280 , 286 , 292 , 299 , 305 , 312 , 318 , 325 , 332 , 339 , 346 , 353 , 361 , 368 , 376 , 383 , 391 , 399 , 408 , 416 , 425 , 433 , 442 , 451 , 460 , 469 , 479 , 489 };
50 
51 // Array that maps the 8-bit integer dPhi --> dPhi-units. It is assumed that this is used for dPhi12,
52 // which has a maximum value of 7.67 degrees (511 units) in the extrapolation units.
53 const int CSCTFPtLUT::dPhiNLBMap_8bit[256] =
54  { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 , 10 , 11 , 12 , 13 , 14 , 16 , 17 , 18 , 19 , 20 , 21 , 22 , 23 , 24 , 25 , 27 , 28 , 29 , 30 , 31 , 32 , 33 , 35 , 36 , 37 , 38 , 39 , 40 , 42 , 43 , 44 , 45 , 46 , 48 , 49 , 50 , 51 , 53 , 54 , 55 , 56 , 58 , 59 , 60 , 61 , 63 , 64 , 65 , 67 , 68 , 69 , 70 , 72 , 73 , 74 , 76 , 77 , 79 , 80 , 81 , 83 , 84 , 85 , 87 , 88 , 90 , 91 , 92 , 94 , 95 , 97 , 98 , 100 , 101 , 103 , 104 , 105 , 107 , 108 , 110 , 111 , 113 , 115 , 116 , 118 , 119 , 121 , 122 , 124 , 125 , 127 , 129 , 130 , 132 , 133 , 135 , 137 , 138 , 140 , 141 , 143 , 145 , 146 , 148 , 150 , 151 , 153 , 155 , 157 , 158 , 160 , 162 , 163 , 165 , 167 , 169 , 171 , 172 , 174 , 176 , 178 , 180 , 181 , 183 , 185 , 187 , 189 , 191 , 192 , 194 , 196 , 198 , 200 , 202 , 204 , 206 , 208 , 210 , 212 , 214 , 216 , 218 , 220 , 222 , 224 , 226 , 228 , 230 , 232 , 234 , 236 , 238 , 240 , 242 , 244 , 246 , 249 , 251 , 253 , 255 , 257 , 259 , 261 , 264 , 266 , 268 , 270 , 273 , 275 , 277 , 279 , 282 , 284 , 286 , 289 , 291 , 293 , 296 , 298 , 300 , 303 , 305 , 307 , 310 , 312 , 315 , 317 , 320 , 322 , 324 , 327 , 329 , 332 , 334 , 337 , 340 , 342 , 345 , 347 , 350 , 352 , 355 , 358 , 360 , 363 , 366 , 368 , 371 , 374 , 376 , 379 , 382 , 385 , 387 , 390 , 393 , 396 , 398 , 401 , 404 , 407 , 410 , 413 , 416 , 419 , 421 , 424 , 427 , 430 , 433 , 436 , 439 , 442 , 445 , 448 , 451 , 454 , 457 , 461 , 464 , 467 , 470 , 473 , 476 , 479 , 483 };
55 
56 
57 //const int CSCTFPtLUT::dEtaCut_Low[24] = {2,2,2,4,2,1,2,4,7,7,3,4,1,1,1,1,7,7,2,2,7,7,1,1};
58 //const int CSCTFPtLUT::dEtaCut_Mid[24] = {2,2,3,5,2,2,3,5,7,7,4,5,2,2,2,2,7,7,2,2,7,7,2,2};
59 //const int CSCTFPtLUT::dEtaCut_High_A[24] = {3,3,4,6,3,2,4,6,7,7,5,6,2,2,2,2,7,7,3,3,7,7,2,2};
60 //const int CSCTFPtLUT::dEtaCut_High_B[24] = {3,3,4,7,3,3,5,7,7,7,6,7,2,2,3,3,7,7,3,3,7,7,3,2};
61 //const int CSCTFPtLUT::dEtaCut_High_C[24] = {4,4,5,7,4,3,6,7,7,7,7,7,3,3,3,3,7,7,4,4,7,7,3,3};
62 const int CSCTFPtLUT::dEtaCut_Low[24] = {2,2,2,7,2,1,2,7,3,3,3,7,1,1,1,1,2,2,2,2,1,1,1,1};
63 const int CSCTFPtLUT::dEtaCut_Mid[24] = {2,2,3,7,2,2,3,7,4,4,4,7,2,2,2,2,2,2,2,2,2,2,2,2};
64 const int CSCTFPtLUT::dEtaCut_High_A[24] = {3,3,4,7,3,2,4,7,5,5,5,7,2,2,2,2,3,3,3,3,2,2,2,2};
65 const int CSCTFPtLUT::dEtaCut_High_B[24] = {3,3,4,7,3,3,5,7,6,6,6,7,2,2,3,3,3,3,3,3,3,3,3,2};
66 const int CSCTFPtLUT::dEtaCut_High_C[24] = {4,4,5,7,4,3,6,7,7,7,7,7,3,3,3,3,4,4,4,4,3,3,3,3};
67 const int CSCTFPtLUT::dEtaCut_Open[24] = {7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7};
68 
69 const int CSCTFPtLUT::getPtbyMLH = 0xFFFF; // all modes on
70 
71 
73  : read_pt_lut_es(true),
74  read_pt_lut_file(false),
76 {
77  pt_method = 32;
78 
79  lowQualityFlag = 4;
80  isBeamStartConf = true;
81 
83  es.get<L1MuCSCPtLutRcd>().get(ptLUT);
84  theL1MuCSCPtLut_ = ptLUT.product();
85 
86  //std::cout << "theL1MuCSCPtLut_ pointer is "
87  // << theL1MuCSCPtLut_
88  // << std::endl;
89 
91  es.get< L1MuTriggerScalesRcd >().get( scales ) ;
92  trigger_scale = scales.product() ;
93 
95  es.get< L1MuTriggerPtScaleRcd >().get( ptScale ) ;
96  trigger_ptscale = ptScale.product() ;
97 
98  ptMethods = CSCTFPtMethods( ptScale.product() ) ;
99 
100 }
101 
102 
104  const L1MuTriggerScales* scales,
105  const L1MuTriggerPtScale* ptScale)
106  : trigger_scale( scales ),
107  trigger_ptscale( ptScale ),
108  ptMethods( ptScale ),
109  read_pt_lut_es(false),
110  read_pt_lut_file(false),
111  isBinary(false)
112 {
113 
114  read_pt_lut_file = pset.getParameter<bool>("ReadPtLUT");
115  if(read_pt_lut_file)
116  {
117  // if read from file, then need to set extra variables
118  pt_lut_file = pset.getParameter<edm::FileInPath>("PtLUTFile");
119  isBinary = pset.getParameter<bool>("isBinary");
120 
121  edm::LogInfo("CSCTFPtLUT::CSCTFPtLUT") << "Reading file: "
122  << pt_lut_file.fullPath().c_str()
123  << " isBinary?(1/0): "
124  << isBinary;
125  }
126 
127  // Determine the pt assignment method to use
128  // 1 - Darin's parameterization method
129  // 2 - Cathy Yeh's chi-square minimization method
130  // 3 - Hybrid
131  // 4 - Anna's parameterization method
132  // 5 - Anna's parameterization method
133  //with improvments at ME1/1a: find max pt for 3 links hypothesis
134  // 11 - Anna's: for fw 20101011 <- 2011 data taking <- not valide any more
135  // 12 - Anna's: for fw 20101011 <- 2011 data taking <- not valide any more
136  //with improvments at ME1/1a: find max pt for 3 links hypothesis
137  // 21 - Anna's: for fw 20110118 and up, curves with data 2010 <- 2011 data taking
138  // 22 - Anna's: for fw 20110118 and up, curves with data 2010 <- 2011 data taking
139  //with improvments at ME1/1a: find max pt for 3 links hypothesis
140  // 23 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
141  // 24 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
142  //with improvments at ME1/1a: find max pt for 3 links hypothesis
143  //25 and 26 like 23 and 24 correspondenly but fix high pt assignment in DT-CSC region
144  // 25 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
145  // 26 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
146  //with improvments at ME1/1a: find max pt for 3 links hypothesis
147  // change Quality: Q = 3 for mode 5, Quility = 2 for mode = 8, 9, 10 at eta = 1.6-1.8
148  // 27 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
149  // 28 - Anna's: for fw 20110118 and up, curves with MC like method 4 <- 2011 data taking
150  //with improvments at ME1/1a: find max pt for 3 links hypothesis
151  // 29 - Bobby's medium Quality: using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning.
152  // 33 - Bobby's medium Quality: using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning. No max pt at eta > 2.1
153  // 30 - Bobby's loose Quality: using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning.
154  // 31 - Bobby's tight Quality: using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning.
155  // 32 - Bobby's medium Quality+ {tight only mode5 at eta > 2.1}: using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning.
156  pt_method = pset.getUntrackedParameter<unsigned>("PtMethod",32);
157  //std::cout << "pt_method from pset " << std::endl;
158  // what does this mean???
159  lowQualityFlag = pset.getUntrackedParameter<unsigned>("LowQualityFlag",4);
160 
161  if(read_pt_lut_file)
162  {
163  pt_lut = new ptdat[1<<21];
164  readLUT();
165  }
166 
167  isBeamStartConf = pset.getUntrackedParameter<bool>("isBeamStartConf", true);
168 
169 }
170 
172 {
173  ptdat result;
174 
175  if(read_pt_lut_es)
176  {
177  unsigned int shortAdd = (address.toint()& 0x1fffff);
178 
179  ptdat tmp( theL1MuCSCPtLut_->pt(shortAdd) );
180 
181  result = tmp;
182  }
183 
184  else if (read_pt_lut_file)
185  {
186  int shortAdd = (address.toint()& 0x1fffff);
187  result = pt_lut[shortAdd];
188  }
189 
190  else
191  result = calcPt(address);
192 
193  return result;
194 }
195 
196 ptdat CSCTFPtLUT::Pt(const unsigned& address) const
197 {
198  return Pt(ptadd(address));
199 }
200 
201 ptdat CSCTFPtLUT::Pt(const unsigned& delta_phi_12, const unsigned& delta_phi_23,
202  const unsigned& track_eta, const unsigned& track_mode,
203  const unsigned& track_fr, const unsigned& delta_phi_sign) const
204 {
205  ptadd address;
206  address.delta_phi_12 = delta_phi_12;
207  address.delta_phi_23 = delta_phi_23;
208  address.track_eta = track_eta;
209  address.track_mode = track_mode;
210  address.track_fr = track_fr;
211  address.delta_phi_sign = delta_phi_sign;
212 
213  return Pt(address);
214 }
215 
216 ptdat CSCTFPtLUT::Pt(const unsigned& delta_phi_12, const unsigned& track_eta,
217  const unsigned& track_mode, const unsigned& track_fr,
218  const unsigned& delta_phi_sign) const
219 {
220  ptadd address;
221  address.delta_phi_12 = ((1<<8)-1)&delta_phi_12;
222  address.delta_phi_23 = ((1<<4)-1)&(delta_phi_12>>8);
223  address.track_eta = track_eta;
224  address.track_mode = track_mode;
225  address.track_fr = track_fr;
226  address.delta_phi_sign = delta_phi_sign;
227 
228  return Pt(address);
229 }
230 
231 
233 {
234  ptdat result;
235 
236  double Pi = acos(-1.);
237  float etaR = 0, ptR_front = 0, ptR_rear = 0, dphi12R = 0, dphi23R = 0;
238  int charge12, charge23;
239  unsigned type, mode, eta, fr, quality, charge, absPhi12, absPhi23;
240 
241  mode = address.track_mode;
242 
243  int usedetaCUT = true;
244  // Chose Eta cut tightness. 1=tightest, 2=moderate, 3=loose, 4=very loose, 5=extremely loose, 6=open
245 
246  // modes 6, 7, 13
247  int EtaCutLevel_1 = 2;
248  int dEtaCut_1[24];
249 
250  for (int i=0;i<24;i++)
251  {
252  dEtaCut_1[i] = 10;
253  if (EtaCutLevel_1 == 1)
254  dEtaCut_1[i] = dEtaCut_Low[i];
255  else if (EtaCutLevel_1 == 2)
256  dEtaCut_1[i] = dEtaCut_Mid[i];
257  else if (EtaCutLevel_1 == 3)
258  dEtaCut_1[i] = dEtaCut_High_A[i];
259  else if (EtaCutLevel_1 == 4)
260  dEtaCut_1[i] = dEtaCut_High_B[i];
261  else if (EtaCutLevel_1 == 5)
262  dEtaCut_1[i] = dEtaCut_High_C[i];
263  else if (EtaCutLevel_1 == 6)
264  dEtaCut_1[i] = dEtaCut_Open[i];
265  }
266  // modes 8, 9, 10
267  int EtaCutLevel_2 = 2;
268  int dEtaCut_2[24];
269 
270  for (int i=0;i<24;i++)
271  {
272  dEtaCut_2[i] = 10;
273  if (EtaCutLevel_2 == 1)
274  dEtaCut_2[i] = dEtaCut_Low[i];
275  else if (EtaCutLevel_2 == 2)
276  dEtaCut_2[i] = dEtaCut_Mid[i];
277  else if (EtaCutLevel_2 == 3)
278  dEtaCut_2[i] = dEtaCut_High_A[i];
279  else if (EtaCutLevel_2 == 4)
280  dEtaCut_2[i] = dEtaCut_High_B[i];
281  else if (EtaCutLevel_2 == 5)
282  dEtaCut_2[i] = dEtaCut_High_C[i];
283  else if (EtaCutLevel_2 == 6)
284  dEtaCut_2[i] = dEtaCut_Open[i];
285 
286  float scalef = 1.0;
287  if (mode == 8 || mode == 10)
288  dEtaCut_2[i] = scalef*dEtaCut_2[i];
289 
290  }
291 
292 
293 
294  eta = address.track_eta;
295 
296  fr = address.track_fr;
297  charge = address.delta_phi_sign;
298  quality = trackQuality(eta, mode, fr);
299  unsigned front_pt, rear_pt;
300  front_pt = 0.; rear_pt = 0.;
301  unsigned front_quality, rear_quality;
302 
303  etaR = trigger_scale->getRegionalEtaScale(2)->getLowEdge(2*eta+1);
304 
305  front_quality = rear_quality = quality;
306 
307  unsigned int remerged;
308  int iME11;
309  int CLCT_pattern;
310  int dEta;
311  int index = 0;
312  float bestLH = -999;
313  float bestLH_front = -999.0;
314  float bestLH_rear = -999.0;
315 
316  int PtbyMLH = false;
317 
318  //***************************************************//
319  if(pt_method >= 29 && pt_method <= 33)
320  {
321  // using fw 2012_01_31. Switch to Global Log(L). Non-Linear dphi binning.
322  PtbyMLH = 0x1 & (getPtbyMLH >> (int)mode);
324  // switch off any improvment for eta > 2.1
325  if(etaR > 2.1){
326  usedetaCUT = false;
327  PtbyMLH = 0x0;
328  }
330 
331  switch(mode)
332  {
333  case 2:
334  case 3:
335  case 4:
336  case 5:
337 
338 
339  charge12 = 1;
340 
341  // First remake the 12-bit dPhi word from the core
342  remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
343 
344  // Now separate it into 7-bit dPhi12 and 5-bit dPhi23 parts
345  absPhi12 = ((1<<7)-1) & remerged;
346  absPhi23 = ((1<<5)-1) & (remerged >> 7);
347 
348  // Now get the corresponding dPhi value in our phi-units using the inverse dPhi LUTs
349  absPhi12 = dPhiNLBMap_7bit[absPhi12];
350  absPhi23 = dPhiNLBMap_5bit[absPhi23];
351 
352  if(charge) charge23 = 1;
353  else charge23 = -1;
354 
355  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
356  dphi23R = (static_cast<float>(absPhi23)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
357  if(charge12 * charge23 < 0) dphi23R = -dphi23R;
358 
359  ptR_front = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12R, dphi23R, PtbyMLH, bestLH, 1, int(pt_method));
360  bestLH_front = bestLH;
361  ptR_rear = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12R, dphi23R, PtbyMLH, bestLH, 0, int(pt_method));
362  bestLH_rear = bestLH;
363 
364  if((pt_method == 29 || pt_method == 32 || pt_method == 30 || pt_method == 31) && mode != 5 && etaR > 2.1)//exclude mode without ME11a
365  {
366  float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees
367  float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
368  float dphi23Rmin = dphi23R;
369  float dphi23Rmax = dphi23R;
370  //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
371  //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
372  float ptR_front_min = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmin, dphi23Rmin, PtbyMLH, bestLH, 1, int(pt_method));
373  float bestLH_front_min = bestLH;
374  float ptR_rear_min = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmin, dphi23Rmin, PtbyMLH, bestLH, 0, int(pt_method));
375  float bestLH_rear_min = bestLH;
376  float ptR_front_max = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmax, dphi23Rmax, PtbyMLH, bestLH, 1, int(pt_method));
377  float bestLH_front_max = bestLH;
378  float ptR_rear_max = ptMethods.Pt3Stn2012(int(mode), etaR, dphi12Rmax, dphi23Rmax, PtbyMLH, bestLH, 0, int(pt_method));
379  float bestLH_rear_max = bestLH;
380 
381  if (PtbyMLH)
382  {
383  float best_pt_front = ptR_front;
384  float best_LH_front = bestLH_front;
385  if (bestLH_front_min > best_LH_front)
386  {
387  best_pt_front = ptR_front_min;
388  best_LH_front = bestLH_front_min;
389  }
390  if (bestLH_front_max > best_LH_front)
391  {
392  best_pt_front = ptR_front_max;
393  best_LH_front = bestLH_front_max;
394  }
395  ptR_front = best_pt_front;
396 
397  float best_pt_rear = ptR_rear;
398  float best_LH_rear = bestLH_rear;
399  if (bestLH_rear_min > best_LH_rear)
400  {
401  best_pt_rear = ptR_rear_min;
402  best_LH_rear = bestLH_rear_min;
403  }
404  if (bestLH_rear_max > best_LH_rear)
405  {
406  best_pt_rear = ptR_rear_max;
407  best_LH_rear = bestLH_rear_max;
408  }
409  ptR_rear = best_pt_rear;
410  }
411  else
412  {
413  // select max pt solution for 3 links:
414  ptR_front = std::max(ptR_front, ptR_front_min);
415  ptR_front = std::max(ptR_front, ptR_front_max);
416  ptR_rear = std::max(ptR_rear, ptR_rear_min);
417  ptR_rear = std::max(ptR_rear, ptR_rear_max);
418  }
419  }
420  break;
421  case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit
422  case 7:
423  case 13: // ME1-ME4
424 
425  // First remake the 12-bit dPhi word from the core
426  remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
427  // Now get 8-bit dPhi12
428  absPhi12 = ((1<<8)-1) & remerged;
429  // Now get 3-bit dEta
430  dEta = ((1<<3)-1) & (remerged >> 8);
431  // New get CLCT bit. CLCT = true if CLCTPattern = 8, 9, or 10, else 0.
432  CLCT_pattern = 0x1 & (remerged >> 11);
433 
434  iME11 = int(charge); // = 0 if ME1/1, = 1 if ME1/2 or ME1/3 station
435  if(iME11 == 1 && etaR > 1.6) etaR = 1.55; // shift for ME1/2 station
436  if(iME11 == 0 && etaR < 1.6) etaR = 1.65; // shift for ME1/1 station
437 
438  // Get the 8-bit dPhi bin number
439  absPhi12 = ((1<<8)-1) & address.delta_phi_12;
440 
441  // Now get the corresponding dPhi value in our phi-units using the inverse dPhi LUTs
442  absPhi12 = dPhiNLBMap_8bit[absPhi12];
443 
444  //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
445 
446  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
447 
448  //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
449  ptR_front = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 1, int(pt_method));
450  bestLH_front = bestLH;
451  ptR_rear = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 0, int(pt_method));
452  bestLH_rear = bestLH;
453  if((pt_method == 29 || pt_method == 32 || pt_method == 30 || pt_method == 31) && etaR > 2.1)//exclude tracks without ME11a
454  {
455  float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees
456  float ptR_front_min = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12Rmin, PtbyMLH, bestLH, 1, int(pt_method));
457  float bestLH_front_min = bestLH;
458  float ptR_rear_min = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12Rmin, PtbyMLH, bestLH, 0, int(pt_method));
459  float bestLH_rear_min = bestLH;
460 
461  if (PtbyMLH)
462  {
463  ptR_front = bestLH_front > bestLH_front_min ? ptR_front : ptR_front_min;
464  ptR_rear = bestLH_rear > bestLH_rear_min ? ptR_rear : ptR_rear_min;
465  }
466  else
467  {
468  // select max pt solution for 3 links:
469  ptR_front = std::max(ptR_front, ptR_front_min);
470  ptR_rear = std::max(ptR_rear, ptR_rear_min);
471  }
472  }
473 
474  if( (!CLCT_pattern) && (ptR_front > 5.)) ptR_front = 5.;
475  if( (!CLCT_pattern) && (ptR_rear > 5.)) ptR_rear = 5.;
476 
477  // Check dEta against reasonable values for high-pt muons
478  index = 0;
479  if (mode == 6) index = 0;
480  if (mode == 7) index = 4;
481  if (mode == 13) index = 8;
482 
483  if (usedetaCUT)
484  {
485  if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
486  if (dEta>dEtaCut_1[index+0] )
487  {
488  if (ptR_front > 5) ptR_front = 5;
489  if (ptR_rear > 5) ptR_rear = 5;
490  }
491  if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
492  if (dEta>dEtaCut_1[index+1])
493  {
494  if (ptR_front > 5) ptR_front = 5;
495  if (ptR_rear > 5) ptR_rear = 5;
496  }
497 
498  if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
499  if (dEta>dEtaCut_1[index+2] )
500  {
501  if (ptR_front > 5) ptR_front = 5;
502  if (ptR_rear > 5) ptR_rear = 5;
503  }
504  if (fabs(etaR)>2.1)
505  if (dEta>dEtaCut_1[index+3] )
506  {
507  if (ptR_front > 5) ptR_front = 5;
508  if (ptR_rear > 5) ptR_rear = 5;
509  }
510  }
511 
512  break;
513 
514  case 8:
515  case 9:
516  case 10:
517 
518 
519  // First remake the 12-bit dPhi word from the core
520  remerged = (address.delta_phi_12 | (address.delta_phi_23 << 8 ) );
521  // Now get 9-bit dPhi12
522  absPhi12 = ((1<<9)-1) & remerged;
523  // Now get 3-bit dEta
524  dEta = ((1<<3)-1) & (remerged >> 9);
525 
526  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
527 
528  //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
529  ptR_front = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 1, int(pt_method));
530  ptR_rear = ptMethods.Pt2Stn2012(int(mode), etaR, dphi12R, PtbyMLH, bestLH, 0, int(pt_method));
531 
532  index = 0;
533  if (mode == 8) index = 12;
534  if (mode == 9) index = 16;
535  if (mode == 10) index = 20;
536 
537 
538 
539 
540  if (usedetaCUT)
541  {
542  if (fabs(etaR)>1.2 && fabs(etaR)<=1.5)
543  if (dEta>dEtaCut_2[index+0] )
544  {
545  if (ptR_front > 5) ptR_front = 5;
546  if (ptR_rear > 5) ptR_rear = 5;
547  }
548  if (fabs(etaR)>1.5 && fabs(etaR)<=1.65)
549  if (dEta>dEtaCut_2[index+1])
550  {
551  if (ptR_front > 5) ptR_front = 5;
552  if (ptR_rear > 5) ptR_rear = 5;
553  }
554 
555  if (fabs(etaR)>1.65 && fabs(etaR)<=2.1)
556  if (dEta>dEtaCut_2[index+2] )
557  {
558  if (ptR_front > 5) ptR_front = 5;
559  if (ptR_rear > 5) ptR_rear = 5;
560  }
561  if (fabs(etaR)>2.1)
562  if (dEta>dEtaCut_2[index+3] )
563  {
564  if (ptR_front > 5) ptR_front = 5;
565  if (ptR_rear > 5) ptR_rear = 5;
566  }
567  }
568 
569  break;
570  // for overlap DT-CSC region using curves from data 2010
571  case 11: // FR = 1 -> b1-1-3, FR = 0 -> b1-3
572  case 12: // FR = 1 -> b1-2-3, FR = 0 -> b1-2
573  case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
574 
575 
576  //sign definition: sign dphi12 = Phi_DT - Phi_CSC
577  // sing dphi23 = 5th sign. bit of phiBend
578  // -> charge = 1 -> dphi12 = +, phiBend = -
579  // -> charge = 0 -> dphi12 = +, phiBend = +
580  charge12 = 1;
581 
582  // DT tracks are still using linear dPhi binning
583  absPhi12 = address.delta_phi_12;
584  absPhi23 = address.delta_phi_23;
585 
586  if(charge) charge23 = -1;
587  else charge23 = 1;
588 
589  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
590  dphi23R = float(absPhi23);
591  if(charge12 * charge23 < 0) dphi23R = -dphi23R;
592 
593  int mode1;
594  mode1 = int(mode);
595  if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
596 
597  ptR_front = ptMethods.Pt3Stn2012_DT(mode1, etaR, dphi12R, dphi23R, PtbyMLH, bestLH, int(0), int(pt_method));
598  ptR_rear = ptMethods.Pt3Stn2012_DT(mode1, etaR, dphi12R, dphi23R, PtbyMLH, bestLH, int(0), int(pt_method));
599 
600  break;
601  case 15: // halo trigger
602  case 1: // tracks that fail delta phi cuts
603  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
604  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
605  break;
606  default: // Tracks in this category are not considered muons.
607  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV
608  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
609  };// end switch
610 
611  front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
612  rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
613 
614  } //end pt_methods 29
615 
616 
617 //***************************************************//
618  if(pt_method >= 23 && pt_method <= 28){ //here we have only pt_methods greater then
619  //for fw 20110118 <- 2011 data taking, curves from MC like method 4
620  // mode definition you could find at page 6 & 7:
621  // http://www.phys.ufl.edu/~madorsky/sp/2011-11-18/sp_core_interface.pdf
622  // it is valid starting the beggining of 2011
623  //std::cout << " pt_method = " << pt_method << std::endl;//test
624  switch(mode)
625  {
626  case 2:
627  case 3:
628  case 4:
629  case 5:
630 
631  charge12 = 1;
632  absPhi12 = address.delta_phi_12;
633  absPhi23 = address.delta_phi_23;
634 
635  if(charge) charge23 = 1;
636  else charge23 = -1;
637 
638  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
639  dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
640  if(charge12 * charge23 < 0) dphi23R = -dphi23R;
641 
642  ptR_front = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12R, dphi23R, 1, int(pt_method));
643  ptR_rear = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12R, dphi23R, 0, int(pt_method));
644 
645  if((pt_method == 24 || pt_method == 26 || pt_method == 28) && mode != 5 && etaR > 2.1)//exclude mode without ME11a
646  {
647  float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees
648  float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
649  float dphi23Rmin = dphi23R;
650  float dphi23Rmax = dphi23R;
651  //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
652  //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
653  float ptR_front_min = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
654  float ptR_rear_min = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
655  float ptR_front_max = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
656  float ptR_rear_max = ptMethods.Pt3Stn2010(int(mode), etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
657  // select max pt solution for 3 links:
658  ptR_front = std::max(ptR_front, ptR_front_min);
659  ptR_front = std::max(ptR_front, ptR_front_max);
660  ptR_rear = std::max(ptR_rear, ptR_rear_min);
661  ptR_rear = std::max(ptR_rear, ptR_rear_max);
662  }
663  break;
664  case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit
665  case 7:
666  case 13: // ME1-ME4
667  int iME11;
668  iME11 = int(charge); // = 0 if ME1/1, = 1 if ME1/2 or ME1/3 station
669  if(iME11 == 1 && etaR > 1.6) etaR = 1.55; // shift for ME1/2 station
670  if(iME11 == 0 && etaR < 1.6) etaR = 1.65; // shift for ME1/1 station
671  absPhi12 = address.delta_phi_12;
672  //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
673  int CLCT_pattern;
674  CLCT_pattern = int(address.delta_phi_23);
675  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
676 
677  //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
678  ptR_front = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 1, int(pt_method));
679  ptR_rear = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 0, int(pt_method));
680  if((pt_method == 24 || pt_method == 26 || pt_method == 28) && etaR > 2.1)//exclude tracks without ME11a
681  {
682  float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees
683  float ptR_front_min = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12Rmin, 1, int(pt_method));
684  float ptR_rear_min = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12Rmin, 0, int(pt_method));
685  // select max pt solution for 3 links:
686  ptR_front = std::max(ptR_front, ptR_front_min);
687  ptR_rear = std::max(ptR_rear, ptR_rear_min);
688  }
689  if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
690  if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
691  //std::cout << "mode = "<< mode << " CLCT_pattern = " << CLCT_pattern << " ptR_rear = " << ptR_rear << std::endl;
692 
693  break;
694  case 8:
695  case 9:
696  case 10:
697  if(charge) absPhi12 = address.delta_phi();
698  else
699  {
700  int temp_phi = address.delta_phi();
701  absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
702  }
703 
704  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
705 
706  //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
707  ptR_front = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 1, int(pt_method));
708  ptR_rear = ptMethods.Pt2Stn2010(int(mode), etaR, dphi12R, 0, int(pt_method));
709 
710  break;
711  // for overlap DT-CSC region using curves from data 2010
712  case 11: // FR = 1 -> b1-1-3, FR = 0 -> b1-3
713  case 12: // FR = 1 -> b1-2-3, FR = 0 -> b1-2
714  case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
715 
716  //sign definition: sign dphi12 = Phi_DT - Phi_CSC
717  // sing dphi23 = 5th sign. bit of phiBend
718  // -> charge = 1 -> dphi12 = +, phiBend = -
719  // -> charge = 0 -> dphi12 = +, phiBend = +
720  charge12 = 1;
721  absPhi12 = address.delta_phi_12;
722  absPhi23 = address.delta_phi_23;
723 
724  if(charge) charge23 = -1;
725  else charge23 = 1;
726 
727  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
728  dphi23R = float(absPhi23);
729  if(charge12 * charge23 < 0) dphi23R = -dphi23R;
730 
731  int mode1;
732  mode1 = int(mode);
733  if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
734 
735  ptR_front = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
736  ptR_rear = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
737 
738  break;
739  case 15: // halo trigger
740  case 1: // tracks that fail delta phi cuts
741  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
742  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
743  break;
744  default: // Tracks in this category are not considered muons.
745  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV
746  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
747  };// end switch
748 
749  front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
750  rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
751 
752  } //end pt_methods 23 - 28
753 
754 //***************************************************//
755 //***************************************************//
756  if(pt_method == 21 || pt_method == 22){ //here we have only pt_methods greater then
757  //for fw 20110118 <- 2011 data taking
758  // mode definition you could find at page 6 & 7:
759  // http://www.phys.ufl.edu/~madorsky/sp/2011-11-18/sp_core_interface.pdf
760  // it is valid starting the beggining of 2011
761  switch(mode)
762  {
763  case 2:
764  case 3:
765  case 4:
766  case 5:
767 
768  charge12 = 1;
769  absPhi12 = address.delta_phi_12;
770  absPhi23 = address.delta_phi_23;
771 
772  if(charge) charge23 = 1;
773  else charge23 = -1;
774 
775  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
776  dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
777  if(charge12 * charge23 < 0) dphi23R = -dphi23R;
778 
779  ptR_front = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12R, dphi23R, 1, int(pt_method));
780  ptR_rear = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12R, dphi23R, 0, int(pt_method));
781 
782  if(pt_method == 22 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
783  {
784  float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees
785  float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
786  float dphi23Rmin = dphi23R;
787  float dphi23Rmax = dphi23R;
788  //if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
789  //if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
790  float ptR_front_min = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
791  float ptR_rear_min = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
792  float ptR_front_max = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
793  float ptR_rear_max = ptMethods.Pt3Stn2011(int(mode), etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
794  // select max pt solution for 3 links:
795  ptR_front = std::max(ptR_front, ptR_front_min);
796  ptR_front = std::max(ptR_front, ptR_front_max);
797  ptR_rear = std::max(ptR_rear, ptR_rear_min);
798  ptR_rear = std::max(ptR_rear, ptR_rear_max);
799  }
800  break;
801  case 6: // for mode 6, 7 and 13 add CLCT information in dph23 bit and iME11 in charge bit
802  case 7:
803  case 13: // ME1-ME4
804  int iME11;
805  iME11 = int(charge);
806  absPhi12 = address.delta_phi_12;
807  //int CLCT_pattern = static_cast<int>(address.delta_phi_23);
808  int CLCT_pattern;
809  CLCT_pattern = int(address.delta_phi_23);
810 
811  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
812 
813  //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
814  ptR_front = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 1, int(pt_method), iME11);
815  ptR_rear = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 0, int(pt_method), iME11);
816  if((pt_method == 22) && etaR > 2.1)//exclude tracks without ME11a
817  {
818  float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees
819  float ptR_front_min = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12Rmin, 1, int(pt_method), iME11);
820  float ptR_rear_min = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12Rmin, 0, int(pt_method), iME11);
821  // select max pt solution for 3 links:
822  ptR_front = std::max(ptR_front, ptR_front_min);
823  ptR_rear = std::max(ptR_rear, ptR_rear_min);
824  }
825  if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_front > 5.)) ptR_front = 5.;
826  if( ((CLCT_pattern < 8) || (CLCT_pattern > 10)) && (ptR_rear > 5.)) ptR_rear = 5.;
827 
828  break;
829  case 8:
830  case 9:
831  case 10:
832  if(charge) absPhi12 = address.delta_phi();
833  else
834  {
835  int temp_phi = address.delta_phi();
836  absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
837  }
838 
839  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
840 
841  //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
842  ptR_front = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 1, int(pt_method), int(2));
843  ptR_rear = ptMethods.Pt2Stn2011(int(mode), etaR, dphi12R, 0, int(pt_method), int(2));
844 
845  break;
846  case 11: // FR = 1 -> b1-1-3, FR = 0 -> b1-3
847  case 12: // FR = 1 -> b1-2-3, FR = 0 -> b1-2
848  case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
849 
850  //sign definition: sign dphi12 = Phi_DT - Phi_CSC
851  // sing dphi23 = 5th sign. bit of phiBend
852  // -> charge = 1 -> dphi12 = +, phiBend = -
853  // -> charge = 0 -> dphi12 = +, phiBend = +
854  charge12 = 1;
855  absPhi12 = address.delta_phi_12;
856  absPhi23 = address.delta_phi_23;
857 
858  if(charge) charge23 = -1;
859  else charge23 = 1;
860 
861  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
862  dphi23R = float(absPhi23);
863  if(charge12 * charge23 < 0) dphi23R = -dphi23R;
864 
865  int mode1;
866  mode1 = int(mode);
867  if(fr == 1 && mode1 == 11) mode1 = 14; // 3 station track we use dphi12 and phiBend for 2 and 3 station track
868 
869  ptR_front = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
870  ptR_rear = ptMethods.Pt3Stn2011(mode1, etaR, dphi12R, dphi23R, int(0), int(pt_method));
871 
872  break;
873  case 15: // halo trigger
874  case 1: // tracks that fail delta phi cuts
875  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
876  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
877  break;
878  default: // Tracks in this category are not considered muons.
879  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV
880  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
881  };// end switch
882 
883  front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
884  rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
885 
886  } //end pt_methods greater or equal to 21
887 
888 //***************************************************//
889 //***************************************************//
890  if(pt_method >= 11 && pt_method < 20){ //here we have only pt_methods greater or equal to 11
891  //for fw 20101011 <- 2011 data taking
892  // mode definition you could find at page 6 & 7:
893  // http://www.phys.ufl.edu/~madorsky/sp/2010-10-11/sp_core_interface.pdf
894  // it is valid starting the beggining of 2011
895  switch(mode)
896  {
897  case 2:
898  case 3:
899  case 4:
900  case 5:
901 
902  charge12 = 1;
903  absPhi12 = address.delta_phi_12;
904  absPhi23 = address.delta_phi_23;
905 
906  if(charge) charge23 = 1;
907  else charge23 = -1;
908 
909  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
910  dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
911  if(charge12 * charge23 < 0) dphi23R = -dphi23R;
912 
913  ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
914  ptR_rear = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 0, int(pt_method));
915 
916  if(pt_method == 12 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
917  {
918  float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees
919  float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
920  float dphi23Rmin = dphi23R;
921  float dphi23Rmax = dphi23R;
922  if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
923  if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
924  float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
925  float ptR_rear_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
926  float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
927  float ptR_rear_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
928  // select max pt solution for 3 links:
929  ptR_front = std::max(ptR_front, ptR_front_min);
930  ptR_front = std::max(ptR_front, ptR_front_max);
931  ptR_rear = std::max(ptR_rear, ptR_rear_min);
932  ptR_rear = std::max(ptR_rear, ptR_rear_max);
933  }
934  break;
935  case 6:
936  case 7:
937  case 8:
938  case 9:
939  case 10:
940  case 13: // ME1-ME4
941  type = mode - 5;
942 
943  if(charge) absPhi12 = address.delta_phi();
944  else
945  {
946  int temp_phi = address.delta_phi();
947  absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
948  }
949 
950  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
951 
952  //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
953  ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
954  ptR_rear = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
955  if((pt_method == 12) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)//exclude tracks without ME11a
956  {
957  float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees
958  float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
959  float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
960  // select max pt solution for 3 links:
961  ptR_front = std::max(ptR_front, ptR_front_min);
962  ptR_rear = std::max(ptR_rear, ptR_rear_min);
963  }
964 
965  break;
966  case 11: // FR = 1 -> b1-1-3, FR = 0 -> b1-3
967  case 12: // FR = 1 -> b1-2-3, FR = 0 -> b1-2
968  case 14: // FR = 1 -> b1-1-2-(3), FR = 0 -> b1-1
969 
970  if(fr == 0){ // 2 station track
971  if(charge) absPhi12 = address.delta_phi();
972  else
973  {
974  int temp_phi = address.delta_phi();
975  absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
976  }
977  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
978  ptR_rear = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
979 
980  }// end fr == 0
981  if(fr == 1){ // 3 station track
982  charge12 = 1;
983  absPhi12 = address.delta_phi_12;
984  absPhi23 = address.delta_phi_23;
985 
986  if(charge) charge23 = 1;
987  else charge23 = -1;
988 
989  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
990  dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
991  if(charge12 * charge23 < 0) dphi23R = -dphi23R;
992 
993  ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
994 
995  if(pt_method == 12 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
996  {
997  float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees
998  float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
999  float dphi23Rmin = dphi23R;
1000  float dphi23Rmax = dphi23R;
1001  if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
1002  if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
1003  float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
1004  float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
1005  // select max pt solution for 3 links:
1006  ptR_front = std::max(ptR_front, ptR_front_min);
1007  ptR_front = std::max(ptR_front, ptR_front_max);
1008  }
1009  } // end fr == 1
1010 
1011  break;
1012  case 15: // halo trigger
1013  case 1: // tracks that fail delta phi cuts
1014  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(3); // 2 GeV
1015  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(3);
1016  break;
1017  default: // Tracks in this category are not considered muons.
1018  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0); // 0 GeV
1019  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
1020  };// end switch
1021 
1022  front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
1023  rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
1024 
1025  } //end pt_methods greater or equal to 11
1026 //***************************************************//
1027  if(pt_method <= 5){ //here we have only pt_methods less or equal to 5
1028  // mode definition you could find at https://twiki.cern.ch/twiki/pub/Main/PtLUTs/mode_codes.xls
1029  // it is valid till the end 2010
1030 
1031  // kluge to use 2-stn track in overlap region
1032  // see also where this routine is called, and encode LUTaddress, and assignPT
1033  if (pt_method != 4 && pt_method !=5
1034  && (mode == 2 || mode == 3 || mode == 4) && (eta<3)) mode = 6;
1035  if (pt_method != 4 && pt_method !=5 && (mode == 5)
1036  && (eta<3)) mode = 8;
1037 
1038  switch(mode)
1039  {
1040  case 2:
1041  case 3:
1042  case 4:
1043  case 5:
1044  type = mode - 1;
1045  charge12 = 1;
1046  absPhi12 = address.delta_phi_12;
1047  absPhi23 = address.delta_phi_23;
1048 
1049  if(charge) charge23 = 1;
1050  else charge23 = -1;
1051 
1052  // now convert to real numbers for input into PT assignment algos.
1053 
1054  if(pt_method == 4 || pt_method == 5) // param method 2010
1055  {
1056  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
1057  dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
1058  if(charge12 * charge23 < 0) dphi23R = -dphi23R;
1059 
1060  ptR_front = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 1, int(pt_method));
1061  ptR_rear = ptMethods.Pt3Stn2010(mode, etaR, dphi12R, dphi23R, 0, int(pt_method));
1062 
1063  if(pt_method == 5 && mode != 5 && etaR > 2.1)//exclude mode without ME11a
1064  {
1065  float dphi12Rmin = dphi12R - Pi*10/180/3; // 10/3 degrees
1066  float dphi12Rmax = dphi12R + Pi*10/180/3; // 10/3 degrees
1067  float dphi23Rmin = dphi23R;
1068  float dphi23Rmax = dphi23R;
1069  if(dphi12Rmin*dphi12R < 0) dphi23Rmin = -dphi23R;
1070  if(dphi12Rmax*dphi12R < 0) dphi23Rmax = -dphi23R;
1071  float ptR_front_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 1, int(pt_method));
1072  float ptR_rear_min = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmin, dphi23Rmin, 0, int(pt_method));
1073  float ptR_front_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 1, int(pt_method));
1074  float ptR_rear_max = ptMethods.Pt3Stn2010(mode, etaR, dphi12Rmax, dphi23Rmax, 0, int(pt_method));
1075  // select max pt solution for 3 links:
1076  ptR_front = std::max(ptR_front, ptR_front_min);
1077  ptR_front = std::max(ptR_front, ptR_front_max);
1078  ptR_rear = std::max(ptR_rear, ptR_rear_min);
1079  ptR_rear = std::max(ptR_rear, ptR_rear_max);
1080  }
1081  }
1082  else if(pt_method == 1) // param method
1083  {
1084  dphi12R = (static_cast<float>(absPhi12<<1)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
1085  dphi23R = (static_cast<float>(absPhi23<<4)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
1086  if(charge12 * charge23 < 0) dphi23R = -dphi23R;
1087 
1088  ptR_front = ptMethods.Pt3Stn(type, etaR, dphi12R, dphi23R, 1);
1089  ptR_rear = ptMethods.Pt3Stn(type, etaR, dphi12R, dphi23R, 0);
1090 
1091  }
1092  else if(pt_method == 2) // cathy's method
1093  {
1094  if(type <= 2)
1095  {
1096  ptR_front = ptMethods.Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
1097  ptR_rear = ptMethods.Pt3StnChiSq(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
1098  }
1099  else
1100  {
1101  ptR_front = ptMethods.Pt2StnChiSq(type-2, etaR, absPhi12<<1, 1);
1102  ptR_rear = ptMethods.Pt2StnChiSq(type-2, etaR, absPhi12<<1, 0);
1103  }
1104 
1105  }
1106  else // hybrid
1107  {
1108 
1109  if(type <= 2)
1110  {
1111  ptR_front = ptMethods.Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 1);
1112  ptR_rear = ptMethods.Pt3StnHybrid(type+3, etaR, absPhi12<<1, ((charge == 0) ? -(absPhi23<<4) : (absPhi23<<4)), 0);
1113  }
1114  else
1115  {
1116  ptR_front = ptMethods.Pt2StnHybrid(type-2, etaR, absPhi12<<1, 1);
1117  ptR_rear = ptMethods.Pt2StnHybrid(type-2, etaR, absPhi12<<1, 0);
1118  }
1119 
1120  }
1121  break;
1122  case 6:
1123  case 7:
1124  case 8:
1125  case 9:
1126  case 10:
1127  type = mode - 5;
1128 
1129  if(charge) absPhi12 = address.delta_phi();
1130  else
1131  {
1132  int temp_phi = address.delta_phi();
1133  absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
1134  }
1135 
1136  if(absPhi12 < (1<<9))
1137  {
1138  if(pt_method == 1 || type == 5)
1139  {
1140  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
1141 
1142  ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
1143  ptR_rear = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
1144 
1145  }
1146  else if(pt_method == 2)
1147  {
1148  ptR_front = ptMethods.Pt2StnChiSq(type-1, etaR, absPhi12, 1);
1149  ptR_rear = ptMethods.Pt2StnChiSq(type-1, etaR, absPhi12, 0);
1150  }
1151  else
1152  {
1153  ptR_front = ptMethods.Pt2StnHybrid(type-1, etaR, absPhi12, 1);
1154  ptR_rear = ptMethods.Pt2StnHybrid(type-1, etaR, absPhi12, 0);
1155  }
1156  }
1157  else
1158  {
1159  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
1160  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(1);
1161  }
1162  if(pt_method == 4 || pt_method == 5) // param method 2010
1163  {
1164  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
1165 
1166  //std::cout<< " Sector_rad = " << (CSCTFConstants::SECTOR_RAD) << std::endl;
1167  ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
1168  ptR_rear = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
1169  if((pt_method == 5) && etaR > 2.1 && mode != 8 && mode !=9 && mode !=10)//exclude tracks without ME11a
1170  {
1171  float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees
1172  float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
1173  float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
1174  // select max pt solution for 3 links:
1175  ptR_front = std::max(ptR_front, ptR_front_min);
1176  ptR_rear = std::max(ptR_rear, ptR_rear_min);
1177  }
1178  }
1179 
1180  break;
1181  case 12: // 1-2-b1 calculated only delta_phi12 = 2-b1
1182  case 14:
1183  type = 2;
1184 
1185  if(charge) absPhi12 = address.delta_phi();
1186  else
1187  {
1188  int temp_phi = address.delta_phi();
1189  absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
1190  }
1191  if(absPhi12 < (1<<9))
1192  {
1193  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
1194  ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
1195  ptR_rear = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
1196  }
1197  else
1198  {
1199  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
1200  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(1);
1201  }
1202  if(pt_method == 4 || pt_method == 5) // param method 2010
1203  {
1204  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
1205 
1206  ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
1207  ptR_rear = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
1208 
1209  if(fabs(dphi12R)<0.01 && (ptR_rear < 10 || ptR_front < 10))
1210  std::cout << "dphi12R = " << dphi12R << " ptR_rear = " << ptR_rear
1211  << " ptR_front = " << ptR_front << " etaR = " << etaR << " mode = " << mode << std::endl;
1212  }
1213  break;
1214  case 13:
1215  type = 4;
1216 
1217  if(charge) absPhi12 = address.delta_phi();
1218  else
1219  {
1220  int temp_phi = address.delta_phi();
1221  absPhi12 = static_cast<unsigned>(-temp_phi) & 0xfff;
1222  }
1223  if(absPhi12 < (1<<9))
1224  {
1225  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
1226  ptR_front = ptMethods.Pt2Stn(type, etaR, dphi12R, 1);
1227  ptR_rear = ptMethods.Pt2Stn(type, etaR, dphi12R, 0);
1228  }
1229  else
1230  {
1231  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(1);
1232  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(1);
1233  }
1234 
1235  if(pt_method == 4 || pt_method == 5) // param method 2010
1236  {
1237  dphi12R = (static_cast<float>(absPhi12)) / (static_cast<float>(1<<12)) * CSCTFConstants::SECTOR_RAD;
1238 
1239  ptR_front = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 1, int(pt_method));
1240  ptR_rear = ptMethods.Pt2Stn2010(mode, etaR, dphi12R, 0, int(pt_method));
1241  if((pt_method == 5) && etaR > 2.1)//mode = 13: ME1-ME4 exclude tracks without ME11a
1242  {
1243  float dphi12Rmin = fabs(fabs(dphi12R) - Pi*10/180/3); // 10/3 degrees
1244  float ptR_front_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 1, int(pt_method));
1245  float ptR_rear_min = ptMethods.Pt2Stn2010(mode, etaR, dphi12Rmin, 0, int(pt_method));
1246  // select max pt solution for 3 links:
1247  ptR_front = std::max(ptR_front, ptR_front_min);
1248  ptR_rear = std::max(ptR_rear, ptR_rear_min);
1249  }
1250  }
1251 
1252  break;
1253  case 11:
1254  // singles trigger
1255  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
1256  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
1257  //ptR_front = trigger_ptscale->getPtScale()->getLowEdge(31);
1258  //ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(31);
1259  break;
1260  case 15:
1261  // halo trigger
1262  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
1263  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
1264  break;
1265  case 1:
1266  // tracks that fail delta phi cuts
1267  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(5);
1268  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(5);
1269  break;
1270  default: // Tracks in this category are not considered muons.
1271  ptR_front = trigger_ptscale->getPtScale()->getLowEdge(0);
1272  ptR_rear = trigger_ptscale->getPtScale()->getLowEdge(0);
1273  };
1274 
1275  front_pt = trigger_ptscale->getPtScale()->getPacked(ptR_front);
1276  rear_pt = trigger_ptscale->getPtScale()->getPacked(ptR_rear);
1277 
1278  // kluge to set arbitrary Pt for some tracks with lousy resolution (and no param)
1279  if(pt_method != 4 && pt_method != 5)
1280  {
1281  if ((front_pt==0 || front_pt==1) && (eta<3) && quality==1 && pt_method != 2) front_pt = 31;
1282  if ((rear_pt==0 || rear_pt==1) && (eta<3) && quality==1 && pt_method != 2) rear_pt = 31;
1283  }
1284  if(pt_method != 2 && pt_method != 4 && quality == 1)
1285  {
1286  if (front_pt < 5) front_pt = 5;
1287  if (rear_pt < 5) rear_pt = 5;
1288  }
1289 
1290  // in order to match the pt assignement of the previous routine
1291  if(isBeamStartConf && pt_method != 2 && pt_method != 4 && pt_method !=5) {
1292  if(quality == 3 && mode == 5) {
1293 
1294  if (front_pt < 5) front_pt = 5;
1295  if (rear_pt < 5) rear_pt = 5;
1296  }
1297 
1298  if(quality == 2 && mode > 7 && mode < 11) {
1299 
1300  if (front_pt < 5) front_pt = 5;
1301  if (rear_pt < 5) rear_pt = 5;
1302  }
1303  }
1304 
1305  } // end if for pt_method less or equal to 5
1306 //***************************************************//
1307 
1308 
1309  result.front_rank = front_pt | front_quality << 5;
1310  result.rear_rank = rear_pt | rear_quality << 5;
1311 
1312  result.charge_valid_front = 1; //ptMethods.chargeValid(front_pt, quality, eta, pt_method);
1313  result.charge_valid_rear = 1; //ptMethods.chargeValid(rear_pt, quality, eta, pt_method);
1314 
1315 
1316  /* if (mode == 1) {
1317  std::cout << "F_pt: " << front_pt << std::endl;
1318  std::cout << "R_pt: " << rear_pt << std::endl;
1319  std::cout << "F_quality: " << front_quality << std::endl;
1320  std::cout << "R_quality: " << rear_quality << std::endl;
1321  std::cout << "F_rank: " << std::hex << result.front_rank << std::endl;
1322  std::cout << "R_rank: " << std::hex << result.rear_rank << std::endl;
1323  }
1324  */
1325  return result;
1326 }
1327 
1328 
1329 unsigned CSCTFPtLUT::trackQuality(const unsigned& eta, const unsigned& mode, const unsigned& fr) const
1330 {
1331  // eta and mode should be only 4-bits, since that is the input to the large LUT
1332  if (eta>15 || mode>15)
1333  {
1334  //std::cout << "Error: Eta or Mode out of range in AU quality assignment" << std::endl;
1335  edm::LogError("CSCTFPtLUT::trackQuality()")<<"Eta or Mode out of range in AU quality assignment";
1336  return 0;
1337  }
1338  unsigned int quality;
1339  switch (mode) {
1340  case 2:
1341  quality = 3;
1342  if(pt_method > 10 && eta < 3) quality = 1; //eta < 1.2
1343  if(pt_method == 32 && eta >= 12) quality = 2; // eta > 2.1
1344  break;
1345  case 3:
1346  case 4:
1348  // quality = 2;
1349  quality = 3;
1350  if(pt_method == 32 && eta >= 12) quality = 2; // eta > 2.1
1351  break;
1352  case 5:
1353  quality = 1;
1354  if (isBeamStartConf && eta >= 12 && pt_method < 20) // eta > 2.1
1355  quality = 3;
1356  if(pt_method == 27 || pt_method == 28 || pt_method == 29 || pt_method == 32 || pt_method == 30 || pt_method == 33) quality = 3;// all mode = 5 set to quality 3 due to a lot dead ME1/1a stations
1357  break;
1358  case 6:
1359  if (eta>=3) // eta > 1.2
1360  quality = 2;
1361  else
1362  quality = 1;
1363  if(pt_method == 32 && eta >= 12) quality = 1; // eta > 2.1
1364  break;
1365  case 7:
1366  quality = 2;
1367  if(pt_method > 10 && eta < 3) quality = 1; //eta < 1.2
1368  if(pt_method == 32 && eta >= 12) quality = 1; // eta > 2.1
1369  break;
1370  case 8:
1371  case 9:
1372  case 10:
1373  quality = 1;
1374  if (isBeamStartConf && eta >= 12 && pt_method < 20) // eta > 2.1
1375  quality = 2;
1376  if((pt_method == 27 || pt_method == 28 || pt_method == 30) && (eta >= 7 && eta < 9)) quality = 2; //set to quality 2 for eta = 1.6-1.8 due to a lot dead ME1/1a stations
1377  break;
1378  case 11:
1379  // single LCTs
1380  quality = 1;
1381  // overlap region
1382  if(pt_method > 10 && fr == 0) quality = 2;
1383  if(pt_method > 10 && fr == 1) quality = 3;
1384  if(pt_method > 20 && fr == 0) quality = 3;
1385  break;
1386  case 12:
1387  quality = 3;
1388  // overlap region
1389  if(pt_method > 10 && fr == 0) quality = 2;
1390  if(pt_method > 10 && fr == 1) quality = 3;
1391  if(pt_method > 20 && fr == 0) quality = 3;
1392  break;
1393  case 13:
1394  quality = 2;
1395  if(pt_method == 32 && eta >= 12) quality = 1; // eta > 2.1
1396  break;
1397  case 14:
1398  quality = 2;
1399  // overlap region
1400  if(pt_method > 10 && fr == 0) quality = 2;
1401  if(pt_method > 10 && fr == 1) quality = 3;
1402  if(pt_method > 20 && fr == 0) quality = 3;
1403  break;
1404  case 15:
1405  // halo triggers
1406  quality = 1;
1407  break;
1408  //DEA: keep muons that fail delta phi cut
1409  case 1:
1410  quality = 1;
1411  break;
1412  default:
1413  quality = 0;
1414  break;
1415  }
1416 
1417  // allow quality = 1 only in overlap region or eta = 1.6 region
1418  // if ((quality == 1) && (eta >= 4) && (eta != 6) && (eta != 7)) quality = 0;
1419  // if ( (quality == 1) && (eta >= 4) ) quality = 0;
1420 
1421  if ( (quality == 1) && (eta >= 4) && (eta < 11)
1422  && ((lowQualityFlag&4)==0) ) quality = 0;
1423  if ( (quality == 1) && (eta < 4) && ((lowQualityFlag&1)==0)
1424  && ((lowQualityFlag&4)==0) ) quality = 0;
1425  if ( (quality == 1) && (eta >=11) && ((lowQualityFlag&2)==0)
1426  && ((lowQualityFlag&4)==0) ) quality = 0;
1427 
1428  return quality;
1429 
1430 }
1431 
1433 {
1434  std::ifstream PtLUT;
1435 
1436  if(isBinary)
1437  {
1438  PtLUT.open(pt_lut_file.fullPath().c_str(), std::ios::binary);
1439  PtLUT.seekg(0, std::ios::end);
1440  int length = PtLUT.tellg();;
1441  if( length == (1<<CSCBitWidths::kPtAddressWidth)*sizeof(short) )
1442  {
1443  PtLUT.seekg(0, std::ios::beg);
1444  PtLUT.read(reinterpret_cast<char*>(pt_lut),length);
1445  }
1446  else
1447  {
1448  edm::LogError("CSCPtLUT") << "File " << pt_lut_file.fullPath() << " is incorrect size!\n";
1449  }
1450  PtLUT.close();
1451  }
1452  else
1453  {
1454  PtLUT.open(pt_lut_file.fullPath().c_str());
1455  unsigned i = 0;
1456  unsigned short temp = 0;
1457  while(!PtLUT.eof() && i < 1 << CSCBitWidths::kPtAddressWidth)
1458  {
1459  PtLUT >> temp;
1460  pt_lut[i++] = (*reinterpret_cast<ptdat*>(&temp));
1461  }
1462  PtLUT.close();
1463  }
1464 }
1465 
1466 
float Pt3Stn2012_DT(int type, float eta, float dphi1, float dphi2, int PtbyMLH, float &theLH, int fr=-1, int method=11) const
CSCTFPtMethods ptMethods
Definition: CSCTFPtLUT.h:66
const double Pi
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
const L1MuTriggerScales * trigger_scale
Definition: CSCTFPtLUT.h:62
ptdat Pt(const ptadd &) const
Definition: CSCTFPtLUT.cc:171
char * address
Definition: mlp_lapack.h:14
float Pt3StnHybrid(int type, float eta, int dphi1, int dphi2, int fr) const
unsigned lowQualityFlag
Definition: CSCTFPtLUT.h:75
const L1MuScale * getPtScale() const
get the Pt scale
CSCTFPtLUT(const edm::EventSetup &c)
KK.
Definition: CSCTFPtLUT.cc:72
bool isBeamStartConf
Definition: CSCTFPtLUT.h:73
virtual float getLowEdge(unsigned packed) const =0
get the low edge of bin represented by packed
const L1MuCSCPtLut * theL1MuCSCPtLut_
Definition: CSCTFPtLUT.h:61
float Pt2Stn2010(int type, float eta, float dphi, int fr=-1, int method=11) const
bool read_pt_lut_es
Definition: CSCTFPtLUT.h:73
static const int getPtbyMLH
Definition: CSCTFPtLUT.h:56
float Pt2StnChiSq(int type, float eta, int dphi, int fr) const
float Pt2Stn2011(int type, float eta, float dphi, int fr=-1, int method=11, int phiSign=2) const
ptdat * pt_lut
Definition: CSCTFPtLUT.h:71
float Pt3Stn2011(int type, float eta, float dphi1, float dphi2, int fr=-1, int method=11) const
unsigned pt_method
Definition: CSCTFPtLUT.h:75
T eta() const
float Pt3StnChiSq(int type, float eta, int dphi1, int dphi2, int fr) const
double charge(const std::vector< uint8_t > &Ampls)
static const int dEtaCut_High_C[24]
Definition: CSCTFPtLUT.h:53
float Pt3Stn(int type, float eta, float dphi1, float dphi2, int fr=-1) const
static const int dPhiNLBMap_8bit[256]
Definition: CSCTFPtLUT.h:46
static const int dEtaCut_Mid[24]
Definition: CSCTFPtLUT.h:50
static const int dEtaCut_Low[24]
Definition: CSCTFPtLUT.h:49
const T & max(const T &a, const T &b)
float Pt2StnHybrid(int type, float eta, int dphi, int fr) const
tuple result
Definition: query.py:137
bool read_pt_lut_file
Definition: CSCTFPtLUT.h:73
#define end
Definition: vmac.h:38
void readLUT()
Definition: CSCTFPtLUT.cc:1432
float Pt3Stn2010(int type, float eta, float dphi1, float dphi2, int fr=-1, int method=11) const
float Pt3Stn2012(int type, float eta, float dphi1, float dphi2, int PtbyMLH, float &theLH, int fr=-1, int method=11) const
edm::FileInPath pt_lut_file
Definition: CSCTFPtLUT.h:74
static const int dEtaCut_High_A[24]
Definition: CSCTFPtLUT.h:51
unsigned trackQuality(const unsigned &eta, const unsigned &mode, const unsigned &fr) const
Definition: CSCTFPtLUT.cc:1329
unsigned short pt(unsigned long addr) const
Definition: L1MuCSCPtLut.h:18
class pt_address ptadd
class pt_data ptdat
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
ptdat calcPt(const ptadd &) const
Definition: CSCTFPtLUT.cc:232
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
const L1MuScale * getRegionalEtaScale(int isys) const
get the regioanl muon trigger eta scale, isys = 0(DT), 1(bRPC), 2(CSC), 3(fwdRPC) ...
static const int dEtaCut_Open[24]
Definition: CSCTFPtLUT.h:54
float Pt2Stn2012(int type, float eta, float dphi, int PtbyMLH, float &theLH, int fr=-1, int method=11) const
virtual unsigned getPacked(float value) const =0
pack a value
static const int dPhiNLBMap_7bit[128]
Definition: CSCTFPtLUT.h:45
static const double SECTOR_RAD
tuple cout
Definition: gather_cfg.py:121
bool isBinary
Definition: CSCTFPtLUT.h:73
std::string fullPath() const
Definition: FileInPath.cc:171
float Pt2Stn(int type, float eta, float dphi, int fr=-1) const
const L1MuTriggerPtScale * trigger_ptscale
Definition: CSCTFPtLUT.h:63
static const int dEtaCut_High_B[24]
Definition: CSCTFPtLUT.h:52
static const int dPhiNLBMap_5bit[32]
Definition: CSCTFPtLUT.h:44