CMS 3D CMS Logo

SingleHitTrack.cc
Go to the documentation of this file.
2 
3 void SingleHitTrack::configure(int verbose, int endcap, int sector, int bx, int maxTracks, bool useSingleHits) {
5  endcap_ = endcap;
6  sector_ = sector;
7  bx_ = bx;
8 
10 
11  useSingleHits_ = useSingleHits;
12 }
13 
14 void SingleHitTrack::process(const EMTFHitCollection& conv_hits, EMTFTrackCollection& best_tracks) const {
15  if (conv_hits.empty())
16  return;
17 
18  if (!useSingleHits_)
19  return;
20 
21  if (int(best_tracks.size()) >= maxTracks_)
22  return;
23 
24  // New collection to contain single-hit tracks
25  EMTFTrackCollection one_hit_trks;
26 
27  // Loop over [subsector, CSC ID] pairs in order: [2,3], [2,2], [2,1], [1,3], [1,2], [1,1]
28  for (int sub_ID = 5; sub_ID >= 0; sub_ID--) {
29  int subsector = 1 + (sub_ID / 3);
30  int CSC_ID = 1 + (sub_ID % 3);
31 
32  // Loop over all the hits in a given BX
33  for (const auto& conv_hits_it : conv_hits) {
34  // Require subsector and CSC ID to match
35  if (conv_hits_it.Subsector() != subsector || conv_hits_it.CSC_ID() != CSC_ID)
36  continue;
37 
38  // Only consider CSC LCTs
39  if (conv_hits_it.Is_CSC() != 1)
40  continue;
41 
42  // Only consider hits in station 1, ring 1
43  if (conv_hits_it.Station() != 1 || (conv_hits_it.Ring() % 3) != 1)
44  continue;
45 
46  // Only consider hits in the same sector (not neighbor hits)
47  if ((conv_hits_it.Endcap() == 1) != (endcap_ == 1) || conv_hits_it.Sector() != sector_)
48  continue;
49 
50  // Check if a hit has already been used in a track
51  bool already_used = false;
52 
53  // Loop over existing multi-hit tracks
54  for (const auto& best_tracks_it : best_tracks) {
55  // Only consider tracks with a hit in station 1
56  if (best_tracks_it.Mode() < 8)
57  continue;
58 
59  // Check if hit in track is identical
60  // "Duplicate" hits (with same strip but different wire) are considered identical
61  // const EMTFHit& conv_hit_i = *conv_hits_it;
62  auto conv_hit_j = best_tracks_it.Hits().front();
63 
64  if ((conv_hits_it.Subsystem() == conv_hit_j.Subsystem()) &&
65  (conv_hits_it.PC_station() == conv_hit_j.PC_station()) &&
66  (conv_hits_it.PC_chamber() == conv_hit_j.PC_chamber()) &&
67  ((conv_hits_it.Ring() % 3) == (conv_hit_j.Ring() % 3)) && // because of ME1/1
68  (conv_hits_it.Strip() == conv_hit_j.Strip()) &&
69  // (conv_hits_it.Wire() == conv_hit_j.Wire()) &&
70  (conv_hits_it.BX() == conv_hit_j.BX()) && true) {
71  already_used = true;
72  break;
73  }
74  } // End loop: for (const auto & best_tracks_it : best_tracks)
75 
76  // Only use hits that have not been used in a track
77  if (already_used)
78  continue;
79 
80  int zone = -1;
81  int zone_code = conv_hits_it.Zone_code();
82  if (zone_code & 0b1000)
83  zone = 4;
84  else if (zone_code & 0b0100)
85  zone = 3;
86  else if (zone_code & 0b0010)
87  zone = 2;
88  else if (zone_code & 0b0001)
89  zone = 1;
90  else {
91  emtf_assert(false && "Incorrect zone_code");
92  }
93 
94  EMTFTrack new_trk;
95  new_trk.push_Hit(conv_hits_it);
96 
97  EMTFPtLUT empty_LUT = {};
98  new_trk.set_PtLUT(empty_LUT);
99 
100  new_trk.set_endcap(conv_hits_it.Endcap());
101  new_trk.set_sector(conv_hits_it.Sector());
102  new_trk.set_sector_idx(conv_hits_it.Sector_idx());
103  new_trk.set_mode(1); // Set "mode" to 1
104  new_trk.set_mode_inv(0);
105  new_trk.set_rank(0b0100000); // Station 1 hit, straightness 0 (see "rank" in AngleCalculation.cc)
106  new_trk.set_winner(maxTracks_ - 1); // Always set to the last / lowest track
107  new_trk.set_bx(bx_);
108  new_trk.set_first_bx(bx_);
109  new_trk.set_second_bx(bx_);
110  new_trk.set_zone(zone);
111  new_trk.set_ph_num(conv_hits_it.Zone_hit());
112  new_trk.set_ph_q(0b010000); // Original "quality_code" from PatternRecognition.cc
113  new_trk.set_theta_fp(conv_hits_it.Theta_fp());
114  new_trk.set_theta(conv_hits_it.Theta());
115  new_trk.set_eta(conv_hits_it.Eta());
116  new_trk.set_phi_fp(conv_hits_it.Phi_fp());
117  new_trk.set_phi_loc(conv_hits_it.Phi_loc());
118  new_trk.set_phi_glob(conv_hits_it.Phi_glob());
119  new_trk.set_track_num(maxTracks_ - 1);
120 
121  one_hit_trks.push_back(new_trk);
122 
123  if (int(best_tracks.size()) + int(one_hit_trks.size()) >= maxTracks_)
124  break;
125 
126  // Firmware only sends one single-hit track per sector
127  if (!one_hit_trks.empty())
128  break;
129 
130  } // End loop: for (const auto & conv_hits_it : conv_hits)
131 
132  if (!one_hit_trks.empty())
133  break;
134 
135  } // End loop: for (int sub_ID = 5; sub_ID > 0; sub_ID--) {
136 
137  best_tracks.insert(best_tracks.end(), one_hit_trks.begin(), one_hit_trks.end());
138 }
void set_mode(int bits)
Definition: EMTFTrack.h:134
void set_bx(int bits)
Definition: EMTFTrack.h:139
l1t::EMTFTrackCollection EMTFTrackCollection
Definition: Common.h:27
void set_second_bx(int bits)
Definition: EMTFTrack.h:141
void process(const EMTFHitCollection &conv_hits, EMTFTrackCollection &best_tracks) const
void set_sector(int bits)
Definition: EMTFTrack.h:132
void set_phi_fp(int bits)
Definition: EMTFTrack.h:152
bool verbose
void set_first_bx(int bits)
Definition: EMTFTrack.h:140
void set_ph_num(int bits)
Definition: EMTFTrack.h:147
l1t::EMTFHitCollection EMTFHitCollection
Definition: Common.h:23
void set_PtLUT(EMTFPtLUT bits)
Definition: EMTFTrack.h:128
void set_sector_idx(int bits)
Definition: EMTFTrack.h:133
void set_zone(int bits)
Definition: EMTFTrack.h:146
void set_track_num(int bits)
Definition: EMTFTrack.h:163
void set_rank(int bits)
Definition: EMTFTrack.h:136
void set_theta_fp(int bits)
Definition: EMTFTrack.h:149
void set_eta(float val)
Definition: EMTFTrack.h:151
void set_winner(int bits)
Definition: EMTFTrack.h:137
void set_theta(float val)
Definition: EMTFTrack.h:150
#define emtf_assert(expr)
Definition: DebugTools.h:18
void set_endcap(int bits)
Definition: EMTFTrack.h:131
void set_ph_q(int bits)
Definition: EMTFTrack.h:148
maxTracks
Definition: DMR_cfg.py:159
void push_Hit(const EMTFHit &hit)
Definition: EMTFTrack.h:101
void set_phi_loc(float val)
Definition: EMTFTrack.h:153
void configure(int verbose, int endcap, int sector, int bx, int maxTracks, bool useSingleHits)
void set_phi_glob(float val)
Definition: EMTFTrack.h:154
void set_mode_inv(int bits)
Definition: EMTFTrack.h:135