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