CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
AngleCalculation Class Reference

#include <AngleCalculation.h>

Public Member Functions

void calculate_angles (EMTFTrack &track) const
 
void calculate_bx (EMTFTrack &track) const
 
void configure (int verbose, int endcap, int sector, int bx, int bxWindow, int thetaWindow, int thetaWindowRPC, bool bugME11Dupes)
 
void erase_tracks (EMTFTrackCollection &tracks) const
 
void process (emtf::zone_array< EMTFTrackCollection > &zone_tracks) const
 

Private Attributes

bool bugME11Dupes_
 
int bx_
 
int bxWindow_
 
int endcap_
 
int sector_
 
int thetaWindow_
 
int thetaWindowRPC_
 
int verbose_
 

Detailed Description

Definition at line 7 of file AngleCalculation.h.

Member Function Documentation

void AngleCalculation::calculate_angles ( EMTFTrack track) const

Definition at line 82 of file AngleCalculation.cc.

References a, funct::abs(), b, l1t::EMTFPtLUT::bt_ci, l1t::EMTFPtLUT::bt_hi, l1t::EMTFPtLUT::bt_si, l1t::EMTFPtLUT::bt_vi, bugME11Dupes_, emtf::calc_eta_from_theta_deg(), emtf::calc_phi_glob_deg(), emtf::calc_phi_loc_deg(), emtf::calc_theta_deg_from_int(), relativeConstraints::chamber, l1t::EMTFTrack::clear_Hits(), l1t::EMTFPtLUT::cpattern, l1t::EMTFPtLUT::delta_ph, l1t::EMTFPtLUT::delta_th, l1t::EMTFTrack::Endcap(), l1t::EMTFPtLUT::fr, l1t::EMTFTrack::Hits(), mps_fire::i, L1TMuon::TriggerPrimitive::kGEM, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, emtf::NUM_STATION_PAIRS, emtf::NUM_STATIONS, l1t::EMTFTrack::Phi_loc(), l1t::EMTFTrack::Rank(), mps_fire::result, relativeConstraints::ring, l1t::EMTFTrack::Sector(), l1t::EMTFTrack::set_eta(), l1t::EMTFTrack::set_Hits(), l1t::EMTFTrack::set_mode(), l1t::EMTFTrack::set_mode_inv(), l1t::EMTFTrack::set_phi_fp(), l1t::EMTFTrack::set_phi_glob(), l1t::EMTFTrack::set_phi_loc(), l1t::EMTFTrack::set_PtLUT(), l1t::EMTFTrack::set_rank(), l1t::EMTFTrack::set_theta(), l1t::EMTFTrack::set_theta_fp(), l1t::EMTFPtLUT::sign_ph, l1t::EMTFPtLUT::sign_th, l1t::EMTFPtLUT::st1_ring2, relativeConstraints::station, l1t::EMTFTrack::Theta(), theta(), thetaWindow_, thetaWindowRPC_, findQualityFiles::v, and globals_cff::x1.

Referenced by process().

82  {
83  // Group track hits by station
84  std::array<EMTFHitCollection, emtf::NUM_STATIONS> st_conv_hits;
85 
86  for (int istation = 0; istation < emtf::NUM_STATIONS; ++istation) {
87  for (const auto& conv_hit : track.Hits()) {
88  if ((conv_hit.Station() - 1) == istation) {
89  st_conv_hits.at(istation).push_back(conv_hit);
90  }
91  }
92 
93  if (bugME11Dupes_) {
94  if (not (st_conv_hits.at(istation).size() <= 4)) // ambiguity in theta is max 4
95  { edm::LogError("L1T") << "st_conv_hits.at(istation).size() = " << st_conv_hits.at(istation).size(); return; }
96  } else {
97  if (not (st_conv_hits.at(istation).size() <= 2)) // ambiguity in theta is max 2
98  { edm::LogError("L1T") << "st_conv_hits.at(istation).size() = " << st_conv_hits.at(istation).size(); return; }
99  }
100  }
101  if (not (st_conv_hits.size() == emtf::NUM_STATIONS))
102  { edm::LogError("L1T") << "st_conv_hits.size() = " << st_conv_hits.size() << ", emtf::NUM_STATIONS = " << emtf::NUM_STATIONS; return; }
103 
104 
105  // Best theta deltas and phi deltas
106  // from 0 to 5: dtheta12, dtheta13, dtheta14, dtheta23, dtheta24, dtheta34
107  std::array<int, emtf::NUM_STATION_PAIRS> best_dtheta_arr; // Best of up to 4 dTheta values per pair of stations (with duplicate thetas)
108  std::array<int, emtf::NUM_STATION_PAIRS> best_dtheta_sign_arr;
109  std::array<int, emtf::NUM_STATION_PAIRS> best_dphi_arr; // Not really "best" - there is only one dPhi value per pair of stations
110  std::array<int, emtf::NUM_STATION_PAIRS> best_dphi_sign_arr;
111 
112  // Best angles
113  // from 0 to 5: ME2, ME3, ME4, ME2, ME2, ME3
114  // dtheta12, dtheta13, dtheta14, dtheta23, dtheta24, dtheta34
115  std::array<int, emtf::NUM_STATION_PAIRS> best_theta_arr;
116  std::array<int, emtf::NUM_STATION_PAIRS> best_phi_arr;
117 
118  // Keep track of which pair is valid
119  std::array<bool, emtf::NUM_STATION_PAIRS> best_dtheta_valid_arr;
120  std::array<bool, emtf::NUM_STATION_PAIRS> best_has_rpc_arr; // Not used - should remove (AWB 21.05.17)
121 
122  // Initialize
123  best_dtheta_arr .fill(invalid_dtheta);
124  best_dtheta_sign_arr .fill(1);
125  best_dphi_arr .fill(invalid_dphi);
126  best_dphi_sign_arr .fill(1);
127  best_phi_arr .fill(0);
128  best_theta_arr .fill(0);
129  best_dtheta_valid_arr.fill(false);
130  best_has_rpc_arr .fill(false);
131 
132  auto abs_diff = [](int a, int b) { return std::abs(a-b); };
133 
134  // Calculate angles
135  int ipair = 0;
136 
137  for (int ist1 = 0; ist1+1 < emtf::NUM_STATIONS; ++ist1) { // station A
138  for (int ist2 = ist1+1; ist2 < emtf::NUM_STATIONS; ++ist2) { // station B
139  const EMTFHitCollection& conv_hitsA = st_conv_hits.at(ist1);
140  const EMTFHitCollection& conv_hitsB = st_conv_hits.at(ist2);
141 
142  // More than 1 hit per station when hit has ambigous theta
143  for (const auto& conv_hitA : conv_hitsA) {
144  for (const auto& conv_hitB : conv_hitsB) {
145  // Has RPC?
146  //bool has_rpc = (conv_hitA.Subsystem() == TriggerPrimitive::kRPC || conv_hitB.Subsystem() == TriggerPrimitive::kRPC);
147 
148  // Calculate theta deltas
149  int thA = conv_hitA.Theta_fp();
150  int thB = conv_hitB.Theta_fp();
151  int dth = abs_diff(thA, thB);
152  int dth_sign = (thA <= thB); // sign
153  if (not(thA != 0 && thB != 0))
154  { edm::LogError("L1T") << "thA = " << thA << ", thB = " << thB; return; }
155  if (not(dth < invalid_dtheta))
156  { edm::LogError("L1T") << "dth = " << dth << ", invalid_dtheta = " << invalid_dtheta; return; }
157 
158  if (best_dtheta_arr.at(ipair) >= dth) {
159  best_dtheta_arr.at(ipair) = dth;
160  best_dtheta_sign_arr.at(ipair) = dth_sign;
161  best_dtheta_valid_arr.at(ipair) = true;
162  // best_has_rpc_arr.at(ipair) = has_rpc; // FW doesn't check whether a segment is CSC or RPC, should remove - AWB 21.05.17
163 
164  // first 3 pairs, use station B
165  // last 3 pairs, use station A
166  best_theta_arr.at(ipair) = (ipair < 3) ? thB : thA;
167  }
168 
169  // Calculate phi deltas
170  int phA = conv_hitA.Phi_fp();
171  int phB = conv_hitB.Phi_fp();
172  int dph = abs_diff(phA, phB);
173  int dph_sign = (phA <= phB);
174 
175  if (best_dphi_arr.at(ipair) >= dph) {
176  best_dphi_arr.at(ipair) = dph;
177  best_dphi_sign_arr.at(ipair) = dph_sign;
178 
179  // first 3 pairs, use station B
180  // last 3 pairs, use station A
181  best_phi_arr.at(ipair) = (ipair < 3) ? phB : phA;
182  }
183  } // end loop over conv_hits in station B
184  } // end loop over conv_hits in station A
185 
186  ++ipair;
187  } // end loop over station B
188  } // end loop over station A
189  if (not(ipair == emtf::NUM_STATION_PAIRS))
190  { edm::LogError("L1T") << "ipair = " << ipair << ", emtf::NUM_STATION_PAIRS = " << emtf::NUM_STATION_PAIRS; return; }
191 
192 
193  // Apply cuts on dtheta
194 
195  // There is a possible bug in FW. After a dtheta pair fails the theta window
196  // cut, the valid flag of the pair is not updated. Later on, theta from
197  // this pair is used to assign the precise theta of the track.
198  std::array<bool, emtf::NUM_STATION_PAIRS> best_dtheta_valid_arr_1;
199 
200  for (int ipair = 0; ipair < emtf::NUM_STATION_PAIRS; ++ipair) {
201  if (best_has_rpc_arr.at(ipair))
202  best_dtheta_valid_arr_1.at(ipair) = best_dtheta_valid_arr.at(ipair) && (best_dtheta_arr.at(ipair) <= thetaWindowRPC_);
203  else
204  best_dtheta_valid_arr_1.at(ipair) = best_dtheta_valid_arr.at(ipair) && (best_dtheta_arr.at(ipair) <= thetaWindow_);
205  }
206 
207  // Find valid segments
208  // vmask contains valid station mask = {ME4,ME3,ME2,ME1}. "0b" prefix for binary.
209  int vmask1 = 0, vmask2 = 0, vmask3 = 0;
210 
211  if (best_dtheta_valid_arr_1.at(0)) {
212  vmask1 |= 0b0011; // 12
213  }
214  if (best_dtheta_valid_arr_1.at(1)) {
215  vmask1 |= 0b0101; // 13
216  }
217  if (best_dtheta_valid_arr_1.at(2)) {
218  vmask1 |= 0b1001; // 14
219  }
220  if (best_dtheta_valid_arr_1.at(3)) {
221  vmask2 |= 0b0110; // 23
222  }
223  if (best_dtheta_valid_arr_1.at(4)) {
224  vmask2 |= 0b1010; // 24
225  }
226  if (best_dtheta_valid_arr_1.at(5)) {
227  vmask3 |= 0b1100; // 34
228  }
229 
230  // merge station masks only if they share bits
231  // Station 1 hits pass if any dTheta1X values pass
232  // Station 2 hits pass if any dTheta2X values pass, *EXCEPT* the following cases:
233  // Only {13, 24} pass, only {13, 24, 34} pass,
234  // Only {14, 23} pass, only {14, 23, 34} pass.
235  // Station 3 hits pass if any dTheta3X values pass, *EXCEPT* the following cases:
236  // Only {12, 34} pass, only {14, 23} pass.
237  // Station 4 hits pass if any dTheta4X values pass, *EXCEPT* the following cases:
238  // Only {12, 34} pass, only {13, 24} pass.
239  int vstat = vmask1; // valid stations based on th coordinates
240  if ((vstat & vmask2) != 0 || vstat == 0)
241  vstat |= vmask2;
242  if ((vstat & vmask3) != 0 || vstat == 0)
243  vstat |= vmask3;
244 
245  // remove valid flag for station if hit does not pass the dTheta mask
246  for (int istation = 0; istation < emtf::NUM_STATIONS; ++istation) {
247  if ((vstat & (1 << istation)) == 0) { // station bit not set
248  st_conv_hits.at(istation).clear();
249  }
250  }
251 
252  // assign precise phi and theta for the track
253  int phi_fp = 0;
254  int theta_fp = 0;
255  int best_pair = -1;
256 
257  if ((vstat & (1<<1)) != 0) { // ME2 present
258  if (!best_has_rpc_arr.at(0) && best_dtheta_valid_arr.at(0)) // 12, no RPC
259  best_pair = 0;
260  else if (!best_has_rpc_arr.at(3) && best_dtheta_valid_arr.at(3)) // 23, no RPC
261  best_pair = 3;
262  else if (!best_has_rpc_arr.at(4) && best_dtheta_valid_arr.at(4)) // 24, no RPC
263  best_pair = 4;
264  else if (best_dtheta_valid_arr.at(0)) // 12, has RPC
265  best_pair = 0;
266  else if (best_dtheta_valid_arr.at(3)) // 23, has RPC
267  best_pair = 3;
268  else if (best_dtheta_valid_arr.at(4)) // 24, has RPC
269  best_pair = 4;
270  } else if ((vstat & (1<<2)) != 0) { // ME3 present
271  if (!best_has_rpc_arr.at(1) && best_dtheta_valid_arr.at(1)) // 13, no RPC
272  best_pair = 1;
273  else if (!best_has_rpc_arr.at(5) && best_dtheta_valid_arr.at(5)) // 34, no RPC
274  best_pair = 5;
275  else if (best_dtheta_valid_arr.at(1)) // 13, has RPC
276  best_pair = 1;
277  else if (best_dtheta_valid_arr.at(5)) // 34, has RPC
278  best_pair = 5;
279  } else if ((vstat & (1<<3)) != 0) { // ME4 present
280  if (best_dtheta_valid_arr.at(2)) // 14
281  best_pair = 2;
282  }
283 
284  if (best_pair != -1) {
285  phi_fp = best_phi_arr.at(best_pair);
286  theta_fp = best_theta_arr.at(best_pair);
287  if (not(theta_fp != 0))
288  { edm::LogError("L1T") << "theta_fp = " << theta_fp; return; }
289 
290  // In firmware, the track is associated to LCTs by the segment number, which
291  // identifies the best strip, but does not resolve the ambiguity in theta.
292  // In emulator, this additional logic also resolves the ambiguity in theta.
293  struct {
294  typedef EMTFHit value_type;
295  bool operator()(const value_type& lhs, const value_type& rhs) const {
296  return std::abs(lhs.Theta_fp()-theta) < std::abs(rhs.Theta_fp()-theta);
297  }
298  int theta;
299  } less_dtheta_cmp;
300  less_dtheta_cmp.theta = theta_fp; // capture
301 
302  for (int istation = 0; istation < emtf::NUM_STATIONS; ++istation) {
303  std::stable_sort(st_conv_hits.at(istation).begin(), st_conv_hits.at(istation).end(), less_dtheta_cmp);
304  if (st_conv_hits.at(istation).size() > 1)
305  st_conv_hits.at(istation).resize(1); // just the minimum in dtheta
306  }
307  }
308 
309  // update rank taking into account available stations after theta deltas
310  // keep straightness as it was
311  int old_rank = (track.Rank() << 1); // output rank is one bit longer than input rank, to accomodate ME4 separately
312  int rank = (
313  (((old_rank >> 6) & 1) << 6) | // straightness
314  (((old_rank >> 4) & 1) << 4) | // straightness
315  (((old_rank >> 2) & 1) << 2) | // straightness
316  (((vstat >> 0) & 1) << 5) | // ME1
317  (((vstat >> 1) & 1) << 3) | // ME2
318  (((vstat >> 2) & 1) << 1) | // ME3
319  (((vstat >> 3) & 1) << 0) // ME4
320  );
321 
322  int mode = (
323  (((vstat >> 0) & 1) << 3) | // ME1
324  (((vstat >> 1) & 1) << 2) | // ME2
325  (((vstat >> 2) & 1) << 1) | // ME3
326  (((vstat >> 3) & 1) << 0) // ME4
327  );
328 
329  int mode_inv = vstat;
330 
331  // if less than 2 segments, kill rank
332  if (vstat == 0b0001 || vstat == 0b0010 || vstat == 0b0100 || vstat == 0b1000 || vstat == 0)
333  rank = 0;
334 
335  // From RecoMuon/DetLayers/src/MuonCSCDetLayerGeometryBuilder.cc
336  auto isFront = [](int station, int ring, int chamber, int subsystem) {
337 
338  // // RPCs are behind the CSCs in stations 1, 3, and 4; in front in 2
339  // if (subsystem == TriggerPrimitive::kRPC)
340  // return (station == 2);
341 
342  // In EMTF firmware, RPC hits are treated as if they came from the corresponding
343  // CSC chamber, so the FR bit assignment is the same as for CSCs - AWB 06.06.17
344 
345  // GEMs are in front of the CSCs
346  if (subsystem == TriggerPrimitive::kGEM)
347  return true;
348 
349  bool result = false;
350  bool isOverlapping = !(station == 1 && ring == 3);
351  // not overlapping means back
352  if(isOverlapping)
353  {
354  bool isEven = (chamber % 2 == 0);
355  // odd chambers are bolted to the iron, which faces
356  // forward in 1&2, backward in 3&4, so...
357  result = (station < 3) ? isEven : !isEven;
358  }
359  return result;
360  };
361 
362  // Fill ptlut_data
363  EMTFPtLUT ptlut_data = {};
364  for (int i = 0; i < emtf::NUM_STATION_PAIRS; ++i) {
365  ptlut_data.delta_ph[i] = best_dphi_arr.at(i);
366  ptlut_data.sign_ph[i] = best_dphi_sign_arr.at(i);
367  ptlut_data.delta_th[i] = best_dtheta_arr.at(i);
368  ptlut_data.sign_th[i] = best_dtheta_sign_arr.at(i);
369  }
370 
371  for (int i = 0; i < emtf::NUM_STATIONS; ++i) {
372  const auto& v = st_conv_hits.at(i);
373  ptlut_data.cpattern[i] = v.empty() ? 0 : v.front().Pattern(); // Automatically set to 0 for RPCs
374  ptlut_data.fr[i] = v.empty() ? 0 : isFront(v.front().Station(), v.front().Ring(), v.front().Chamber(), v.front().Subsystem());
375  if (i == 0)
376  ptlut_data.st1_ring2 = v.empty() ? 0 : (v.front().Station() == 1 && (v.front().Ring() == 2 || v.front().Ring() == 3));
377  }
378 
379  for (int i = 0; i < emtf::NUM_STATIONS+1; ++i) { // 'bt' arrays use 5-station convention
380  ptlut_data.bt_vi[i] = 0;
381  ptlut_data.bt_hi[i] = 0;
382  ptlut_data.bt_ci[i] = 0;
383  ptlut_data.bt_si[i] = 0;
384  }
385 
386  for (int i = 0; i < emtf::NUM_STATIONS; ++i) {
387  const auto& v = st_conv_hits.at(i);
388  if (!v.empty()) {
389  int bt_station = v.front().BT_station();
390  if (not(0 <= bt_station && bt_station <= 4))
391  { edm::LogError("L1T") << "bt_station = " << bt_station; return; }
392 
393  int bt_segment = v.front().BT_segment();
394  ptlut_data.bt_vi[bt_station] = 1;
395  ptlut_data.bt_hi[bt_station] = (bt_segment >> 5) & 0x3;
396  ptlut_data.bt_ci[bt_station] = (bt_segment >> 1) & 0xf;
397  ptlut_data.bt_si[bt_station] = (bt_segment >> 0) & 0x1;
398  }
399  }
400 
401  // ___________________________________________________________________________
402  // Output
403 
404  track.set_rank ( rank );
405  track.set_mode ( mode );
406  track.set_mode_inv ( mode_inv );
407  track.set_phi_fp ( phi_fp );
408  track.set_theta_fp ( theta_fp );
409  track.set_PtLUT ( ptlut_data );
410 
411  track.set_phi_loc ( emtf::calc_phi_loc_deg(phi_fp) );
412  track.set_phi_glob ( emtf::calc_phi_glob_deg(track.Phi_loc(), track.Sector()) );
413  track.set_theta ( emtf::calc_theta_deg_from_int(theta_fp) );
414  track.set_eta ( emtf::calc_eta_from_theta_deg(track.Theta(), track.Endcap()) );
415 
416  // Only keep the best segments
417  track.clear_Hits();
418 
419  EMTFHitCollection tmp_hits = track.Hits();
420  flatten_container(st_conv_hits, tmp_hits);
421  track.set_Hits( tmp_hits );
422 
423 }
void set_mode(int bits)
Definition: EMTFTrack.h:91
void clear_Hits()
Definition: EMTFTrack.h:55
float Theta() const
Definition: EMTFTrack.h:139
int NUM_STATION_PAIRS
Definition: Common.h:61
uint16_t bt_si[5]
Definition: EMTFTrack.h:32
uint16_t bt_ci[5]
Definition: EMTFTrack.h:31
uint16_t sign_ph[6]
Definition: EMTFTrack.h:25
int Endcap() const
Definition: EMTFTrack.h:119
void set_phi_fp(int bits)
Definition: EMTFTrack.h:107
int Sector() const
Definition: EMTFTrack.h:120
uint16_t bt_vi[5]
Definition: EMTFTrack.h:29
Geom::Theta< T > theta() const
double calc_phi_loc_deg(int bits)
Definition: TrackTools.h:149
uint16_t delta_ph[6]
Definition: EMTFTrack.h:23
void set_PtLUT(EMTFPtLUT bits)
Definition: EMTFTrack.h:85
uint16_t delta_th[6]
Definition: EMTFTrack.h:24
double calc_theta_deg_from_int(int theta_int)
Definition: TrackTools.h:110
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
uint16_t cpattern[4]
Definition: EMTFTrack.h:27
int NUM_STATIONS
Definition: Common.h:60
l1t::EMTFHitCollection EMTFHitCollection
Definition: Common.h:20
double calc_phi_glob_deg(double loc, int sector)
Definition: TrackTools.h:139
uint16_t fr[4]
Definition: EMTFTrack.h:28
void set_rank(int bits)
Definition: EMTFTrack.h:93
void set_theta_fp(int bits)
Definition: EMTFTrack.h:104
void set_eta(float val)
Definition: EMTFTrack.h:106
EMTFHitCollection Hits() const
Definition: EMTFTrack.h:77
float Phi_loc() const
Definition: EMTFTrack.h:142
void set_theta(float val)
Definition: EMTFTrack.h:105
uint16_t sign_th[6]
Definition: EMTFTrack.h:26
uint16_t st1_ring2
Definition: EMTFTrack.h:21
double b
Definition: hdecay.h:120
double calc_eta_from_theta_deg(double theta_deg, int endcap)
Definition: TrackTools.h:95
double a
Definition: hdecay.h:121
void set_Hits(const EMTFHitCollection &hits)
Definition: EMTFTrack.h:66
void set_phi_loc(float val)
Definition: EMTFTrack.h:108
void set_phi_glob(float val)
Definition: EMTFTrack.h:109
uint16_t bt_hi[5]
Definition: EMTFTrack.h:30
void set_mode_inv(int bits)
Definition: EMTFTrack.h:92
int Rank() const
Definition: EMTFTrack.h:127
void AngleCalculation::calculate_bx ( EMTFTrack track) const

Definition at line 425 of file AngleCalculation.cc.

References bx_, bxWindow_, counter, l1t::EMTFTrack::Hits(), mps_fire::i, l1t::EMTFTrack::set_first_bx(), and l1t::EMTFTrack::set_second_bx().

Referenced by process().

425  {
426  const int delayBX = bxWindow_ - 1;
427  if (not(delayBX >= 0))
428  { edm::LogError("L1T") << "delayBX = " << delayBX; return; }
429  std::vector<int> counter(delayBX+1, 0);
430 
431  for (const auto& conv_hit : track.Hits()) {
432  for (int i = delayBX; i >= 0; i--) {
433  if (conv_hit.BX() <= bx_ - i)
434  counter.at(i) += 1; // Count stubs delayed by i BX or more
435  }
436  }
437 
438  int first_bx = bx_ - delayBX;
439  int second_bx = 99;
440  for (int i = delayBX; i >= 0; i--) {
441  if (counter.at(i) >= 2) { // If 2 or more stubs are delayed by i BX or more
442  second_bx = bx_ - i; // if i == delayBX, analyze immediately
443  break;
444  }
445  }
446  if (not(second_bx != 99))
447  { edm::LogError("L1T") << "second_bx = " << second_bx; return; }
448 
449  // ___________________________________________________________________________
450  // Output
451 
452  track.set_first_bx ( first_bx );
453  track.set_second_bx ( second_bx );
454 }
void set_second_bx(int bits)
Definition: EMTFTrack.h:98
void set_first_bx(int bits)
Definition: EMTFTrack.h:97
EMTFHitCollection Hits() const
Definition: EMTFTrack.h:77
static std::atomic< unsigned int > counter
void AngleCalculation::configure ( int  verbose,
int  endcap,
int  sector,
int  bx,
int  bxWindow,
int  thetaWindow,
int  thetaWindowRPC,
bool  bugME11Dupes 
)
void AngleCalculation::erase_tracks ( EMTFTrackCollection tracks) const

Definition at line 456 of file AngleCalculation.cc.

References emtf::NUM_STATIONS, HiIsolationCommonParameters_cff::track, and x.

Referenced by process().

456  {
457  // Erase tracks with rank == 0
458  // using erase-remove idiom
459  struct {
460  typedef EMTFTrack value_type;
461  bool operator()(const value_type& x) const {
462  return (x.Rank() == 0);
463  }
464  } rank_zero_pred;
465 
466  tracks.erase(std::remove_if(tracks.begin(), tracks.end(), rank_zero_pred), tracks.end());
467 
468  for (const auto& track : tracks) {
469  if (not(!track.Hits().empty()))
470  { edm::LogError("L1T") << "track.Hits().empty() = " << track.Hits().empty(); return; }
471  if (not(track.Hits().size() <= emtf::NUM_STATIONS))
472  { edm::LogError("L1T") << "track.Hits().size() = " << track.Hits().size() << ", emtf::NUM_STATIONS= " << emtf::NUM_STATIONS; return; }
473  }
474 }
int NUM_STATIONS
Definition: Common.h:60
void AngleCalculation::process ( emtf::zone_array< EMTFTrackCollection > &  zone_tracks) const

Definition at line 31 of file AngleCalculation.cc.

References calculate_angles(), calculate_bx(), gather_cfg::cout, erase_tracks(), emtf::NUM_ZONES, to_hex(), HiIsolationCommonParameters_cff::track, l1t::tracks, and verbose_.

Referenced by ConfigBuilder.ConfigBuilder::addExtraStream(), ConfigBuilder.ConfigBuilder::completeInputCommand(), ConfigBuilder.ConfigBuilder::doNotInlineEventContent(), ConfigBuilder.ConfigBuilder.PrintAllModules::leave(), ConfigBuilder.ConfigBuilder::prepare(), ConfigBuilder.ConfigBuilder::prepare_ALCA(), ConfigBuilder.ConfigBuilder::prepare_DQM(), ConfigBuilder.ConfigBuilder::prepare_HLT(), ConfigBuilder.ConfigBuilder::prepare_LHE(), ConfigBuilder.ConfigBuilder::prepare_PATFILTER(), ConfigBuilder.ConfigBuilder::prepare_VALIDATION(), SectorProcessor::process_single_bx(), ConfigBuilder.ConfigBuilder::renameHLTprocessInSequence(), ConfigBuilder.ConfigBuilder::renameInputTagsInSequence(), and ConfigBuilder.ConfigBuilder::scheduleSequence().

33  {
34 
35  for (int izone = 0; izone < emtf::NUM_ZONES; ++izone) {
36  EMTFTrackCollection& tracks = zone_tracks.at(izone); // pass by reference
37 
38  EMTFTrackCollection::iterator tracks_it = tracks.begin();
39  EMTFTrackCollection::iterator tracks_end = tracks.end();
40 
41  // Calculate deltas
42  for (; tracks_it != tracks_end; ++tracks_it) {
43  calculate_angles(*tracks_it);
44  }
45 
46  // Erase tracks with rank = 0
47  // Erase hits that are not selected as the best phi and theta in each station
48  erase_tracks(tracks);
49 
50  tracks_it = tracks.begin();
51  tracks_end = tracks.end();
52 
53  // Calculate bx
54  // (in the firmware, this happens during best track selection.)
55  for (; tracks_it != tracks_end; ++tracks_it) {
56  calculate_bx(*tracks_it);
57  }
58  } // end loop over zones
59 
60  if (verbose_ > 0) { // debug
61  for (const auto& tracks : zone_tracks) {
62  for (const auto& track : tracks) {
63  std::cout << "deltas: z: " << track.Zone()-1 << " pat: " << track.Winner() << " rank: " << to_hex(track.Rank())
64  << " delta_ph: " << array_as_string(track.PtLUT().delta_ph)
65  << " delta_th: " << array_as_string(track.PtLUT().delta_th)
66  << " sign_ph: " << array_as_string(track.PtLUT().sign_ph)
67  << " sign_th: " << array_as_string(track.PtLUT().sign_th)
68  << " phi: " << track.Phi_fp()
69  << " theta: " << track.Theta_fp()
70  << " cpat: " << array_as_string(track.PtLUT().cpattern)
71  << " v: " << array_as_string(track.PtLUT().bt_vi)
72  << " h: " << array_as_string(track.PtLUT().bt_hi)
73  << " c: " << array_as_string(track.PtLUT().bt_ci)
74  << " s: " << array_as_string(track.PtLUT().bt_si)
75  << std::endl;
76  }
77  }
78  }
79 
80 }
static char to_hex(unsigned int i)
Definition: types.cc:29
void calculate_bx(EMTFTrack &track) const
int NUM_ZONES
Definition: Common.h:56
l1t::EMTFTrackCollection EMTFTrackCollection
Definition: Common.h:24
void calculate_angles(EMTFTrack &track) const
void erase_tracks(EMTFTrackCollection &tracks) const

Member Data Documentation

bool AngleCalculation::bugME11Dupes_
private

Definition at line 31 of file AngleCalculation.h.

Referenced by calculate_angles(), and configure().

int AngleCalculation::bx_
private

Definition at line 27 of file AngleCalculation.h.

Referenced by calculate_bx(), and configure().

int AngleCalculation::bxWindow_
private

Definition at line 29 of file AngleCalculation.h.

Referenced by calculate_bx(), and configure().

int AngleCalculation::endcap_
private

Definition at line 27 of file AngleCalculation.h.

Referenced by configure().

int AngleCalculation::sector_
private

Definition at line 27 of file AngleCalculation.h.

Referenced by configure().

int AngleCalculation::thetaWindow_
private

Definition at line 30 of file AngleCalculation.h.

Referenced by calculate_angles(), and configure().

int AngleCalculation::thetaWindowRPC_
private

Definition at line 30 of file AngleCalculation.h.

Referenced by calculate_angles(), and configure().

int AngleCalculation::verbose_
private

Definition at line 27 of file AngleCalculation.h.

Referenced by configure(), and process().