CMS 3D CMS Logo

MkSeedPartitioners-phase1.cc
Go to the documentation of this file.
6 
7 namespace {
8  using namespace mkfit;
9 
10  [[maybe_unused]] void partitionSeeds0(const TrackerInfo &trk_info,
11  const TrackVec &in_seeds,
12  const EventOfHits &eoh,
14  const size_t size = in_seeds.size();
15 
16  for (size_t i = 0; i < size; ++i) {
17  const Track &S = in_seeds[i];
18 
19  const bool z_dir_pos = S.pz() > 0;
20 
21  const auto &hot = S.getLastHitOnTrack();
22  const float eta = eoh[hot.layer].refHit(hot.index).eta();
23 
24  // Region to be defined by propagation / intersection tests
26 
27  const LayerInfo &outer_brl = trk_info.outer_barrel_layer();
28 
29  // Define first (mkFit) layer IDs for each strip subdetector.
30  constexpr int tib1_id = 4;
31  constexpr int tob1_id = 10;
32  constexpr int tecp1_id = 27;
33  constexpr int tecn1_id = 54;
34 
35  const LayerInfo &tib1 = trk_info.layer(tib1_id);
36  const LayerInfo &tob1 = trk_info.layer(tob1_id);
37 
38  const LayerInfo &tecp1 = trk_info.layer(tecp1_id);
39  const LayerInfo &tecn1 = trk_info.layer(tecn1_id);
40 
41  const LayerInfo &tec_first = z_dir_pos ? tecp1 : tecn1;
42 
43  const float maxR = S.maxReachRadius();
44  float z_at_maxr;
45 
46  bool can_reach_outer_brl = S.canReachRadius(outer_brl.rout());
47  float z_at_outer_brl;
48  bool misses_first_tec;
49  if (can_reach_outer_brl) {
50  z_at_outer_brl = S.zAtR(outer_brl.rout());
51  if (z_dir_pos)
52  misses_first_tec = z_at_outer_brl < tec_first.zmin();
53  else
54  misses_first_tec = z_at_outer_brl > tec_first.zmax();
55  } else {
56  z_at_maxr = S.zAtR(maxR);
57  if (z_dir_pos)
58  misses_first_tec = z_at_maxr < tec_first.zmin();
59  else
60  misses_first_tec = z_at_maxr > tec_first.zmax();
61  }
62 
63  if (misses_first_tec) {
64  reg = TrackerInfo::Reg_Barrel;
65  } else {
66  if ((S.canReachRadius(tib1.rin()) && tib1.is_within_z_limits(S.zAtR(tib1.rin()))) ||
67  (S.canReachRadius(tob1.rin()) && tob1.is_within_z_limits(S.zAtR(tob1.rin())))) {
68  reg = z_dir_pos ? TrackerInfo::Reg_Transition_Pos : TrackerInfo::Reg_Transition_Neg;
69  } else {
70  reg = z_dir_pos ? TrackerInfo::Reg_Endcap_Pos : TrackerInfo::Reg_Endcap_Neg;
71  }
72  }
73 
74  part.m_region[i] = reg;
75  if (part.m_phi_eta_foo)
76  part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta);
77  }
78  }
79 
80  [[maybe_unused]] void partitionSeeds1(const TrackerInfo &trk_info,
81  const TrackVec &in_seeds,
82  const EventOfHits &eoh,
84  // Define first (mkFit) layer IDs for each strip subdetector.
85  constexpr int tib1_id = 4;
86  constexpr int tob1_id = 10;
87  constexpr int tidp1_id = 21;
88  constexpr int tidn1_id = 48;
89  constexpr int tecp1_id = 27;
90  constexpr int tecn1_id = 54;
91 
92  const LayerInfo &tib1 = trk_info.layer(tib1_id);
93  const LayerInfo &tob1 = trk_info.layer(tob1_id);
94 
95  const LayerInfo &tidp1 = trk_info.layer(tidp1_id);
96  const LayerInfo &tidn1 = trk_info.layer(tidn1_id);
97 
98  const LayerInfo &tecp1 = trk_info.layer(tecp1_id);
99  const LayerInfo &tecn1 = trk_info.layer(tecn1_id);
100 
101  // Merge first two layers to account for mono/stereo coverage.
102  // TrackerInfo could hold joint limits for sub-detectors.
103  const auto &L = trk_info;
104  const float tidp_rin = std::min(L[tidp1_id].rin(), L[tidp1_id + 1].rin());
105  const float tidp_rout = std::max(L[tidp1_id].rout(), L[tidp1_id + 1].rout());
106  const float tecp_rin = std::min(L[tecp1_id].rin(), L[tecp1_id + 1].rin());
107  const float tecp_rout = std::max(L[tecp1_id].rout(), L[tecp1_id + 1].rout());
108  const float tidn_rin = std::min(L[tidn1_id].rin(), L[tidn1_id + 1].rin());
109  const float tidn_rout = std::max(L[tidn1_id].rout(), L[tidn1_id + 1].rout());
110  const float tecn_rin = std::min(L[tecn1_id].rin(), L[tecn1_id + 1].rin());
111  const float tecn_rout = std::max(L[tecn1_id].rout(), L[tecn1_id + 1].rout());
112 
113  // Bias towards more aggressive transition-region assignemnts.
114  // With current tunning it seems to make things a bit worse.
115  const float tid_z_extra = 0.0f; // 5.0f;
116  const float tec_z_extra = 0.0f; // 10.0f;
117 
118  const size_t size = in_seeds.size();
119 
120  auto barrel_pos_check = [](const Track &S, float maxR, float rin, float zmax) -> bool {
121  bool inside = maxR > rin && S.zAtR(rin) < zmax;
122  return inside;
123  };
124 
125  auto barrel_neg_check = [](const Track &S, float maxR, float rin, float zmin) -> bool {
126  bool inside = maxR > rin && S.zAtR(rin) > zmin;
127  return inside;
128  };
129 
130  auto endcap_pos_check = [](const Track &S, float maxR, float rout, float rin, float zmin) -> bool {
131  bool inside = maxR > rout ? S.zAtR(rout) > zmin : (maxR > rin && S.zAtR(maxR) > zmin);
132  return inside;
133  };
134 
135  auto endcap_neg_check = [](const Track &S, float maxR, float rout, float rin, float zmax) -> bool {
136  bool inside = maxR > rout ? S.zAtR(rout) < zmax : (maxR > rin && S.zAtR(maxR) < zmax);
137  return inside;
138  };
139 
140  for (size_t i = 0; i < size; ++i) {
141  const Track &S = in_seeds[i];
142 
143  const auto &hot = S.getLastHitOnTrack();
144  const float eta = eoh[hot.layer].refHit(hot.index).eta();
145 
146  // Region to be defined by propagation / intersection tests
148 
149  const bool z_dir_pos = S.pz() > 0;
150  const float maxR = S.maxReachRadius();
151 
152  if (z_dir_pos) {
153  const bool in_tib = barrel_pos_check(S, maxR, tib1.rin(), tib1.zmax());
154  const bool in_tob = barrel_pos_check(S, maxR, tob1.rin(), tob1.zmax());
155 
156  if (!in_tib && !in_tob) {
157  reg = TrackerInfo::Reg_Endcap_Pos;
158  } else {
159  const bool in_tid = endcap_pos_check(S, maxR, tidp_rout, tidp_rin, tidp1.zmin() - tid_z_extra);
160  const bool in_tec = endcap_pos_check(S, maxR, tecp_rout, tecp_rin, tecp1.zmin() - tec_z_extra);
161 
162  if (!in_tid && !in_tec) {
163  reg = TrackerInfo::Reg_Barrel;
164  } else {
165  reg = TrackerInfo::Reg_Transition_Pos;
166  }
167  }
168  } else {
169  const bool in_tib = barrel_neg_check(S, maxR, tib1.rin(), tib1.zmin());
170  const bool in_tob = barrel_neg_check(S, maxR, tob1.rin(), tob1.zmin());
171 
172  if (!in_tib && !in_tob) {
173  reg = TrackerInfo::Reg_Endcap_Neg;
174  } else {
175  const bool in_tid = endcap_neg_check(S, maxR, tidn_rout, tidn_rin, tidn1.zmax() + tid_z_extra);
176  const bool in_tec = endcap_neg_check(S, maxR, tecn_rout, tecn_rin, tecn1.zmax() + tec_z_extra);
177 
178  if (!in_tid && !in_tec) {
179  reg = TrackerInfo::Reg_Barrel;
180  } else {
181  reg = TrackerInfo::Reg_Transition_Neg;
182  }
183  }
184  }
185 
186  part.m_region[i] = reg;
187  if (part.m_phi_eta_foo)
188  part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta);
189  }
190  }
191 
192  [[maybe_unused]] void partitionSeeds1debug(const TrackerInfo &trk_info,
193  const TrackVec &in_seeds,
194  const EventOfHits &eoh,
196  // Define first (mkFit) layer IDs for each strip subdetector.
197  constexpr int tib1_id = 4;
198  constexpr int tob1_id = 10;
199  constexpr int tidp1_id = 21;
200  constexpr int tidn1_id = 48;
201  constexpr int tecp1_id = 27;
202  constexpr int tecn1_id = 54;
203 
204  const LayerInfo &tib1 = trk_info.layer(tib1_id);
205  const LayerInfo &tob1 = trk_info.layer(tob1_id);
206 
207  const LayerInfo &tidp1 = trk_info.layer(tidp1_id);
208  const LayerInfo &tidn1 = trk_info.layer(tidn1_id);
209 
210  const LayerInfo &tecp1 = trk_info.layer(tecp1_id);
211  const LayerInfo &tecn1 = trk_info.layer(tecn1_id);
212 
213  // Merge first two layers to account for mono/stereo coverage.
214  // TrackerInfo could hold joint limits for sub-detectors.
215  const auto &L = trk_info;
216  const float tidp_rin = std::min(L[tidp1_id].rin(), L[tidp1_id + 1].rin());
217  const float tidp_rout = std::max(L[tidp1_id].rout(), L[tidp1_id + 1].rout());
218  const float tecp_rin = std::min(L[tecp1_id].rin(), L[tecp1_id + 1].rin());
219  const float tecp_rout = std::max(L[tecp1_id].rout(), L[tecp1_id + 1].rout());
220  const float tidn_rin = std::min(L[tidn1_id].rin(), L[tidn1_id + 1].rin());
221  const float tidn_rout = std::max(L[tidn1_id].rout(), L[tidn1_id + 1].rout());
222  const float tecn_rin = std::min(L[tecn1_id].rin(), L[tecn1_id + 1].rin());
223  const float tecn_rout = std::max(L[tecn1_id].rout(), L[tecn1_id + 1].rout());
224 
225  // Bias towards more aggressive transition-region assignemnts.
226  // With current tunning it seems to make things a bit worse.
227  const float tid_z_extra = 0.0f; // 5.0f;
228  const float tec_z_extra = 0.0f; // 10.0f;
229 
230  const int size = in_seeds.size();
231 
232  auto barrel_pos_check = [](const Track &S, float maxR, float rin, float zmax, const char *det) -> bool {
233  bool inside = maxR > rin && S.zAtR(rin) < zmax;
234 
235  printf(" in_%s=%d maxR=%7.3f, rin=%7.3f -- ", det, inside, maxR, rin);
236  if (maxR > rin) {
237  printf("maxR > rin: S.zAtR(rin) < zmax -- %.3f <? %.3f\n", S.zAtR(rin), zmax);
238  } else {
239  printf("maxR < rin: no pie.\n");
240  }
241 
242  return inside;
243  };
244 
245  auto barrel_neg_check = [](const Track &S, float maxR, float rin, float zmin, const char *det) -> bool {
246  bool inside = maxR > rin && S.zAtR(rin) > zmin;
247 
248  printf(" in_%s=%d maxR=%7.3f, rin=%7.3f -- ", det, inside, maxR, rin);
249  if (maxR > rin) {
250  printf("maxR > rin: S.zAtR(rin) > zmin -- %.3f >? %.3f\n", S.zAtR(rin), zmin);
251  } else {
252  printf("maxR < rin: no pie.\n");
253  }
254 
255  return inside;
256  };
257 
258  auto endcap_pos_check = [](const Track &S, float maxR, float rout, float rin, float zmin, const char *det) -> bool {
259  bool inside = maxR > rout ? S.zAtR(rout) > zmin : (maxR > rin && S.zAtR(maxR) > zmin);
260 
261  printf(" in_%s=%d maxR=%7.3f, rout=%7.3f, rin=%7.3f -- ", det, inside, maxR, rout, rin);
262  if (maxR > rout) {
263  printf("maxR > rout: S.zAtR(rout) > zmin -- %.3f >? %.3f\n", S.zAtR(rout), zmin);
264  } else if (maxR > rin) {
265  printf("maxR > rin: S.zAtR(maxR) > zmin) -- %.3f >? %.3f\n", S.zAtR(maxR), zmin);
266  } else {
267  printf("maxR < rin: no pie.\n");
268  }
269 
270  return inside;
271  };
272 
273  auto endcap_neg_check = [](const Track &S, float maxR, float rout, float rin, float zmax, const char *det) -> bool {
274  bool inside = maxR > rout ? S.zAtR(rout) < zmax : (maxR > rin && S.zAtR(maxR) < zmax);
275 
276  printf(" in_%s=%d maxR=%7.3f, rout=%7.3f, rin=%7.3f -- ", det, inside, maxR, rout, rin);
277  if (maxR > rout) {
278  printf("maxR > rout: S.zAtR(rout) < zmax -- %.3f <? %.3f\n", S.zAtR(rout), zmax);
279  } else if (maxR > rin) {
280  printf("maxR > rin: S.zAtR(maxR) < zmax -- %.3f <? %.3f\n", S.zAtR(maxR), zmax);
281  } else {
282  printf("maxR < rin: no pie.\n");
283  }
284 
285  return inside;
286  };
287 
288  for (int i = 0; i < size; ++i) {
289  const Track &S = in_seeds[i];
290 
291  HitOnTrack hot = S.getLastHitOnTrack();
292  float eta = eoh[hot.layer].refHit(hot.index).eta();
293  // float eta = S.momEta();
294 
295  // Region to be defined by propagation / intersection tests
297 
298  const bool z_dir_pos = S.pz() > 0;
299  const float maxR = S.maxReachRadius();
300 
301  printf("partitionSeeds1debug seed index %d, z_dir_pos=%d (pz=%.3f), maxR=%.3f\n", i, z_dir_pos, S.pz(), maxR);
302 
303  if (z_dir_pos) {
304  bool in_tib = barrel_pos_check(S, maxR, tib1.rin(), tib1.zmax(), "TIBp");
305  bool in_tob = barrel_pos_check(S, maxR, tob1.rin(), tob1.zmax(), "TOBp");
306 
307  if (!in_tib && !in_tob) {
308  reg = TrackerInfo::Reg_Endcap_Pos;
309  printf(" --> region = %d, endcap pos\n", reg);
310  } else {
311  bool in_tid = endcap_pos_check(S, maxR, tidp_rout, tidp_rin, tidp1.zmin() - tid_z_extra, "TIDp");
312  bool in_tec = endcap_pos_check(S, maxR, tecp_rout, tecp_rin, tecp1.zmin() - tec_z_extra, "TECp");
313 
314  if (!in_tid && !in_tec) {
315  reg = TrackerInfo::Reg_Barrel;
316  printf(" --> region = %d, barrel\n", reg);
317  } else {
318  reg = TrackerInfo::Reg_Transition_Pos;
319  printf(" --> region = %d, transition pos\n", reg);
320  }
321  }
322  } else {
323  bool in_tib = barrel_neg_check(S, maxR, tib1.rin(), tib1.zmin(), "TIBn");
324  bool in_tob = barrel_neg_check(S, maxR, tob1.rin(), tob1.zmin(), "TOBn");
325 
326  if (!in_tib && !in_tob) {
327  reg = TrackerInfo::Reg_Endcap_Neg;
328  printf(" --> region = %d, endcap neg\n", reg);
329  } else {
330  bool in_tid = endcap_neg_check(S, maxR, tidn_rout, tidn_rin, tidn1.zmax() + tid_z_extra, "TIDn");
331  bool in_tec = endcap_neg_check(S, maxR, tecn_rout, tecn_rin, tecn1.zmax() + tec_z_extra, "TECn");
332 
333  if (!in_tid && !in_tec) {
334  reg = TrackerInfo::Reg_Barrel;
335  printf(" --> region = %d, barrel\n", reg);
336  } else {
337  reg = TrackerInfo::Reg_Transition_Neg;
338  printf(" --> region = %d, transition neg\n", reg);
339  }
340  }
341  }
342 
343  part.m_region[i] = reg;
344  if (part.m_phi_eta_foo)
345  part.m_phi_eta_foo(eoh[hot.layer].refHit(hot.index).phi(), eta);
346  }
347  }
348 
349  CMS_SA_ALLOW struct register_seed_partitioners {
350  register_seed_partitioners() {
351  IterationConfig::register_seed_partitioner("phase1:0", partitionSeeds0);
352  IterationConfig::register_seed_partitioner("phase1:1", partitionSeeds1);
353  IterationConfig::register_seed_partitioner("phase1:1:debug", partitionSeeds1debug);
354  }
355  } rsp_instance;
356 } // namespace
size
Write out results.
#define CMS_SA_ALLOW
float rin() const
Definition: TrackerInfo.h:67
const LayerInfo & outer_barrel_layer() const
Definition: TrackerInfo.h:210
float zmax() const
Definition: TrackerInfo.h:71
bool is_within_z_limits(float z) const
Definition: TrackerInfo.h:81
float zmin() const
Definition: TrackerInfo.h:70
const LayerInfo & layer(int l) const
Definition: TrackerInfo.h:203
std::vector< Track > TrackVec
part
Definition: HCALResponse.h:20
float rout() const
Definition: TrackerInfo.h:68