CMS 3D CMS Logo

runFunctions.cc
Go to the documentation of this file.
4 
5 #include "oneapi/tbb/parallel_for.h"
6 
7 #include <memory>
8 
9 namespace mkfit {
10 
11  //==============================================================================
12  // run_OneIteration
13  //
14  // One-stop function for running track building from CMSSW.
15  //==============================================================================
16 
19  const std::vector<const std::vector<bool> *> &m_mask_vector;
20 
21  IterationMaskIfcCmssw(const TrackerInfo &ti, const std::vector<const std::vector<bool> *> &maskvec)
22  : m_trk_info(ti), m_mask_vector(maskvec) {}
23 
24  const std::vector<bool> *get_mask_for_layer(int layer) const override {
25  return m_trk_info.layer(layer).is_pixel() ? m_mask_vector[0] : m_mask_vector[1];
26  }
27  };
28 
29  void run_OneIteration(const TrackerInfo &trackerInfo,
30  const IterationConfig &itconf,
31  const EventOfHits &eoh,
32  const std::vector<const std::vector<bool> *> &hit_masks,
33  MkBuilder &builder,
34  TrackVec &seeds,
35  TrackVec &out_tracks,
36  bool do_seed_clean,
37  bool do_backward_fit,
38  bool do_remove_duplicates) {
39  IterationMaskIfcCmssw it_mask_ifc(trackerInfo, hit_masks);
40 
41  MkJob job({trackerInfo, itconf, eoh, eoh.refBeamSpot(), &it_mask_ifc});
42 
43  builder.begin_event(&job, nullptr, __func__);
44 
45  // Seed cleaning not done on all iterations.
46  do_seed_clean = do_seed_clean && itconf.m_seed_cleaner;
47 
48  if (do_seed_clean)
49  itconf.m_seed_cleaner(seeds, itconf, eoh.refBeamSpot());
50 
51  // Check nans in seeds -- this should not be needed when Slava fixes
52  // the track parameter coordinate transformation.
53  builder.seed_post_cleaning(seeds);
54 
55  if (itconf.m_requires_seed_hit_sorting) {
56  for (auto &s : seeds)
57  s.sortHitsByLayer(); // sort seed hits for the matched hits (I hope it works here)
58  }
59 
60  builder.find_tracks_load_seeds(seeds, do_seed_clean);
61 
62  builder.findTracksCloneEngine();
63 
64  if (itconf.m_pre_bkfit_filter) {
65  builder.filter_comb_cands(itconf.m_pre_bkfit_filter);
66  }
67 
68  job.switch_to_backward();
69 
70  if (do_backward_fit) {
71  if (itconf.m_backward_search) {
73  }
74 
75  builder.backwardFit();
76 
77  if (itconf.m_backward_search) {
78  builder.beginBkwSearch();
80  builder.endBkwSearch();
81  }
82 
83  if (itconf.m_post_bkfit_filter) {
84  builder.filter_comb_cands(itconf.m_post_bkfit_filter);
85  }
86  }
87 
88  builder.filter_comb_cands(StdSeq::qfilter_nan_n_silly<TrackCand>);
89 
90  builder.export_best_comb_cands(out_tracks, true);
91 
92  if (do_remove_duplicates && itconf.m_duplicate_cleaner) {
93  itconf.m_duplicate_cleaner(out_tracks, itconf);
94  }
95 
96  builder.end_event();
97  builder.release_memory();
98  }
99 
100 } // end namespace mkfit
const BeamSpot & refBeamSpot() const
void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits)
Definition: MkBuilder.h:66
void findTracksCloneEngine(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
Definition: MkBuilder.cc:927
void begin_event(MkJob *job, Event *ev, const char *build_type)
Definition: MkBuilder.cc:197
bool is_pixel() const
Definition: TrackerInfo.h:69
clean_seeds_func m_seed_cleaner
int filter_comb_cands(IterationConfig::filter_candidates_func filter)
Definition: MkBuilder.cc:304
void run_OneIteration(const TrackerInfo &trackerInfo, const IterationConfig &itconf, const EventOfHits &eoh, const std::vector< const std::vector< bool > *> &hit_masks, MkBuilder &builder, TrackVec &seeds, TrackVec &out_tracks, bool do_seed_clean, bool do_backward_fit, bool do_remove_duplicates)
Definition: runFunctions.cc:29
void find_tracks_load_seeds(const TrackVec &in_seeds, const bool seeds_sorted)
Definition: MkBuilder.cc:613
void release_memory()
Definition: MkBuilder.cc:225
void seed_post_cleaning(TrackVec &tv)
Definition: MkBuilder.cc:398
const LayerInfo & layer(int l) const
Definition: TrackerInfo.h:162
filter_candidates_func m_post_bkfit_filter
const std::vector< bool > * get_mask_for_layer(int layer) const override
Definition: runFunctions.cc:24
std::vector< Track > TrackVec
const std::vector< const std::vector< bool > * > & m_mask_vector
Definition: runFunctions.cc:19
clean_duplicates_func m_duplicate_cleaner
void beginBkwSearch()
Definition: MkBuilder.h:70
void export_best_comb_cands(TrackVec &out_vec, bool remove_missing_hits=false)
Definition: MkBuilder.cc:372
void endBkwSearch()
Definition: MkBuilder.h:71
const TrackerInfo & m_trk_info
Definition: runFunctions.cc:18
IterationMaskIfcCmssw(const TrackerInfo &ti, const std::vector< const std::vector< bool > *> &maskvec)
Definition: runFunctions.cc:21
filter_candidates_func m_pre_bkfit_filter