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 
73  // Init Parameters
74  auto& out_trk = out_tracks.emplace_back();
75 
76  out_trk.setEndcap(endcap_pm);
77  out_trk.setSector(sector);
78  out_trk.setBx(bx);
79  out_trk.setUnconstrained(displaced_en ? true : false);
80  out_trk.setValid(track.valid);
81 
82  out_trk.setModelPtAddress(track.pt_address);
83  out_trk.setModelRelsAddress(track.rels_address);
84  out_trk.setModelDxyAddress(track.dxy_address);
85  out_trk.setModelPattern(track.pattern);
86  out_trk.setModelQual(track.quality);
87  out_trk.setModelPhi(track.phi);
88  out_trk.setModelEta(track.theta);
89  out_trk.setModelFeatures(model_features);
90 
91  out_trk.setEmtfQ(track.q);
92  out_trk.setEmtfPt(track.pt);
93  out_trk.setEmtfRels(track.rels);
94  out_trk.setEmtfD0(std::abs(track.dxy));
95  out_trk.setEmtfZ0(0); // not yet implemented
96  out_trk.setEmtfBeta(0); // not yet implemented
97  out_trk.setEmtfModeV1(emtf_mode_v1);
98  out_trk.setEmtfModeV2(emtf_mode_v2);
99 
100  out_trk.setSiteHits(site_hits);
101  out_trk.setSiteSegs(site_segs);
102  out_trk.setSiteMask(site_mask);
103  out_trk.setSiteRMMask(site_rm_mask);
104  } // End loop tracks
105 }
106 
108  int mode = 0;
109 
110  if (x[0] or x[9] or x[1] or x[5] or x[11]) { // ME1/1, GE1/1, ME1/2, RE1/2, ME0
111  mode |= (1 << 3);
112  }
113 
114  if (x[2] or x[10] or x[6]) { // ME2, GE2/1, RE2/2
115  mode |= (1 << 2);
116  }
117 
118  if (x[3] or x[7]) { // ME3, RE3
119  mode |= (1 << 1);
120  }
121 
122  if (x[4] or x[8]) { // ME4, RE4
123  mode |= (1 << 0);
124  }
125 
126  return mode;
127 }
128 
129 // SingleMu (12)
130 // - at least one station-1 segment (ME1/1, GE1/1, ME1/2, RE1/2, ME0)
131 // with one of the following requirements on stations 2,3,4
132 // a. if there is ME1/2 or RE1/2,
133 // i. if there is ME1/2, require 1 more CSC station
134 // ii. else, require 1 more CSC station + 1 more station
135 // b. if there is ME1/1 or GE1/1,
136 // i. if there is ME1/1, require 1 more CSC station + 1 more station
137 // ii. else, require 2 more CSC stations
138 // c. if there is ME0,
139 // i. if there is ME1/1, require 1 more station in stations 3,4
140 // ii. else, require 1 more CSC station + 1 more station
141 //
142 // DoubleMu (8)
143 // - at least one station-1 segment (ME1/1, GE1/1, ME1/2, RE1/2, ME0)
144 // with one of the following requirements on stations 2,3,4
145 // a. if there is ME1/1 or ME1/2, require 1 more station
146 // b. if there is GE1/1 or RE1/2, require 1 more CSC station
147 // c. if there is ME0,
148 // i. if there is ME1/1, require 1 more station
149 // ii. else, require 1 more CSC station
150 //
151 // TripleMu (4)
152 // - at least two stations
153 // a. if there is ME1/1 or ME1/2, require 1 more station
154 // b. if there is GE1/1 or RE1/2, require 1 more CSC station
155 // c. if there is ME0,
156 // i. if there is ME1/1, require 1 more station
157 // ii. else, require 1 more CSC station
158 // d. else, require 2 more CSC stations
159 //
160 // SingleHit (0)
161 // - at least one station
162 //
163 // Note that SingleMu, DoubleMu, TripleMu, SingleHit are mutually-exclusive categories.
165  int mode = 0;
166  int cnt_ye11 = x[0] + x[9]; // ME1/1, GE1/1
167  int cnt_ye12 = x[1] + x[5]; // ME1/2, RE1/2
168  int cnt_ye22 = x[2] + x[10] + x[6]; // ME2, GE2/1, RE2/2
169  int cnt_ye23 = x[3] + x[7]; // ME3, RE3
170  int cnt_ye24 = x[4] + x[8]; // ME4, RE4
171  int cnt_ye2a = (cnt_ye22 != 0) + (cnt_ye23 != 0) + (cnt_ye24 != 0); //
172  int cnt_ye2b = (cnt_ye23 != 0) + (cnt_ye24 != 0); //
173  int cnt_me11 = x[0]; // ME1/1 only
174  int cnt_me12 = x[1]; // ME1/2 only
175  int cnt_me14 = x[11]; // ME0 only
176  int cnt_me2a = (x[2] != 0) + (x[3] != 0) + (x[4] != 0); //
177 
178  // SingleMu (12)
179  {
180  bool rule_a_i = (cnt_me12 != 0) and (cnt_me2a >= 1);
181  bool rule_a_ii = (cnt_ye12 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2);
182  bool rule_b_i = (cnt_me11 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2);
183  bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 2);
184  bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2b >= 1);
185  bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1) and (cnt_ye2a >= 2);
186 
187  if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii) {
188  mode |= (1 << 3);
189  mode |= (1 << 2);
190  }
191  }
192 
193  // DoubleMu (8)
194  if (mode < (1 << 3)) {
195  bool rule_a_i = (cnt_me12 != 0) and (cnt_ye2a >= 1);
196  bool rule_a_ii = (cnt_me11 != 0) and (cnt_ye2a >= 1);
197  bool rule_b_i = (cnt_ye12 != 0) and (cnt_me2a >= 1);
198  bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 1);
199  bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2a >= 1);
200  bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1);
201 
202  if (rule_a_i or rule_a_ii or rule_b_i or rule_b_ii or rule_c_i or rule_c_ii) {
203  mode |= (1 << 3);
204  }
205  }
206 
207  // TripleMu (4)
208  if (mode < (1 << 2)) {
209  bool rule_a_i = (cnt_me12 != 0) and (cnt_ye2a >= 1);
210  bool rule_a_ii = (cnt_me11 != 0) and (cnt_ye2a >= 1);
211  bool rule_b_i = (cnt_ye12 != 0) and (cnt_me2a >= 1);
212  bool rule_b_ii = (cnt_ye11 != 0) and (cnt_me2a >= 1);
213  bool rule_c_i = (cnt_me14 != 0) and (cnt_me11 != 0) and (cnt_ye2a >= 1);
214  bool rule_c_ii = (cnt_me14 != 0) and (cnt_me2a >= 1);
215  bool rule_d = (cnt_me2a >= 2);
216 
217  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) {
218  mode |= (1 << 2);
219  }
220  }
221 
222  return mode;
223 }
std::vector< int16_t > features_t
Definition: EMTFTrack.h:12
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:164
int findEMTFModeV1(const track_t::site_mask_t &) const
Definition: OutputLayer.cc:107
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