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) const {
62  int quality = 0;
63  if (theta > 87) { // if (eta < 1.2)
64  switch (mode) {
65  case 15: quality = 8; break;
66  case 14: quality = 4; break;
67  case 13: quality = 4; break;
68  case 12: quality = 4; break;
69  case 11: quality = 4; break;
70  default: quality = 4; break;
71  }
72  } else {
73  switch (mode) {
74  case 15: quality = 12; break;
75  case 14: quality = 12; break;
76  case 13: quality = 12; break;
77  case 12: quality = 8; break;
78  case 11: quality = 12; break;
79  case 10: quality = 8; break;
80  case 7: quality = 8; break;
81  default: quality = 4; break;
82  }
83  }
84  quality |= (mode & 3);
85 
86  // Fix for missing CSC LCTs in ME1/1, including dead "water-leak" chambers ME1/1/34 and 35
87  if (promoteMode7 && mode == 7 && theta <= 50)
88  quality = 12;
89 
90  return quality;
91 }
92 
93 std::pair<int,int> PtAssignmentEngineAux::getGMTCharge(int mode, const std::vector<int>& phidiffs) const {
94  // -1 = postive physical charge to match pdgId code (i.e. -13 is positive, anti-muon). +1 = negative physical charge.
95  // Also matches DN-2015/017 format for track finder --> uGMT interface format, where 0 indicates positive, 1 negative.
96  int emuCharge = 0;
97 
98  // Note: sign_ph[0] == 1 in firmware actually translates to phidiffs[0] >= 0 (instead of phidiffs[0] > 0 in the old emulator)
99  // The effect needs to be checked
100 
101  switch (mode) {
102  case 15: // 1-2-3-4
103  if (phidiffs[0] >= 0) // 1-2 (should use > 0)
104  emuCharge = 1;
105  else if (phidiffs[0] == 0 && phidiffs[1] < 0) // 1-3
106  emuCharge = 1;
107  else if (phidiffs[1] == 0 && phidiffs[2] < 0) // 1-4
108  emuCharge = 1;
109  else
110  emuCharge = -1;
111  break;
112 
113  case 14: // 1-2-3
114  if (phidiffs[0] < 0) // 1-2
115  emuCharge = -1;
116  else if (phidiffs[0] == 0 && phidiffs[1] < 0) // 1-3
117  emuCharge = -1;
118  else
119  emuCharge = 1;
120  break;
121 
122  case 13: // 1-2-4
123  if (phidiffs[0] >= 0) // 1-2 (should use > 0)
124  emuCharge = 1;
125  else if (phidiffs[0] == 0 && phidiffs[2] < 0) // 1-4
126  emuCharge = 1;
127  else
128  emuCharge = -1;
129  break;
130 
131  case 12: // 1-2
132  if (phidiffs[0] >= 0) // 1-2
133  emuCharge = 1;
134  else
135  emuCharge = -1;
136  break;
137 
138  case 11: // 1-3-4
139  if (phidiffs[1] >= 0) // 1-3 (should use > 0)
140  emuCharge = 1;
141  else if (phidiffs[1] == 0 && phidiffs[2] < 0) // 1-4
142  emuCharge = 1;
143  else
144  emuCharge = -1;
145  break;
146 
147  case 10: // 1-3
148  if (phidiffs[1] >= 0) // 1-3
149  emuCharge = 1;
150  else
151  emuCharge = -1;
152  break;
153 
154  case 9: // 1-4
155  if (phidiffs[2] >= 0) // 1-4
156  emuCharge = 1;
157  else
158  emuCharge = -1;
159  break;
160 
161  case 7: // 2-3-4
162  if (phidiffs[3] >= 0) // 2-3 (should use > 0)
163  emuCharge = 1;
164  else if (phidiffs[3] == 0 && phidiffs[4] < 0) // 2-4
165  emuCharge = 1;
166  else
167  emuCharge = -1;
168  break;
169 
170  case 6: // 2-3
171  if (phidiffs[3] >= 0) // 2-3
172  emuCharge = 1;
173  else
174  emuCharge = -1;
175  break;
176 
177  case 5: // 2-4
178  if (phidiffs[4] >= 0) // 2-4
179  emuCharge = 1;
180  else
181  emuCharge = -1;
182  break;
183 
184  case 3: // 3-4
185  if (phidiffs[5] >= 0) // 3-4
186  emuCharge = 1;
187  else
188  emuCharge = -1;
189  break;
190 
191  default:
192  //emuCharge = -1;
193  emuCharge = 0;
194  break;
195  }
196 
197  int charge = 0;
198  if (emuCharge == 1)
199  charge = 1;
200 
201  int charge_valid = 1;
202  if (emuCharge == 0)
203  charge_valid = 0;
204  return std::make_pair(charge, charge_valid);
205 }
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 getGMTQuality(int mode, int theta, bool promoteMode7) 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]