CMS 3D CMS Logo

PtAssignmentEngineAux.cc
Go to the documentation of this file.
2 
3 // _____________________________________________________________________________
4 static const int GMT_eta_from_theta[128] = {
5  239, 235, 233, 230, 227, 224, 222, 219, 217, 214, 212, 210, 207, 205, 203, 201, 199, 197, 195, 193, 191, 189,
6  187, 186, 184, 182, 180, 179, 177, 176, 174, 172, 171, 169, 168, 166, 165, 164, 162, 161, 160, 158, 157, 156,
7  154, 153, 152, 151, 149, 148, 147, 146, 145, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133, 132, 131,
8  130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 116, 115, 114, 113, 112, 111, 110,
9  110, 109, 108, 107, 106, 106, 105, 104, 103, 102, 102, 101, 100, 99, 99, 98, 97, 96, 96, 95, 94, 93,
10  93, 92, 91, 91, 90, 89, 89, 88, 87, 87, 86, 85, 84, 84, 83, 83, 82, 81};
11 
13  // compressed pt = pt*2 (scale) + 1 (pt = 0 is empty candidate)
14  int gmt_pt = (pt * 2) + 1;
15  gmt_pt = (gmt_pt > 511) ? 511 : gmt_pt;
16  return gmt_pt;
17 }
18 
20  // compressed pt = pt*1 (scale) + 1 (pt = 0 is empty candidate)
21  int gmt_pt_dxy = (pt * 1) + 1;
22  gmt_pt_dxy = (gmt_pt_dxy > 255) ? 255 : gmt_pt_dxy;
23  return gmt_pt_dxy;
24 }
25 
27  int gmt_dxy = 0;
28  if (std::abs(dxy) < 25.) {
29  gmt_dxy = 0;
30  } else if (std::abs(dxy) < 50.) {
31  gmt_dxy = 1;
32  } else if (std::abs(dxy) < 75.) {
33  gmt_dxy = 2;
34  } else {
35  gmt_dxy = 3;
36  }
37  return gmt_dxy;
38 }
39 
40 float PtAssignmentEngineAux::getPtFromGMTPt(int gmt_pt) const {
41  float pt = (gmt_pt <= 0) ? 0 : 0.5 * (gmt_pt - 1);
42  return pt;
43 }
44 
45 float PtAssignmentEngineAux::getPtFromGMTPtDxy(int gmt_pt_dxy) const {
46  float pt = (gmt_pt_dxy <= 0) ? 0 : 1.0 * (gmt_pt_dxy - 1);
47  return pt;
48 }
49 
51  // convert phi into gmt scale according to DN15-017
52  // full scale is -16 to 100, or 116 values, covers range -10 to 62.5 deg
53  // my internal ph scale is 0..5000, covers from -22 to 63.333 deg
54  // converted to GMT scale it is from -35 to 95
55  // bt_phi * 107.01/4096, equivalent to bt_phi * 6849/0x40000
56  phi *= 6849;
57  phi >>= 18; // divide by 0x40000
58  phi -= 35; // offset of -22 deg
59  return phi;
60 }
61 
63  // convert phi into gmt scale according to DN15-017
64  phi *= 6991;
65  phi >>= 18; // divide by 0x40000
66  phi -= 35; // offset of -22 deg
67  return phi;
68 }
69 
70 int PtAssignmentEngineAux::getGMTEta(int theta, int endcap) const { // [-1,+1]
71  if (theta < 0)
72  return 0;
73  if (endcap == -1 && theta > 127)
74  return -240;
75  if (endcap == +1 && theta > 127)
76  return 239;
77 
79  if (endcap == -1)
80  eta = -eta;
81  return eta;
82 }
83 
84 int PtAssignmentEngineAux::getGMTQuality(int mode, int theta, bool promoteMode7, int version) const {
85  int quality = 0;
86 
87  if (version == 2) { // 2018 mode <--> quality mapping
88  switch (mode) {
89  case 15:
90  quality = 15;
91  break;
92  case 14:
93  quality = 14;
94  break;
95  case 13:
96  quality = 13;
97  break;
98  case 12:
99  quality = 7;
100  break;
101  case 11:
102  quality = 12;
103  break;
104  case 10:
105  quality = 10;
106  break;
107  case 9:
108  quality = 9;
109  break;
110  case 7:
111  quality = 11;
112  break;
113  case 6:
114  quality = 6;
115  break;
116  case 5:
117  quality = 5;
118  break;
119  case 3:
120  quality = 4;
121  break;
122  default:
123  quality = 0;
124  break;
125  }
126 
127  if (theta > 88) { // if (eta < 1.19)
128  quality /= 4;
129  }
130  } // End 2018 mode <--> quality mapping
131 
132  else { // 2016 and 2017 mode <--> quality mapping
133  if (theta > 87) { // if (eta < 1.2)
134  switch (mode) {
135  case 15:
136  quality = 8;
137  break;
138  case 14:
139  quality = 4;
140  break;
141  case 13:
142  quality = 4;
143  break;
144  case 12:
145  quality = 4;
146  break;
147  case 11:
148  quality = 4;
149  break;
150  default:
151  quality = 4;
152  break;
153  }
154  } else {
155  switch (mode) {
156  case 15:
157  quality = 12;
158  break;
159  case 14:
160  quality = 12;
161  break;
162  case 13:
163  quality = 12;
164  break;
165  case 12:
166  quality = 8;
167  break;
168  case 11:
169  quality = 12;
170  break;
171  case 10:
172  quality = 8;
173  break;
174  case 7:
175  quality = 8;
176  break;
177  default:
178  quality = 4;
179  break;
180  }
181  }
182  quality |= (mode & 3);
183  } // End 2016 and 2017 mode <--> quality mapping
184 
185  // Fix for missing CSC LCTs in ME1/1, including dead "water-leak" chambers ME1/1/34 and 35
186  if (promoteMode7 && mode == 7 && theta <= 50)
187  quality = 12;
188 
189  return quality;
190 }
191 
192 std::pair<int, int> PtAssignmentEngineAux::getGMTCharge(int mode, const std::vector<int>& phidiffs) const {
193  // -1 = postive physical charge to match pdgId code (i.e. -13 is positive, anti-muon). +1 = negative physical charge.
194  // Also matches DN-2015/017 format for track finder --> uGMT interface format, where 0 indicates positive, 1 negative.
195  int emuCharge = 0;
196 
197  // Note: sign_ph[0] == 1 in firmware actually translates to phidiffs[0] >= 0 (instead of phidiffs[0] > 0 in the old emulator)
198  // The effect needs to be checked
199 
200  switch (mode) {
201  case 15: // 1-2-3-4
202  if (phidiffs[0] >= 0) // 1-2 (should use > 0)
203  emuCharge = 1;
204  else if (phidiffs[0] == 0 && phidiffs[1] < 0) // 1-3
205  emuCharge = 1;
206  else if (phidiffs[1] == 0 && phidiffs[2] < 0) // 1-4
207  emuCharge = 1;
208  else
209  emuCharge = -1;
210  break;
211 
212  case 14: // 1-2-3
213  if (phidiffs[0] < 0) // 1-2
214  emuCharge = -1;
215  else if (phidiffs[0] == 0 && phidiffs[1] < 0) // 1-3
216  emuCharge = -1;
217  else
218  emuCharge = 1;
219  break;
220 
221  case 13: // 1-2-4
222  if (phidiffs[0] >= 0) // 1-2 (should use > 0)
223  emuCharge = 1;
224  else if (phidiffs[0] == 0 && phidiffs[2] < 0) // 1-4
225  emuCharge = 1;
226  else
227  emuCharge = -1;
228  break;
229 
230  case 12: // 1-2
231  if (phidiffs[0] >= 0) // 1-2
232  emuCharge = 1;
233  else
234  emuCharge = -1;
235  break;
236 
237  case 11: // 1-3-4
238  if (phidiffs[1] >= 0) // 1-3 (should use > 0)
239  emuCharge = 1;
240  else if (phidiffs[1] == 0 && phidiffs[2] < 0) // 1-4
241  emuCharge = 1;
242  else
243  emuCharge = -1;
244  break;
245 
246  case 10: // 1-3
247  if (phidiffs[1] >= 0) // 1-3
248  emuCharge = 1;
249  else
250  emuCharge = -1;
251  break;
252 
253  case 9: // 1-4
254  if (phidiffs[2] >= 0) // 1-4
255  emuCharge = 1;
256  else
257  emuCharge = -1;
258  break;
259 
260  case 7: // 2-3-4
261  if (phidiffs[3] >= 0) // 2-3 (should use > 0)
262  emuCharge = 1;
263  else if (phidiffs[3] == 0 && phidiffs[4] < 0) // 2-4
264  emuCharge = 1;
265  else
266  emuCharge = -1;
267  break;
268 
269  case 6: // 2-3
270  if (phidiffs[3] >= 0) // 2-3
271  emuCharge = 1;
272  else
273  emuCharge = -1;
274  break;
275 
276  case 5: // 2-4
277  if (phidiffs[4] >= 0) // 2-4
278  emuCharge = 1;
279  else
280  emuCharge = -1;
281  break;
282 
283  case 3: // 3-4
284  if (phidiffs[5] >= 0) // 3-4
285  emuCharge = 1;
286  else
287  emuCharge = -1;
288  break;
289 
290  default:
291  //emuCharge = -1;
292  emuCharge = 0;
293  break;
294  }
295 
296  int charge = 0;
297  if (emuCharge == 1)
298  charge = 1;
299 
300  int charge_valid = 1;
301  if (emuCharge == 0)
302  charge_valid = 0;
303  return std::make_pair(charge, charge_valid);
304 }
int getGMTPtDxy(float pt) const
float getPtFromGMTPt(int gmt_pt) const
int getGMTQuality(int mode, int theta, bool promoteMode7, int version) const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int getGMTPt(float pt) const
std::pair< int, int > getGMTCharge(int mode, const std::vector< int > &phidiffs) const
int getGMTEta(int theta, int endcap) const
int getGMTPhi(int phi) const
int getGMTPhiV2(int phi) const
string quality
int getGMTDxy(float dxy) const
Geom::Theta< T > theta() const
static const int GMT_eta_from_theta[128]
float getPtFromGMTPtDxy(int gmt_pt_dxy) const