CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PtAssignment.h
Go to the documentation of this file.
1 
9 #include <stdio.h>
10 #include <stdlib.h>
11 #include <math.h>
13 //add this bobby the 3 files below
17 //add this bobby
18 #include <fstream>
19 
20 const Double_t ptscale[31] = { 0,
21  1.5, 2.0, 2.5, 3.0, 3.5, 4.0,
22  4.5, 5.0, 6.0, 7.0, 8.0, 10.0, 12.0, 14.0,
23  16.0, 18.0, 20.0, 25.0, 30.0, 35.0, 40.0, 45.0,
24  50.0, 60.0, 70.0, 80.0, 90.0, 100.0, 120.0, 140.0 };//
25 
26 int useCorr= false;
27 int doComp = true;
28 int makeLUT_ = false;
29 
30 int whichScheme = 3;
31 
32  //ofstream file("LUT.dat",ios::out);
33 
34 //ModeVariables is a 2D arrary indexed by [TrackMode(13 Total Listed Below)][VariableNumber(20 Total Constructed Above)]
35 // Variable numbering
36 // 0 = dPhi12
37 // 1 = dPhi13
38 // 2 = dPhi14
39 // 3 = dPhi23
40 // 4 = dPhi24
41 // 5 = dPhi34
42 // 6 = dEta12
43 // 7 = dEta13
44 // 8 = dEta14
45 // 9 = dEta23
46 // 10 = dEta24
47 // 11 = dEta34
48 // 12 = CLCT1
49 // 13 = CLCT2
50 // 14 = CLCT3
51 // 15 = CLCT4
52 // 16 = CSCID1
53 // 17 = CSCID2
54 // 18 = CSCID3
55 // 19 = CSCID4
56 // 20 = FR1
57 // 21 = FR2
58 // 22 = FR3
59 // 23 = FR4
60 
61 // Bobby's Scheme3 (or "SchemeC"), with 30 bit compression //
62 //3:TrackEta:dPhi12:dEta12:CLCT1:CLCT2:FR1
63 //4:Single Station Track Not Possible
64 //5:TrackEta:dPhi13:dEta13:CLCT1:CLCT3:FR1
65 //6:TrackEta:dPhi23:dEta23:CLCT2:CLCT3:FR2
66 //7:TrackEta:dPhi12:dPhi23:dEta13:CLCT1:FR1
67 //8:Single Station Track Not Possible
68 //9:TrackEta:dPhi14:dEta14:CLCT1:CLCT4:FR1
69 //10:TrackEta:dPhi24:dEta24:CLCT2:CLCT4:FR2
70 //11:TrackEta:dPhi12:dPhi24:dEta14:CLCT1:FR1
71 //12:TrackEta:dPhi34:dEta34:CLCT3:CLCT4:FR3
72 //13:TrackEta:dPhi13:dPhi34:dEta14:CLCT1:FR1
73 //14:TrackEta:dPhi23:dPhi34:dEta24:CLCT2
74 //15:TrackEta:dPhi12:dPhi23:dPhi34:FR1
76  {
77  {0,6,12,13,20,-999}, // 3
78  {-999,-999,-999,-999,-999,-999}, // 4
79  {1,7,12,14,20,-999}, // 5
80  {3,9,13,14,21,-999}, // 6
81  {0,3,7,12,20,-999}, // 7
82  {-999,-999,-999,-999,-999,-999}, // 8
83  {2,8,12,15,20,-999}, // 9
84  {4,10,13,15,21,-999}, // 10
85  {0,4,8,12,20,-999}, // 11
86  {5,11,14,15,22,-999}, // 12
87  {1,5,8,16,20,-999}, // 13
88  {3,5,10,13,-999,-999}, // 14
89  {0,3,5,20,-999,-999} // 15
90  };
91 //const char *dirSchemeC = "L1Trigger/L1TMuonEndCap/plugins/ModeVariables/trees";
92 const char *dirSchemeC = "L1Trigger/L1TMuon/data/emtf_luts/ModeVariables/trees";
93 
94 //------------------------------------------------//
95 
96 // 256 max units----
97 
98 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};
99 
100 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};
101 
102 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};
103 
104 
105 // 512 max units----
106 const int dPhiNLBMap_7bit_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, 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};
107 
108 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};
109 
110 
111 const int dPhiNLBMap_5bit[32] =
112  { 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};
113 
114 // Array that maps the 7-bit integer dPhi --> dPhi-units. It is assumed that this is used for dPhi12,
115 // which has a maximum value of 7.67 degrees (511 units) in the extrapolation units.
116 const int dPhiNLBMap_7bit[128] =
117  { 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 };
118 
119 // Array that maps the 8-bit integer dPhi --> dPhi-units. It is assumed that this is used for dPhi12,
120 // which has a maximum value of 7.67 degrees (511 units) in the extrapolation units.
121 const int dPhiNLBMap_8bit[256] =
122  { 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 };
123 
124 
125 
126 float getNLBdPhi(float dPhi, int bits, int max=512)
127 {
128  float dPhi_= max;
129  float sign_ = 1;
130  if (dPhi<0)
131  sign_ = -1;
132  dPhi = fabs(dPhi);
133 
134  if (max==256)
135  {
136  if (bits == 5)
137  {
138  dPhi_ = dPhiNLBMap_5bit_256Max[(1<<bits)-1];
139  for (int edge=0; edge<(1<<bits)-1; edge++)
140  if (dPhiNLBMap_5bit_256Max[edge]<=dPhi && dPhiNLBMap_5bit_256Max[edge+1]>dPhi)
141  {
142  dPhi_ = dPhiNLBMap_5bit_256Max[edge];
143  break;
144  }
145  }
146  if (bits == 6)
147  {
148  dPhi_ = dPhiNLBMap_6bit_256Max[(1<<bits)-1];
149  for (int edge=0; edge<(1<<bits)-1; edge++)
150  if (dPhiNLBMap_6bit_256Max[edge]<=dPhi && dPhiNLBMap_6bit_256Max[edge+1]>dPhi)
151  {
152  dPhi_ = dPhiNLBMap_6bit_256Max[edge];
153  break;
154  }
155  }
156  if (bits == 7)
157  {
158  dPhi_ = dPhiNLBMap_7bit_256Max[(1<<bits)-1];
159  for (int edge=0; edge<(1<<bits)-1; edge++)
160  if (dPhiNLBMap_7bit_256Max[edge]<=dPhi && dPhiNLBMap_7bit_256Max[edge+1]>dPhi)
161  {
162  dPhi_ = dPhiNLBMap_7bit_256Max[edge];
163  break;
164  }
165  }
166  }
167  if (max==512)
168  {
169  if (bits == 7)
170  {
171  dPhi_ = dPhiNLBMap_7bit_512Max[(1<<bits)-1];
172  for (int edge=0; edge<(1<<bits)-1; edge++)
173  if (dPhiNLBMap_7bit_512Max[edge]<=dPhi && dPhiNLBMap_7bit_512Max[edge+1]>dPhi)
174  {
175  dPhi_ = dPhiNLBMap_7bit_512Max[edge];
176  break;
177  }
178  }
179  if (bits == 8)
180  {
181  dPhi_ = dPhiNLBMap_8bit_512Max[(1<<bits)-1];
182  for (int edge=0; edge<(1<<bits)-1; edge++)
183  if (dPhiNLBMap_8bit_512Max[edge]<=dPhi && dPhiNLBMap_8bit_512Max[edge+1]>dPhi)
184  {
185  dPhi_ = dPhiNLBMap_8bit_512Max[edge];
186  break;
187  }
188  }
189  }
190 
191  if (dPhi>=max) dPhi_ = max;
192  return (sign_ * dPhi_);
193 }
194 
195 
196 
197 int getNLBdPhiBin(float dPhi, int bits, int max=512)
198 {
199  int dPhiBin_= (1<<bits)-1;
200  //float sign_ = 1;
201  //if (dPhi<0)
202  // sign_ = -1;
203  dPhi = fabs(dPhi);
204 
205  if (max==256)
206  {
207  if (bits == 5)
208  {
209  for (int edge=0; edge<(1<<bits)-1; edge++)
210  if (dPhiNLBMap_5bit_256Max[edge]<=dPhi && dPhiNLBMap_5bit_256Max[edge+1]>dPhi)
211  {
212  dPhiBin_ = edge;
213  break;
214  }
215  }
216  if (bits == 6)
217  {
218  for (int edge=0; edge<(1<<bits)-1; edge++)
219  if (dPhiNLBMap_6bit_256Max[edge]<=dPhi && dPhiNLBMap_6bit_256Max[edge+1]>dPhi)
220  {
221  dPhiBin_ = edge;
222  break;
223  }
224  }
225  if (bits == 7)
226  {
227  for (int edge=0; edge<(1<<bits)-1; edge++)
228  if (dPhiNLBMap_7bit_256Max[edge]<=dPhi && dPhiNLBMap_7bit_256Max[edge+1]>dPhi)
229  {
230  dPhiBin_ = edge;
231  break;
232  }
233  }
234  }
235  if (max==512)
236  {
237  if (bits == 7)
238  {
239  for (int edge=0; edge<(1<<bits)-1; edge++)
240  if (dPhiNLBMap_7bit_512Max[edge]<=dPhi && dPhiNLBMap_7bit_512Max[edge+1]>dPhi)
241  {
242  dPhiBin_ = edge;
243  break;
244  }
245  }
246  if (bits == 8)
247  {
248  for (int edge=0; edge<(1<<bits)-1; edge++)
249  if (dPhiNLBMap_8bit_512Max[edge]<=dPhi && dPhiNLBMap_8bit_512Max[edge+1]>dPhi)
250  {
251  dPhiBin_ = edge;
252  break;
253  }
254  }
255  }
256 
257  return ( dPhiBin_);
258 }
259 
260 
261 float getdPhiFromBin(int dPhiBin, int bits, int max=512)
262 {
263  int dPhi_= (1<<bits)-1;
264 
265  if (dPhiBin>(1<<bits)-1)
266  dPhiBin = (1<<bits)-1;
267 
268  if (max==256)
269  {
270  if (bits == 5)
271  dPhi_ = dPhiNLBMap_5bit_256Max[dPhiBin];
272 
273  if (bits == 6)
274  dPhi_ = dPhiNLBMap_6bit_256Max[dPhiBin];
275 
276  if (bits == 7)
277  dPhi_ = dPhiNLBMap_7bit_256Max[dPhiBin];
278  }
279  if (max==512)
280  {
281  if (bits == 7)
282  dPhi_ = dPhiNLBMap_7bit_512Max[dPhiBin];
283 
284  if (bits == 8)
285  dPhi_ = dPhiNLBMap_8bit_512Max[dPhiBin];
286  }
287 
288  return ( dPhi_);
289 }
290 
291 float getCLCT(float clct)
292 {
293  if ((int)clct==10)
294  clct=0;
295  else if ((int)clct==9)
296  clct=1;
297  else if ((int)clct==8)
298  clct=-1;
299  else if ((int)clct==7)
300  clct=2;
301  else if ((int)clct==6)
302  clct=-2;
303  else if ((int)clct==5)
304  clct=3;
305  else if ((int)clct==4)
306  clct=-3;
307  else if ((int)clct==3)
308  clct=4;
309  else if ((int)clct==2)
310  clct=-4;
311  else
312  clct=-999;
313 
314  float clct_ = 0;
315  float sign_ = 1;
316 
317  if (clct<0)
318  sign_ = -1;
319 
320  clct = fabs(clct);
321 
322  if (clct<=0) // 0
323  clct_ = 0;
324  else if (clct<=1) //1,2
325  clct_ = 1;
326  else if (clct<=2)// 3,4
327  clct_ = 2;
328  else
329  clct_ = 3; // 5,6
330 
331  return (sign_ * clct_);
332 }
333 
334 float getdEta(float deta)
335 {
336  float deta_ = 0;
337  //float sign_ = 1;
338 
339  //if (deta<0)
340  // sign_ = -1;
341 
342  //deta = fabs(deta);
343 
344  if (deta<=-5)
345  deta_ = 0;
346  else if (deta<=-2)
347  deta_ = 1;
348  else if (deta<=-1)
349  deta_ = 2;
350  else if (deta<=0)
351  deta_ = 3;
352  else if (deta<=1)
353  deta_ = 4;
354  else if (deta<=3)
355  deta_ = 5;
356  else if (deta<=6)
357  deta_ = 6;
358  else
359  deta_ = 7;
360 
361  return ( deta_);
362 }
363 
364 float getEta(float eta, int bits=5)
365 {
366  float eta_ = 0;
367  float sign_ = 1;
368  if (eta<0)
369  sign_ = -1;
370 
371  if (bits>5) bits = 5;
372  int shift = 5 - bits;
373  int etaInt = (fabs(eta) - 0.9)*(32.0/(1.6))-0.5;
374  etaInt = (etaInt>>shift)<<shift;
375 
376  eta_ = 0.9 + (etaInt + 0.5)*(1.6/32.0);
377  return (eta_*sign_);
378 }
379 
380 int getEtaInt(float eta, int bits=5)
381 {
382  //float eta_ = 0;
383  //float sign_ = 1;
384  //if (eta<0)
385  // sign_ = -1;
386 
387  if (bits>5) bits = 5;
388  int shift = 5 - bits;
389  int etaInt = (fabs(eta) - 0.9)*(32.0/(1.6))-0.5;
390  etaInt = (etaInt>>shift);
391  //eta_ = 0.9 + (etaInt + 0.5)*(1.6/32.0);
392  return (etaInt);
393 }
394 
395 float getEtafromBin(int etaBin, int bits=5)
396 {
397  if (etaBin>((1<<5)-1))
398  etaBin = ((1<<5)-1);
399  if (etaBin<0)
400  etaBin = 0;
401 
402  if (bits>5) bits = 5;
403  int shift = 5 - bits;
404  int etaInt_ = etaBin << shift;
405  float eta_ = 0.9 + (etaInt_ + 0.5)*(1.6/32.0);
406  return (eta_);
407 }
408 
409 
410 float getPt(unsigned long Address)
411 {
412  bool verbose = false;
413 
417  int ModeVariables[13][6];
418  //int ModeBits[13][6];
419 
420  for (int i=0;i<13;i++)
421  for (int j=0;j<6;j++)
422  {
423  if (whichScheme == 3)
424  {
425  ModeVariables[i][j] = ModeVariables_Scheme3[i][j];
426  }
427  }
428 
429  const char *dir="";
430  if (whichScheme == 3)
431  dir = dirSchemeC;
432 
433  int dphi[6] = {-999,-999,-999,-999,-999,-999}, deta[6] = {-999,-999,-999,-999,-999,-999};
434  int clct[4] = {-999,-999,-999,-999}, cscid[4] = {-999,-999,-999,-999};
435  int phis[4] = {-999,-999,-999,-999}, etas[4] = {-999,-999,-999,-999}, mode = 0;;
436  int FR[4] = {-999,-999,-999,-999};
437  float eta =0 ;
438 
439  float dPhi12 = dphi[0];
440  float dPhi13 = dphi[1];
441  float dPhi14 = dphi[2];
442  float dPhi23 = dphi[3];
443  float dPhi24 = dphi[4];
444  float dPhi34 = dphi[5];
445  float dEta12 = deta[0];
446  float dEta13 = deta[1];
447  float dEta14 = deta[2];
448  float dEta23 = deta[3];
449  float dEta24 = deta[4];
450  float dEta34 = deta[5];
451  float TrackEta = 0;
452  float CLCT1 = clct[0];
453  float CLCT2 = clct[1];
454  float CLCT3 = clct[2];
455  float CLCT4 = clct[3];
456  float FR1 = FR[0];
457  float FR2 = FR[1];
458  float FR3 = FR[2];
459  float FR4 = FR[3];
460 
461  mode = (Address >> (30-4)) & ((1<<4)-1);
462 
463  // Decode the Pt LUT Address
464  //unsigned long Address = 0x0;
465 
466  if (verbose) std::cout << "PtAssignment:getPt: decoding, Mode = " << mode << std::endl;
467 
468  if (mode == 3) // 1-2
469  {
470  int dPhi12_ = (Address >> (0)) & ((1<<9)-1);
471  float sign12 = (Address >> (0+9)) & ((1<<1)-1);
472  dEta12 = (Address >> (0+9+1)) & ((1<<3)-1);
473  CLCT1 = (Address >> (0+9+1+2)) & ((1<<2)-1);
474  float CLCT1Sign= (Address >> (0+9+1+2+3)) & ((1<<1)-1);
475  CLCT2 = (Address >> (0+9+1+2+3+1)) & ((1<<2)-1);
476  float CLCT2Sign= (Address >> (0+9+1+2+3+1+2)) & ((1<<1)-1);
477  FR1 = (Address >> (0+9+1+2+3+1+2+1)) & ((1<<1)-1);
478  FR2 = (Address >> (0+9+1+2+3+1+2+1+1)) & ((1<<1)-1);
479  int TrackEta_ = (Address >> (0+9+1+2+3+1+2+1+1+1)) & ((1<<5)-1);
480 
481  dPhi12 = dPhi12_;
482  TrackEta = getEtafromBin( TrackEta_, 5);
483 
484  if (sign12 == 0) dPhi12 = -1*dPhi12;
485  if (CLCT1Sign == 0) CLCT1 = -1*CLCT1;
486  if (CLCT2Sign == 0) CLCT2 = -1*CLCT2;
487 
488  if (verbose) std::cout << "PtAssignment:getPt: decoding, Addess = 0x" << hex << Address << std::endl;
489  if (verbose) std::cout << "PtAssignment:getPt: decoding, dPhi12 = " << dec << dPhi12_ << std::endl;
490 
491  }
492 
493  if (mode == 5) // 1-3
494  {
495  int dPhi13_ = (Address >> (0)) & ((1<<9)-1);
496  float sign13 = (Address >> (0+9)) & ((1<<1)-1);
497  dEta13 = (Address >> (0+9+1)) & ((1<<3)-1);
498  CLCT1 = (Address >> (0+9+1+2)) & ((1<<2)-1);
499  float CLCT1Sign= (Address >> (0+9+1+2+3)) & ((1<<1)-1);
500  CLCT3 = (Address >> (0+9+1+2+3+1)) & ((1<<2)-1);
501  float CLCT3Sign= (Address >> (0+9+1+2+3+1+2)) & ((1<<1)-1);
502  FR1 = (Address >> (0+9+1+2+3+1+2+1)) & ((1<<1)-1);
503  FR3 = (Address >> (0+9+1+2+3+1+2+1+1)) & ((1<<1)-1);
504  int TrackEta_ = (Address >> (0+9+1+2+3+1+2+1+1+1)) & ((1<<5)-1);
505 
506  dPhi13 = dPhi13_;
507  TrackEta = getEtafromBin( TrackEta_, 5);
508 
509  if (sign13 == 0) dPhi13 = -1*dPhi13;
510  if (CLCT1Sign == 0) CLCT1 = -1*CLCT1;
511  if (CLCT3Sign == 0) CLCT3 = -1*CLCT3;
512  }
513 
514  if (mode == 9) // 1-4
515  {
516  int dPhi14_ = (Address >> (0)) & ((1<<9)-1);
517  float sign14 = (Address >> (0+9)) & ((1<<1)-1);
518  dEta14 = (Address >> (0+9+1)) & ((1<<3)-1);
519  CLCT1 = (Address >> (0+9+1+2)) & ((1<<2)-1);
520  float CLCT1Sign= (Address >> (0+9+1+2+3)) & ((1<<1)-1);
521  CLCT4 = (Address >> (0+9+1+2+3+1)) & ((1<<2)-1);
522  float CLCT4Sign= (Address >> (0+9+1+2+3+1+2)) & ((1<<1)-1);
523  FR1 = (Address >> (0+9+1+2+3+1+2+1)) & ((1<<1)-1);
524  FR4 = (Address >> (0+9+1+2+3+1+2+1+1)) & ((1<<1)-1);
525  int TrackEta_ = (Address >> (0+9+1+2+3+1+2+1+1+1)) & ((1<<5)-1);
526 
527  dPhi14 = dPhi14_;
528  TrackEta = getEtafromBin( TrackEta_, 5);
529 
530  if (sign14 == 0) dPhi14 = -1*dPhi14;
531  if (CLCT1Sign == 0) CLCT1 = -1*CLCT1;
532  if (CLCT4Sign == 0) CLCT4 = -1*CLCT4;
533  }
534 
535  if (mode == 6) // 2-3
536  {
537  int dPhi23_ = (Address >> (0)) & ((1<<9)-1);
538  float sign23 = (Address >> (0+9)) & ((1<<1)-1);
539  dEta23 = (Address >> (0+9+1)) & ((1<<3)-1);
540  CLCT2 = (Address >> (0+9+1+2)) & ((1<<2)-1);
541  float CLCT2Sign= (Address >> (0+9+1+2+3)) & ((1<<1)-1);
542  CLCT3 = (Address >> (0+9+1+2+3+1)) & ((1<<2)-1);
543  float CLCT3Sign= (Address >> (0+9+1+2+3+1+2)) & ((1<<1)-1);
544  FR2 = (Address >> (0+9+1+2+3+1+2+1)) & ((1<<1)-1);
545  FR3 = (Address >> (0+9+1+2+3+1+2+1+1)) & ((1<<1)-1);
546  int TrackEta_ = (Address >> (0+9+1+2+3+1+2+1+1+1)) & ((1<<5)-1);
547 
548  dPhi23 = dPhi23_;
549  TrackEta = getEtafromBin( TrackEta_, 5);
550 
551  if (sign23 == 0) dPhi23 = -1*dPhi23;
552  if (CLCT2Sign == 0) CLCT2 = -1*CLCT2;
553  if (CLCT3Sign == 0) CLCT3 = -1*CLCT3;
554  }
555  if (mode == 10) // 2-4
556  {
557  int dPhi24_ = (Address >> (0)) & ((1<<9)-1);
558  float sign24 = (Address >> (0+9)) & ((1<<1)-1);
559  dEta24 = (Address >> (0+9+1)) & ((1<<3)-1);
560  CLCT2 = (Address >> (0+9+1+2)) & ((1<<2)-1);
561  float CLCT2Sign= (Address >> (0+9+1+2+3)) & ((1<<1)-1);
562  CLCT4 = (Address >> (0+9+1+2+3+1)) & ((1<<2)-1);
563  float CLCT4Sign= (Address >> (0+9+1+2+3+1+2)) & ((1<<1)-1);
564  FR2 = (Address >> (0+9+1+2+3+1+2+1)) & ((1<<1)-1);
565  FR4 = (Address >> (0+9+1+2+3+1+2+1+1)) & ((1<<1)-1);
566  int TrackEta_ = (Address >> (0+9+1+2+3+1+2+1+1+1)) & ((1<<5)-1);
567 
568  dPhi24 = dPhi24_;
569  TrackEta = getEtafromBin( TrackEta_, 5);
570 
571  if (sign24 == 0) dPhi24 = -1*dPhi24;
572  if (CLCT2Sign == 0) CLCT2 = -1*CLCT2;
573  if (CLCT4Sign == 0) CLCT4 = -1*CLCT4;
574  }
575  if (mode == 12) // 3-4
576  {
577  int dPhi34_ = (Address >> (0)) & ((1<<9)-1);
578  float sign34 = (Address >> (0+9)) & ((1<<1)-1);
579  dEta34 = (Address >> (0+9+1)) & ((1<<3)-1);
580  CLCT3 = (Address >> (0+9+1+2)) & ((1<<2)-1);
581  float CLCT3Sign= (Address >> (0+9+1+2+3)) & ((1<<1)-1);
582  CLCT4 = (Address >> (0+9+1+2+3+1)) & ((1<<2)-1);
583  float CLCT4Sign= (Address >> (0+9+1+2+3+1+2)) & ((1<<1)-1);
584  FR3 = (Address >> (0+9+1+2+3+1+2+1)) & ((1<<1)-1);
585  FR4 = (Address >> (0+9+1+2+3+1+2+1+1)) & ((1<<1)-1);
586  int TrackEta_ = (Address >> (0+9+1+2+3+1+2+1+1+1)) & ((1<<5)-1);
587 
588  dPhi34 = dPhi34_;
589  TrackEta = getEtafromBin( TrackEta_, 5);
590 
591  if (sign34 == 0) dPhi34 = -1*dPhi34;
592  if (CLCT3Sign == 0) CLCT3 = -1*CLCT3;
593  if (CLCT4Sign == 0) CLCT4 = -1*CLCT4;
594  }
595  if (mode == 7) //1-2-3
596  {
597  int dPhi12_ = (Address >> (0)) & ((1<<7)-1);
598  int dPhi23_ = (Address >> (0+7)) & ((1<<5)-1);
599  float sign12 = (Address >> (0+7+5)) & ((1<<1)-1);
600  float sign23 = (Address >> (0+7+5+1)) & ((1<<1)-1);
601  dEta13 = (Address >> (0+7+5+1+1)) & ((1<<3)-1);
602  CLCT1 = (Address >> (0+7+5+1+1+3)) & ((1<<2)-1);
603  float CLCT1Sign= (Address >> (0+7+5+1+1+3+2)) & ((1<<1)-1);
604  FR1 = (Address >> (0+7+5+1+1+3+2+1)) & ((1<<1)-1);
605  int TrackEta_ = (Address >> (0+7+5+1+1+3+2+1+1)) & ((1<<5)-1);
606 
607  dPhi12 = getdPhiFromBin( dPhi12_, 7, 512 );
608  dPhi23 = getdPhiFromBin( dPhi23_, 5, 256 );
609 
610  //cout << "getPt: dPhi12: " << dPhi12_ << " " << dPhi12 << endl;
611  //cout << "getPt: dPhi23: " << dPhi23_ << " " << dPhi23 << endl;
612 
613  TrackEta = getEtafromBin( TrackEta_, 5);
614 
615  if (sign12 == 0) dPhi12 = -1*dPhi12;
616  if (sign23 == 0) dPhi23 = -1*dPhi23;
617  if (CLCT1Sign == 0) CLCT1 = -1*CLCT1;
618  }
619  if (mode == 11) // 1-2-4
620  {
621  int dPhi12_ = (Address >> (0)) & ((1<<7)-1);
622  int dPhi24_ = (Address >> (0+7)) & ((1<<5)-1);
623  float sign12 = (Address >> (0+7+5)) & ((1<<1)-1);
624  float sign24 = (Address >> (0+7+5+1)) & ((1<<1)-1);
625  dEta14 = (Address >> (0+7+5+1+1)) & ((1<<3)-1);
626  CLCT1 = (Address >> (0+7+5+1+1+3)) & ((1<<2)-1);
627  float CLCT1Sign= (Address >> (0+7+5+1+1+3+2)) & ((1<<1)-1);
628  FR1 = (Address >> (0+7+5+1+1+3+2+1)) & ((1<<1)-1);
629  int TrackEta_ = (Address >> (0+7+5+1+1+3+2+1+1)) & ((1<<5)-1);
630 
631  dPhi12 = getdPhiFromBin( dPhi12_, 7, 512 );
632  dPhi24 = getdPhiFromBin( dPhi24_, 5, 256 );
633  TrackEta = getEtafromBin( TrackEta_, 5);
634 
635  if (sign12 == 0) dPhi12 = -1*dPhi12;
636  if (sign24 == 0) dPhi24 = -1*dPhi24;
637  if (CLCT1Sign == 0) CLCT1 = -1*CLCT1;
638  }
639  if (mode == 13) // 1-3-4
640  {
641  int dPhi13_ = (Address >> (0)) & ((1<<7)-1);
642  int dPhi34_ = (Address >> (0+7)) & ((1<<5)-1);
643  float sign13 = (Address >> (0+7+5)) & ((1<<1)-1);
644  float sign34 = (Address >> (0+7+5+1)) & ((1<<1)-1);
645  dEta14 = (Address >> (0+7+5+1+1)) & ((1<<3)-1);
646  CLCT1 = (Address >> (0+7+5+1+1+3)) & ((1<<2)-1);
647  float CLCT1Sign= (Address >> (0+7+5+1+1+3+2)) & ((1<<1)-1);
648  FR1 = (Address >> (0+7+5+1+1+3+2+1)) & ((1<<1)-1);
649  int TrackEta_ = (Address >> (0+7+5+1+1+3+2+1+1)) & ((1<<5)-1);
650 
651  dPhi13 = getdPhiFromBin( dPhi13_, 7, 512 );
652  dPhi34 = getdPhiFromBin( dPhi34_, 5, 256 );
653  TrackEta = getEtafromBin( TrackEta_, 5);
654 
655  if (sign13 == 0) dPhi13 = -1*dPhi13;
656  if (sign34 == 0) dPhi34 = -1*dPhi34;
657  if (CLCT1Sign == 0) CLCT1 = -1*CLCT1;
658  }
659  if (mode == 14) // 2-3-4
660  {
661  int dPhi23_ = (Address >> (0)) & ((1<<7)-1);
662  int dPhi34_ = (Address >> (0+7)) & ((1<<6)-1);
663  float sign23 = (Address >> (0+7+6)) & ((1<<1)-1);
664  float sign34 = (Address >> (0+7+6+1)) & ((1<<1)-1);
665  dEta24 = (Address >> (0+7+6+1+1)) & ((1<<3)-1);
666  CLCT2 = (Address >> (0+7+5+1+1+3)) & ((1<<2)-1);
667  float CLCT2Sign= (Address >> (0+7+6+1+1+3+2)) & ((1<<1)-1);
668  int TrackEta_ = (Address >> (0+7+6+1+1+3+2+1)) & ((1<<5)-1);
669 
670  dPhi23 = getdPhiFromBin( dPhi23_, 7, 512 );
671  dPhi34 = getdPhiFromBin( dPhi34_, 6, 256 );
672  TrackEta = getEtafromBin( TrackEta_, 5);
673 
674  if (sign23 == 0) dPhi23 = -1*dPhi23;
675  if (sign34 == 0) dPhi34 = -1*dPhi34;
676  if (CLCT2Sign == 0) CLCT2 = -1*CLCT2;
677  }
678  if (mode == 15)
679  {
680  int dPhi12_ = (Address >> (0)) & ((1<<7)-1);
681  int dPhi23_ = (Address >> (0+7)) & ((1<<5)-1);
682  int dPhi34_ = (Address >> (0+7+5)) & ((1<<6)-1);
683  int sign23 = (Address >> (0+7+5+6)) & ((1<<1)-1);
684  int sign34 = (Address >> (0+7+5+6+1)) & ((1<<1)-1);
685  FR1 = (Address >> (0+7+5+6+1+1)) & ((1<<1)-1);
686  int TrackEta_ = (Address >> (0+7+5+6+1+1+1)) & ((1<<5)-1);
687 
688  dPhi12 = getdPhiFromBin( dPhi12_, 7, 512 );
689  dPhi23 = getdPhiFromBin( dPhi23_, 5, 256 );
690  dPhi34 = getdPhiFromBin( dPhi34_, 6, 256 );
691  TrackEta = getEtafromBin( TrackEta_, 5 );
692 
693  if (sign23 == 0) dPhi23 = -1*dPhi23;
694  if (sign34 == 0) dPhi34 = -1*dPhi34;
695  }
696 
697 
698 
699  if(verbose){
700  if (mode == 15) // 1-2-3-4
701  cout << "Mode 15: " << hex << Address << " " << dec << dPhi12 << " " << dPhi23 << " " << dPhi34 << " " << " " << FR1 << " " << TrackEta << " " << dec << endl;
702  if (mode == 14) // 2-3-4
703  cout << "Mode 14: " << hex << Address << " " << dec << dPhi23 << " " << dPhi34 << " " << " " << " " << TrackEta << " " << dec << endl;
704  if (mode == 13) // 1-3-4
705  cout << "Mode 13: " << hex << Address << " " << dec << dPhi13 << " " << dPhi34 << " " << " " << FR1 << " " << TrackEta << " " << dec << endl;
706  if (mode == 11) // 1-2-4
707  cout << "Mode 11: " << hex << Address << " " << dec << dPhi12 << " " << dPhi24 << " " << " " << FR1 << " " << TrackEta << " " << dec << endl;
708  if (mode == 7)
709  cout << "Mode 7: " << hex << Address << " " << dec << dPhi12 << " " << dPhi23 << " " << " " << FR1 << " " << TrackEta << " " << dec << endl;
710  if (mode == 3)
711  cout << "Mode 3: " << hex << Address << " " << dec << dPhi12 << " " << " " << FR1 << " " << TrackEta << " " << dec << endl;
712  }
713 
714  // now use rebinned values
715  dphi[0] = dPhi12;
716  dphi[1] = dPhi13;
717  dphi[2] = dPhi14;
718  dphi[3] = dPhi23;
719  dphi[4] = dPhi24;
720  dphi[5] = dPhi34;
721  deta[0] = dEta12;
722  deta[1] = dEta13;
723  deta[2] = dEta14;
724  deta[3] = dEta23;
725  deta[4] = dEta24;
726  deta[5] = dEta34;
727  eta = TrackEta;
728  clct[0] = CLCT1;
729  clct[1] = CLCT2;
730  clct[2] = CLCT3;
731  clct[3] = CLCT4;
732  FR[0] = FR1;
733  FR[1] = FR2;
734  FR[2] = FR3;
735  FR[3] = FR4;
736 
737 
738  if(verbose){
739  for(int f=0;f<4;f++){
740  std::cout<<"\nphis["<<f<<"] = "<<phis[f]<<" and etas = "<<etas[f]<<std::endl;
741  std::cout<<"\nclct["<<f<<"] = "<<clct[f]<<" and cscid = "<<cscid[f]<<std::endl;
742  }
743 
744  for(int u=0;u<6;u++)
745  std::cout<<"\ndphi["<<u<<"] = "<<dphi[u]<<" and deta = "<<deta[u]<<std::endl;
746  }
747 
748  float MpT = -1;//final pT to return
749 
750 
754 
755  int size[13] = {5,0,5,5,5,0,5,5,5,5,5,4,4};
756  int Variables[24] = {dphi[0], dphi[1], dphi[2], dphi[3], dphi[4], dphi[5], deta[0], deta[1], deta[2], deta[3], deta[4], deta[5],
757  clct[0], clct[1], clct[2], clct[3], cscid[0], cscid[1], cscid[2], cscid[3], FR[0], FR[1], FR[2], FR[3]};
758 
759 
760 
764  //float gpt = -1;
765 
766  int goodMode = false;
767  int allowedModes[11] = {3,5,9,6,10,12,7,11,13,14,15};
768  for (int i=0;i<11;i++)
769  if (allowedModes[i] == mode)
770  {
771  goodMode = true;
772  break;
773  }
774 
775  if (goodMode)
776  for(int i=3;i<16;i++){
777 
778  if(i != mode)
779  continue;
780 
781  //std::cout<<"\nMode = "<<mode<<"\n\n";
782 
783  Forest *forest = new Forest();
784  //const char *dir = "L1Trigger/L1TMuonEndCap/plugins/ModeVariables/trees";
785  std::stringstream ss;
786  ss << dir << "/" << mode;//
787 
788  forest-> loadForestFromXML(ss.str().c_str(),64);
789 
790  std::vector<Double_t> Data;
791  Data.push_back(1.0);
792  Data.push_back(eta);
793  for(int y=0;y<size[mode-3];y++){
794 
795  Data.push_back(Variables[ModeVariables[mode-3][y]]);
796  if(verbose) std::cout<<"Generalized Variables "<<y<<" "<<Variables[ModeVariables[mode-3][y]]<<"\n";
797  }
798 
799  if(verbose){
800  std::cout<<"Data.size() = "<<Data.size()<<"\n";
801  for(int i=0;i<5;i++)
802  std::cout<<"Data["<<i<<"] = "<<Data[i]<<"\n";
803  }
804 
805  Event *event = new Event();
806  event->data = Data;
807 
808  std::vector<Event*> vevent;
809  vevent.push_back(event);
810 
811  forest->predictEvents(vevent,64);
812 
813  float OpT = vevent[0]->predictedValue;
814  MpT = 1/OpT;
815 
816 
817  if (MpT<0.0) MpT = 1.0;
818  if (MpT>200.0) MpT = 200.0;
819 
820  float BDTPt = MpT;
821  float BDTPt__ = MpT;
822 
823  if (useCorr)
824  {
825 
826  TrackEta = getEtaInt(TrackEta, 5);
827 
828  if (i==3) // 1-2
829  BDTPt__ = getMaxPT(BDTPt, fabs(TrackEta), dPhi12, 0*dPhi23, 0*dPhi34, 95);
830 
831  if (i==6) // 2-3
832  BDTPt__ = getMaxPT(BDTPt, fabs(TrackEta), 0*dPhi12, dPhi23, 0*dPhi34, 95);
833 
834  if (i==12) // 3-4
835  BDTPt__ = getMaxPT(BDTPt, fabs(TrackEta), 0*dPhi12, 0*dPhi23, dPhi34, 95);
836 
837  if (i==7) // 1-2-3
838  BDTPt__ = getMaxPT(BDTPt, fabs(TrackEta), dPhi12, dPhi23, 0*dPhi34, 95);
839 
840  if (i==11) // 1-2-4
841  BDTPt__ = getMaxPT(BDTPt, fabs(TrackEta), dPhi12, 0*dPhi23, 0*dPhi34, 95);
842 
843  if (i==13) // 1-3-4
844  BDTPt__ = getMaxPT(BDTPt, fabs(TrackEta), 0*dPhi12, 0*dPhi23, dPhi34, 95);
845 
846  if (i==11) // 2-3-4
847  BDTPt__ = getMaxPT(BDTPt, fabs(TrackEta), 0*dPhi12, dPhi23, dPhi34, 95);
848 
849  if (i==15) // 1-2-3-4
850  BDTPt__ = getMaxPT(BDTPt, fabs(TrackEta), dPhi12, dPhi23, dPhi34, 95);
851 
852  cout << "getMaxPT: eta = " << TrackEta << ", old = " << BDTPt << " , new = " << BDTPt__ << endl;
853  MpT = BDTPt__;
854  }
855 
856  delete forest;
857  }
858 
859  return MpT;
860 }
861 
862 void makeLUT()//
863 {
864  // ofstream file2("LUT2.dat",ios::out);
865 
866 
867  if (true)
868  for (unsigned long i=0; i<((1<<26)-1); i++)
869  {
870  //int mode = (i >> (30-4)) & ((1<<4)-1);
871 
872  float BDTPt1 = fabs(getPt(i));
873 
874  if (BDTPt1>140.0) BDTPt1 = 139.9999;
875 
876  //int index=0;
877  for (int pts=0; pts<31; pts++)
878  {
879  if (ptscale[pts]<=BDTPt1 && ptscale[pts+1]>BDTPt1)
880  {
881  BDTPt1 = ptscale[pts];
882  //index = pts;
883  break;
884  }
885  }
886 
887  //file << index << endl;
888  //file2 << std::setw(20) << i << std::setw(20) << mode << std::setw(20) << getPt(i) << endl;
889 
890  }
891 
892  /*
893  for (int i=0;i<10;i++) cout << i << " " ;
894  cout << endl;
895  cout << endl;
896  cout << endl;
897 
898  for (int dp12=0;dp12<((1<<7));dp12++)
899  {
900  cout << "makeLUT, dp12 = " << dp12 << endl;
901  for (int dp23=0;dp23<((1<<5));dp23++)
902  {
903  cout << "makeLUT, dp23 = " << dp23 << endl;
904  int dEta13 = 0;
905  int dPhi12 = dp12;
906  int dPhi23 = dp23;
907  int CLCT1 = 10;
908 
909  int dPhi12Sign = 1;
910  int dPhi23Sign = 1;
911  int dPhi34Sign = 1;
912  int dEta13Sign = 1;
913  int CLCT1Sign = 1;
914 
915  if (dPhi12<0) dPhi12Sign = -1;
916  if (dPhi23<0) dPhi23Sign = -1;
917  if (CLCT1<0) CLCT1Sign = -1;
918 
919  // Make Pt LUT Address
920  int dPhi12_ = dp12;//getNLBdPhiBin(dPhi12, 7, 512);
921  int dPhi23_ = dp23;//getNLBdPhiBin(dPhi23, 5, 256);
922  int sign12_ = dPhi12Sign > 0 ? 1 : 0;
923  int sign23_ = dPhi23Sign > 0 ? 1 : 0;
924  int dEta13_ = getdEta(dEta13);
925  int CLCT1_ = getCLCT(fabs(CLCT1));
926  int CLCT1Sign_ = CLCT1Sign > 0 ? 1 : 0;
927  int FR1_ = 0;//FR1;
928  int eta_ = 18;//getEtaInt(TrackEta, 5);
929  int Mode_ = 7;//mode;
930 
931  unsigned long Address = 0x0;
932  Address += (( dPhi12_ & ((1<<7)-1)) << (0));
933  Address += (( dPhi23_ & ((1<<5)-1)) << (0+7));
934  Address += (( sign12_ & ((1<<1)-1)) << (0+7+5));
935  Address += (( sign23_ & ((1<<1)-1)) << (0+7+5+1));
936  Address += (( dEta13_ & ((1<<3)-1)) << (0+7+5+1+1));
937  Address += (( CLCT1_ & ((1<<2)-1)) << (0+7+5+1+1+3));
938  Address += (( CLCT1Sign_ & ((1<<1)-1)) << (0+7+5+1+1+3+2));
939  Address += (( FR1_ & ((1<<1)-1)) << (0+7+5+1+1+3+2+1));
940  Address += (( eta_ & ((1<<5)-1)) << (0+7+5+1+1+3+2+1+1));
941  Address += (( Mode_ & ((1<<4)-1)) << (0+7+5+1+1+3+2+1+1+5));
942 
943  int dPhi12__ = (Address >> (0)) & ((1<<7)-1);
944  int dPhi23__ = (Address >> (0+7)) & ((1<<5)-1);
945  int dPhi12test = getdPhiFromBin( dPhi12__, 7, 512 );
946  int dPhi23test = getdPhiFromBin( dPhi23__, 5, 256 );
947 
948  cout << "makeLUT: dPhi12: " << dPhi12_ << " " << dPhi12__ << " " << dPhi12test << endl;
949  cout << "makeLUT: dPhi23: " << dPhi23_ << " " << dPhi23__ << " " << dPhi23test << endl;
950 
951  file << getPt(Address) << endl;
952  }
953  }
954  */
955 }
956 
957 //float CalculatePt(L1TMuon::InternalTrack track){
959  edm::ESHandle<CSCGeometry> cscGeometry;
960  es.get<MuonGeometryRecord>().get(cscGeometry);
961 
962  if (makeLUT_)
963  makeLUT();
964 
965  bool verbose = false;
966 
970  /*int ModeVariables[13][6];
971  //int ModeBits[13][6];
972 
973  for (int i=0;i<13;i++)
974  for (int j=0;j<6;j++)
975  {
976  if (whichScheme == 3)
977  {
978  ModeVariables[i][j] = ModeVariables_Scheme3[i][j];
979  }
980  }*/
981 
982  //const char *dir="";//maybe need to keep this?
983  //if (whichScheme == 3)
984  // dir = dirSchemeC;
985 
986  int dphi[6] = {-999,-999,-999,-999,-999,-999}, deta[6] = {-999,-999,-999,-999,-999,-999};
987  int clct[4] = {-999,-999,-999,-999}, cscid[4] = {-999,-999,-999,-999};
988  int phis[4] = {-999,-999,-999,-999}, etas[4] = {-999,-999,-999,-999}, mode = 0;;
989  int FR[4] = {-999,-999,-999,-999};
990 
991  float theta_angle = ((track.theta)*0.2851562 + 8.5)*(3.14159265359/180);//2851562 //2874016
992  float eta = (-1)*log(tan(theta_angle/2));
993 
994  const TriggerPrimitiveStationMap stubs = track.getStubs();
995 
996  //track.print(std::cout);
997 
998  if(verbose) std::cout<<"Track eta = "<<eta<<" and has hits in stations ";//
999 
1000  int x=0; //12
1001  for(unsigned int s=8;s<12;s++){
1002  if((stubs.find(s)->second).size() == 1){
1003 
1004 
1005  if(verbose) std::cout<< "s= " << s << " " << endl;
1006  etas[s-8] = (fabs((stubs.find(s)->second)[0].getCMSGlobalEta()) + 0.9)/(0.0125);
1007  if(verbose) std::cout<< "eta= " << etas[s-8] << " " << endl;
1008  phis[s-8] = track.phis[x];//(stubs.find(s)->second)[0].getCMSGlobalPhi();//
1009  if(verbose) std::cout<< "phi= " << phis[s-8] << " " << endl;
1010  clct[s-8] = (stubs.find(s)->second)[0].getPattern();
1011  if(verbose) std::cout<< "clct= " << clct[s-8] << " " << endl;
1012  cscid[s-8] = (stubs.find(s)->second)[0].Id();
1013  if(verbose) std::cout<< "cscid= " << cscid[s-8] << " " << endl;
1014 
1015  if(verbose) std::cout<< s << " " << (stubs.find(s)->second)[0].detId<CSCDetId>().station()<<" " << phis[s-8] << endl;;
1016 
1017  const CSCChamber* layer = cscGeometry->chamber((stubs.find(s)->second)[0].detId<CSCDetId>());
1018  LocalPoint llc(0.,0.,0.);
1019  GlobalPoint glc = layer->toGlobal(llc);
1020 
1021 
1022  int FR_ = 0;
1023  int coord[5] = {586,686,815,924,1013};
1024  for(int i=0;i<5;i++){
1025 
1026  if((fabs(glc.z()) < (coord[i] + 7)) && (fabs(glc.z()) > (coord[i] - 7)))
1027  FR_ = 1;
1028 
1029  FR[s-8] = FR_;
1030 
1031  }
1032 
1033  switch(s-7){
1034  case 1: mode |= 1;break;
1035  case 2: mode |= 2;break;
1036  case 3: mode |= 4;break;
1037  case 4: mode |= 8;break;
1038  default: mode |= 0;
1039  }
1040  x++;
1041  }
1042  }
1043 
1044  if(verbose) std::cout<<"\nMode = "<<mode<<std::endl;
1045 
1049 
1050  if(phis[0] > 0 && phis[1] > 0){ // 1 - 2
1051  dphi[0] = phis[1] - phis[0];
1052  deta[0] = etas[1] - etas[0];
1053  }
1054  if(phis[0] > 0 && phis[2] > 0){ // 1 - 3
1055  dphi[1] = phis[2] - phis[0];
1056  deta[1] = etas[2] - etas[0];
1057  }
1058  if(phis[0] > 0 && phis[3] > 0){ // 1 - 4
1059  dphi[2] = phis[3] - phis[0];
1060  deta[2] = etas[3] - etas[0];
1061  }
1062  if(phis[1] > 0 && phis[2] > 0){ // 2 - 3
1063  dphi[3] = phis[2] - phis[1];
1064  deta[3] = etas[2] - etas[1];
1065  }
1066  if(phis[1] > 0 && phis[3] > 0){ // 2 - 4
1067  dphi[4] = phis[3] - phis[1];
1068  deta[4] = etas[3] - etas[1];
1069  }
1070  if(phis[2] > 0 && phis[3] > 0){ // 3 - 4
1071  dphi[5] = phis[3] - phis[2];
1072  deta[5] = etas[3] - etas[2];
1073  }
1074 
1075 
1076  if(verbose){
1077  if (mode==3) // 1-2
1078  {
1079  float dPhi12__ = fabs(dphi[0]);
1080  float eta__ = getEta(eta, 5);
1081  float clct1__ = getCLCT(clct[0]);
1082  float clct2__ = getCLCT(clct[1]);
1083 
1084  std::cout << std::endl;
1085  std::cout << "Mode 3 Track " << endl;
1086  std::cout << std::setw(10) << "dPhi12: " << dphi[0] << std::setw(10) << dPhi12__ << std::endl;
1087  std::cout << std::setw(10) << "CLCT1: " << clct[0] << std::setw(10) << clct1__ << std::endl;
1088  std::cout << std::setw(10) << "CLCT2: " << clct[1] << std::setw(10) << clct2__ << std::endl;
1089  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1090  }
1091  if (mode==5) // 1-3
1092  {
1093  float dPhi13__ = fabs(dphi[1]);
1094  float eta__ = getEta(eta, 5);
1095  float clct1__ = getCLCT(clct[0]);
1096  float clct3__ = getCLCT(clct[2]);
1097 
1098  std::cout << std::endl;
1099  std::cout << "Mode 5 Track " << endl;
1100  std::cout << std::setw(10) << "dPhi13: " << dphi[1] << std::setw(10) << dPhi13__ << std::endl;
1101  std::cout << std::setw(10) << "CLCT1: " << clct[0] << std::setw(10) << clct1__ << std::endl;
1102  std::cout << std::setw(10) << "CLCT3: " << clct[2] << std::setw(10) << clct3__ << std::endl;
1103  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1104  }
1105  if (mode==9) // 1-4
1106  {
1107  float dPhi14__ = fabs(dphi[2]);
1108  float eta__ = getEta(eta, 5);
1109  float clct1__ = getCLCT(clct[0]);
1110  float clct4__ = getCLCT(clct[3]);
1111 
1112  std::cout << std::endl;
1113  std::cout << "Mode 9 Track " << endl;
1114  std::cout << std::setw(10) << "dPhi14: " << dphi[2] << std::setw(10) << dPhi14__ << std::endl;
1115  std::cout << std::setw(10) << "CLCT1: " << clct[0] << std::setw(10) << clct1__ << std::endl;
1116  std::cout << std::setw(10) << "CLCT4: " << clct[3] << std::setw(10) << clct4__ << std::endl;
1117  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1118  }
1119  if (mode==6) // 2-3
1120  {
1121  float dPhi23__ = fabs(dphi[3]);
1122  float eta__ = getEta(eta, 5);
1123  float clct2__ = getCLCT(clct[1]);
1124  float clct3__ = getCLCT(clct[2]);
1125 
1126  std::cout << std::endl;
1127  std::cout << "Mode 9 Track " << endl;
1128  std::cout << std::setw(10) << "dPhi23: " << dphi[3] << std::setw(10) << dPhi23__ << std::endl;
1129  std::cout << std::setw(10) << "CLCT2: " << clct[1] << std::setw(10) << clct2__ << std::endl;
1130  std::cout << std::setw(10) << "CLCT3: " << clct[2] << std::setw(10) << clct3__ << std::endl;
1131  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1132  }
1133  if (mode==10) // 2-4
1134  {
1135  float dPhi24__ = fabs(dphi[4]);
1136  float eta__ = getEta(eta, 5);
1137  float clct2__ = getCLCT(clct[1]);
1138  float clct4__ = getCLCT(clct[3]);
1139 
1140  std::cout << std::endl;
1141  std::cout << "Mode 10 Track " << endl;
1142  std::cout << std::setw(10) << "dPhi24: " << dphi[4] << std::setw(10) << dPhi24__ << std::endl;
1143  std::cout << std::setw(10) << "CLCT2: " << clct[1] << std::setw(10) << clct2__ << std::endl;
1144  std::cout << std::setw(10) << "CLCT4: " << clct[3] << std::setw(10) << clct4__ << std::endl;
1145  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1146  }
1147  if (mode==12) // 3-4
1148  {
1149  float dPhi34__ = fabs(dphi[5]);
1150  float eta__ = getEta(eta, 5);
1151  float clct3__ = getCLCT(clct[2]);
1152  float clct4__ = getCLCT(clct[3]);
1153 
1154  std::cout << std::endl;
1155  std::cout << "Mode 12 Track " << endl;
1156  std::cout << std::setw(10) << "dPhi34: " << dphi[5] << std::setw(10) << dPhi34__ << std::endl;
1157  std::cout << std::setw(10) << "CLCT3: " << clct[2] << std::setw(10) << clct3__ << std::endl;
1158  std::cout << std::setw(10) << "CLCT4: " << clct[3] << std::setw(10) << clct4__ << std::endl;
1159  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1160  }
1161 
1162  if (mode==7) // 1-2-3
1163  {
1164  float dPhi12__ = getNLBdPhi(dphi[0],7, 512);
1165  float dPhi23__ = getNLBdPhi(dphi[3],5, 256);
1166  float eta__ = getEta(eta, 5);
1167  float clct1__ = getCLCT(clct[0]);
1168  std::cout << std::endl;
1169  std::cout << "Mode 7 Track " << endl;
1170  std::cout << std::setw(10) << "dPhi12: " << dphi[0] << std::setw(10) << dPhi12__ << std::endl;
1171  std::cout << std::setw(10) << "dPhi23: " << dphi[3] << std::setw(10) << dPhi23__ << std::endl;
1172  std::cout << std::setw(10) << "CLCT1: " << clct[0] << std::setw(10) << clct1__ << std::endl;
1173  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1174  }
1175  if (mode==11) // 1-2-4
1176  {
1177  float dPhi12__ = getNLBdPhi(dphi[0],7, 512);
1178  float dPhi24__ = getNLBdPhi(dphi[4],5, 256);
1179  float eta__ = getEta(eta, 5);
1180  float clct1__ = getCLCT(clct[0]);
1181  std::cout << std::endl;
1182  std::cout << "Mode 11 Track " << endl;
1183  std::cout << std::setw(10) << "dPhi12: " << dphi[0] << std::setw(10) << dPhi12__ << std::endl;
1184  std::cout << std::setw(10) << "dPhi24: " << dphi[4] << std::setw(10) << dPhi24__ << std::endl;
1185  std::cout << std::setw(10) << "CLCT1: " << clct[0] << std::setw(10) << clct1__ << std::endl;
1186  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1187  }
1188  if (mode==13) // 1-3-4
1189  {
1190  float dPhi13__ = getNLBdPhi(dphi[1],7, 512);
1191  float dPhi34__ = getNLBdPhi(dphi[5],5, 256);
1192  float eta__ = getEta(eta, 5);
1193  float clct1__ = getCLCT(clct[0]);
1194  std::cout << std::endl;
1195  std::cout << "Mode 13 Track " << endl;
1196  std::cout << std::setw(10) << "dPhi13: " << dphi[1] << std::setw(10) << dPhi13__ << std::endl;
1197  std::cout << std::setw(10) << "dPhi34: " << dphi[5] << std::setw(10) << dPhi34__ << std::endl;
1198  std::cout << std::setw(10) << "CLCT1: " << clct[0] << std::setw(10) << clct1__ << std::endl;
1199  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1200  }
1201  if (mode==14) // 2-3-4
1202  {
1203  float dPhi23__ = getNLBdPhi(dphi[3],7, 512);
1204  float dPhi34__ = getNLBdPhi(dphi[5],5, 256);
1205  float eta__ = getEta(eta, 5);
1206  float clct2__ = getCLCT(clct[1]);
1207  std::cout << std::endl;
1208  std::cout << "Mode 14 Track " << endl;
1209  std::cout << std::setw(10) << "dPhi23: " << dphi[3] << std::setw(10) << dPhi23__ << std::endl;
1210  std::cout << std::setw(10) << "dPhi34: " << dphi[5] << std::setw(10) << dPhi34__ << std::endl;
1211  std::cout << std::setw(10) << "CLCT2: " << clct[1] << std::setw(10) << clct2__ << std::endl;
1212  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1213  }
1214  if (mode==15) //1-2-3-4
1215  {
1216  float dPhi12__ = getNLBdPhi(dphi[0],7, 512);
1217  float dPhi23__ = getNLBdPhi(dphi[3],5, 256);
1218  float dPhi34__ = getNLBdPhi(dphi[5],6, 256);
1219  float eta__ = getEta(eta, 5);
1220 
1221  std::cout << std::endl;
1222  std::cout << "Mode 15 Track " << endl;
1223  std::cout << std::setw(10) << "dPhi12: " << dphi[0] << std::setw(10) << dPhi12__ << std::endl;
1224  std::cout << std::setw(10) << "dPhi23: " << dphi[3] << std::setw(10) << dPhi23__ << std::endl;
1225  std::cout << std::setw(10) << "dPhi34: " << dphi[5] << std::setw(10) << dPhi34__ << std::endl;
1226  std::cout << std::setw(10) << "eta : " << eta << std::setw(10) << eta__ << std::endl;
1227  }
1228  }
1229 
1230  float dPhi12 = dphi[0];
1231  float dPhi13 = dphi[1];
1232  float dPhi14 = dphi[2];
1233  float dPhi23 = dphi[3];
1234  float dPhi24 = dphi[4];
1235  float dPhi34 = dphi[5];
1236  float dEta12 = deta[0];
1237  float dEta13 = deta[1];
1238  float dEta14 = deta[2];
1239  float dEta23 = deta[3];
1240  float dEta24 = deta[4];
1241  float dEta34 = deta[5];
1242  float TrackEta = eta;
1243  float CLCT1 = clct[0];
1244  float CLCT2 = clct[1];
1245  float CLCT3 = clct[2];
1246  float CLCT4 = clct[3];
1247  float FR1 = FR[0];
1248  float FR2 = FR[1];
1249  float FR3 = FR[2];
1250  float FR4 = FR[3];
1251 
1252  unsigned long Address = 0x0;
1253 
1254  if (doComp && mode==3)
1255  {
1256 
1257  int dPhi12Sign = 1;
1258  //int dEta13Sign = 1;
1259  int CLCT1Sign = 1;
1260  int CLCT2Sign = 1;
1261 
1262  if (dPhi12<0) dPhi12Sign = -1;
1263  if (CLCT1<0) CLCT1Sign = -1;
1264  if (CLCT2<0) CLCT2Sign = -1;
1265 
1266  // Make Pt LUT Address
1267  int dPhi12_ = fabs(dPhi12);
1268  int sign12_ = dPhi12Sign > 0 ? 1 : 0;
1269  int dEta12_ = getdEta(dEta12);
1270  int CLCT1_ = getCLCT(fabs(CLCT1));
1271  int CLCT1Sign_ = CLCT1Sign > 0 ? 1 : 0;
1272  int CLCT2_ = getCLCT(fabs(CLCT2));
1273  int CLCT2Sign_ = CLCT2Sign > 0 ? 1 : 0;
1274  int FR1_ = FR1;
1275  int FR2_ = FR2;
1276  int eta_ = getEtaInt(TrackEta, 5);
1277  int Mode_ = mode;
1278 
1279  Address += ( dPhi12_ & ((1<<9)-1)) << (0);
1280  Address += ( sign12_ & ((1<<1)-1)) << (0+9);
1281  Address += ( dEta12_ & ((1<<3)-1)) << (0+9+1);
1282  Address += ( CLCT1_ & ((1<<2)-1)) << (0+9+1+3);
1283  Address += ( CLCT1Sign_ & ((1<<1)-1)) << (0+9+1+3+2);
1284  Address += ( CLCT2_ & ((1<<2)-1)) << (0+9+1+3+2+1);
1285  Address += ( CLCT2Sign_ & ((1<<1)-1)) << (0+9+1+3+2+1+2);
1286  Address += ( FR1_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1);
1287  Address += ( FR2_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1+1);
1288  Address += ( eta_ & ((1<<5)-1)) << (0+9+1+3+2+1+2+1+1+1);
1289  Address += ( Mode_ & ((1<<4)-1)) << (0+9+1+3+2+1+2+1+1+1+5);
1290  }
1291 
1292  if (doComp && mode==5)
1293  {
1294  // signed full precision dPhi12
1295  int dPhi13Sign = 1;
1296  //int dEta13Sign = 1;
1297  int CLCT1Sign = 1;
1298  int CLCT3Sign = 1;
1299 
1300  if (dPhi13<0) dPhi13Sign = -1;
1301  if (CLCT1<0) CLCT1Sign = -1;
1302  if (CLCT3<0) CLCT3Sign = -1;
1303 
1304  // Make Pt LUT Address
1305  int dPhi13_ = fabs(dPhi13);
1306  int sign13_ = dPhi13Sign > 0 ? 1 : 0;
1307  int dEta13_ = getdEta(dEta13);
1308  int CLCT1_ = getCLCT(fabs(CLCT1));
1309  int CLCT1Sign_ = CLCT1Sign > 0 ? 1 : 0;
1310  int CLCT3_ = getCLCT(fabs(CLCT3));
1311  int CLCT3Sign_ = CLCT3Sign > 0 ? 1 : 0;
1312  int FR1_ = FR1;
1313  int FR3_ = FR3;
1314  int eta_ = getEtaInt(TrackEta, 5);
1315  int Mode_ = mode;
1316 
1317  Address += ( dPhi13_ & ((1<<9)-1)) << (0);
1318  Address += ( sign13_ & ((1<<1)-1)) << (0+9);
1319  Address += ( dEta13_ & ((1<<3)-1)) << (0+9+1);
1320  Address += ( CLCT1_ & ((1<<2)-1)) << (0+9+1+3);
1321  Address += ( CLCT1Sign_ & ((1<<1)-1)) << (0+9+1+3+2);
1322  Address += ( CLCT3_ & ((1<<2)-1)) << (0+9+1+3+2+1);
1323  Address += ( CLCT3Sign_ & ((1<<1)-1)) << (0+9+1+3+2+1+2);
1324  Address += ( FR1_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1);
1325  Address += ( FR3_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1+1);
1326  Address += ( eta_ & ((1<<5)-1)) << (0+9+1+3+2+1+2+1+1+1);
1327  Address += ( Mode_ & ((1<<4)-1)) << (0+9+1+3+2+1+2+1+1+1+5);
1328  }
1329 
1330  if (doComp && mode==9)
1331  {
1332  // signed full precision dPhi12
1333  int dPhi14Sign = 1;
1334  //int dEta14Sign = 1;
1335  int CLCT1Sign = 1;
1336  int CLCT4Sign = 1;
1337 
1338  if (dPhi14<0) dPhi14Sign = -1;
1339  if (CLCT1<0) CLCT1Sign = -1;
1340  if (CLCT4<0) CLCT4Sign = -1;
1341 
1342  // Make Pt LUT Address
1343  int dPhi14_ = fabs(dPhi14);
1344  int sign14_ = dPhi14Sign > 0 ? 1 : 0;
1345  int dEta14_ = getdEta(dEta14);
1346  int CLCT1_ = getCLCT(fabs(CLCT1));
1347  int CLCT1Sign_ = CLCT1Sign > 0 ? 1 : 0;
1348  int CLCT4_ = getCLCT(fabs(CLCT4));
1349  int CLCT4Sign_ = CLCT4Sign > 0 ? 1 : 0;
1350  int FR1_ = FR1;
1351  int FR4_ = FR4;
1352  int eta_ = getEtaInt(TrackEta, 5);
1353  int Mode_ = mode;
1354 
1355  Address += ( dPhi14_ & ((1<<9)-1)) << (0);
1356  Address += ( sign14_ & ((1<<1)-1)) << (0+9);
1357  Address += ( dEta14_ & ((1<<3)-1)) << (0+9+1);
1358  Address += ( CLCT1_ & ((1<<2)-1)) << (0+9+1+3);
1359  Address += ( CLCT1Sign_ & ((1<<1)-1)) << (0+9+1+3+2);
1360  Address += ( CLCT4_ & ((1<<2)-1)) << (0+9+1+3+2+1);
1361  Address += ( CLCT4Sign_ & ((1<<1)-1)) << (0+9+1+3+2+1+2);
1362  Address += ( FR1_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1);
1363  Address += ( FR4_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1+1);
1364  Address += ( eta_ & ((1<<5)-1)) << (0+9+1+3+2+1+2+1+1+1);
1365  Address += ( Mode_ & ((1<<4)-1)) << (0+9+1+3+2+1+2+1+1+1+5);
1366  }
1367  if (doComp && mode==6) // 2-3
1368  {
1369  // signed full precision dPhi12
1370  int dPhi23Sign = 1;
1371  //int dEta23Sign = 1;
1372  int CLCT2Sign = 1;
1373  int CLCT3Sign = 1;
1374 
1375  if (dPhi23<0) dPhi23Sign = -1;
1376  if (CLCT2<0) CLCT2Sign = -1;
1377  if (CLCT3<0) CLCT3Sign = -1;
1378 
1379  // Make Pt LUT Address
1380  int dPhi23_ = fabs(dPhi23);
1381  int sign23_ = dPhi23Sign > 0 ? 1 : 0;
1382  int dEta23_ = getdEta(dEta23);
1383  int CLCT2_ = getCLCT(fabs(CLCT2));
1384  int CLCT2Sign_ = CLCT2Sign > 0 ? 1 : 0;
1385  int CLCT3_ = getCLCT(fabs(CLCT3));
1386  int CLCT3Sign_ = CLCT3Sign > 0 ? 1 : 0;
1387  int FR2_ = FR2;
1388  int FR3_ = FR3;
1389  int eta_ = getEtaInt(TrackEta, 5);
1390  int Mode_ = mode;
1391 
1392  Address += ( dPhi23_ & ((1<<9)-1)) << (0);
1393  Address += ( sign23_ & ((1<<1)-1)) << (0+9);
1394  Address += ( dEta23_ & ((1<<3)-1)) << (0+9+1);
1395  Address += ( CLCT2_ & ((1<<2)-1)) << (0+9+1+3);
1396  Address += ( CLCT2Sign_ & ((1<<1)-1)) << (0+9+1+3+2);
1397  Address += ( CLCT3_ & ((1<<2)-1)) << (0+9+1+3+2+1);
1398  Address += ( CLCT3Sign_ & ((1<<1)-1)) << (0+9+1+3+2+1+2);
1399  Address += ( FR2_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1);
1400  Address += ( FR3_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1+1);
1401  Address += ( eta_ & ((1<<5)-1)) << (0+9+1+3+2+1+2+1+1+1);
1402  Address += ( Mode_ & ((1<<4)-1)) << (0+9+1+3+2+1+2+1+1+1+5);
1403  }
1404  if (doComp && mode==10) // 2-4
1405  {
1406  // signed full precision dPhi12
1407  int dPhi24Sign = 1;
1408  //int dEta24Sign = 1;
1409  int CLCT2Sign = 1;
1410  int CLCT4Sign = 1;
1411 
1412  if (dPhi24<0) dPhi24Sign = -1;
1413  if (CLCT2<0) CLCT2Sign = -1;
1414  if (CLCT4<0) CLCT4Sign = -1;
1415 
1416  // Make Pt LUT Address
1417  int dPhi24_ = fabs(dPhi24);
1418  int sign24_ = dPhi24Sign > 0 ? 1 : 0;
1419  int dEta24_ = getdEta(dEta24);
1420  int CLCT2_ = getCLCT(fabs(CLCT2));
1421  int CLCT2Sign_ = CLCT2Sign > 0 ? 1 : 0;
1422  int CLCT4_ = getCLCT(fabs(CLCT4));
1423  int CLCT4Sign_ = CLCT4Sign > 0 ? 1 : 0;
1424  int FR2_ = FR2;
1425  int FR3_ = FR3;
1426  int eta_ = getEtaInt(TrackEta, 5);
1427  int Mode_ = mode;
1428 
1429  Address += ( dPhi24_ & ((1<<9)-1)) << (0);
1430  Address += ( sign24_ & ((1<<1)-1)) << (0+9);
1431  Address += ( dEta24_ & ((1<<3)-1)) << (0+9+1);
1432  Address += ( CLCT2_ & ((1<<2)-1)) << (0+9+1+3);
1433  Address += ( CLCT2Sign_ & ((1<<1)-1)) << (0+9+1+3+2);
1434  Address += ( CLCT4_ & ((1<<2)-1)) << (0+9+1+3+2+1);
1435  Address += ( CLCT4Sign_ & ((1<<1)-1)) << (0+9+1+3+2+1+2);
1436  Address += ( FR2_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1);
1437  Address += ( FR3_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1+1);
1438  Address += ( eta_ & ((1<<5)-1)) << (0+9+1+3+2+1+2+1+1+1);
1439  Address += ( Mode_ & ((1<<4)-1)) << (0+9+1+3+2+1+2+1+1+1+5);
1440  }
1441  if (doComp && mode==12) // 3-4
1442  {
1443  int dPhi34Sign = 1;
1444  //int dEta34Sign = 1;
1445  int CLCT3Sign = 1;
1446  int CLCT4Sign = 1;
1447 
1448  if (dPhi34<0) dPhi34Sign = -1;
1449  if (CLCT3<0) CLCT3Sign = -1;
1450  if (CLCT4<0) CLCT4Sign = -1;
1451 
1452  // Make Pt LUT Address
1453  int dPhi34_ = fabs(dPhi34);
1454  int sign34_ = dPhi34Sign > 0 ? 1 : 0;
1455  int dEta34_ = getdEta(dEta34);
1456  int CLCT3_ = getCLCT(fabs(CLCT3));
1457  int CLCT3Sign_ = CLCT3Sign > 0 ? 1 : 0;
1458  int CLCT4_ = getCLCT(fabs(CLCT4));
1459  int CLCT4Sign_ = CLCT4Sign > 0 ? 1 : 0;
1460  int FR3_ = FR3;
1461  int FR4_ = FR4;
1462  int eta_ = getEtaInt(TrackEta, 5);
1463  int Mode_ = mode;
1464 
1465  Address += ( dPhi34_ & ((1<<9)-1)) << (0);
1466  Address += ( sign34_ & ((1<<1)-1)) << (0+9);
1467  Address += ( dEta34_ & ((1<<3)-1)) << (0+9+1);
1468  Address += ( CLCT3_ & ((1<<2)-1)) << (0+9+1+3);
1469  Address += ( CLCT3Sign_ & ((1<<1)-1)) << (0+9+1+3+2);
1470  Address += ( CLCT4_ & ((1<<2)-1)) << (0+9+1+3+2+1);
1471  Address += ( CLCT4Sign_ & ((1<<1)-1)) << (0+9+1+3+2+1+2);
1472  Address += ( FR3_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1);
1473  Address += ( FR4_ & ((1<<1)-1)) << (0+9+1+3+2+1+2+1+1);
1474  Address += ( eta_ & ((1<<5)-1)) << (0+9+1+3+2+1+2+1+1+1);
1475  Address += ( Mode_ & ((1<<4)-1)) << (0+9+1+3+2+1+2+1+1+1+5);
1476  }
1477 
1478  if (doComp && mode==7) // 1-2-3
1479  {
1480  int dPhi12Sign = 1;
1481  int dPhi23Sign = 1;
1482  //int dPhi34Sign = 1;
1483  //int dEta13Sign = 1;
1484  int CLCT1Sign = 1;
1485 
1486  if (dPhi12<0) dPhi12Sign = -1;
1487  if (dPhi23<0) dPhi23Sign = -1;
1488  //if (dPhi34<0) dPhi34Sign = -1;
1489  if (CLCT1<0) CLCT1Sign = -1;
1490 
1491  // Make Pt LUT Address
1492  int dPhi12_ = getNLBdPhiBin(dPhi12, 7, 512);
1493  int dPhi23_ = getNLBdPhiBin(dPhi23, 5, 256);
1494  int sign12_ = dPhi12Sign > 0 ? 1 : 0;
1495  int sign23_ = dPhi23Sign > 0 ? 1 : 0;
1496  int dEta13_ = getdEta(dEta13);
1497  int CLCT1_ = getCLCT(fabs(CLCT1));
1498  int CLCT1Sign_ = CLCT1Sign > 0 ? 1 : 0;
1499  int FR1_ = FR1;
1500  int eta_ = getEtaInt(TrackEta, 5);
1501  int Mode_ = mode;
1502 
1503  Address += ( dPhi12_ & ((1<<7)-1)) << (0);
1504  Address += ( dPhi23_ & ((1<<5)-1)) << (0+7);
1505  Address += ( sign12_ & ((1<<1)-1)) << (0+7+5);
1506  Address += ( sign23_ & ((1<<1)-1)) << (0+7+5+1);
1507  Address += ( dEta13_ & ((1<<3)-1)) << (0+7+5+1+1);
1508  Address += ( CLCT1_ & ((1<<2)-1)) << (0+7+5+1+1+3);
1509  Address += ( CLCT1Sign_ & ((1<<1)-1)) << (0+7+5+1+1+3+2);
1510  Address += ( FR1_ & ((1<<1)-1)) << (0+7+5+1+1+3+2+1);
1511  Address += ( eta_ & ((1<<5)-1)) << (0+7+5+1+1+3+2+1+1);
1512  Address += ( Mode_ & ((1<<4)-1)) << (0+7+5+1+1+3+2+1+1+5);
1513  }
1514 
1515  if (doComp && mode==11)
1516  {
1517  int dPhi12Sign = 1;
1518  int dPhi24Sign = 1;
1519  //int dEta14Sign = 1;
1520  int CLCT1Sign = 1;
1521 
1522  if (dPhi12<0) dPhi12Sign = -1;
1523  if (dPhi24<0) dPhi24Sign = -1;
1524  if (CLCT1<0) CLCT1Sign = -1;
1525 
1526  // Make Pt LUT Address
1527  int dPhi12_ = getNLBdPhiBin(dPhi12, 7, 512);
1528  int dPhi24_ = getNLBdPhiBin(dPhi24, 5, 256);
1529  int sign12_ = dPhi12Sign > 0 ? 1 : 0;
1530  int sign24_ = dPhi24Sign > 0 ? 1 : 0;
1531  int dEta14_ = getdEta(dEta14);
1532  int CLCT1_ = getCLCT(fabs(CLCT1));
1533  int CLCT1Sign_ = CLCT1Sign > 0 ? 1 : 0;
1534  int FR1_ = FR1;
1535  int eta_ = getEtaInt(TrackEta, 5);
1536  int Mode_ = mode;
1537 
1538  Address += ( dPhi12_ & ((1<<7)-1)) << (0);
1539  Address += ( dPhi24_ & ((1<<5)-1)) << (0+7);
1540  Address += ( sign12_ & ((1<<1)-1)) << (0+7+5);
1541  Address += ( sign24_ & ((1<<1)-1)) << (0+7+5+1);
1542  Address += ( dEta14_ & ((1<<3)-1)) << (0+7+5+1+1);
1543  Address += ( CLCT1_ & ((1<<2)-1)) << (0+7+5+1+1+3);
1544  Address += ( CLCT1Sign_ & ((1<<1)-1)) << (0+7+5+1+1+3+2);
1545  Address += ( FR1_ & ((1<<1)-1)) << (0+7+5+1+1+3+2+1);
1546  Address += ( eta_ & ((1<<5)-1)) << (0+7+5+1+1+3+2+1+1);
1547  Address += ( Mode_ & ((1<<4)-1)) << (0+7+5+1+1+3+2+1+1+5);
1548  }
1549  if (doComp && mode==13) // 1-3-4
1550  {
1551  int dPhi13Sign = 1;
1552  int dPhi34Sign = 1;
1553  //int dEta14Sign = 1;
1554  int CLCT1Sign = 1;
1555 
1556  if (dPhi13<0) dPhi13Sign = -1;
1557  if (dPhi34<0) dPhi34Sign = -1;
1558  if (CLCT1<0) CLCT1Sign = -1;
1559 
1560  // Make Pt LUT Address
1561  int dPhi13_ = getNLBdPhiBin(dPhi13, 7, 512);
1562  int dPhi34_ = getNLBdPhiBin(dPhi34, 5, 256);
1563  int sign13_ = dPhi13Sign > 0 ? 1 : 0;
1564  int sign34_ = dPhi34Sign > 0 ? 1 : 0;
1565  int dEta14_ = getdEta(dEta14);
1566  int CLCT1_ = getCLCT(fabs(CLCT1));
1567  int CLCT1Sign_ = CLCT1Sign > 0 ? 1 : 0;
1568  int FR1_ = FR1;
1569  int eta_ = getEtaInt(TrackEta, 5);
1570  int Mode_ = mode;
1571 
1572  Address += ( dPhi13_ & ((1<<7)-1)) << (0);
1573  Address += ( dPhi34_ & ((1<<5)-1)) << (0+7);
1574  Address += ( sign13_ & ((1<<1)-1)) << (0+7+5);
1575  Address += ( sign34_ & ((1<<1)-1)) << (0+7+5+1);
1576  Address += ( dEta14_ & ((1<<3)-1)) << (0+7+5+1+1);
1577  Address += ( CLCT1_ & ((1<<2)-1)) << (0+7+5+1+1+3);
1578  Address += ( CLCT1Sign_ & ((1<<1)-1)) << (0+7+5+1+1+3+2);
1579  Address += ( FR1_ & ((1<<1)-1)) << (0+7+5+1+1+3+2+1);
1580  Address += ( eta_ & ((1<<5)-1)) << (0+7+5+1+1+3+2+1+1);
1581  Address += ( Mode_ & ((1<<4)-1)) << (0+7+5+1+1+3+2+1+1+5);
1582  }
1583 
1584  if (doComp && mode==14) // 2-3-4
1585  {
1586  int dPhi23Sign = 1;
1587  int dPhi34Sign = 1;
1588  //int dEta24Sign = 1;
1589  int CLCT2Sign = 1;
1590 
1591  if (dPhi23<0) dPhi23Sign = -1;
1592  if (dPhi34<0) dPhi34Sign = -1;
1593  if (CLCT2<0) CLCT2Sign = -1;
1594 
1595  // Make Pt LUT Address
1596  int dPhi23_ = getNLBdPhiBin(dPhi23, 7, 512);
1597  int dPhi34_ = getNLBdPhiBin(dPhi34, 5, 256);
1598  int sign23_ = dPhi23Sign > 0 ? 1 : 0;
1599  int sign34_ = dPhi34Sign > 0 ? 1 : 0;
1600  int dEta24_ = getdEta(dEta24);
1601  int CLCT2_ = getCLCT(fabs(CLCT2));
1602  int CLCT2Sign_ = CLCT2Sign > 0 ? 1 : 0;
1603  int eta_ = getEtaInt(TrackEta, 5);
1604  int Mode_ = mode;
1605 
1606  Address += ( dPhi23_ & ((1<<7)-1)) << (0);
1607  Address += ( dPhi34_ & ((1<<6)-1)) << (0+7);
1608  Address += ( sign23_ & ((1<<1)-1)) << (0+7+6);
1609  Address += ( sign34_ & ((1<<1)-1)) << (0+7+6+1);
1610  Address += ( dEta24_ & ((1<<3)-1)) << (0+7+6+1+1);
1611  Address += ( CLCT2_ & ((1<<2)-1)) << (0+7+6+1+1+3);
1612  Address += ( CLCT2Sign_ & ((1<<1)-1)) << (0+7+6+1+1+3+2);
1613  Address += ( eta_ & ((1<<5)-1)) << (0+7+6+1+1+3+2+1);
1614  Address += ( Mode_ & ((1<<4)-1)) << (0+7+6+1+1+3+2+1+5);
1615  }
1616 
1617  if (doComp && mode==15) // 1-2-3-4
1618  {
1619  int dPhi12Sign = 1;
1620  int dPhi23Sign = 1;
1621  int dPhi34Sign = 1;
1622 
1623  if (dPhi12<0) dPhi12Sign = -1;
1624  if (dPhi23<0) dPhi23Sign = -1;
1625  if (dPhi34<0) dPhi34Sign = -1;
1626 
1627  if (dPhi12Sign==-1 && dPhi23Sign==-1 && dPhi34Sign==-1)
1628  { dPhi12Sign=1;dPhi23Sign=1;dPhi34Sign=1;}
1629  else if (dPhi12Sign==-1 && dPhi23Sign==1 && dPhi34Sign==1)
1630  { dPhi12Sign=1;dPhi23Sign=-1;dPhi34Sign=-1;}
1631  else if (dPhi12Sign==-1 && dPhi23Sign==-1 && dPhi34Sign==1)
1632  { dPhi12Sign=1;dPhi23Sign=1;dPhi34Sign=-1;}
1633  else if (dPhi12Sign==-1 && dPhi23Sign==1 && dPhi34Sign==-1)
1634  { dPhi12Sign=1;dPhi23Sign=-1;dPhi34Sign=1;}
1635 
1636  // Make Pt LUT Address
1637  int dPhi12_ = getNLBdPhiBin(dPhi12, 7, 512);
1638  int dPhi23_ = getNLBdPhiBin(dPhi23, 5, 256);
1639  int dPhi34_ = getNLBdPhiBin(dPhi34, 6, 256);
1640  int sign23_ = dPhi23Sign > 0 ? 1 : 0;
1641  int sign34_ = dPhi34Sign > 0 ? 1 : 0;
1642  int FR1_ = FR1;
1643  int eta_ = getEtaInt(TrackEta, 5);
1644  int Mode_ = mode;
1645 
1646  Address += ( dPhi12_ & ((1<<7)-1)) << 0;
1647  Address += ( dPhi23_ & ((1<<5)-1)) << (0+7);
1648  Address += ( dPhi34_ & ((1<<6)-1)) << (0+7+5);
1649  Address += ( sign23_ & ((1<<1)-1)) << (0+7+5+6);
1650  Address += ( sign34_ & ((1<<1)-1)) << (0+7+5+6+1);
1651  Address += ( FR1_ & ((1<<1)-1)) << (0+7+5+6+1+1);
1652  Address += ( eta_ & ((1<<5)-1)) << (0+7+5+6+1+1+1);
1653  Address += ( Mode_ & ((1<<4)-1)) << (0+7+5+6+1+1+1+5);
1654  }
1655 
1656  return getPt(Address);
1657 }
1658 
1659 
1660 
int getNLBdPhiBin(float dPhi, int bits, int max=512)
Definition: PtAssignment.h:197
int i
Definition: DBlmapReader.cc:9
int ModeVariables_Scheme3[13][6]
Definition: PtAssignment.h:75
const TriggerPrimitiveStationMap & getStubs() const
void makeLUT()
Definition: PtAssignment.h:862
float getMaxPT(float ptHyp, Int_t eta, float dPhi12, float dPhi23, float dPhi34, int perCUT=100)
Definition: getMaxPt.h:192
float getNLBdPhi(float dPhi, int bits, int max=512)
Definition: PtAssignment.h:126
float getdPhiFromBin(int dPhiBin, int bits, int max=512)
Definition: PtAssignment.h:261
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:52
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
const int dPhiNLBMap_7bit_256Max[128]
Definition: PtAssignment.h:102
int getEtaInt(float eta, int bits=5)
Definition: PtAssignment.h:380
float getPt(unsigned long Address)
Definition: PtAssignment.h:410
void predictEvents(std::vector< Event * > eventsp, unsigned int trees)
Definition: Forest.cc:382
int doComp
Definition: PtAssignment.h:27
float getCLCT(float clct)
Definition: PtAssignment.h:291
static const double pts[33]
Definition: Constants.h:30
float getdEta(float deta)
Definition: PtAssignment.h:334
T x() const
Cartesian x coordinate.
const int dPhiNLBMap_7bit[128]
Definition: PtAssignment.h:116
float CalculatePt(L1TMuon::InternalTrack track, const edm::EventSetup &es)
Definition: PtAssignment.h:958
int whichScheme
Definition: PtAssignment.h:30
double dPhi(double phi1, double phi2)
Definition: JetUtil.h:30
T z() const
Definition: PV3DBase.h:64
const int dPhiNLBMap_5bit_256Max[32]
Definition: PtAssignment.h:98
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
int j
Definition: DBlmapReader.cc:9
const int dPhiNLBMap_8bit_512Max[256]
Definition: PtAssignment.h:108
double f[11][100]
int useCorr
Definition: PtAssignment.h:26
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 and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
globcontrol glc
Definition: vlib.cc:6
std::vector< int > phis
const char * dirSchemeC
Definition: PtAssignment.h:92
const T & get() const
Definition: EventSetup.h:56
Definition: Forest.h:9
float getEtafromBin(int etaBin, int bits=5)
Definition: PtAssignment.h:395
const int dPhiNLBMap_6bit_256Max[64]
Definition: PtAssignment.h:100
static unsigned int const shift
float getEta(float eta, int bits=5)
Definition: PtAssignment.h:364
tuple cout
Definition: gather_cfg.py:145
dbl *** dir
Definition: mlp_gen.cc:35
std::map< unsigned, TriggerPrimitiveCollection > TriggerPrimitiveStationMap
int makeLUT_
Definition: PtAssignment.h:28
const Double_t ptscale[31]
Definition: PtAssignment.h:20
const int dPhiNLBMap_7bit_512Max[256]
Definition: PtAssignment.h:106
const int dPhiNLBMap_8bit[256]
Definition: PtAssignment.h:121
tuple size
Write out results.
const int dPhiNLBMap_5bit[32]
Definition: PtAssignment.h:111