CMS 3D CMS Logo

OutputLayer.cc
Go to the documentation of this file.
2 
6 
8 
9 using namespace emtf::phase2;
10 using namespace emtf::phase2::algo;
11 
13 
14 void OutputLayer::apply(const int& endcap,
15  const int& sector,
16  const int& bx,
17  const std::map<int, int>& seg_to_hit,
18  const std::vector<track_t>& tracks,
19  const bool& displaced_en,
20  EMTFTrackCollection& out_tracks) const {
21  const int endcap_pm = (endcap == 2) ? -1 : endcap; // 1: +endcap, -1: -endcap
22 
23  for (auto& track : tracks) { // Begin loop tracks
24  // Fill Site/Hit Vectors
25  int hit_count = 0;
26 
27  EMTFTrack::site_hits_t site_hits;
28  EMTFTrack::site_segs_t site_segs;
29  EMTFTrack::site_mask_t site_mask;
30  EMTFTrack::site_mask_t site_rm_mask;
31 
32  for (unsigned int i = 0; i < v3::kNumTrackSites; i++) {
33  // Get attached segments
34  const auto& site_seg_id = track.site_segs[i];
35  const auto& site_bit = track.site_mask[i];
36  const auto& site_rm_bit = track.site_rm_mask[i];
37 
38  // Increase hit count
39  if (site_bit == 1) {
40  hit_count += 1;
41  }
42 
43  // Convert segment to hit
44  int hit_id = 0;
45 
46  if ((site_bit == 1) || (site_rm_bit == 1)) {
47  hit_id = seg_to_hit.at(site_seg_id);
48  }
49 
50  // Save Info
51  site_hits.push_back(hit_id);
52  site_segs.push_back(site_seg_id);
53  site_mask.push_back(site_bit);
54  site_rm_mask.push_back(site_rm_bit);
55  }
56 
57  // Short-Circuit: Only keep tracks with hits
58  if (!track.valid && hit_count == 0) {
59  continue;
60  }
61 
62  // Fill Feature Vector
63  EMTFTrack::features_t model_features;
64 
65  for (unsigned int i = 0; i < v3::kNumTrackFeatures; i++) {
66  model_features.push_back(track.features[i]);
67  }
68 
69  // Find EMTF/GMT variables
70  const int emtf_mode_v1 = findEMTFModeV1(track.site_mask);
71  const int emtf_mode_v2 = findEMTFModeV2(track.site_mask);
72  const int emtf_quality = findEMTFQuality(track, emtf_mode_v1, emtf_mode_v2);
73 
74  // Init Parameters
75  auto& out_trk = out_tracks.emplace_back();
76 
77  out_trk.setEndcap(endcap_pm);
78  out_trk.setSector(sector);
79  out_trk.setBx(bx);
80  out_trk.setUnconstrained(displaced_en ? true : false);
81  out_trk.setValid(track.valid);
82 
83  out_trk.setModelPtAddress(track.pt_address);
84  out_trk.setModelRelsAddress(track.rels_address);
85  out_trk.setModelDxyAddress(track.dxy_address);
86  out_trk.setModelPattern(track.pattern);
87  out_trk.setModelQual(track.quality);
88  out_trk.setModelPhi(track.phi);
89  out_trk.setModelEta(track.theta);
90  out_trk.setModelFeatures(model_features);
91 
92  out_trk.setEmtfQ(track.q);
93  out_trk.setEmtfPt(track.pt);
94  out_trk.setEmtfRels(track.rels);
95  out_trk.setEmtfD0(std::abs(track.dxy));
96  out_trk.setEmtfZ0(0); // not yet implemented
97  out_trk.setEmtfBeta(0); // not yet implemented
98  out_trk.setEmtfModeV1(emtf_mode_v1);
99  out_trk.setEmtfModeV2(emtf_mode_v2);
100  out_trk.setEmtfQuality(emtf_quality);
101 
102  out_trk.setSiteHits(site_hits);
103  out_trk.setSiteSegs(site_segs);
104  out_trk.setSiteMask(site_mask);
105  out_trk.setSiteRMMask(site_rm_mask);
106  } // End loop tracks
107 }
108 
110  int mode = 0;
111 
112  if (x[0] or x[9] or x[1] or x[5] or x[11]) { // ME1/1, GE1/1, ME1/2, RE1/2, ME0
113  mode |= (1 << 3);
114  }
115 
116  if (x[2] or x[10] or x[6]) { // ME2, GE2/1, RE2/2
117  mode |= (1 << 2);
118  }
119 
120  if (x[3] or x[7]) { // ME3, RE3
121  mode |= (1 << 1);
122  }
123 
124  if (x[4] or x[8]) { // ME4, RE4
125  mode |= (1 << 0);
126  }
127 
128  return mode;
129 }
130 
131 // SingleMu (12)
132 // - at least one station-1 segment (ME1/1, GE1/1, ME1/2, RE1/2, ME0)
133 // with one of the following requirements on stations 2,3,4
134 // a. if there is ME1/2 or RE1/2,
135 // i. if there is ME1/2, require 1 more CSC station
136 // ii. else, require 1 more CSC station + 1 more station
137 // b. if there is ME1/1 or GE1/1,
138 // i. if there is ME1/1, require 1 more CSC station + 1 more station
139 // ii. else, require 2 more CSC stations
140 // c. if there is ME0,
141 // i. if there is ME1/1, require 1 more station in stations 3,4
142 // ii. else, require 1 more CSC station + 1 more station
143 //
144 // DoubleMu (8)
145 // - at least one station-1 segment (ME1/1, GE1/1, ME1/2, RE1/2, ME0)
146 // with one of the following requirements on stations 2,3,4
147 // a. if there is ME1/1 or ME1/2, require 1 more station
148 // b. if there is GE1/1 or RE1/2, require 1 more CSC station
149 // c. if there is ME0,
150 // i. if there is ME1/1, require 1 more station
151 // ii. else, require 1 more CSC station
152 //
153 // TripleMu (4)
154 // - at least two stations
155 // a. if there is ME1/1 or ME1/2, require 1 more station
156 // b. if there is GE1/1 or RE1/2, require 1 more CSC station
157 // c. if there is ME0,
158 // i. if there is ME1/1, require 1 more station
159 // ii. else, require 1 more CSC station
160 // d. else, require 2 more CSC stations
161 //
162 // SingleHit (0)
163 // - at least one station
164 //
165 // Note that SingleMu, DoubleMu, TripleMu, SingleHit are mutually-exclusive categories.
167  int mode = 0;
168  int cnt_ye11 = x[0] + x[9]; // ME1/1, GE1/1
169  int cnt_ye12 = x[1] + x[5]; // ME1/2, RE1/2
170  int cnt_ye22 = x[2] + x[10] + x[6]; // ME2, GE2/1, RE2/2
171  int cnt_ye23 = x[3] + x[7]; // ME3, RE3
172  int cnt_ye24 = x[4] + x[8]; // ME4, RE4
173  int cnt_ye2a = (cnt_ye22 != 0) + (cnt_ye23 != 0) + (cnt_ye24 != 0); //
174  int cnt_ye2b = (cnt_ye23 != 0) + (cnt_ye24 != 0); //
175  int cnt_me11 = x[0]; // ME1/1 only
176  int cnt_me12 = x[1]; // ME1/2 only
177  int cnt_me14 = x[11]; // ME0 only
178  int cnt_me2a = (x[2] != 0) + (x[3] != 0) + (x[4] != 0); //
179 
180  // SingleMu (12)
181  {
182  bool rule_a_i = (cnt_me12 != 0) and (cnt_me2a >= 1);
183  bool rule_a_ii = (cnt_ye12 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2);
184  bool rule_b_i = (cnt_me11 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2);
185  bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 2);
186  bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2b >= 1);
187  bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2);
188 
189  if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii) {
190  mode |= (1 << 3);
191  mode |= (1 << 2);
192  }
193  }
194 
195  // DoubleMu (8)
196  if (mode < (1 << 3)) {
197  bool rule_a_i = (cnt_me12 != 0) and (cnt_ye2a >= 1);
198  bool rule_a_ii = (cnt_me11 != 0) and (cnt_ye2a >= 1);
199  bool rule_b_i = (cnt_ye12 != 0) and (cnt_me2a >= 1);
200  bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 1);
201  bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2a >= 1);
202  bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1);
203 
204  if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii) {
205  mode |= (1 << 3);
206  }
207  }
208 
209  // TripleMu (4)
210  if (mode < (1 << 2)) {
211  bool rule_a_i = (cnt_me12 != 0) and (cnt_ye2a >= 1);
212  bool rule_a_ii = (cnt_me11 != 0) and (cnt_ye2a >= 1);
213  bool rule_b_i = (cnt_ye12 != 0) and (cnt_me2a >= 1);
214  bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 1);
215  bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2a >= 1);
216  bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1);
217  bool rule_d = (cnt_me2a >= 2);
218 
219  if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii or rule_d) {
220  mode |= (1 << 2);
221  }
222  }
223 
224  return mode;
225 }
226 
227 int OutputLayer::findEMTFQuality(const track_t& track, const int& mode_v1, const int& mode_v2) const {
228  // Short-Circuit: Invalid track
229  if (track.valid == 0) {
230  return 0;
231  }
232 
233  // Short-Circuit: Single Station
234  bool is_single_station = (mode_v1 == 0);
235  is_single_station |= (mode_v1 == 1);
236  is_single_station |= (mode_v1 == 2);
237  is_single_station |= (mode_v1 == 4);
238  is_single_station |= (mode_v1 == 8);
239 
240  if (is_single_station) {
241  return 0;
242  }
243 
244  // Calculate Quality Based on ModeV2
245  if (mode_v2 == 0) {
246  // Single Hit
247  if ((0 <= track.quality) && (track.quality <= 3)) {
248  return 1;
249  } else if ((4 <= track.quality) && (track.quality <= 7)) {
250  return 2;
251  } else if (7 < track.quality) {
252  return 3;
253  }
254 
255  return 0;
256  } else if (mode_v2 == 4) {
257  // Triple Muon Quality
258  if ((8 <= track.quality) && (track.quality <= 11)) {
259  return 5;
260  } else if ((12 <= track.quality) && (track.quality <= 15)) {
261  return 6;
262  } else if (15 < track.quality) {
263  return 7;
264  }
265 
266  return 4;
267  } else if (mode_v2 == 8) {
268  // Double Muon Quality
269  bool valid_mode = (mode_v1 == 9);
270  valid_mode |= (mode_v1 == 10);
271  valid_mode |= (mode_v1 == 12);
272 
273  if (valid_mode) {
274  if ((16 <= track.quality) && (track.quality <= 23)) {
275  return 9;
276  } else if ((24 <= track.quality) && (track.quality <= 31)) {
277  return 10;
278  } else if (31 < track.quality) {
279  return 11;
280  }
281  }
282 
283  return 8;
284  } else if (mode_v2 == 12) {
285  // Single Muon Quality
286  bool valid_mode = (mode_v1 == 11);
287  valid_mode |= (mode_v1 == 13);
288  valid_mode |= (mode_v1 == 14);
289  valid_mode |= (mode_v1 == 15);
290 
291  if (valid_mode) {
292  if ((32 <= track.quality) && (track.quality <= 39)) {
293  return 13;
294  } else if ((40 <= track.quality) && (track.quality <= 51)) {
295  return 14;
296  } else if (51 < track.quality) {
297  return 15;
298  }
299  }
300 
301  return 12;
302  }
303 
304  // Invalid track
305  return 0;
306 }
std::vector< int16_t > features_t
Definition: EMTFTrack.h:12
int findEMTFQuality(const track_t &, const int &, const int &) const
Definition: OutputLayer.cc:227
l1t::phase2::EMTFTrackCollection EMTFTrackCollection
Definition: EMTFTypes.h:31
constexpr int kNumTrackFeatures
Definition: EMTFConstants.h:40
int findEMTFModeV2(const track_t::site_mask_t &) const
Definition: OutputLayer.cc:166
int findEMTFModeV1(const track_t::site_mask_t &) const
Definition: OutputLayer.cc:109
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
std::vector< uint8_t > site_mask_t
Definition: EMTFTrack.h:15
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< uint16_t > site_segs_t
Definition: EMTFTrack.h:14
std::vector< uint16_t > site_hits_t
Definition: EMTFTrack.h:13
constexpr int kNumTrackSites
Definition: EMTFConstants.h:42
float x
OutputLayer(const EMTFContext &)
Definition: OutputLayer.cc:12
void apply(const int &, const int &, const int &, const std::map< int, int > &, const std::vector< track_t > &, const bool &, EMTFTrackCollection &) const
Definition: OutputLayer.cc:14
std::array< trk_site_bit_t, v3::kNumTrackSites > site_mask_t
Definition: EMTFTypes.h:118