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  // MkJob
26  //==============================================================================
27 
28  //==============================================================================
29  // MkBuilder
30  //==============================================================================
31 
32  class MkBuilder {
33  public:
34  using insert_seed_foo = void(const Track &, int, int);
35 
36  typedef std::vector<std::pair<int, int>> CandIdx_t;
37 
38  MkBuilder(bool silent = true) : m_silent(silent) {}
39  ~MkBuilder() = default;
40 
41  // --------
42 
43  static std::unique_ptr<MkBuilder> make_builder(bool silent = true);
44  static void populate();
45 
46  int total_cands() const;
47  std::pair<int, int> max_hits_layer(const EventOfHits &eoh) const;
48 
49  // --------
50 
51  void begin_event(MkJob *job, Event *ev, const char *build_type);
52  void end_event();
53  void release_memory();
54 
55  void import_seeds(const TrackVec &in_seeds, const bool seeds_sorted, std::function<insert_seed_foo> insert_seed);
56 
57  // filter for rearranging cands that will / will not do backward search.
59 
61 
62  void select_best_comb_cands(bool clear_m_tracks = false, bool remove_missing_hits = false);
63  void export_best_comb_cands(TrackVec &out_vec, bool remove_missing_hits = false);
64  void export_tracks(TrackVec &out_vec);
65 
66  void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits) {
67  m_event_of_comb_cands.compactifyHitStorageForBestCand(remove_seed_hits, backward_fit_min_hits);
68  }
69 
72 
73  // MIMI hack to export tracks for BH
74  const TrackVec &ref_tracks() const { return m_tracks; }
76 
77  // --------
78 
79  void find_tracks_load_seeds_BH(const TrackVec &in_seeds, const bool seeds_sorted); // for FindTracksBestHit
80  void find_tracks_load_seeds(const TrackVec &in_seeds, const bool seeds_sorted);
81 
82  int find_tracks_unroll_candidates(std::vector<std::pair<int, int>> &seed_cand_vec,
83  int start_seed,
84  int end_seed,
85  int layer,
86  int prev_layer,
87  bool pickup_only,
88  SteeringParams::IterationType_e iteration_dir);
89 
91  const LayerInfo &layer_info,
92  std::vector<std::vector<TrackCand>> &tmp_cands,
93  const std::vector<std::pair<int, int>> &seed_cand_idx,
94  const int region,
95  const int start_seed,
96  const int itrack,
97  const int end);
98 
99  void find_tracks_in_layers(CandCloner &cloner,
100  MkFinder *mkfndr,
101  SteeringParams::IterationType_e iteration_dir,
102  const int start_seed,
103  const int end_seed,
104  const int region);
105 
106  // --------
107 
108  void seed_post_cleaning(TrackVec &tv);
109 
113 
114  void backwardFitBH();
115  void fit_cands_BH(MkFinder *mkfndr, int start_cand, int end_cand, int region);
116 
117  void backwardFit();
118  void fit_cands(MkFinder *mkfndr, int start_cand, int end_cand, int region);
119 
120  private:
121  void fit_one_seed_set(TrackVec &simtracks, int itrack, int end, MkFitter *mkfttr, const bool is_brl[]);
122 
123  MkJob *m_job = nullptr;
124 
125  // MIMI -- Used by seed processing / validation.
126  Event *m_event = nullptr;
127 
128  // State for BestHit
130 
131  // State for Std / CloneEngine
133 
134  // Per-region seed information
135  std::vector<int> m_seedEtaSeparators;
136  std::vector<int> m_seedMinLastLayer;
137  std::vector<int> m_seedMaxLastLayer;
138 
140 
141  bool m_silent;
142  };
143 
144 } // end namespace mkfit
145 
146 #endif
void import_seeds(const TrackVec &in_seeds, const bool seeds_sorted, std::function< insert_seed_foo > insert_seed)
Definition: MkBuilder.cc:231
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:625
static void populate()
Definition: MkBuilder.cc:171
std::pair< int, int > max_hits_layer(const EventOfHits &eoh) const
Definition: MkBuilder.cc:173
void export_tracks(TrackVec &out_vec)
Definition: MkBuilder.cc:387
void findTracksBestHit(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
Definition: MkBuilder.cc:464
~MkBuilder()=default
std::atomic< int > m_nan_n_silly_per_layer_count
Definition: MkBuilder.h:139
void find_min_max_hots_size()
Definition: MkBuilder.cc:344
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
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:1160
int filter_comb_cands(IterationConfig::filter_candidates_func filter)
Definition: MkBuilder.cc:304
void find_tracks_load_seeds_BH(const TrackVec &in_seeds, const bool seeds_sorted)
Definition: MkBuilder.cc:449
void findTracksStandard(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
Definition: MkBuilder.cc:748
void find_tracks_load_seeds(const TrackVec &in_seeds, const bool seeds_sorted)
Definition: MkBuilder.cc:613
void release_memory()
Definition: MkBuilder.cc:225
TrackVec m_tracks
Definition: MkBuilder.h:129
TrackVec & ref_tracks_nc()
Definition: MkBuilder.h:75
std::vector< int > m_seedEtaSeparators
Definition: MkBuilder.h:135
void seed_post_cleaning(TrackVec &tv)
Definition: MkBuilder.cc:398
Event * m_event
Definition: MkBuilder.h:126
void select_best_comb_cands(bool clear_m_tracks=false, bool remove_missing_hits=false)
Definition: MkBuilder.cc:366
int total_cands() const
Definition: MkBuilder.cc:186
const TrackVec & ref_tracks() const
Definition: MkBuilder.h:74
std::vector< Track > TrackVec
EventOfCombCandidates m_event_of_comb_cands
Definition: MkBuilder.h:132
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:690
void beginBkwSearch()
Definition: MkBuilder.h:70
std::vector< int > m_seedMaxLastLayer
Definition: MkBuilder.h:137
void export_best_comb_cands(TrackVec &out_vec, bool remove_missing_hits=false)
Definition: MkBuilder.cc:372
void(const Track &, int, int) insert_seed_foo
Definition: MkBuilder.h:34
static std::unique_ptr< MkBuilder > make_builder(bool silent=true)
Definition: MkBuilder.cc:169
MkBuilder(bool silent=true)
Definition: MkBuilder.h:38
void fit_cands(MkFinder *mkfndr, int start_cand, int end_cand, int region)
Definition: MkBuilder.cc:1315
void endBkwSearch()
Definition: MkBuilder.h:71
std::vector< int > m_seedMinLastLayer
Definition: MkBuilder.h:136
void fit_one_seed_set(TrackVec &simtracks, int itrack, int end, MkFitter *mkfttr, const bool is_brl[])
std::function< filter_candidates_cf > filter_candidates_func
std::vector< std::pair< int, int > > CandIdx_t
Definition: MkBuilder.h:36
void fit_cands_BH(MkFinder *mkfndr, int start_cand, int end_cand, int region)
Definition: MkBuilder.cc:1179
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:962