CMS 3D CMS Logo

PtAssignmentEngineAux2016.cc
Go to the documentation of this file.
2 
3 //ModeVariables is a 2D arrary indexed by [TrackMode(13 Total Listed Below)][VariableNumber(20 Total Constructed Above)]
4 // Variable numbering
5 // 0 = dPhi12
6 // 1 = dPhi13
7 // 2 = dPhi14
8 // 3 = dPhi23
9 // 4 = dPhi24
10 // 5 = dPhi34
11 // 6 = dEta12
12 // 7 = dEta13
13 // 8 = dEta14
14 // 9 = dEta23
15 // 10 = dEta24
16 // 11 = dEta34
17 // 12 = CLCT1
18 // 13 = CLCT2
19 // 14 = CLCT3
20 // 15 = CLCT4
21 // 16 = CSCID1
22 // 17 = CSCID2
23 // 18 = CSCID3
24 // 19 = CSCID4
25 // 20 = FR1
26 // 21 = FR2
27 // 22 = FR3
28 // 23 = FR4
29 
30 // Bobby's Scheme3 (or "SchemeC"), with 30 bit compression //
31 //3:TrackEta:dPhi12:dEta12:CLCT1:CLCT2:FR1
32 //4:Single Station Track Not Possible
33 //5:TrackEta:dPhi13:dEta13:CLCT1:CLCT3:FR1
34 //6:TrackEta:dPhi23:dEta23:CLCT2:CLCT3:FR2
35 //7:TrackEta:dPhi12:dPhi23:dEta13:CLCT1:FR1
36 //8:Single Station Track Not Possible
37 //9:TrackEta:dPhi14:dEta14:CLCT1:CLCT4:FR1
38 //10:TrackEta:dPhi24:dEta24:CLCT2:CLCT4:FR2
39 //11:TrackEta:dPhi12:dPhi24:dEta14:CLCT1:FR1
40 //12:TrackEta:dPhi34:dEta34:CLCT3:CLCT4:FR3
41 //13:TrackEta:dPhi13:dPhi34:dEta14:CLCT1:FR1
42 //14:TrackEta:dPhi23:dPhi34:dEta24:CLCT2
43 //15:TrackEta:dPhi12:dPhi23:dPhi34:FR1
44 
45 static const int ModeVariables_Scheme3[13][6] =
46 {
47  {0,6,12,13,20,-999}, // 3
48  {-999,-999,-999,-999,-999,-999}, // 4
49  {1,7,12,14,20,-999}, // 5
50  {3,9,13,14,21,-999}, // 6
51  {0,3,7,12,20,-999}, // 7
52  {-999,-999,-999,-999,-999,-999}, // 8
53  {2,8,12,15,20,-999}, // 9
54  {4,10,13,15,21,-999}, // 10
55  {0,4,8,12,20,-999}, // 11
56  {5,11,14,15,22,-999}, // 12
57  {1,5,8,16,20,-999}, // 13
58  {3,5,10,13,-999,-999}, // 14
59  {0,3,5,20,-999,-999} // 15
60 };
61 
62 // 256 max units----
63 
64 static const int dPhiNLBMap_5bit_256Max[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20, 21, 23, 25, 28, 31, 34, 39, 46, 55, 68, 91, 136};
65 
66 static const int dPhiNLBMap_6bit_256Max[64] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 36, 37, 38, 39, 40, 42, 43, 45, 47, 49, 51, 53, 56, 58, 61, 65, 68, 73, 78, 83, 89, 97, 106, 116, 129, 145, 166, 193, 232};
67 
68 static const int dPhiNLBMap_7bit_256Max[128] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, 90, 91, 93, 94, 96, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 118, 120, 123, 125, 128, 131, 134, 138, 141, 145, 149, 153, 157, 161, 166, 171, 176, 182, 188, 194, 201, 209, 217, 225, 235, 245};
69 
70 // 512 max units----
71 
72 static const int dPhiNLBMap_7bit_512Max[128] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 83, 84, 86, 87, 89, 91, 92, 94, 96, 98, 100, 102, 105, 107, 110, 112, 115, 118, 121, 124, 127, 131, 135, 138, 143, 147, 152, 157, 162, 168, 174, 181, 188, 196, 204, 214, 224, 235, 247, 261, 276, 294, 313, 336, 361, 391, 427, 470};
73 
74 static const int dPhiNLBMap_8bit_512Max[256] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 164, 165, 166, 167, 168, 170, 171, 172, 174, 175, 176, 178, 179, 180, 182, 183, 185, 186, 188, 190, 191, 193, 194, 196, 198, 200, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219, 221, 223, 225, 228, 230, 232, 235, 237, 240, 242, 245, 248, 250, 253, 256, 259, 262, 265, 268, 272, 275, 278, 282, 285, 289, 293, 297, 300, 305, 309, 313, 317, 322, 327, 331, 336, 341, 347, 352, 358, 363, 369, 375, 382, 388, 395, 402, 410, 417, 425, 433, 442, 450, 460, 469, 479, 490, 500};
75 
76 static const int dPhiNLBMap_5bit[32] = {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};
77 
78 // Array that maps the 7-bit integer dPhi --> dPhi-units. It is assumed that this is used for dPhi12,
79 // which has a maximum value of 7.67 degrees (511 units) in the extrapolation units.
80 static const int dPhiNLBMap_7bit[128] = {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};
81 
82 // Array that maps the 8-bit integer dPhi --> dPhi-units. It is assumed that this is used for dPhi12,
83 // which has a maximum value of 7.67 degrees (511 units) in the extrapolation units.
84 static const int dPhiNLBMap_8bit[256] = {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};
85 
86 
88  return ModeVariables_Scheme3;
89 }
90 
92  int dPhi_= max;
93  int sign_ = 1;
94  if (dPhi<0)
95  sign_ = -1;
96  dPhi = sign_ * dPhi;
97 
98  if (max==256)
99  {
100  if (bits == 5)
101  {
102  dPhi_ = dPhiNLBMap_5bit_256Max[(1<<bits)-1];
103  for (int edge=0; edge<(1<<bits)-1; edge++)
104  {
105  if (dPhiNLBMap_5bit_256Max[edge]<=dPhi && dPhiNLBMap_5bit_256Max[edge+1]>dPhi)
106  {
107  dPhi_ = dPhiNLBMap_5bit_256Max[edge];
108  break;
109  }
110  }
111  }
112  if (bits == 6)
113  {
114  dPhi_ = dPhiNLBMap_6bit_256Max[(1<<bits)-1];
115  for (int edge=0; edge<(1<<bits)-1; edge++)
116  {
117  if (dPhiNLBMap_6bit_256Max[edge]<=dPhi && dPhiNLBMap_6bit_256Max[edge+1]>dPhi)
118  {
119  dPhi_ = dPhiNLBMap_6bit_256Max[edge];
120  break;
121  }
122  }
123  }
124  if (bits == 7)
125  {
126  dPhi_ = dPhiNLBMap_7bit_256Max[(1<<bits)-1];
127  for (int edge=0; edge<(1<<bits)-1; edge++)
128  {
129  if (dPhiNLBMap_7bit_256Max[edge]<=dPhi && dPhiNLBMap_7bit_256Max[edge+1]>dPhi)
130  {
131  dPhi_ = dPhiNLBMap_7bit_256Max[edge];
132  break;
133  }
134  }
135  }
136  }
137 
138  else if (max==512)
139  {
140  if (bits == 7)
141  {
142  dPhi_ = dPhiNLBMap_7bit_512Max[(1<<bits)-1];
143  for (int edge=0; edge<(1<<bits)-1; edge++)
144  {
145  if (dPhiNLBMap_7bit_512Max[edge]<=dPhi && dPhiNLBMap_7bit_512Max[edge+1]>dPhi)
146  {
147  dPhi_ = dPhiNLBMap_7bit_512Max[edge];
148  break;
149  }
150  }
151  }
152  if (bits == 8)
153  {
154  dPhi_ = dPhiNLBMap_8bit_512Max[(1<<bits)-1];
155  for (int edge=0; edge<(1<<bits)-1; edge++)
156  {
157  if (dPhiNLBMap_8bit_512Max[edge]<=dPhi && dPhiNLBMap_8bit_512Max[edge+1]>dPhi)
158  {
159  dPhi_ = dPhiNLBMap_8bit_512Max[edge];
160  break;
161  }
162  }
163  }
164  }
165 
166  if (dPhi>=max) dPhi_ = max;
167  return (sign_ * dPhi_);
168 }
169 
171  int dPhiBin_= (1<<bits)-1;
172  int sign_ = 1;
173  if (dPhi<0)
174  sign_ = -1;
175  dPhi = sign_ * dPhi;
176 
177  if (max==256)
178  {
179  if (bits == 5)
180  {
181  for (int edge=0; edge<(1<<bits)-1; edge++)
182  {
183  if (dPhiNLBMap_5bit_256Max[edge]<=dPhi && dPhiNLBMap_5bit_256Max[edge+1]>dPhi)
184  {
185  dPhiBin_ = edge;
186  break;
187  }
188  }
189  }
190  if (bits == 6)
191  {
192  for (int edge=0; edge<(1<<bits)-1; edge++)
193  {
194  if (dPhiNLBMap_6bit_256Max[edge]<=dPhi && dPhiNLBMap_6bit_256Max[edge+1]>dPhi)
195  {
196  dPhiBin_ = edge;
197  break;
198  }
199  }
200  }
201  if (bits == 7)
202  {
203  for (int edge=0; edge<(1<<bits)-1; edge++)
204  {
205  if (dPhiNLBMap_7bit_256Max[edge]<=dPhi && dPhiNLBMap_7bit_256Max[edge+1]>dPhi)
206  {
207  dPhiBin_ = edge;
208  break;
209  }
210  }
211  }
212  }
213 
214  else if (max==512)
215  {
216  if (bits == 7)
217  {
218  for (int edge=0; edge<(1<<bits)-1; edge++)
219  {
220  if (dPhiNLBMap_7bit_512Max[edge]<=dPhi && dPhiNLBMap_7bit_512Max[edge+1]>dPhi)
221  {
222  dPhiBin_ = edge;
223  break;
224  }
225  }
226  }
227  if (bits == 8)
228  {
229  for (int edge=0; edge<(1<<bits)-1; edge++)
230  {
231  if (dPhiNLBMap_8bit_512Max[edge]<=dPhi && dPhiNLBMap_8bit_512Max[edge+1]>dPhi)
232  {
233  dPhiBin_ = edge;
234  break;
235  }
236  }
237  }
238  }
239 
240  return (dPhiBin_);
241 }
242 
244  int dPhi_= (1<<bits)-1;
245 
246  if (dPhiBin>(1<<bits)-1)
247  dPhiBin = (1<<bits)-1;
248 
249  if (max==256)
250  {
251  if (bits == 5)
253  if (bits == 6)
255  if (bits == 7)
257  }
258 
259  else if (max==512)
260  {
261  if (bits == 7)
263  if (bits == 8)
265  }
266 
267  return (dPhi_);
268 }
269 
271  int clct_ = 0;
272  int sign_ = 1;
273 
274  switch (clct) {
275  case 10: clct_ = 0; sign_ = -1; break;
276  case 9: clct_ = 1; sign_ = 1; break;
277  case 8: clct_ = 1; sign_ = -1; break;
278  case 7: clct_ = 2; sign_ = 1; break;
279  case 6: clct_ = 2; sign_ = -1; break;
280  case 5: clct_ = 3; sign_ = 1; break;
281  case 4: clct_ = 3; sign_ = -1; break;
282  case 3: clct_ = 3; sign_ = 1; break;
283  case 2: clct_ = 3; sign_ = -1; break;
284  case 1: clct_ = 3; sign_ = -1; break; //case 1: clct_ = 3; sign_ = 1; break;
285  case 0: clct_ = 3; sign_ = -1; break;
286  default: clct_ = 3; sign_ = -1; break;
287  }
288  return (sign_ * clct_);
289 }
290 
292  int dTheta_ = 0;
293 
294  if (dTheta<=-3)
295  dTheta_ = 0;
296  else if (dTheta<=-2)
297  dTheta_ = 1;
298  else if (dTheta<=-1)
299  dTheta_ = 2;
300  else if (dTheta<=0)
301  dTheta_ = 3;
302  else if (dTheta<=1)
303  dTheta_ = 4;
304  else if (dTheta<=2)
305  dTheta_ = 5;
306  else if (dTheta<=3)
307  dTheta_ = 6;
308  else
309  dTheta_ = 7;
310  return (dTheta_);
311 }
312 
314  int dEta_ = 0;
315 
316  if (dEta<=-5)
317  dEta_ = 0;
318  else if (dEta<=-2)
319  dEta_ = 1;
320  else if (dEta<=-1)
321  dEta_ = 2;
322  else if (dEta<=0)
323  dEta_ = 3;
324  else if (dEta<=1)
325  dEta_ = 4;
326  else if (dEta<=3)
327  dEta_ = 5;
328  else if (dEta<=6)
329  dEta_ = 6;
330  else
331  dEta_ = 7;
332  return (dEta_);
333 }
334 
336  eta = std::abs(eta);
337  eta = (eta < 0.9) ? 0.9 : eta;
338  bits = (bits > 5) ? 5 : bits;
339  // encode 0.9<abs(eta)<1.6 in 5-bit (32 possible values)
340  int etaInt = ((eta - 0.9)*32)/(1.6) - 0.5;
341  int shift = 5 - bits;
342  etaInt >>= shift;
343  etaInt = (etaInt > 31) ? 31 : etaInt;
344  return etaInt;
345 }
346 
347 float PtAssignmentEngineAux2016::getEtaFromThetaInt(int thetaInt, int bits) const {
348  thetaInt = (thetaInt > 127) ? 127 : thetaInt; // 7-bit
349  thetaInt = (thetaInt < 0) ? 0 : thetaInt;
350  float theta = thetaInt;
351  theta = (theta*0.2874016 + 8.5)*(3.14159265359/180); // use this version to reproduce what happened when the pT LUT was made
352  //theta = (theta*(45.0-8.5)/128. + 8.5) * M_PI/180.;
353  float eta = -std::log(std::tan(theta/2));
354  return eta;
355 }
356 
357 float PtAssignmentEngineAux2016::getEtaFromEtaInt(int etaInt, int bits) const {
358  etaInt = (etaInt > 31) ? 31 : etaInt; // 5-bit
359  etaInt = (etaInt < 0) ? 0 : etaInt;
360  bits = (bits > 5) ? 5 : bits;
361  int shift = 5 - bits;
362  etaInt <<= shift;
363  // decode 5-bit etaInt to 0.9<abs(eta)<1.6
364  float eta = ((0.5 + etaInt)*1.6)/32 + 0.9;
365  return eta;
366 }
367 
369  // For backward compatibility
370  return getEtaFromEtaInt(etaBin, bits);
371 }
372 
373 // front-rear LUTs
374 // [sector[0]][station 0-4][chamber id]
375 // chamber numbers start from 1, so add an extra low bit for invalid chamber = 0
376 static const int FRLUT[2][5] = {
377  {0b0000000100100, 0b0000001011010, 0b0101010101010, 0b0010101010100, 0b0010101010100},
378  {0b0000000100100, 0b0000001011010, 0b0111010100100, 0b0000101011010, 0b0000101011010}
379 };
380 
381 int PtAssignmentEngineAux2016::getFRLUT(int sector, int station, int chamber) const {
382  int bits = FRLUT[(sector-1)%2][station];
383  bool isFront = bits & (1<<chamber);
384  return isFront;
385 }
static const int dPhiNLBMap_7bit_512Max[128]
static const int ModeVariables_Scheme3[13][6]
int getdPhiFromBin(int dPhiBin, int bits, int max=512) const
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision bits
static const int dPhiNLBMap_5bit_256Max[32]
Geom::Theta< T > theta() const
int getNLBdPhiBin(int dPhi, int bits, int max=512) const
int getEtaInt(float eta, int bits=5) const
float getEtaFromEtaInt(int etaInt, int bits=5) const
static const int dPhiNLBMap_7bit_256Max[128]
static const int dPhiNLBMap_7bit[128]
static const int dPhiNLBMap_5bit[32]
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static const int dPhiNLBMap_6bit_256Max[64]
int getNLBdPhi(int dPhi, int bits, int max=512) const
float getEtaFromBin(int etaBin, int bits=5) const
static const int FRLUT[2][5]
const int(* getModeVariables() const)[6]
float getEtaFromThetaInt(int thetaInt, int bits=5) const
static const int dPhiNLBMap_8bit[256]
static unsigned int const shift
static const int dPhiNLBMap_8bit_512Max[256]
int getFRLUT(int sector, int station, int chamber) const