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  {0, 6, 12, 13, 20, -999}, // 3
47  {-999, -999, -999, -999, -999, -999}, // 4
48  {1, 7, 12, 14, 20, -999}, // 5
49  {3, 9, 13, 14, 21, -999}, // 6
50  {0, 3, 7, 12, 20, -999}, // 7
51  {-999, -999, -999, -999, -999, -999}, // 8
52  {2, 8, 12, 15, 20, -999}, // 9
53  {4, 10, 13, 15, 21, -999}, // 10
54  {0, 4, 8, 12, 20, -999}, // 11
55  {5, 11, 14, 15, 22, -999}, // 12
56  {1, 5, 8, 16, 20, -999}, // 13
57  {3, 5, 10, 13, -999, -999}, // 14
58  {0, 3, 5, 20, -999, -999} // 15
59 };
60 
61 // 256 max units----
62 
63 static const int dPhiNLBMap_5bit_256Max[32] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
64  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,
67  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
68  32, 33, 34, 36, 37, 38, 39, 40, 42, 43, 45, 47, 49, 51, 53, 56,
69  58, 61, 65, 68, 73, 78, 83, 89, 97, 106, 116, 129, 145, 166, 193, 232};
70 
71 static const int dPhiNLBMap_7bit_256Max[128] = {
72  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
73  22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
74  44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
75  66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 77, 78, 79, 80, 81, 82, 83, 84, 86, 87, 88, 90,
76  91, 93, 94, 96, 97, 99, 101, 103, 105, 107, 109, 111, 113, 115, 118, 120, 123, 125, 128, 131, 134, 138,
77  141, 145, 149, 153, 157, 161, 166, 171, 176, 182, 188, 194, 201, 209, 217, 225, 235, 245};
78 
79 // 512 max units----
80 
81 static const int dPhiNLBMap_7bit_512Max[128] = {
82  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
83  22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
84  44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
85  66, 67, 68, 69, 71, 72, 73, 74, 75, 76, 77, 79, 80, 81, 83, 84, 86, 87, 89, 91, 92, 94,
86  96, 98, 100, 102, 105, 107, 110, 112, 115, 118, 121, 124, 127, 131, 135, 138, 143, 147, 152, 157, 162, 168,
87  174, 181, 188, 196, 204, 214, 224, 235, 247, 261, 276, 294, 313, 336, 361, 391, 427, 470};
88 
89 static const int dPhiNLBMap_8bit_512Max[256] = {
90  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
91  22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
92  44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65,
93  66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87,
94  88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109,
95  110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131,
96  132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 152, 153, 154,
97  155, 156, 157, 158, 159, 160, 161, 162, 164, 165, 166, 167, 168, 170, 171, 172, 174, 175, 176, 178, 179, 180,
98  182, 183, 185, 186, 188, 190, 191, 193, 194, 196, 198, 200, 201, 203, 205, 207, 209, 211, 213, 215, 217, 219,
99  221, 223, 225, 228, 230, 232, 235, 237, 240, 242, 245, 248, 250, 253, 256, 259, 262, 265, 268, 272, 275, 278,
100  282, 285, 289, 293, 297, 300, 305, 309, 313, 317, 322, 327, 331, 336, 341, 347, 352, 358, 363, 369, 375, 382,
101  388, 395, 402, 410, 417, 425, 433, 442, 450, 460, 469, 479, 490, 500};
102 
104 
105 int PtAssignmentEngineAux2016::getNLBdPhi(int dPhi, int bits, int max) const {
106  int dPhi_ = max;
107  int sign_ = 1;
108  if (dPhi < 0)
109  sign_ = -1;
110  dPhi = sign_ * dPhi;
111 
112  if (max == 256) {
113  if (bits == 5) {
114  dPhi_ = dPhiNLBMap_5bit_256Max[(1 << bits) - 1];
115  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
116  if (dPhiNLBMap_5bit_256Max[edge] <= dPhi && dPhiNLBMap_5bit_256Max[edge + 1] > dPhi) {
117  dPhi_ = dPhiNLBMap_5bit_256Max[edge];
118  break;
119  }
120  }
121  }
122  if (bits == 6) {
123  dPhi_ = dPhiNLBMap_6bit_256Max[(1 << bits) - 1];
124  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
125  if (dPhiNLBMap_6bit_256Max[edge] <= dPhi && dPhiNLBMap_6bit_256Max[edge + 1] > dPhi) {
126  dPhi_ = dPhiNLBMap_6bit_256Max[edge];
127  break;
128  }
129  }
130  }
131  if (bits == 7) {
132  dPhi_ = dPhiNLBMap_7bit_256Max[(1 << bits) - 1];
133  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
134  if (dPhiNLBMap_7bit_256Max[edge] <= dPhi && dPhiNLBMap_7bit_256Max[edge + 1] > dPhi) {
135  dPhi_ = dPhiNLBMap_7bit_256Max[edge];
136  break;
137  }
138  }
139  }
140  }
141 
142  else if (max == 512) {
143  if (bits == 7) {
144  dPhi_ = dPhiNLBMap_7bit_512Max[(1 << bits) - 1];
145  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
146  if (dPhiNLBMap_7bit_512Max[edge] <= dPhi && dPhiNLBMap_7bit_512Max[edge + 1] > dPhi) {
147  dPhi_ = dPhiNLBMap_7bit_512Max[edge];
148  break;
149  }
150  }
151  }
152  if (bits == 8) {
153  dPhi_ = dPhiNLBMap_8bit_512Max[(1 << bits) - 1];
154  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
155  if (dPhiNLBMap_8bit_512Max[edge] <= dPhi && dPhiNLBMap_8bit_512Max[edge + 1] > dPhi) {
156  dPhi_ = dPhiNLBMap_8bit_512Max[edge];
157  break;
158  }
159  }
160  }
161  }
162 
163  if (dPhi >= max)
164  dPhi_ = max;
165  return (sign_ * dPhi_);
166 }
167 
168 int PtAssignmentEngineAux2016::getNLBdPhiBin(int dPhi, int bits, int max) const {
169  int dPhiBin_ = (1 << bits) - 1;
170  int sign_ = 1;
171  if (dPhi < 0)
172  sign_ = -1;
173  dPhi = sign_ * dPhi;
174 
175  if (max == 256) {
176  if (bits == 5) {
177  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
178  if (dPhiNLBMap_5bit_256Max[edge] <= dPhi && dPhiNLBMap_5bit_256Max[edge + 1] > dPhi) {
179  dPhiBin_ = edge;
180  break;
181  }
182  }
183  }
184  if (bits == 6) {
185  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
186  if (dPhiNLBMap_6bit_256Max[edge] <= dPhi && dPhiNLBMap_6bit_256Max[edge + 1] > dPhi) {
187  dPhiBin_ = edge;
188  break;
189  }
190  }
191  }
192  if (bits == 7) {
193  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
194  if (dPhiNLBMap_7bit_256Max[edge] <= dPhi && dPhiNLBMap_7bit_256Max[edge + 1] > dPhi) {
195  dPhiBin_ = edge;
196  break;
197  }
198  }
199  }
200  }
201 
202  else if (max == 512) {
203  if (bits == 7) {
204  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
205  if (dPhiNLBMap_7bit_512Max[edge] <= dPhi && dPhiNLBMap_7bit_512Max[edge + 1] > dPhi) {
206  dPhiBin_ = edge;
207  break;
208  }
209  }
210  }
211  if (bits == 8) {
212  for (int edge = 0; edge < (1 << bits) - 1; edge++) {
213  if (dPhiNLBMap_8bit_512Max[edge] <= dPhi && dPhiNLBMap_8bit_512Max[edge + 1] > dPhi) {
214  dPhiBin_ = edge;
215  break;
216  }
217  }
218  }
219  }
220 
221  return (dPhiBin_);
222 }
223 
225  int dPhi_ = (1 << bits) - 1;
226 
227  if (dPhiBin > (1 << bits) - 1)
228  dPhiBin = (1 << bits) - 1;
229 
230  if (max == 256) {
231  if (bits == 5)
233  if (bits == 6)
235  if (bits == 7)
237  }
238 
239  else if (max == 512) {
240  if (bits == 7)
242  if (bits == 8)
244  }
245 
246  return (dPhi_);
247 }
248 
250  int clct_ = 0;
251  int sign_ = 1;
252 
253  switch (clct) {
254  case 10:
255  clct_ = 0;
256  sign_ = -1;
257  break;
258  case 9:
259  clct_ = 1;
260  sign_ = 1;
261  break;
262  case 8:
263  clct_ = 1;
264  sign_ = -1;
265  break;
266  case 7:
267  clct_ = 2;
268  sign_ = 1;
269  break;
270  case 6:
271  clct_ = 2;
272  sign_ = -1;
273  break;
274  case 5:
275  clct_ = 3;
276  sign_ = 1;
277  break;
278  case 4:
279  clct_ = 3;
280  sign_ = -1;
281  break;
282  case 3:
283  clct_ = 3;
284  sign_ = 1;
285  break;
286  case 2:
287  clct_ = 3;
288  sign_ = -1;
289  break;
290  case 1:
291  clct_ = 3;
292  sign_ = -1;
293  break; //case 1: clct_ = 3; sign_ = 1; break;
294  case 0:
295  clct_ = 3;
296  sign_ = -1;
297  break;
298  default:
299  clct_ = 3;
300  sign_ = -1;
301  break;
302  }
303  return (sign_ * clct_);
304 }
305 
307  int dTheta_ = 0;
308 
309  if (dTheta <= -3)
310  dTheta_ = 0;
311  else if (dTheta <= -2)
312  dTheta_ = 1;
313  else if (dTheta <= -1)
314  dTheta_ = 2;
315  else if (dTheta <= 0)
316  dTheta_ = 3;
317  else if (dTheta <= 1)
318  dTheta_ = 4;
319  else if (dTheta <= 2)
320  dTheta_ = 5;
321  else if (dTheta <= 3)
322  dTheta_ = 6;
323  else
324  dTheta_ = 7;
325  return (dTheta_);
326 }
327 
329  int dEta_ = 0;
330 
331  if (dEta <= -5)
332  dEta_ = 0;
333  else if (dEta <= -2)
334  dEta_ = 1;
335  else if (dEta <= -1)
336  dEta_ = 2;
337  else if (dEta <= 0)
338  dEta_ = 3;
339  else if (dEta <= 1)
340  dEta_ = 4;
341  else if (dEta <= 3)
342  dEta_ = 5;
343  else if (dEta <= 6)
344  dEta_ = 6;
345  else
346  dEta_ = 7;
347  return (dEta_);
348 }
349 
350 int PtAssignmentEngineAux2016::getEtaInt(float eta, int bits) const {
351  eta = std::abs(eta);
352  eta = (eta < 0.9) ? 0.9 : eta;
353  bits = (bits > 5) ? 5 : bits;
354  // encode 0.9<abs(eta)<1.6 in 5-bit (32 possible values)
355  int etaInt = ((eta - 0.9) * 32) / (1.6) - 0.5;
356  int shift = 5 - bits;
357  etaInt >>= shift;
358  etaInt = (etaInt > 31) ? 31 : etaInt;
359  return etaInt;
360 }
361 
362 float PtAssignmentEngineAux2016::getEtaFromThetaInt(int thetaInt, int bits) const {
363  thetaInt = (thetaInt > 127) ? 127 : thetaInt; // 7-bit
364  thetaInt = (thetaInt < 0) ? 0 : thetaInt;
365  float theta = thetaInt;
366  theta = (theta * 0.2874016 + 8.5) *
367  (3.14159265359 / 180); // use this version to reproduce what happened when the pT LUT was made
368  //theta = (theta*(45.0-8.5)/128. + 8.5) * M_PI/180.;
369  float eta = -std::log(std::tan(theta / 2));
370  return eta;
371 }
372 
373 float PtAssignmentEngineAux2016::getEtaFromEtaInt(int etaInt, int bits) const {
374  etaInt = (etaInt > 31) ? 31 : etaInt; // 5-bit
375  etaInt = (etaInt < 0) ? 0 : etaInt;
376  bits = (bits > 5) ? 5 : bits;
377  int shift = 5 - bits;
378  etaInt <<= shift;
379  // decode 5-bit etaInt to 0.9<abs(eta)<1.6
380  float eta = ((0.5 + etaInt) * 1.6) / 32 + 0.9;
381  return eta;
382 }
383 
385  // For backward compatibility
386  return getEtaFromEtaInt(etaBin, bits);
387 }
388 
389 // front-rear LUTs
390 // [sector[0]][station 0-4][chamber id]
391 // chamber numbers start from 1, so add an extra low bit for invalid chamber = 0
392 static const int FRLUT[2][5] = {{0b0000000100100, 0b0000001011010, 0b0101010101010, 0b0010101010100, 0b0010101010100},
393  {0b0000000100100, 0b0000001011010, 0b0111010100100, 0b0000101011010, 0b0000101011010}};
394 
395 int PtAssignmentEngineAux2016::getFRLUT(int sector, int station, int chamber) const {
396  int bits = FRLUT[(sector - 1) % 2][station];
397  bool isFront = bits & (1 << chamber);
398  return isFront;
399 }
PtAssignmentEngineAux2016.h
PtAssignmentEngineAux2016::getFRLUT
int getFRLUT(int sector, int station, int chamber) const
Definition: PtAssignmentEngineAux2016.cc:395
PtAssignmentEngineAux2016::getdPhiFromBin
int getdPhiFromBin(int dPhiBin, int bits, int max=512) const
Definition: PtAssignmentEngineAux2016.cc:224
dPhiNLBMap_7bit_256Max
static const int dPhiNLBMap_7bit_256Max[128]
Definition: PtAssignmentEngineAux2016.cc:71
etaBin
int etaBin(const l1t::HGCalMulticluster *cl)
Definition: L1EGammaEEProducer.cc:19
PtAssignmentEngineAux2016::getdEta
int getdEta(int dEta) const
Definition: PtAssignmentEngineAux2016.cc:328
relativeConstraints.station
station
Definition: relativeConstraints.py:67
PtAssignmentEngineAux2016::getNLBdPhiBin
int getNLBdPhiBin(int dPhi, int bits, int max=512) const
Definition: PtAssignmentEngineAux2016.cc:168
dPhiNLBMap_7bit_512Max
static const int dPhiNLBMap_7bit_512Max[128]
Definition: PtAssignmentEngineAux2016.cc:81
HLT_FULL_cff.dPhi
dPhi
Definition: HLT_FULL_cff.py:13702
ModeVariables_Scheme3
static const int ModeVariables_Scheme3[13][6]
Definition: PtAssignmentEngineAux2016.cc:45
PtAssignmentEngineAux2016::getModeVariables
const int(* getModeVariables() const)[6]
Definition: PtAssignmentEngineAux2016.cc:103
PtAssignmentEngineAux2016::getEtaFromEtaInt
float getEtaFromEtaInt(int etaInt, int bits=5) const
Definition: PtAssignmentEngineAux2016.cc:373
PtAssignmentEngineAux2016::getNLBdPhi
int getNLBdPhi(int dPhi, int bits, int max=512) const
Definition: PtAssignmentEngineAux2016.cc:105
PtAssignmentEngineAux2016::getEtaFromBin
float getEtaFromBin(int etaBin, int bits=5) const
Definition: PtAssignmentEngineAux2016.cc:384
PVValHelper::eta
Definition: PVValidationHelpers.h:69
FRLUT
static const int FRLUT[2][5]
Definition: PtAssignmentEngineAux2016.cc:392
theta
Geom::Theta< T > theta() const
Definition: Basic3DVectorLD.h:150
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
dPhiNLBMap_8bit_512Max
static const int dPhiNLBMap_8bit_512Max[256]
Definition: PtAssignmentEngineAux2016.cc:89
funct::tan
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
createfilelist.int
int
Definition: createfilelist.py:10
PtAssignmentEngineAux2016::getCLCT
int getCLCT(int clct) const
Definition: PtAssignmentEngineAux2016.cc:249
dPhiNLBMap_6bit_256Max
static const int dPhiNLBMap_6bit_256Max[64]
Definition: PtAssignmentEngineAux2016.cc:66
PtAssignmentEngineAux2016::getdTheta
int getdTheta(int dTheta) const
Definition: PtAssignmentEngineAux2016.cc:306
PtAssignmentEngineAux2016::getEtaInt
int getEtaInt(float eta, int bits=5) const
Definition: PtAssignmentEngineAux2016.cc:350
edm::shift
static unsigned const int shift
Definition: LuminosityBlockID.cc:7
HLT_FULL_cff.dEta
dEta
Definition: HLT_FULL_cff.py:13701
relativeConstraints.chamber
chamber
Definition: relativeConstraints.py:53
dqm-mbProfile.log
log
Definition: dqm-mbProfile.py:17
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
photonValidator_cfi.dPhiBin
dPhiBin
Definition: photonValidator_cfi.py:78
PtAssignmentEngineAux2016::getEtaFromThetaInt
float getEtaFromThetaInt(int thetaInt, int bits=5) const
Definition: PtAssignmentEngineAux2016.cc:362
dPhiNLBMap_5bit_256Max
static const int dPhiNLBMap_5bit_256Max[32]
Definition: PtAssignmentEngineAux2016.cc:63