Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-01-17 23:25:49

0001 #ifndef RecoTracker_MkFitCore_interface_MkBuilder_h
0002 #define RecoTracker_MkFitCore_interface_MkBuilder_h
0003 
0004 #include "RecoTracker/MkFitCore/interface/IterationConfig.h"
0005 #include "RecoTracker/MkFitCore/interface/HitStructures.h"
0006 #include "RecoTracker/MkFitCore/interface/TrackStructures.h"
0007 #include "RecoTracker/MkFitCore/interface/MkJob.h"
0008 
0009 #include <atomic>
0010 #include <functional>
0011 #include <map>
0012 #include <vector>
0013 
0014 namespace mkfit {
0015 
0016   class CandCloner;
0017   class LayerInfo;
0018   class MkFinder;
0019   class MkFitter;
0020   class TrackerInfo;
0021 
0022   class Event;
0023 
0024   //==============================================================================
0025   // MkBuilder
0026   //==============================================================================
0027 
0028   class MkBuilder {
0029   public:
0030     using insert_seed_foo = void(const Track &, int, int, int);
0031 
0032     typedef std::vector<std::pair<int, int>> CandIdx_t;
0033 
0034     MkBuilder(bool silent = true) : m_silent(silent) {}
0035     ~MkBuilder() = default;
0036 
0037     // --------
0038 
0039     static std::unique_ptr<MkBuilder> make_builder(bool silent = true);
0040     static void populate();
0041     static void clear();
0042 
0043     int total_cands() const;
0044     std::pair<int, int> max_hits_layer(const EventOfHits &eoh) const;
0045 
0046     // --------
0047 
0048     void begin_event(MkJob *job, Event *ev, const char *build_type);
0049     void end_event();
0050     void release_memory();
0051 
0052     void import_seeds(const TrackVec &in_seeds, const bool seeds_sorted, std::function<insert_seed_foo> insert_seed);
0053 
0054     // filter for rearranging cands that will / will not do backward search.
0055     int filter_comb_cands(filter_candidates_func filter, bool attempt_all_cands);
0056 
0057     void find_min_max_hots_size();
0058 
0059     void select_best_comb_cands(bool clear_m_tracks = false, bool remove_missing_hits = false);
0060     void export_best_comb_cands(TrackVec &out_vec, bool remove_missing_hits = false);
0061     void export_tracks(TrackVec &out_vec);
0062 
0063     void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits) {
0064       m_event_of_comb_cands.compactifyHitStorageForBestCand(remove_seed_hits, backward_fit_min_hits);
0065     }
0066 
0067     void beginBkwSearch() { m_event_of_comb_cands.beginBkwSearch(); }
0068     void endBkwSearch() { m_event_of_comb_cands.endBkwSearch(); }
0069 
0070     // MIMI hack to export tracks for BH
0071     const TrackVec &ref_tracks() const { return m_tracks; }
0072     TrackVec &ref_tracks_nc() { return m_tracks; }
0073 
0074     const EventOfCombCandidates &ref_eocc() const { return m_event_of_comb_cands; }
0075 
0076     // --------
0077 
0078     void find_tracks_load_seeds_BH(const TrackVec &in_seeds, const bool seeds_sorted);  // for FindTracksBestHit
0079     void find_tracks_load_seeds(const TrackVec &in_seeds, const bool seeds_sorted);
0080 
0081     int find_tracks_unroll_candidates(std::vector<std::pair<int, int>> &seed_cand_vec,
0082                                       int start_seed,
0083                                       int end_seed,
0084                                       int layer,
0085                                       int prev_layer,
0086                                       bool pickup_only,
0087                                       SteeringParams::IterationType_e iteration_dir);
0088 
0089     void find_tracks_handle_missed_layers(MkFinder *mkfndr,
0090                                           const LayerInfo &layer_info,
0091                                           std::vector<std::vector<TrackCand>> &tmp_cands,
0092                                           const std::vector<std::pair<int, int>> &seed_cand_idx,
0093                                           const int region,
0094                                           const int start_seed,
0095                                           const int itrack,
0096                                           const int end);
0097 
0098     void find_tracks_in_layers(CandCloner &cloner,
0099                                MkFinder *mkfndr,
0100                                SteeringParams::IterationType_e iteration_dir,
0101                                const int start_seed,
0102                                const int end_seed,
0103                                const int region);
0104 
0105     // --------
0106 
0107     void seed_post_cleaning(TrackVec &tv);
0108 
0109     void findTracksBestHit(SteeringParams::IterationType_e iteration_dir = SteeringParams::IT_FwdSearch);
0110     void findTracksStandard(SteeringParams::IterationType_e iteration_dir = SteeringParams::IT_FwdSearch);
0111     void findTracksCloneEngine(SteeringParams::IterationType_e iteration_dir = SteeringParams::IT_FwdSearch);
0112 
0113     void backwardFitBH();
0114     void fit_cands_BH(MkFinder *mkfndr, int start_cand, int end_cand, int region);
0115 
0116     void backwardFit();
0117     void fit_cands(MkFinder *mkfndr, int start_cand, int end_cand, int region);
0118 
0119   private:
0120     void fit_one_seed_set(TrackVec &simtracks, int itrack, int end, MkFitter *mkfttr, const bool is_brl[]);
0121 
0122     MkJob *m_job = nullptr;
0123 
0124     // MIMI -- Used by seed processing / validation.
0125     Event *m_event = nullptr;
0126 
0127     // State for BestHit
0128     TrackVec m_tracks;
0129 
0130     // State for Std / CloneEngine
0131     EventOfCombCandidates m_event_of_comb_cands;
0132 
0133     // Per-region seed information
0134     std::vector<int> m_seedEtaSeparators;
0135     std::vector<int> m_seedMinLastLayer;
0136     std::vector<int> m_seedMaxLastLayer;
0137 
0138     std::atomic<int> m_nan_n_silly_per_layer_count;
0139 
0140     bool m_silent;
0141   };
0142 
0143 }  // end namespace mkfit
0144 
0145 #endif