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,
6  199, 197, 195, 193, 191, 189, 187, 186, 184, 182, 180, 179, 177, 176, 174, 172,
7  171, 169, 168, 166, 165, 164, 162, 161, 160, 158, 157, 156, 154, 153, 152, 151,
8  149, 148, 147, 146, 145, 143, 142, 141, 140, 139, 138, 137, 136, 135, 134, 133,
9  132, 131, 130, 129, 128, 127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117,
10  116, 116, 115, 114, 113, 112, 111, 110, 110, 109, 108, 107, 106, 106, 105, 104,
11  103, 102, 102, 101, 100, 99, 99, 98, 97, 96, 96, 95, 94, 93, 93, 92,
12  91, 91, 90, 89, 89, 88, 87, 87, 86, 85, 84, 84, 83, 83, 82, 81
13 };
14 
16  // compressed pt = pt*2 (scale) + 1 (pt = 0 is empty candidate)
17  int gmt_pt = (pt * 2) + 1;
18  gmt_pt = (gmt_pt > 511) ? 511 : gmt_pt;
19  return gmt_pt;
20 }
21 
22 float PtAssignmentEngineAux::getPtFromGMTPt(int gmt_pt) const {
23  float pt = (gmt_pt <= 0) ? 0 : 0.5 * (gmt_pt-1);
24  return pt;
25 }
26 
28  // convert phi into gmt scale according to DN15-017
29  // full scale is -16 to 100, or 116 values, covers range -10 to 62.5 deg
30  // my internal ph scale is 0..5000, covers from -22 to 63.333 deg
31  // converted to GMT scale it is from -35 to 95
32  // bt_phi * 107.01/4096, equivalent to bt_phi * 6849/0x40000
33  phi *= 6849;
34  phi >>= 18; // divide by 0x40000
35  phi -= 35; // offset of -22 deg
36  return phi;
37 }
38 
40  // convert phi into gmt scale according to DN15-017
41  phi *= 6991;
42  phi >>= 18; // divide by 0x40000
43  phi -= 35; // offset of -22 deg
44  return phi;
45 }
46 
47 int PtAssignmentEngineAux::getGMTEta(int theta, int endcap) const { // [-1,+1]
48  if (theta < 0)
49  return 0;
50  if (endcap == -1 && theta > 127)
51  return -240;
52  if (endcap == +1 && theta > 127)
53  return 239;
54 
56  if (endcap == -1)
57  eta = -eta;
58  return eta;
59 }
60 
61 int PtAssignmentEngineAux::getGMTQuality(int mode, int theta, bool promoteMode7, int version) const {
62  int quality = 0;
63 
64  if (version == 2) { // 2018 mode <--> quality mapping
65  switch (mode) {
66  case 15: quality = 15; break;
67  case 14: quality = 14; break;
68  case 13: quality = 13; break;
69  case 12: quality = 7; break;
70  case 11: quality = 12; break;
71  case 10: quality = 10; break;
72  case 9: quality = 9; break;
73  case 7: quality = 11; break;
74  case 6: quality = 6; break;
75  case 5: quality = 5; break;
76  case 3: quality = 4; break;
77  default: quality = 0; break;
78  }
79 
80  if (theta > 88) { // if (eta < 1.19)
81  quality /= 4;
82  }
83  } // End 2018 mode <--> quality mapping
84 
85  else { // 2016 and 2017 mode <--> quality mapping
86  if (theta > 87) { // if (eta < 1.2)
87  switch (mode) {
88  case 15: quality = 8; break;
89  case 14: quality = 4; break;
90  case 13: quality = 4; break;
91  case 12: quality = 4; break;
92  case 11: quality = 4; break;
93  default: quality = 4; break;
94  }
95  } else {
96  switch (mode) {
97  case 15: quality = 12; break;
98  case 14: quality = 12; break;
99  case 13: quality = 12; break;
100  case 12: quality = 8; break;
101  case 11: quality = 12; break;
102  case 10: quality = 8; break;
103  case 7: quality = 8; break;
104  default: quality = 4; break;
105  }
106  }
107  quality |= (mode & 3);
108  } // End 2016 and 2017 mode <--> quality mapping
109 
110  // Fix for missing CSC LCTs in ME1/1, including dead "water-leak" chambers ME1/1/34 and 35
111  if (promoteMode7 && mode == 7 && theta <= 50)
112  quality = 12;
113 
114  return quality;
115 }
116 
117 std::pair<int,int> PtAssignmentEngineAux::getGMTCharge(int mode, const std::vector<int>& phidiffs) const {
118  // -1 = postive physical charge to match pdgId code (i.e. -13 is positive, anti-muon). +1 = negative physical charge.
119  // Also matches DN-2015/017 format for track finder --> uGMT interface format, where 0 indicates positive, 1 negative.
120  int emuCharge = 0;
121 
122  // Note: sign_ph[0] == 1 in firmware actually translates to phidiffs[0] >= 0 (instead of phidiffs[0] > 0 in the old emulator)
123  // The effect needs to be checked
124 
125  switch (mode) {
126  case 15: // 1-2-3-4
127  if (phidiffs[0] >= 0) // 1-2 (should use > 0)
128  emuCharge = 1;
129  else if (phidiffs[0] == 0 && phidiffs[1] < 0) // 1-3
130  emuCharge = 1;
131  else if (phidiffs[1] == 0 && phidiffs[2] < 0) // 1-4
132  emuCharge = 1;
133  else
134  emuCharge = -1;
135  break;
136 
137  case 14: // 1-2-3
138  if (phidiffs[0] < 0) // 1-2
139  emuCharge = -1;
140  else if (phidiffs[0] == 0 && phidiffs[1] < 0) // 1-3
141  emuCharge = -1;
142  else
143  emuCharge = 1;
144  break;
145 
146  case 13: // 1-2-4
147  if (phidiffs[0] >= 0) // 1-2 (should use > 0)
148  emuCharge = 1;
149  else if (phidiffs[0] == 0 && phidiffs[2] < 0) // 1-4
150  emuCharge = 1;
151  else
152  emuCharge = -1;
153  break;
154 
155  case 12: // 1-2
156  if (phidiffs[0] >= 0) // 1-2
157  emuCharge = 1;
158  else
159  emuCharge = -1;
160  break;
161 
162  case 11: // 1-3-4
163  if (phidiffs[1] >= 0) // 1-3 (should use > 0)
164  emuCharge = 1;
165  else if (phidiffs[1] == 0 && phidiffs[2] < 0) // 1-4
166  emuCharge = 1;
167  else
168  emuCharge = -1;
169  break;
170 
171  case 10: // 1-3
172  if (phidiffs[1] >= 0) // 1-3
173  emuCharge = 1;
174  else
175  emuCharge = -1;
176  break;
177 
178  case 9: // 1-4
179  if (phidiffs[2] >= 0) // 1-4
180  emuCharge = 1;
181  else
182  emuCharge = -1;
183  break;
184 
185  case 7: // 2-3-4
186  if (phidiffs[3] >= 0) // 2-3 (should use > 0)
187  emuCharge = 1;
188  else if (phidiffs[3] == 0 && phidiffs[4] < 0) // 2-4
189  emuCharge = 1;
190  else
191  emuCharge = -1;
192  break;
193 
194  case 6: // 2-3
195  if (phidiffs[3] >= 0) // 2-3
196  emuCharge = 1;
197  else
198  emuCharge = -1;
199  break;
200 
201  case 5: // 2-4
202  if (phidiffs[4] >= 0) // 2-4
203  emuCharge = 1;
204  else
205  emuCharge = -1;
206  break;
207 
208  case 3: // 3-4
209  if (phidiffs[5] >= 0) // 3-4
210  emuCharge = 1;
211  else
212  emuCharge = -1;
213  break;
214 
215  default:
216  //emuCharge = -1;
217  emuCharge = 0;
218  break;
219  }
220 
221  int charge = 0;
222  if (emuCharge == 1)
223  charge = 1;
224 
225  int charge_valid = 1;
226  if (emuCharge == 0)
227  charge_valid = 0;
228  return std::make_pair(charge, charge_valid);
229 }
int getGMTPhiV2(int phi) const
int getGMTEta(int theta, int endcap) const
Geom::Theta< T > theta() const
std::pair< int, int > getGMTCharge(int mode, const std::vector< int > &phidiffs) const
int getGMTPhi(int phi) const
float getPtFromGMTPt(int gmt_pt) const
int getGMTPt(float pt) const
static const int GMT_eta_from_theta[128]
int getGMTQuality(int mode, int theta, bool promoteMode7, int version) const