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