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