CMS 3D CMS Logo

Classes | Functions
mkfit::StdSeq Namespace Reference

Classes

struct  Quality
 

Functions

int clean_cms_seedtracks_iter (TrackVec &seeds, const IterationConfig &itrcfg, const BeamSpot &bspot)
 
void clean_duplicates (TrackVec &tracks, const IterationConfig &itconf)
 
void clean_duplicates_sharedhits (TrackVec &tracks, const IterationConfig &itconf)
 
void clean_duplicates_sharedhits_pixelseed (TrackVec &tracks, const IterationConfig &itconf)
 
void cmssw_LoadHits_Begin (EventOfHits &eoh, const std::vector< const HitVec *> &orig_hitvectors)
 
void cmssw_LoadHits_End (EventOfHits &eoh)
 
void cmssw_Map_TrackHitIndices (const EventOfHits &eoh, TrackVec &seeds)
 
void cmssw_ReMap_TrackHitIndices (const EventOfHits &eoh, TrackVec &out_tracks)
 
void dump_simtracks (Event *event)
 
void handle_duplicates (Event *)
 
void loadDeads (EventOfHits &eoh, const std::vector< DeadVec > &deadvectors)
 
void loadHitsAndBeamSpot (Event &ev, EventOfHits &eoh)
 
void prep_cmsswtracks (Event *event)
 
void prep_recotracks (Event *event)
 
void prep_reftracks (Event *event, TrackVec &tracks, TrackExtraVec &extras, const bool realigntracks)
 
void prep_simtracks (Event *event)
 
void prep_tracks (Event *event, TrackVec &tracks, TrackExtraVec &extras, const bool realigntracks)
 
template<class TRACK >
bool qfilter_n_hits (const TRACK &t, const MkJob &j)
 
template<class TRACK >
bool qfilter_n_hits_pixseed (const TRACK &t, const MkJob &j)
 
template<class TRACK >
bool qfilter_n_layers (const TRACK &t, const MkJob &j)
 
template<class TRACK >
bool qfilter_nan_n_silly (const TRACK &t, const MkJob &)
 
template<class TRACK >
bool qfilter_pixelLessBkwd (const TRACK &t, const MkJob &j)
 quality filter tuned for pixelLess iteration during backward search More...
 
template<class TRACK >
bool qfilter_pixelLessFwd (const TRACK &t, const MkJob &j)
 quality filter tuned for pixelLess iteration during forward search More...
 
void remove_duplicates (TrackVec &tracks)
 
void root_val (Event *event)
 
void root_val_dumb_cmssw (Event *event)
 
void score_tracks (TrackVec &tracks)
 
void track_print (Event *event, const Track &t, const char *pref)
 
float trackScoreDefault (const int nfoundhits, const int ntailholes, const int noverlaphits, const int nmisshits, const float chi2, const float pt, const bool inFindCandidates)
 

Function Documentation

◆ clean_cms_seedtracks_iter()

int mkfit::StdSeq::clean_cms_seedtracks_iter ( TrackVec seeds,
const IterationConfig itrcfg,
const BeamSpot bspot 
)

Definition at line 87 of file MkStdSeqs.cc.

References funct::abs(), mkfit::Track::addHitIdx(), ntupleEnum::Algo, mkfit::binnor< C, A1, A2, NB_first, NB_count >::begin_registration(), mkfit::Config::c_dpt_common, mkfit::Config::c_etamax_brl, mkfit::cdist(), ALCARECOTkAlJpsiMuMu_cff::charge, mkfit::TrackBase::charge(), gather_cfg::cout, d0, mkfit::TrackBase::d0BeamSpot(), PVValHelper::eta, HLT_2023v12_cff::eta1, HLT_2023v12_cff::eta2, f, mkfit::binnor< C, A1, A2, NB_first, NB_count >::finalize_registration(), mkfit::axis_base< R, I, M, N >::from_R_rdr_to_N_bins(), mkfit::axis_pow2_u1< R, I, M, N >::from_R_rdr_to_N_bins(), mkfit::binnor< C, A1, A2, NB_first, NB_count >::get_content(), mkfit::Track::getHitIdx(), mkfit::Track::getHitLyr(), mps_fire::i, testProducerWithPsetDescEmpty_cfi::i1, testProducerWithPsetDescEmpty_cfi::i2, mkfit::TrackBase::invpT(), ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, dqmiolumiharvest::j, mkfit::TrackBase::Status::kMaxSeedHits, LowPtQuadStep_cff::lowPtQuadStep, mkfit::binnor< C, A1, A2, NB_first, NB_count >::m_ranks, mkfit::IterationConfig::m_track_algorithm, mkfit::TrackBase::momEta(), mkfit::TrackBase::momPhi(), mkfit::axis_base< R, I, M, N >::next_N_bin(), mkfit::axis_pow2_u1< R, I, M, N >::next_N_bin(), mkfit::Track::nFoundHits(), nHits, mkfit::Track::nTotalHits(), mkfit::Const::PI, funct::pow(), DiDispStaMuonMonitor_cfi::pt, mkfit::TrackBase::pT(), HLT_2023v12_cff::pt1, HLT_2023v12_cff::pt2, mkfit::binnor< C, A1, A2, NB_first, NB_count >::register_entry_safe(), mkfit::IterationConfig::sc_drmax_bh, mkfit::IterationConfig::sc_drmax_bl, mkfit::IterationConfig::sc_drmax_eh, mkfit::IterationConfig::sc_drmax_el, mkfit::IterationConfig::sc_dzmax_bh, mkfit::IterationConfig::sc_dzmax_bl, mkfit::IterationConfig::sc_dzmax_eh, mkfit::IterationConfig::sc_dzmax_el, mkfit::IterationConfig::sc_ptthr_hpt, HLT_FULL_cff::seeds, mkfit::Track::sortHitsByLayer(), mathSSE::sqrt(), contentValuesCheck::ss, funct::tan(), mkfit::TrackBase::theta(), mkfit::Config::track1GeVradius, tier0::unique(), x, mkfit::TrackBase::x(), mkfit::BeamSpot::x, mkfit::TrackBase::y(), mkfit::BeamSpot::y, and mkfit::TrackBase::z().

87  {
89 
90  const float etamax_brl = Config::c_etamax_brl;
91  const float dpt_common = Config::c_dpt_common;
92 
93  const float dzmax_bh = itrcfg.sc_dzmax_bh;
94  const float drmax_bh = itrcfg.sc_drmax_bh;
95  const float dzmax_eh = itrcfg.sc_dzmax_eh;
96  const float drmax_eh = itrcfg.sc_drmax_eh;
97  const float dzmax_bl = itrcfg.sc_dzmax_bl;
98  const float drmax_bl = itrcfg.sc_drmax_bl;
99  const float dzmax_el = itrcfg.sc_dzmax_el;
100  const float drmax_el = itrcfg.sc_drmax_el;
101 
102  const float ptmin_hpt = itrcfg.sc_ptthr_hpt;
103 
104  const float dzmax2_inv_bh = 1.f / (dzmax_bh * dzmax_bh);
105  const float drmax2_inv_bh = 1.f / (drmax_bh * drmax_bh);
106  const float dzmax2_inv_eh = 1.f / (dzmax_eh * dzmax_eh);
107  const float drmax2_inv_eh = 1.f / (drmax_eh * drmax_eh);
108  const float dzmax2_inv_bl = 1.f / (dzmax_bl * dzmax_bl);
109  const float drmax2_inv_bl = 1.f / (drmax_bl * drmax_bl);
110  const float dzmax2_inv_el = 1.f / (dzmax_el * dzmax_el);
111  const float drmax2_inv_el = 1.f / (drmax_el * drmax_el);
112 
113  // Merge hits from overlapping seeds?
114  // For now always true, we require extra hits after seed,
115  // except for lowPtQuadStep, where we only merge hits for seeds at low pT and large pseudo-rapidity
116  const bool merge_hits = true; // itrcfg.merge_seed_hits_during_cleaning();
117  const float ptmax_merge_lowPtQuad = 0.2;
118  const float etamin_merge_lowPtQuad = 1.5;
119 
120  if (seeds.empty())
121  return 0;
122 
123  const int ns = seeds.size();
124 #ifdef DEBUG
125  std::cout << "before seed cleaning " << seeds.size() << std::endl;
126 #endif
127  TrackVec cleanSeedTracks;
128  cleanSeedTracks.reserve(ns);
129  std::vector<bool> writetrack(ns, true);
130 
131  const float invR1GeV = 1.f / Config::track1GeVradius;
132 
133  std::vector<int> nHits(ns);
134  std::vector<int> charge(ns);
135  std::vector<float> oldPhi(ns);
136  std::vector<float> pos2(ns);
137  std::vector<float> eta(ns);
138  std::vector<float> ctheta(ns);
139  std::vector<float> invptq(ns);
140  std::vector<float> pt(ns);
141  std::vector<float> x(ns);
142  std::vector<float> y(ns);
143  std::vector<float> z(ns);
144  std::vector<float> d0(ns);
145  int i1, i2; //for the sorting
146 
147  axis_pow2_u1<float, unsigned short, 16, 8> ax_phi(-Const::PI, Const::PI);
148  axis<float, unsigned short, 8, 8> ax_eta(-3.0, 3.0, 30u);
149  binnor<unsigned int, decltype(ax_phi), decltype(ax_eta), 24, 8> phi_eta_binnor(ax_phi, ax_eta);
150 
151  phi_eta_binnor.begin_registration(ns);
152 
153  for (int ts = 0; ts < ns; ts++) {
154  const Track &tk = seeds[ts];
155  nHits[ts] = tk.nFoundHits();
156  charge[ts] = tk.charge();
157  oldPhi[ts] = tk.momPhi();
158  pos2[ts] = std::pow(tk.x(), 2) + std::pow(tk.y(), 2);
159  eta[ts] = tk.momEta();
160  ctheta[ts] = 1.f / std::tan(tk.theta());
161  invptq[ts] = tk.charge() * tk.invpT();
162  pt[ts] = tk.pT();
163  x[ts] = tk.x();
164  y[ts] = tk.y();
165  z[ts] = tk.z();
166  d0[ts] = tk.d0BeamSpot(bspot.x, bspot.y);
167 
168  phi_eta_binnor.register_entry_safe(oldPhi[ts], eta[ts]);
169  // If one is sure values are *within* axis ranges: b.register_entry(oldPhi[ts], eta[ts]);
170  }
171 
172  phi_eta_binnor.finalize_registration();
173 
174  for (int sorted_ts = 0; sorted_ts < ns; sorted_ts++) {
175  int ts = phi_eta_binnor.m_ranks[sorted_ts];
176 
177  if (not writetrack[ts])
178  continue; // Note: this speed up prevents transitive masking (possibly marginal gain).
179 
180  const float oldPhi1 = oldPhi[ts];
181  const float pos2_first = pos2[ts];
182  const float eta1 = eta[ts];
183  const float pt1 = pt[ts];
184  const float invptq_first = invptq[ts];
185 
186  // To study some more details -- need EventOfHits for this
187  int n_ovlp_hits_added = 0;
188 
189  auto phi_rng = ax_phi.from_R_rdr_to_N_bins(oldPhi[ts], 0.08f);
190  auto eta_rng = ax_eta.from_R_rdr_to_N_bins(eta[ts], .1f);
191 
192  for (auto i_phi = phi_rng.begin; i_phi != phi_rng.end; i_phi = ax_phi.next_N_bin(i_phi)) {
193  for (auto i_eta = eta_rng.begin; i_eta != eta_rng.end; i_eta = ax_eta.next_N_bin(i_eta)) {
194  const auto cbin = phi_eta_binnor.get_content(i_phi, i_eta);
195  for (auto i = cbin.first; i < cbin.end(); ++i) {
196  int tss = phi_eta_binnor.m_ranks[i];
197 
198  if (not writetrack[ts])
199  continue;
200  if (not writetrack[tss])
201  continue;
202  if (tss == ts)
203  continue;
204 
205  const float pt2 = pt[tss];
206 
207  // Always require charge consistency. If different charge is assigned, do not remove seed-track
208  if (charge[tss] != charge[ts])
209  continue;
210 
211  const float thisDPt = std::abs(pt2 - pt1);
212  // Require pT consistency between seeds. If dpT is large, do not remove seed-track.
213  if (thisDPt > dpt_common * pt1)
214  continue;
215 
216  const float eta2 = eta[tss];
217  const float deta2 = std::pow(eta1 - eta2, 2);
218 
219  const float oldPhi2 = oldPhi[tss];
220 
221  const float pos2_second = pos2[tss];
222  const float thisDXYSign05 = pos2_second > pos2_first ? -0.5f : 0.5f;
223 
224  const float thisDXY = thisDXYSign05 * sqrt(std::pow(x[ts] - x[tss], 2) + std::pow(y[ts] - y[tss], 2));
225 
226  const float invptq_second = invptq[tss];
227 
228  const float newPhi1 = oldPhi1 - thisDXY * invR1GeV * invptq_first;
229  const float newPhi2 = oldPhi2 + thisDXY * invR1GeV * invptq_second;
230 
231  const float dphi = cdist(std::abs(newPhi1 - newPhi2));
232 
233  const float dr2 = deta2 + dphi * dphi;
234 
235  const float thisDZ = z[ts] - z[tss] - thisDXY * (ctheta[ts] + ctheta[tss]);
236  const float dz2 = thisDZ * thisDZ;
237 
238  // Reject tracks within dR-dz elliptical window.
239  // Adaptive thresholds, based on observation that duplicates are more abundant at large pseudo-rapidity and low track pT
240  bool overlapping = false;
241  if (std::abs(eta1) < etamax_brl) {
242  if (pt1 > ptmin_hpt) {
243  if (dz2 * dzmax2_inv_bh + dr2 * drmax2_inv_bh < 1.0f)
244  overlapping = true;
245  } else {
246  if (dz2 * dzmax2_inv_bl + dr2 * drmax2_inv_bl < 1.0f)
247  overlapping = true;
248  }
249  } else {
250  if (pt1 > ptmin_hpt) {
251  if (dz2 * dzmax2_inv_eh + dr2 * drmax2_inv_eh < 1.0f)
252  overlapping = true;
253  } else {
254  if (dz2 * dzmax2_inv_el + dr2 * drmax2_inv_el < 1.0f)
255  overlapping = true;
256  }
257  }
258 
259  if (overlapping) {
260  //Mark tss as a duplicate
261  i1 = ts;
262  i2 = tss;
263  if (d0[tss] > d0[ts])
264  writetrack[tss] = false;
265  else {
266  writetrack[ts] = false;
267  i2 = ts;
268  i1 = tss;
269  }
270  // Add hits from tk2 to the seed we are keeping.
271  // NOTE: We have a limit in Track::Status for the number of seed hits.
272  // There is a check at entry and after adding of a new hit.
273  Track &tk = seeds[i1];
274  if (merge_hits && tk.nTotalHits() < Track::Status::kMaxSeedHits &&
275  (Algo(itrcfg.m_track_algorithm) != Algo::lowPtQuadStep ||
276  (pt1 < ptmax_merge_lowPtQuad && std::abs(eta1) > etamin_merge_lowPtQuad))) {
277  const Track &tk2 = seeds[i2];
278  //We are not actually fitting to the extra hits; use chi2 of 0
279  float fakeChi2 = 0.0;
280 
281  for (int j = 0; j < tk2.nTotalHits(); ++j) {
282  int hitidx = tk2.getHitIdx(j);
283  int hitlyr = tk2.getHitLyr(j);
284  if (hitidx >= 0) {
285  bool unique = true;
286  for (int i = 0; i < tk.nTotalHits(); ++i) {
287  if ((hitidx == tk.getHitIdx(i)) && (hitlyr == tk.getHitLyr(i))) {
288  unique = false;
289  break;
290  }
291  }
292  if (unique) {
293  tk.addHitIdx(tk2.getHitIdx(j), tk2.getHitLyr(j), fakeChi2);
294  ++n_ovlp_hits_added;
295  if (tk.nTotalHits() >= Track::Status::kMaxSeedHits)
296  break;
297  }
298  }
299  }
300  }
301  if (n_ovlp_hits_added > 0)
302  tk.sortHitsByLayer();
303  }
304  } //end of inner loop over tss
305  } //eta bin
306  } //phi bin
307 
308  if (writetrack[ts]) {
309  cleanSeedTracks.emplace_back(seeds[ts]);
310  }
311  }
312 
313  seeds.swap(cleanSeedTracks);
314 
315 #ifdef DEBUG
316  {
317  const int ns2 = seeds.size();
318  printf("Number of CMS seeds before %d --> after %d cleaning\n", ns, ns2);
319 
320  for (int it = 0; it < ns2; it++) {
321  const Track &ss = seeds[it];
322  printf(" %3i q=%+i pT=%7.3f eta=% 7.3f nHits=%i label=% i\n",
323  it,
324  ss.charge(),
325  ss.pT(),
326  ss.momEta(),
327  ss.nFoundHits(),
328  ss.label());
329  }
330  }
331 #endif
332 
333 #ifdef DEBUG
334  std::cout << "AFTER seed cleaning " << seeds.size() << std::endl;
335 #endif
336 
337  return seeds.size();
338  }
constexpr float c_dpt_common
Definition: Config.h:95
float float float z
constexpr float c_etamax_brl
Definition: Config.h:94
T sqrt(T t)
Definition: SSEVec.h:19
def unique(seq, keepstr=True)
Definition: tier0.py:24
TrackBase::TrackAlgorithm TrackAlgorithm
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
#define PI
Definition: QcdUeDQM.h:37
float cdist(float a)
Definition: Config.h:32
std::vector< Track > TrackVec
static constexpr float d0
constexpr float track1GeVradius
Definition: Config.h:93
float x
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
Definition: fakeMenu.h:6

◆ clean_duplicates()

void mkfit::StdSeq::clean_duplicates ( TrackVec tracks,
const IterationConfig itconf 
)

Definition at line 357 of file MkStdSeqs.cc.

References funct::abs(), HLT_2023v12_cff::eta1, f, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, mkfit::Config::maxdEta, mkfit::Config::maxdPhi, mkfit::Config::maxdPt, mkfit::Config::maxdR, SiStripPI::min, mkfit::Config::minFracHitsShared, vertices_cff::ntracks, HLT_2023v12_cff::pt1, remove_duplicates(), mkfit::squashPhiMinimal(), HLT_2023v12_cff::track, DiMuonV_cfg::tracks, mitigatedMETSequence_cff::U, and mkfit::Config::useHitsForDuplicates.

357  {
358  const auto ntracks = tracks.size();
359  float eta1, phi1, pt1, deta, dphi, dr2;
360 
361  if (ntracks == 0) {
362  return;
363  }
364  for (auto itrack = 0U; itrack < ntracks - 1; itrack++) {
365  auto &track = tracks[itrack];
366  eta1 = track.momEta();
367  phi1 = track.momPhi();
368  pt1 = track.pT();
369  for (auto jtrack = itrack + 1; jtrack < ntracks; jtrack++) {
370  auto &track2 = tracks[jtrack];
371  if (track.label() == track2.label())
372  continue;
373  if (track.algoint() != track2.algoint())
374  continue;
375 
376  deta = std::abs(track2.momEta() - eta1);
377  if (deta > Config::maxdEta)
378  continue;
379 
380  dphi = std::abs(squashPhiMinimal(phi1 - track2.momPhi()));
381  if (dphi > Config::maxdPhi)
382  continue;
383 
384  float maxdR = Config::maxdR;
385  float maxdRSquared = maxdR * maxdR;
386  if (std::abs(eta1) > 2.5f)
387  maxdRSquared *= 16.0f;
388  else if (std::abs(eta1) > 1.44f)
389  maxdRSquared *= 9.0f;
390  dr2 = dphi * dphi + deta * deta;
391  if (dr2 < maxdRSquared) {
392  //Keep track with best score
393  if (track.score() > track2.score())
394  track2.setDuplicateValue(true);
395  else
396  track.setDuplicateValue(true);
397  continue;
398  } else {
399  if (pt1 == 0)
400  continue;
401  if (track2.pT() == 0)
402  continue;
403 
404  if (std::abs((1 / track2.pT()) - (1 / pt1)) < Config::maxdPt) {
406  float numHitsShared = 0;
407  for (int ihit2 = 0; ihit2 < track2.nTotalHits(); ihit2++) {
408  const int hitidx2 = track2.getHitIdx(ihit2);
409  const int hitlyr2 = track2.getHitLyr(ihit2);
410  if (hitidx2 >= 0) {
411  auto const it = std::find_if(track.beginHitsOnTrack(),
412  track.endHitsOnTrack(),
413  [&hitidx2, &hitlyr2](const HitOnTrack &element) {
414  return (element.index == hitidx2 && element.layer == hitlyr2);
415  });
416  if (it != track.endHitsOnTrack())
417  numHitsShared++;
418  }
419  }
420 
421  float fracHitsShared = numHitsShared / std::min(track.nFoundHits(), track2.nFoundHits());
422  //Only remove one of the tracks if they share at least X% of the hits (denominator is the shorter track)
423  if (fracHitsShared < Config::minFracHitsShared)
424  continue;
425  }
426  //Keep track with best score
427  if (track.score() > track2.score())
428  track2.setDuplicateValue(true);
429  else
430  track.setDuplicateValue(true);
431  } //end of if dPt
432  } //end of else
433  } //end of loop over track2
434  } //end of loop over track1
435 
437  }
float squashPhiMinimal(float phi)
Definition: Hit.h:26
const float maxdPt
Definition: Config.cc:17
const float maxdR
Definition: Config.cc:20
void remove_duplicates(TrackVec &tracks)
Definition: MkStdSeqs.cc:352
const float maxdEta
Definition: Config.cc:19
const float maxdPhi
Definition: Config.cc:18
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
const bool useHitsForDuplicates
Definition: Config.h:109
const float minFracHitsShared
Definition: Config.cc:21

◆ clean_duplicates_sharedhits()

void mkfit::StdSeq::clean_duplicates_sharedhits ( TrackVec tracks,
const IterationConfig itconf 
)

Definition at line 443 of file MkStdSeqs.cc.

References a, funct::abs(), b, mkfit::IterationConfig::dc_fracSharedHits, HLT_2023v12_cff::fraction, mps_fire::i, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, SiStripPI::min, vertices_cff::ntracks, FastTimerService_cff::range, remove_duplicates(), mkfit::squashPhiMinimal(), funct::tan(), DiMuonV_cfg::tracks, and mitigatedMETSequence_cff::U.

443  {
444  const float fraction = itconf.dc_fracSharedHits;
445  const auto ntracks = tracks.size();
446 
447  std::vector<float> ctheta(ntracks);
448  std::multimap<int, int> hitMap;
449 
450  for (auto itrack = 0U; itrack < ntracks; itrack++) {
451  auto &trk = tracks[itrack];
452  ctheta[itrack] = 1.f / std::tan(trk.theta());
453  for (int i = 0; i < trk.nTotalHits(); ++i) {
454  if (trk.getHitIdx(i) < 0)
455  continue;
456  int a = trk.getHitLyr(i);
457  int b = trk.getHitIdx(i);
458  hitMap.insert(std::make_pair(b * 1000 + a, i > 0 ? itrack : -itrack)); //negative for first hit in trk
459  }
460  }
461 
462  for (auto itrack = 0U; itrack < ntracks; itrack++) {
463  auto &trk = tracks[itrack];
464  auto phi1 = trk.momPhi();
465  auto ctheta1 = ctheta[itrack];
466 
467  std::map<int, int> sharingMap;
468  for (int i = 0; i < trk.nTotalHits(); ++i) {
469  if (trk.getHitIdx(i) < 0)
470  continue;
471  int a = trk.getHitLyr(i);
472  int b = trk.getHitIdx(i);
473  auto range = hitMap.equal_range(b * 1000 + a);
474  for (auto it = range.first; it != range.second; ++it) {
475  if (std::abs(it->second) >= (int)itrack)
476  continue; // don't check your own hits (==) nor sym. checks (>)
477  if (i == 0 && it->second < 0)
478  continue; // shared first - first is not counted
479  sharingMap[std::abs(it->second)]++;
480  }
481  }
482 
483  for (const auto &elem : sharingMap) {
484  auto &track2 = tracks[elem.first];
485 
486  // broad dctheta-dphi compatibility checks; keep mostly to preserve consistency with old results
487  auto dctheta = std::abs(ctheta[elem.first] - ctheta1);
488  if (dctheta > 1.)
489  continue;
490 
491  auto dphi = std::abs(squashPhiMinimal(phi1 - track2.momPhi()));
492  if (dphi > 1.)
493  continue;
494 
495  if (elem.second >= std::min(trk.nFoundHits(), track2.nFoundHits()) * fraction) {
496  if (trk.score() > track2.score())
497  track2.setDuplicateValue(true);
498  else
499  trk.setDuplicateValue(true);
500  }
501  } // end sharing hits loop
502  } // end trk loop
503 
505  }
float squashPhiMinimal(float phi)
Definition: Hit.h:26
void remove_duplicates(TrackVec &tracks)
Definition: MkStdSeqs.cc:352
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ clean_duplicates_sharedhits_pixelseed()

void mkfit::StdSeq::clean_duplicates_sharedhits_pixelseed ( TrackVec tracks,
const IterationConfig itconf 
)

Definition at line 507 of file MkStdSeqs.cc.

References a, funct::abs(), b, HltBtagPostValidation_cff::c, ztail::d, mkfit::IterationConfig::dc_drth_central, mkfit::IterationConfig::dc_drth_forward, mkfit::IterationConfig::dc_drth_obarrel, mkfit::IterationConfig::dc_fracSharedHits, HLT_2023v12_cff::fraction, mps_fire::i, dqmiolumiharvest::j, mkfit::Config::maxcth_fw, mkfit::Config::maxcth_ob, mkfit::Config::maxd1pt, mkfit::Config::maxdcth, mkfit::Config::maxdphi, SiStripPI::min, vertices_cff::ntracks, remove_duplicates(), mkfit::squashPhiMinimal(), funct::tan(), DiMuonV_cfg::tracks, and mitigatedMETSequence_cff::U.

507  {
508  const float fraction = itconf.dc_fracSharedHits;
509  const float drth_central = itconf.dc_drth_central;
510  const float drth_obarrel = itconf.dc_drth_obarrel;
511  const float drth_forward = itconf.dc_drth_forward;
512  const auto ntracks = tracks.size();
513 
514  std::vector<float> ctheta(ntracks);
515  for (auto itrack = 0U; itrack < ntracks; itrack++) {
516  auto &trk = tracks[itrack];
517  ctheta[itrack] = 1.f / std::tan(trk.theta());
518  }
519 
520  float phi1, invpt1, dctheta, ctheta1, dphi, dr2;
521  for (auto itrack = 0U; itrack < ntracks; itrack++) {
522  auto &trk = tracks[itrack];
523  phi1 = trk.momPhi();
524  invpt1 = trk.invpT();
525  ctheta1 = ctheta[itrack];
526  for (auto jtrack = itrack + 1; jtrack < ntracks; jtrack++) {
527  auto &track2 = tracks[jtrack];
528  if (trk.label() == track2.label())
529  continue;
530 
531  dctheta = std::abs(ctheta[jtrack] - ctheta1);
532 
533  if (dctheta > Config::maxdcth)
534  continue;
535 
536  dphi = std::abs(squashPhiMinimal(phi1 - track2.momPhi()));
537 
538  if (dphi > Config::maxdphi)
539  continue;
540 
541  float maxdRSquared = drth_central * drth_central;
542  if (std::abs(ctheta1) > Config::maxcth_fw)
543  maxdRSquared = drth_forward * drth_forward;
544  else if (std::abs(ctheta1) > Config::maxcth_ob)
545  maxdRSquared = drth_obarrel * drth_obarrel;
546  dr2 = dphi * dphi + dctheta * dctheta;
547  if (dr2 < maxdRSquared) {
548  //Keep track with best score
549  if (trk.score() > track2.score())
550  track2.setDuplicateValue(true);
551  else
552  trk.setDuplicateValue(true);
553  continue;
554  }
555 
556  if (std::abs(track2.invpT() - invpt1) > Config::maxd1pt)
557  continue;
558 
559  auto sharedCount = 0;
560  auto sharedFirst = 0;
561  const auto minFoundHits = std::min(trk.nFoundHits(), track2.nFoundHits());
562 
563  for (int i = 0; i < trk.nTotalHits(); ++i) {
564  if (trk.getHitIdx(i) < 0)
565  continue;
566  const int a = trk.getHitLyr(i);
567  const int b = trk.getHitIdx(i);
568  for (int j = 0; j < track2.nTotalHits(); ++j) {
569  if (track2.getHitIdx(j) < 0)
570  continue;
571  const int c = track2.getHitLyr(j);
572  const int d = track2.getHitIdx(j);
573 
574  //this is to count once shared matched hits (may be done more properly...)
575  if (a == c && b == d)
576  sharedCount += 1;
577  if (j == 0 && i == 0 && a == c && b == d)
578  sharedFirst += 1;
579 
580  if ((sharedCount - sharedFirst) >= ((minFoundHits - sharedFirst) * fraction))
581  continue;
582  }
583  if ((sharedCount - sharedFirst) >= ((minFoundHits - sharedFirst) * fraction))
584  continue;
585  }
586 
587  //selection here - 11percent fraction of shared hits to label a duplicate
588  if ((sharedCount - sharedFirst) >= ((minFoundHits - sharedFirst) * fraction)) {
589  if (trk.score() > track2.score())
590  track2.setDuplicateValue(true);
591  else
592  trk.setDuplicateValue(true);
593  }
594  }
595  } //end loop one over tracks
596 
598  }
float squashPhiMinimal(float phi)
Definition: Hit.h:26
const float maxdphi
Definition: Config.cc:24
const float maxd1pt
Definition: Config.cc:23
const float maxdcth
Definition: Config.cc:25
const float maxcth_fw
Definition: Config.cc:27
void remove_duplicates(TrackVec &tracks)
Definition: MkStdSeqs.cc:352
const float maxcth_ob
Definition: Config.cc:26
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
d
Definition: ztail.py:151
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

◆ cmssw_LoadHits_Begin()

void mkfit::StdSeq::cmssw_LoadHits_Begin ( EventOfHits eoh,
const std::vector< const HitVec *> &  orig_hitvectors 
)

Definition at line 31 of file MkStdSeqs.cc.

References mps_fire::i, MainPageGenerator::l, mkfit::EventOfHits::nLayers(), and mkfit::EventOfHits::reset().

Referenced by MkFitEventOfHitsProducer::produce().

31  {
32  eoh.reset();
33  for (int i = 0; i < eoh.nLayers(); ++i) {
34  auto &&l = eoh[i];
35  l.beginRegistrationOfHits(*orig_hitvectors[l.is_pixel() ? 0 : 1]);
36  }
37  }

◆ cmssw_LoadHits_End()

void mkfit::StdSeq::cmssw_LoadHits_End ( EventOfHits eoh)

Definition at line 47 of file MkStdSeqs.cc.

References mps_fire::i, MainPageGenerator::l, and mkfit::EventOfHits::nLayers().

Referenced by MkFitEventOfHitsProducer::produce().

47  {
48  for (int i = 0; i < eoh.nLayers(); ++i) {
49  auto &&l = eoh[i];
50  l.endRegistrationOfHits(false);
51  }
52  }

◆ cmssw_Map_TrackHitIndices()

void mkfit::StdSeq::cmssw_Map_TrackHitIndices ( const EventOfHits eoh,
TrackVec seeds 
)

Definition at line 58 of file MkStdSeqs.cc.

References mps_fire::i, HLT_FULL_cff::seeds, and HLT_2023v12_cff::track.

58  {
59  for (auto &&track : seeds) {
60  for (int i = 0; i < track.nTotalHits(); ++i) {
61  const int hitidx = track.getHitIdx(i);
62  const int hitlyr = track.getHitLyr(i);
63  if (hitidx >= 0) {
64  const auto &loh = eoh[hitlyr];
65  track.setHitIdx(i, loh.getHitIndexFromOriginal(hitidx));
66  }
67  }
68  }
69  }

◆ cmssw_ReMap_TrackHitIndices()

void mkfit::StdSeq::cmssw_ReMap_TrackHitIndices ( const EventOfHits eoh,
TrackVec out_tracks 
)

Definition at line 71 of file MkStdSeqs.cc.

References mps_fire::i, and HLT_2023v12_cff::track.

71  {
72  for (auto &&track : out_tracks) {
73  for (int i = 0; i < track.nTotalHits(); ++i) {
74  const int hitidx = track.getHitIdx(i);
75  const int hitlyr = track.getHitLyr(i);
76  if (hitidx >= 0) {
77  const auto &loh = eoh[hitlyr];
78  track.setHitIdx(i, loh.getOriginalHitIndex(hitidx));
79  }
80  }
81  }
82  }

◆ dump_simtracks()

void mkfit::StdSeq::dump_simtracks ( Event event)

Definition at line 55 of file MkStandaloneSeqs.cc.

References dprint, createfilelist::int, and HLT_2023v12_cff::track.

55  {
56  // Ripped out of MkBuilder::begin_event, ifdefed under DEBUG
57 
58  std::vector<Track> &simtracks = event->simTracks_;
59 
60  for (int itrack = 0; itrack < (int)simtracks.size(); ++itrack) {
61  // bool debug = true;
62  Track track = simtracks[itrack];
63  // simtracks are initially written with label = index; uncomment in case tracks were edited
64  // if (track.label() != itrack) {
65  // dprintf("Bad label for simtrack %d -- %d\n", itrack, track.label());
66  // }
67 
68  dprint("MX - simtrack with nHits=" << track.nFoundHits() << " chi2=" << track.chi2() << " pT=" << track.pT()
69  << " phi=" << track.momPhi() << " eta=" << track.momEta());
70  }
71 
72  for (int itrack = 0; itrack < (int)simtracks.size(); ++itrack) {
73  for (int ihit = 0; ihit < simtracks[itrack].nFoundHits(); ++ihit) {
74  dprint("track #" << itrack << " hit #" << ihit
75  << " hit pos=" << simtracks[itrack].hitsVector(event->layerHits_)[ihit].position()
76  << " phi=" << simtracks[itrack].hitsVector(event->layerHits_)[ihit].phi());
77  }
78  }
79  }
#define dprint(x)
Definition: Debug.h:95
Definition: event.py:1

◆ handle_duplicates()

void mkfit::StdSeq::handle_duplicates ( Event )

Definition at line 33 of file MkStandaloneSeqs.cc.

33  {
34  /*
35  // Mark tracks as duplicates; if within CMSSW, remove duplicate tracks from fit or candidate track collection
36  if (Config::removeDuplicates) {
37  if (Config::quality_val || Config::sim_val || Config::cmssw_val) {
38  clean_duplicates(event->candidateTracks_);
39  if (Config::backwardFit)
40  clean_duplicates(event->fitTracks_);
41  }
42  // For the MEIF benchmarks and the stress tests, no validation flags are set so we will enter this block
43  else {
44  // Only care about the candidate tracks here; no need to run the duplicate removal on both candidate and fit tracks
45  clean_duplicates(event->candidateTracks_);
46  }
47  }
48  */
49  }

◆ loadDeads()

void mkfit::StdSeq::loadDeads ( EventOfHits eoh,
const std::vector< DeadVec > &  deadvectors 
)

Definition at line 21 of file MkStdSeqs.cc.

References deadvectors, and mkfit::EventOfHits::suckInDeads().

Referenced by mkfit::Shell::GoToEvent(), MkFitEventOfHitsProducer::produce(), and test_standard().

21  {
22  for (size_t il = 0; il < deadvectors.size(); il++) {
23  eoh.suckInDeads(int(il), deadvectors[il]);
24  }
25  }
std::vector< DeadVec > deadvectors
Definition: mkFit.cc:44

◆ loadHitsAndBeamSpot()

void mkfit::StdSeq::loadHitsAndBeamSpot ( Event ev,
EventOfHits eoh 
)

Definition at line 20 of file MkStandaloneSeqs.cc.

References makeMEIFBenchmarkPlots::ev, hgcalTBTopologyTester_cfi::layers, mkfit::EventOfHits::reset(), mkfit::EventOfHits::setBeamSpot(), and mkfit::EventOfHits::suckInHits().

Referenced by mkfit::Shell::GoToEvent(), and test_standard().

20  {
21  eoh.reset();
22 
23  // fill vector of hits in each layer
24  // XXXXMT: Does it really makes sense to multi-thread this?
25  tbb::parallel_for(tbb::blocked_range<int>(0, ev.layerHits_.size()), [&](const tbb::blocked_range<int> &layers) {
26  for (int ilay = layers.begin(); ilay < layers.end(); ++ilay) {
27  eoh.suckInHits(ilay, ev.layerHits_[ilay]);
28  }
29  });
30  eoh.setBeamSpot(ev.beamSpot_);
31  }

◆ prep_cmsswtracks()

void mkfit::StdSeq::prep_cmsswtracks ( Event event)

Definition at line 373 of file MkStandaloneSeqs.cc.

References prep_reftracks().

Referenced by root_val().

373 { prep_reftracks(event, event->cmsswTracks_, event->cmsswTracksExtra_, true); }
void prep_reftracks(Event *event, TrackVec &tracks, TrackExtraVec &extras, const bool realigntracks)
Definition: event.py:1

◆ prep_recotracks()

void mkfit::StdSeq::prep_recotracks ( Event event)

Definition at line 280 of file MkStandaloneSeqs.cc.

References mkfit::Config::cmssw_val, prep_tracks(), mkfit::Config::sim_val, and mkfit::Config::sim_val_for_cmssw.

Referenced by root_val(), and root_val_dumb_cmssw().

280  {
281  // seed tracks extras always needed
283  prep_tracks(event, event->seedTracks_, event->seedTracksExtra_, true);
284  } else if (Config::cmssw_val) // seed tracks are not validated, labels used for maps --> do NOT align index and labels!
285  {
286  prep_tracks(event, event->seedTracks_, event->seedTracksExtra_, false);
287  }
288 
289  // make extras + align index == label() for candidate tracks
290  prep_tracks(event, event->candidateTracks_, event->candidateTracksExtra_, true);
291  prep_tracks(event, event->fitTracks_, event->fitTracksExtra_, true);
292  }
void prep_tracks(Event *event, TrackVec &tracks, TrackExtraVec &extras, const bool realigntracks)
Definition: event.py:1

◆ prep_reftracks()

void mkfit::StdSeq::prep_reftracks ( Event event,
TrackVec tracks,
TrackExtraVec extras,
const bool  realigntracks 
)

Definition at line 375 of file MkStandaloneSeqs.cc.

References mkfit::Config::cmsSelMinLayers, prep_tracks(), HLT_2023v12_cff::track, and DiMuonV_cfg::tracks.

Referenced by prep_cmsswtracks(), and prep_simtracks().

375  {
376  prep_tracks(event, tracks, extras, realigntracks);
377 
378  // mark cmsswtracks as unfindable if too short
379  for (auto &track : tracks) {
380  const int nlyr = track.nUniqueLayers();
381  if (nlyr < Config::cmsSelMinLayers)
382  track.setNotFindable();
383  }
384  }
void prep_tracks(Event *event, TrackVec &tracks, TrackExtraVec &extras, const bool realigntracks)
Definition: event.py:1

◆ prep_simtracks()

void mkfit::StdSeq::prep_simtracks ( Event event)

Definition at line 294 of file MkStandaloneSeqs.cc.

References funct::abs(), submitPVResolutionJobs::count, spr::find(), heavyIonCSV_trainingSettings::idx, label, mkfit::Config::mtvLikeValidation, mkfit::Config::mtvRequireSeeds, prep_reftracks(), and mkfit::TrackBase::Signal.

Referenced by root_val_dumb_cmssw(), and mkfit::runBtpCe_MultiIter().

294  {
295  // First prep sim tracks to have hits sorted, then mark unfindable if too short
296  prep_reftracks(event, event->simTracks_, event->simTracksExtra_, false);
297 
298  // Now, make sure sim track shares at least four hits with a single cmssw seed.
299  // This ensures we factor out any weakness from CMSSW
300 
301  // First, make a make a map of [lyr][hit idx].vector(seed trk labels)
302  LayIdxIDVecMapMap seedHitIDMap;
303  std::map<int, int> labelNHitsMap;
304  std::map<int, int> labelAlgoMap;
305  std::map<int, std::vector<int>> labelSeedHitsMap;
306  for (const auto &seedtrack : event->seedTracks_) {
307  for (int ihit = 0; ihit < seedtrack.nTotalHits(); ihit++) {
308  const auto lyr = seedtrack.getHitLyr(ihit);
309  const auto idx = seedtrack.getHitIdx(ihit);
310 
311  if (lyr < 0 || idx < 0)
312  continue; // standard check
313  seedHitIDMap[lyr][idx].push_back(seedtrack.label());
314  labelSeedHitsMap[seedtrack.label()].push_back(lyr);
315  }
316  labelNHitsMap[seedtrack.label()] = seedtrack.nTotalHits();
317  labelAlgoMap[seedtrack.label()] = seedtrack.algoint();
318  }
319 
320  // Then, loop over sim tracks, and add up how many lyrs they possess of a single seed track
321  unsigned int count = 0;
322  for (auto &simtrack : event->simTracks_) {
323  if (simtrack.isNotFindable())
324  continue; // skip ones we already know are bad
325  TrkIDLaySetMap seedIDMap;
326  for (int ihit = 0; ihit < simtrack.nTotalHits(); ihit++) {
327  const auto lyr = simtrack.getHitLyr(ihit);
328  const auto idx = simtrack.getHitIdx(ihit);
329 
330  if (lyr < 0 || idx < 0)
331  continue; // standard check
332 
333  if (!seedHitIDMap.count(lyr))
334  continue; // ensure seed hit map has at least one entry for this layer
335  if (!seedHitIDMap.at(lyr).count(idx))
336  continue; // ensure seed hit map has at least one entry for this idx
337 
338  for (const auto label : seedHitIDMap.at(lyr).at(idx)) {
339  const auto &seedLayers = labelSeedHitsMap[label];
340  if (std::find(seedLayers.begin(), seedLayers.end(), lyr) != seedLayers.end()) //seed check moved here
341  seedIDMap[label].emplace(lyr);
342  }
343  }
344 
345  // now see if one of the seedIDs matched has at least 4 hits!
346  bool isSimSeed = false;
347  for (const auto &seedIDpair : seedIDMap) {
348  if ((int)seedIDpair.second.size() == labelNHitsMap[seedIDpair.first]) {
349  isSimSeed = true;
351  simtrack.setAlgoint(labelAlgoMap[seedIDpair.first]);
353  event->simTracksExtra_[count].addAlgo(labelAlgoMap[seedIDpair.first]);
354  //break;
355  }
356  }
358  // Apply MTV selection criteria and then return
359  if (simtrack.prodType() != Track::ProdType::Signal || simtrack.charge() == 0 || simtrack.posR() > 2.5 ||
360  std::abs(simtrack.z()) > 30 || std::abs(simtrack.momEta()) > 3.0)
361  simtrack.setNotFindable();
362  else if (Config::mtvRequireSeeds && !isSimSeed)
363  simtrack.setNotFindable();
364  } else {
365  // set findability based on bool isSimSeed
366  if (!isSimSeed)
367  simtrack.setNotFindable();
368  }
369  count++;
370  }
371  }
void prep_reftracks(Event *event, TrackVec &tracks, TrackExtraVec &extras, const bool realigntracks)
std::map< int, std::unordered_set< int > > TrkIDLaySetMap
Definition: TrackExtra.h:38
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
char const * label
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::map< int, std::map< int, std::vector< int > > > LayIdxIDVecMapMap
Definition: TrackExtra.h:37
Definition: event.py:1

◆ prep_tracks()

void mkfit::StdSeq::prep_tracks ( Event event,
TrackVec tracks,
TrackExtraVec extras,
const bool  realigntracks 
)

Definition at line 386 of file MkStandaloneSeqs.cc.

References mps_fire::i, label, and DiMuonV_cfg::tracks.

Referenced by prep_recotracks(), and prep_reftracks().

386  {
387  for (size_t i = 0; i < tracks.size(); i++) {
388  extras.emplace_back(tracks[i].label());
389  }
390  if (realigntracks)
391  event->validation_.alignTracks(tracks, extras, false);
392  }
char const * label

◆ qfilter_n_hits()

template<class TRACK >
bool mkfit::StdSeq::qfilter_n_hits ( const TRACK &  t,
const MkJob j 
)

Definition at line 619 of file MkStdSeqs.cc.

References dqmiolumiharvest::j, and submitPVValidationJobs::t.

619  {
620  int seedHits = t.getNSeedHits();
621  int seedReduction = (seedHits <= 5) ? 2 : 3;
622  return t.nFoundHits() - seedReduction >= j.params_cur().minHitsQF;
623  }

◆ qfilter_n_hits_pixseed()

template<class TRACK >
bool mkfit::StdSeq::qfilter_n_hits_pixseed ( const TRACK &  t,
const MkJob j 
)

Definition at line 627 of file MkStdSeqs.cc.

References dqmiolumiharvest::j, and submitPVValidationJobs::t.

627  {
628  return t.nFoundHits() >= j.params_cur().minHitsQF;
629  }

◆ qfilter_n_layers()

template<class TRACK >
bool mkfit::StdSeq::qfilter_n_layers ( const TRACK &  t,
const MkJob j 
)

Definition at line 634 of file MkStdSeqs.cc.

References funct::abs(), MuonTCMETValueMapProducer_cff::d0_max, dqmiolumiharvest::j, submitPVValidationJobs::t, mkfit::BeamSpot::x, and mkfit::BeamSpot::y.

634  {
635  const BeamSpot &bspot = j.m_beam_spot;
636  const TrackerInfo &trk_inf = j.m_trk_info;
637  int enhits = t.nHitsByTypeEncoded(trk_inf);
638  int npixhits = t.nPixelDecoded(enhits);
639  int enlyrs = t.nLayersByTypeEncoded(trk_inf);
640  int npixlyrs = t.nPixelDecoded(enlyrs);
641  int nmatlyrs = t.nTotMatchDecoded(enlyrs);
642  int llyr = t.getLastFoundHitLyr();
643  int lplyr = t.getLastFoundPixelHitLyr();
644  float invpt = t.invpT();
645 
646  // based on fr and eff vs pt (convert to native invpt)
647  float invptmin = 1.43; // min 1/pT (=1/0.7) for full filter on (npixhits<=3 .or. npixlyrs<=3)
648  float d0BS = t.d0BeamSpot(bspot.x, bspot.y);
649  float d0_max = 0.1; // 1 mm, max for somewhat prompt
650 
651  // next-to-outermost pixel layers (almost): BPIX3 or FPIX1
652  bool endsInsidePix = (llyr == 2 || llyr == 18 || llyr == 45);
653  // not last pixel layers: BPIX[123] or FPIX[12]
654  bool lastInsidePix = ((0 <= lplyr && lplyr < 3) || (18 <= lplyr && lplyr < 20) || (45 <= lplyr && lplyr < 47));
655  // reject short tracks missing last pixel layer except for prompt-looking
656  return !(((npixhits <= 3 || npixlyrs <= 3) && endsInsidePix &&
657  (invpt < invptmin || (invpt >= invptmin && std::abs(d0BS) > d0_max))) ||
658  ((npixlyrs <= 3 && nmatlyrs <= 6) && lastInsidePix && llyr != lplyr && std::abs(d0BS) > d0_max));
659  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ qfilter_nan_n_silly()

template<class TRACK >
bool mkfit::StdSeq::qfilter_nan_n_silly ( const TRACK &  t,
const MkJob  
)

Definition at line 40 of file MkStdSeqs.h.

References submitPVValidationJobs::t.

40  {
41  return !(t.hasNanNSillyValues());
42  }

◆ qfilter_pixelLessBkwd()

template<class TRACK >
bool mkfit::StdSeq::qfilter_pixelLessBkwd ( const TRACK &  t,
const MkJob j 
)

quality filter tuned for pixelLess iteration during backward search

Definition at line 696 of file MkStdSeqs.cc.

References funct::abs(), MuonTCMETValueMapProducer_cff::d0_max, dqmiolumiharvest::j, nHits, mkfit::Const::PIOver2, submitPVValidationJobs::t, mkfit::BeamSpot::x, and mkfit::BeamSpot::y.

696  {
697  const BeamSpot &bspot = j.m_beam_spot;
698  const TrackerInfo &tk_info = j.m_trk_info;
699  float d0BS = t.d0BeamSpot(bspot.x, bspot.y);
700  float d0_max = 0.1; // 1 mm
701 
702  int encoded;
703  encoded = t.nLayersByTypeEncoded(tk_info);
704  int nLyrs = t.nTotMatchDecoded(encoded);
705  encoded = t.nHitsByTypeEncoded(tk_info);
706  int nHits = t.nTotMatchDecoded(encoded);
707 
708  // based on fr and eff vs pt and eta (convert to native invpt and theta)
709  float invpt = t.invpT();
710  float invptmin = 1.11; // =1/0.9
711 
712  float thetasym = std::abs(t.theta() - Const::PIOver2);
713  float thetasymmin_l = 0.80; // -> |eta|=0.9
714  float thetasymmin_h = 1.11; // -> |eta|=1.45
715 
716  // reject too short or too displaced tracks
717  return !(
718  ((nLyrs <= 3 || nHits <= 3)) ||
719  ((nLyrs <= 4 || nHits <= 4) && (invpt < invptmin || (thetasym > thetasymmin_l && std::abs(d0BS) > d0_max))) ||
720  ((nLyrs <= 5 || nHits <= 5) && (invpt > invptmin && thetasym > thetasymmin_h && std::abs(d0BS) > d0_max)));
721  }
constexpr float PIOver2
Definition: Config.h:9
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits

◆ qfilter_pixelLessFwd()

template<class TRACK >
bool mkfit::StdSeq::qfilter_pixelLessFwd ( const TRACK &  t,
const MkJob j 
)

quality filter tuned for pixelLess iteration during forward search

Definition at line 664 of file MkStdSeqs.cc.

References funct::abs(), MuonTCMETValueMapProducer_cff::d0_max, dqmiolumiharvest::j, nHits, mkfit::Const::PIOver2, submitPVValidationJobs::t, mkfit::BeamSpot::x, and mkfit::BeamSpot::y.

664  {
665  const BeamSpot &bspot = j.m_beam_spot;
666  const TrackerInfo &tk_info = j.m_trk_info;
667  float d0BS = t.d0BeamSpot(bspot.x, bspot.y);
668  float d0_max = 0.05; // 0.5 mm, max for somewhat prompt
669 
670  int encoded;
671  encoded = t.nLayersByTypeEncoded(tk_info);
672  int nLyrs = t.nTotMatchDecoded(encoded);
673  encoded = t.nHitsByTypeEncoded(tk_info);
674  int nHits = t.nTotMatchDecoded(encoded);
675 
676  // to subtract stereo seed layers to count just r-phi seed layers (better pt err)
677  int seedReduction = (t.getNSeedHits() <= 5) ? 2 : 3;
678 
679  // based on fr and eff vs pt and eta (convert to native invpt and theta)
680  float invpt = t.invpT();
681  float invptmin = 1.11; // =1/0.9
682 
683  float thetasym = std::abs(t.theta() - Const::PIOver2);
684  float thetasymmin = 1.11; // -> |eta|=1.45
685 
686  // accept longer tracks, reject too short and displaced
687  return (((t.nFoundHits() - seedReduction >= 4 && invpt < invptmin) ||
688  (t.nFoundHits() - seedReduction >= 3 && invpt > invptmin && thetasym <= thetasymmin) ||
689  (t.nFoundHits() - seedReduction >= 4 && invpt > invptmin && thetasym > thetasymmin)) &&
690  !((nLyrs <= 4 || nHits <= 4) && std::abs(d0BS) > d0_max && invpt < invptmin));
691  }
constexpr float PIOver2
Definition: Config.h:9
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TupleMultiplicity< TrackerTraits > const *__restrict__ uint32_t nHits

◆ remove_duplicates()

void mkfit::StdSeq::remove_duplicates ( TrackVec tracks)

Definition at line 352 of file MkStdSeqs.cc.

References HLT_2023v12_cff::track, and DiMuonV_cfg::tracks.

Referenced by clean_duplicates(), clean_duplicates_sharedhits(), and clean_duplicates_sharedhits_pixelseed().

352  {
353  tracks.erase(std::remove_if(tracks.begin(), tracks.end(), [](auto track) { return track.getDuplicateValue(); }),
354  tracks.end());
355  }

◆ root_val()

void mkfit::StdSeq::root_val ( Event event)

Definition at line 260 of file MkStandaloneSeqs.cc.

References mkfit::Config::backwardFit, mkfit::Config::cmssw_val, prep_cmsswtracks(), prep_recotracks(), and score_tracks().

Referenced by mkfit::runBtpCe_MultiIter(), mkfit::runBuildingTestPlexBestHit(), mkfit::runBuildingTestPlexCloneEngine(), and mkfit::runBuildingTestPlexStandard().

260  {
261  // score the tracks
262  score_tracks(event->seedTracks_);
263  score_tracks(event->candidateTracks_);
264 
265  // deal with fit tracks
266  if (Config::backwardFit) {
267  score_tracks(event->fitTracks_);
268  } else
269  event->fitTracks_ = event->candidateTracks_;
270 
271  // sort hits + make extras, align if needed
273  if (Config::cmssw_val)
275 
276  // validate
277  event->validate();
278  }
void score_tracks(TrackVec &tracks)
void prep_recotracks(Event *event)
Definition: event.py:1
void prep_cmsswtracks(Event *event)

◆ root_val_dumb_cmssw()

void mkfit::StdSeq::root_val_dumb_cmssw ( Event event)

Definition at line 239 of file MkStandaloneSeqs.cc.

References mkfit::Config::nItersCMSSW, prep_recotracks(), and prep_simtracks().

Referenced by mkfit::runBuildingTestPlexDumbCMSSW().

239  {
240  // get labels correct first
241  event->relabel_bad_seedtracks();
242  event->relabel_cmsswtracks_from_seeds();
243 
244  //collection cleaning
245  if (Config::nItersCMSSW > 0)
246  event->select_tracks_iter(Config::nItersCMSSW);
247 
248  // set the track collections to each other
249  event->candidateTracks_ = event->cmsswTracks_;
250  event->fitTracks_ = event->candidateTracks_;
251 
252  // prep the tracks + extras
255 
256  // validate
257  event->validate();
258  }
void prep_simtracks(Event *event)
void prep_recotracks(Event *event)
Definition: event.py:1

◆ score_tracks()

void mkfit::StdSeq::score_tracks ( TrackVec tracks)

Definition at line 394 of file MkStandaloneSeqs.cc.

References mkfit::IterationConfig::get_track_scorer(), mkfit::getScoreCand(), HLT_2023v12_cff::track, and DiMuonV_cfg::tracks.

Referenced by root_val().

394  {
395  auto score_func = IterationConfig::get_track_scorer("default");
396  for (auto &track : tracks) {
397  track.setScore(getScoreCand(score_func, track));
398  }
399  }
float getScoreCand(const track_score_func &score_func, const Track &cand1, bool penalizeTailMissHits=false, bool inFindCandidates=false)
Definition: Track.h:615

◆ track_print()

void mkfit::StdSeq::track_print ( Event event,
const Track t,
const char *  pref 
)

Definition at line 81 of file MkStandaloneSeqs.cc.

References heavyIonCSV_trainingSettings::idx, mkfit::print(), submitPVValidationJobs::t, and hit::z.

81  {
82  printf("%s with q=%+i pT=%7.3f eta=% 7.3f nHits=%2d label=%4d\nState:\n",
83  pref,
84  t.charge(),
85  t.pT(),
86  t.momEta(),
87  t.nFoundHits(),
88  t.label());
89 
90  print(t.state());
91 
92  printf("Hits:\n");
93  for (int ih = 0; ih < t.nTotalHits(); ++ih) {
94  int lyr = t.getHitLyr(ih);
95  int idx = t.getHitIdx(ih);
96  if (idx >= 0) {
97  const Hit &hit = event->layerHits_[lyr][idx];
98  printf(" hit %2d lyr=%2d idx=%4d pos r=%7.3f z=% 8.3f mc_hit=%4d mc_trk=%4d\n",
99  ih,
100  lyr,
101  idx,
102  hit.r(),
103  hit.z(),
104  hit.mcHitID(),
105  hit.mcTrackID(event->simHitsInfo_));
106  } else
107  printf(" hit %2d idx=%i\n", ih, t.getHitIdx(ih));
108  }
109  }
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47
Definition: event.py:1

◆ trackScoreDefault()

float mkfit::StdSeq::trackScoreDefault ( const int  nfoundhits,
const int  ntailholes,
const int  noverlaphits,
const int  nmisshits,
const float  chi2,
const float  pt,
const bool  inFindCandidates 
)

Definition at line 740 of file MkStdSeqs.cc.

References nano_mu_local_reco_cff::chi2, f, SiStripPI::min, mkfit::Config::missingHitPenalty_, mkfit::Config::overlapHitBonus_, DiDispStaMuonMonitor_cfi::pt, offlineSlimmedPrimaryVertices_cfi::score, mkfit::Config::tailMissingHitPenalty_, mkfit::Config::validHitBonus_, and mkfit::Config::validHitSlope_.

746  {
747  float maxBonus = 8.0;
748  float bonus = Config::validHitSlope_ * nfoundhits + Config::validHitBonus_;
749  float penalty = Config::missingHitPenalty_;
750  float tailPenalty = Config::tailMissingHitPenalty_;
751  float overlapBonus = Config::overlapHitBonus_;
752  if (pt < 0.9) {
753  penalty *= inFindCandidates ? 1.7f : 1.5f;
754  bonus = std::min(bonus * (inFindCandidates ? 0.9f : 1.0f), maxBonus);
755  }
756  float score =
757  bonus * nfoundhits + overlapBonus * noverlaphits - penalty * nmisshits - tailPenalty * ntailholes - chi2;
758  return score;
759  }
constexpr float validHitSlope_
Definition: Config.h:76
constexpr float tailMissingHitPenalty_
Definition: Config.h:79
double f[11][100]
constexpr float overlapHitBonus_
Definition: Config.h:77
constexpr float validHitBonus_
Definition: Config.h:75
constexpr float missingHitPenalty_
Definition: Config.h:78