test
CMS 3D CMS Logo

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