CMS 3D CMS Logo

MkBuilder.h
Go to the documentation of this file.
1 #ifndef RecoTracker_MkFitCore_interface_MkBuilder_h
2 #define RecoTracker_MkFitCore_interface_MkBuilder_h
3 
8 
9 #include <atomic>
10 #include <functional>
11 #include <map>
12 #include <vector>
13 
14 namespace mkfit {
15 
16  class CandCloner;
17  class LayerInfo;
18  class MkFinder;
19  class MkFitter;
20  class TrackerInfo;
21 
22  class Event;
23 
24  //==============================================================================
25  // MkBuilder
26  //==============================================================================
27 
28  class MkBuilder {
29  public:
30  using insert_seed_foo = void(const Track &, int, int, int);
31 
32  typedef std::vector<std::pair<int, int>> CandIdx_t;
33 
34  MkBuilder(bool silent = true) : m_silent(silent) {}
35  ~MkBuilder() = default;
36 
37  // --------
38 
39  static std::unique_ptr<MkBuilder> make_builder(bool silent = true);
40  static void populate();
41  static void clear();
42 
43  int total_cands() const;
44  std::pair<int, int> max_hits_layer(const EventOfHits &eoh) const;
45 
46  // --------
47 
48  void begin_event(MkJob *job, Event *ev, const char *build_type);
49  void end_event();
50  void release_memory();
51 
52  void import_seeds(const TrackVec &in_seeds, const bool seeds_sorted, std::function<insert_seed_foo> insert_seed);
53 
54  // filter for rearranging cands that will / will not do backward search.
55  int filter_comb_cands(filter_candidates_func filter, bool attempt_all_cands);
56 
58 
59  void select_best_comb_cands(bool clear_m_tracks = false, bool remove_missing_hits = false);
60  void export_best_comb_cands(TrackVec &out_vec, bool remove_missing_hits = false);
61  void export_tracks(TrackVec &out_vec);
62 
63  void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits) {
64  m_event_of_comb_cands.compactifyHitStorageForBestCand(remove_seed_hits, backward_fit_min_hits);
65  }
66 
69 
70  // MIMI hack to export tracks for BH
71  const TrackVec &ref_tracks() const { return m_tracks; }
73 
75 
76  // --------
77 
78  void find_tracks_load_seeds_BH(const TrackVec &in_seeds, const bool seeds_sorted); // for FindTracksBestHit
79  void find_tracks_load_seeds(const TrackVec &in_seeds, const bool seeds_sorted);
80 
81  int find_tracks_unroll_candidates(std::vector<std::pair<int, int>> &seed_cand_vec,
82  int start_seed,
83  int end_seed,
84  int layer,
85  int prev_layer,
86  bool pickup_only,
87  SteeringParams::IterationType_e iteration_dir);
88 
90  const LayerInfo &layer_info,
91  std::vector<std::vector<TrackCand>> &tmp_cands,
92  const std::vector<std::pair<int, int>> &seed_cand_idx,
93  const int region,
94  const int start_seed,
95  const int itrack,
96  const int end);
97 
98  void find_tracks_in_layers(CandCloner &cloner,
99  MkFinder *mkfndr,
100  SteeringParams::IterationType_e iteration_dir,
101  const int start_seed,
102  const int end_seed,
103  const int region);
104 
105  // --------
106 
107  void seed_post_cleaning(TrackVec &tv);
108 
112 
113  void backwardFitBH();
114  void fit_cands_BH(MkFinder *mkfndr, int start_cand, int end_cand, int region);
115 
116  void backwardFit();
117  void fit_cands(MkFinder *mkfndr, int start_cand, int end_cand, int region);
118 
119  private:
120  void fit_one_seed_set(TrackVec &simtracks, int itrack, int end, MkFitter *mkfttr, const bool is_brl[]);
121 
122  MkJob *m_job = nullptr;
123 
124  // MIMI -- Used by seed processing / validation.
125  Event *m_event = nullptr;
126 
127  // State for BestHit
129 
130  // State for Std / CloneEngine
132 
133  // Per-region seed information
134  std::vector<int> m_seedEtaSeparators;
135  std::vector<int> m_seedMinLastLayer;
136  std::vector<int> m_seedMaxLastLayer;
137 
139 
140  bool m_silent;
141  };
142 
143 } // end namespace mkfit
144 
145 #endif
void import_seeds(const TrackVec &in_seeds, const bool seeds_sorted, std::function< insert_seed_foo > insert_seed)
Definition: MkBuilder.cc:235
int find_tracks_unroll_candidates(std::vector< std::pair< int, int >> &seed_cand_vec, int start_seed, int end_seed, int layer, int prev_layer, bool pickup_only, SteeringParams::IterationType_e iteration_dir)
Definition: MkBuilder.cc:628
void(const Track &, int, int, int) insert_seed_foo
Definition: MkBuilder.h:30
const EventOfCombCandidates & ref_eocc() const
Definition: MkBuilder.h:74
static void populate()
Definition: MkBuilder.cc:174
std::pair< int, int > max_hits_layer(const EventOfHits &eoh) const
Definition: MkBuilder.cc:177
void export_tracks(TrackVec &out_vec)
Definition: MkBuilder.cc:403
void findTracksBestHit(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
Definition: MkBuilder.cc:461
~MkBuilder()=default
std::atomic< int > m_nan_n_silly_per_layer_count
Definition: MkBuilder.h:138
void find_min_max_hots_size()
Definition: MkBuilder.cc:363
void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits)
Definition: MkBuilder.h:63
void findTracksCloneEngine(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
Definition: MkBuilder.cc:939
void begin_event(MkJob *job, Event *ev, const char *build_type)
Definition: MkBuilder.cc:201
void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits)
TEMPL(T2) struct Divides void
Definition: Factorize.h:24
void backwardFitBH()
Definition: MkBuilder.cc:1230
void find_tracks_load_seeds_BH(const TrackVec &in_seeds, const bool seeds_sorted)
Definition: MkBuilder.cc:446
void findTracksStandard(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
Definition: MkBuilder.cc:753
std::function< filter_candidates_cf > filter_candidates_func
Definition: FunctionTypes.h:28
void find_tracks_load_seeds(const TrackVec &in_seeds, const bool seeds_sorted)
Definition: MkBuilder.cc:616
void release_memory()
Definition: MkBuilder.cc:229
TrackVec m_tracks
Definition: MkBuilder.h:128
TrackVec & ref_tracks_nc()
Definition: MkBuilder.h:72
std::vector< int > m_seedEtaSeparators
Definition: MkBuilder.h:134
void seed_post_cleaning(TrackVec &tv)
Definition: MkBuilder.cc:414
Event * m_event
Definition: MkBuilder.h:125
void select_best_comb_cands(bool clear_m_tracks=false, bool remove_missing_hits=false)
Definition: MkBuilder.cc:385
int filter_comb_cands(filter_candidates_func filter, bool attempt_all_cands)
Definition: MkBuilder.cc:308
int total_cands() const
Definition: MkBuilder.cc:190
const TrackVec & ref_tracks() const
Definition: MkBuilder.h:71
std::vector< Track > TrackVec
EventOfCombCandidates m_event_of_comb_cands
Definition: MkBuilder.h:131
void find_tracks_handle_missed_layers(MkFinder *mkfndr, const LayerInfo &layer_info, std::vector< std::vector< TrackCand >> &tmp_cands, const std::vector< std::pair< int, int >> &seed_cand_idx, const int region, const int start_seed, const int itrack, const int end)
Definition: MkBuilder.cc:693
void beginBkwSearch()
Definition: MkBuilder.h:67
std::vector< int > m_seedMaxLastLayer
Definition: MkBuilder.h:136
void export_best_comb_cands(TrackVec &out_vec, bool remove_missing_hits=false)
Definition: MkBuilder.cc:391
static std::unique_ptr< MkBuilder > make_builder(bool silent=true)
Definition: MkBuilder.cc:172
MkBuilder(bool silent=true)
Definition: MkBuilder.h:34
void fit_cands(MkFinder *mkfndr, int start_cand, int end_cand, int region)
Definition: MkBuilder.cc:1345
void endBkwSearch()
Definition: MkBuilder.h:68
std::vector< int > m_seedMinLastLayer
Definition: MkBuilder.h:135
void fit_one_seed_set(TrackVec &simtracks, int itrack, int end, MkFitter *mkfttr, const bool is_brl[])
static void clear()
Definition: MkBuilder.cc:175
std::vector< std::pair< int, int > > CandIdx_t
Definition: MkBuilder.h:32
void fit_cands_BH(MkFinder *mkfndr, int start_cand, int end_cand, int region)
Definition: MkBuilder.cc:1249
void find_tracks_in_layers(CandCloner &cloner, MkFinder *mkfndr, SteeringParams::IterationType_e iteration_dir, const int start_seed, const int end_seed, const int region)
Definition: MkBuilder.cc:974