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);
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 
42  int total_cands() const;
43  std::pair<int, int> max_hits_layer(const EventOfHits &eoh) const;
44 
45  // --------
46 
47  void begin_event(MkJob *job, Event *ev, const char *build_type);
48  void end_event();
49  void release_memory();
50 
51  void import_seeds(const TrackVec &in_seeds, const bool seeds_sorted, std::function<insert_seed_foo> insert_seed);
52 
53  // filter for rearranging cands that will / will not do backward search.
54  int filter_comb_cands(filter_candidates_func filter, bool attempt_all_cands);
55 
57 
58  void select_best_comb_cands(bool clear_m_tracks = false, bool remove_missing_hits = false);
59  void export_best_comb_cands(TrackVec &out_vec, bool remove_missing_hits = false);
60  void export_tracks(TrackVec &out_vec);
61 
62  void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits) {
63  m_event_of_comb_cands.compactifyHitStorageForBestCand(remove_seed_hits, backward_fit_min_hits);
64  }
65 
68 
69  // MIMI hack to export tracks for BH
70  const TrackVec &ref_tracks() const { return m_tracks; }
72 
74 
75  // --------
76 
77  void find_tracks_load_seeds_BH(const TrackVec &in_seeds, const bool seeds_sorted); // for FindTracksBestHit
78  void find_tracks_load_seeds(const TrackVec &in_seeds, const bool seeds_sorted);
79 
80  int find_tracks_unroll_candidates(std::vector<std::pair<int, int>> &seed_cand_vec,
81  int start_seed,
82  int end_seed,
83  int layer,
84  int prev_layer,
85  bool pickup_only,
86  SteeringParams::IterationType_e iteration_dir);
87 
89  const LayerInfo &layer_info,
90  std::vector<std::vector<TrackCand>> &tmp_cands,
91  const std::vector<std::pair<int, int>> &seed_cand_idx,
92  const int region,
93  const int start_seed,
94  const int itrack,
95  const int end);
96 
97  void find_tracks_in_layers(CandCloner &cloner,
98  MkFinder *mkfndr,
99  SteeringParams::IterationType_e iteration_dir,
100  const int start_seed,
101  const int end_seed,
102  const int region);
103 
104  // --------
105 
106  void seed_post_cleaning(TrackVec &tv);
107 
111 
112  void backwardFitBH();
113  void fit_cands_BH(MkFinder *mkfndr, int start_cand, int end_cand, int region);
114 
115  void backwardFit();
116  void fit_cands(MkFinder *mkfndr, int start_cand, int end_cand, int region);
117 
118  private:
119  void fit_one_seed_set(TrackVec &simtracks, int itrack, int end, MkFitter *mkfttr, const bool is_brl[]);
120 
121  MkJob *m_job = nullptr;
122 
123  // MIMI -- Used by seed processing / validation.
124  Event *m_event = nullptr;
125 
126  // State for BestHit
128 
129  // State for Std / CloneEngine
131 
132  // Per-region seed information
133  std::vector<int> m_seedEtaSeparators;
134  std::vector<int> m_seedMinLastLayer;
135  std::vector<int> m_seedMaxLastLayer;
136 
138 
139  bool m_silent;
140  };
141 
142 } // end namespace mkfit
143 
144 #endif
void import_seeds(const TrackVec &in_seeds, const bool seeds_sorted, std::function< insert_seed_foo > insert_seed)
Definition: MkBuilder.cc:228
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:618
const EventOfCombCandidates & ref_eocc() const
Definition: MkBuilder.h:73
static void populate()
Definition: MkBuilder.cc:168
std::pair< int, int > max_hits_layer(const EventOfHits &eoh) const
Definition: MkBuilder.cc:170
void export_tracks(TrackVec &out_vec)
Definition: MkBuilder.cc:396
void findTracksBestHit(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
Definition: MkBuilder.cc:454
~MkBuilder()=default
std::atomic< int > m_nan_n_silly_per_layer_count
Definition: MkBuilder.h:137
void find_min_max_hots_size()
Definition: MkBuilder.cc:356
void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits)
Definition: MkBuilder.h:62
void findTracksCloneEngine(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
Definition: MkBuilder.cc:923
void begin_event(MkJob *job, Event *ev, const char *build_type)
Definition: MkBuilder.cc:194
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:1165
void find_tracks_load_seeds_BH(const TrackVec &in_seeds, const bool seeds_sorted)
Definition: MkBuilder.cc:439
void findTracksStandard(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
Definition: MkBuilder.cc:741
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:606
void release_memory()
Definition: MkBuilder.cc:222
TrackVec m_tracks
Definition: MkBuilder.h:127
TrackVec & ref_tracks_nc()
Definition: MkBuilder.h:71
std::vector< int > m_seedEtaSeparators
Definition: MkBuilder.h:133
void seed_post_cleaning(TrackVec &tv)
Definition: MkBuilder.cc:407
Event * m_event
Definition: MkBuilder.h:124
void select_best_comb_cands(bool clear_m_tracks=false, bool remove_missing_hits=false)
Definition: MkBuilder.cc:378
int filter_comb_cands(filter_candidates_func filter, bool attempt_all_cands)
Definition: MkBuilder.cc:301
int total_cands() const
Definition: MkBuilder.cc:183
const TrackVec & ref_tracks() const
Definition: MkBuilder.h:70
std::vector< Track > TrackVec
EventOfCombCandidates m_event_of_comb_cands
Definition: MkBuilder.h:130
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:683
void beginBkwSearch()
Definition: MkBuilder.h:66
std::vector< int > m_seedMaxLastLayer
Definition: MkBuilder.h:135
void export_best_comb_cands(TrackVec &out_vec, bool remove_missing_hits=false)
Definition: MkBuilder.cc:384
void(const Track &, int, int) insert_seed_foo
Definition: MkBuilder.h:30
static std::unique_ptr< MkBuilder > make_builder(bool silent=true)
Definition: MkBuilder.cc:166
MkBuilder(bool silent=true)
Definition: MkBuilder.h:34
void fit_cands(MkFinder *mkfndr, int start_cand, int end_cand, int region)
Definition: MkBuilder.cc:1279
void endBkwSearch()
Definition: MkBuilder.h:67
std::vector< int > m_seedMinLastLayer
Definition: MkBuilder.h:134
void fit_one_seed_set(TrackVec &simtracks, int itrack, int end, MkFitter *mkfttr, const bool is_brl[])
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:1184
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:958