CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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_pix_lyr() ? 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, &it_mask_ifc});
42 
43  builder.begin_event(&job, nullptr, __func__);
44 
45  if (do_seed_clean) {
46  // Seed cleaning not done on pixelLess / tobTec iters
47  if (itconf.m_requires_dupclean_tight)
48  StdSeq::clean_cms_seedtracks_iter(&seeds, itconf, eoh.refBeamSpot());
49  }
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);
61 
62  builder.findTracksCloneEngine();
63 
67  builder.filter_comb_cands([&](const TrackCand &t) { return StdSeq::qfilter_n_hits_pixseed(t, 3); });
68  } else if (Algo(itconf.m_track_algorithm) == Algo::pixelLessStep) {
69  builder.filter_comb_cands(
70  [&](const TrackCand &t) { return StdSeq::qfilter_pixelLessFwd(t, eoh.refBeamSpot(), trackerInfo); });
71  } else {
72  builder.filter_comb_cands(
73  [&](const TrackCand &t) { return StdSeq::qfilter_n_hits(t, itconf.m_params.minHitsQF); });
74  }
75  }
76 
77  if (do_backward_fit) {
78  if (itconf.m_backward_search) {
80  }
81 
82  builder.backwardFit();
83 
84  if (itconf.m_backward_search) {
85  builder.beginBkwSearch();
87  builder.endBkwSearch();
88  }
89 
93  builder.filter_comb_cands(
94  [&](const TrackCand &t) { return StdSeq::qfilter_n_layers(t, eoh.refBeamSpot(), trackerInfo); });
95  } else if (Algo(itconf.m_track_algorithm) == Algo::pixelLessStep) {
96  builder.filter_comb_cands(
97  [&](const TrackCand &t) { return StdSeq::qfilter_pixelLessBkwd(t, eoh.refBeamSpot(), trackerInfo); });
98  }
99  }
100  }
101 
102  builder.filter_comb_cands([&](const TrackCand &t) { return StdSeq::qfilter_nan_n_silly(t); });
103 
104  builder.export_best_comb_cands(out_tracks, true);
105 
106  if (do_remove_duplicates) {
107  StdSeq::find_and_remove_duplicates(out_tracks, itconf);
108  }
109 
110  builder.end_event();
111  builder.release_memory();
112  }
113 
114 } // end namespace mkfit
void find_and_remove_duplicates(TrackVec &tracks, const IterationConfig &itconf)
Definition: MkStdSeqs.cc:591
bool qfilter_n_hits_pixseed(const TRACK &t, int nMinHits)
Definition: MkStdSeqs.h:50
bool qfilter_pixelLessFwd(const TRACK &t, const BeamSpot &bspot, const TrackerInfo &tk_info)
quality filter tuned for pixelLess iteration during forward search
Definition: MkStdSeqs.h:78
IterationParams m_params
const LayerInfo & layer(int l) const
Definition: TrackerInfo.h:146
bool is_pix_lyr() const
Definition: TrackerInfo.h:62
const BeamSpot & refBeamSpot() const
bool qfilter_n_hits(const TRACK &t, int nMinHits)
Definition: MkStdSeqs.h:42
IterationMaskIfcCmssw(const TrackerInfo &ti, const std::vector< const std::vector< bool > * > &maskvec)
Definition: runFunctions.cc:21
bool qfilter_n_layers(const TRACK &t, const BeamSpot &bspot, const TrackerInfo &trk_inf)
Definition: MkStdSeqs.h:56
int filter_comb_cands(std::function< filter_track_cand_foo > filter)
Definition: MkBuilder.cc:277
void compactifyHitStorageForBestCand(bool remove_seed_hits, int backward_fit_min_hits)
Definition: MkBuilder.h:106
void findTracksCloneEngine(SteeringParams::IterationType_e iteration_dir=SteeringParams::IT_FwdSearch)
Definition: MkBuilder.cc:900
void begin_event(MkJob *job, Event *ev, const char *build_type)
Definition: MkBuilder.cc:177
constexpr std::array< uint8_t, layerIndexSize > layer
void release_memory()
Definition: MkBuilder.cc:205
tuple Algo
Definition: ntupleEnum.py:25
bool qfilter_pixelLessBkwd(const TRACK &t, const BeamSpot &bspot, const TrackerInfo &tk_info)
quality filter tuned for pixelLess iteration during backward search
Definition: MkStdSeqs.h:104
void seed_post_cleaning(TrackVec &tv)
Definition: MkBuilder.cc:380
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
void find_tracks_load_seeds(const TrackVec &in_seeds)
Definition: MkBuilder.cc:596
void beginBkwSearch()
Definition: MkBuilder.h:110
bool qfilter_nan_n_silly(const TRACK &t)
Definition: MkStdSeqs.h:128
void export_best_comb_cands(TrackVec &out_vec, bool remove_missing_hits=false)
Definition: MkBuilder.cc:354
void endBkwSearch()
Definition: MkBuilder.h:111
TrackAlgorithm
track algorithm; copy from TrackBase.h to keep in standalone builds
Definition: Track.h:275
const TrackerInfo & m_trk_info
Definition: runFunctions.cc:18
Definition: fakeMenu.h:6
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
int clean_cms_seedtracks_iter(TrackVec *seed_ptr, const IterationConfig &itrcfg, const BeamSpot &bspot)
Definition: MkStdSeqs.cc:84