CMS 3D CMS Logo

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