Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-08-17 23:57:47

0001 #include "RecoTracker/MkFitCMS/interface/runFunctions.h"
0002 #include "RecoTracker/MkFitCore/interface/MkBuilder.h"
0003 #include "RecoTracker/MkFitCMS/interface/MkStdSeqs.h"
0004 
0005 #include "oneapi/tbb/parallel_for.h"
0006 
0007 #include <memory>
0008 
0009 namespace mkfit {
0010 
0011   //==============================================================================
0012   // run_OneIteration
0013   //
0014   // One-stop function for running track building from CMSSW.
0015   //==============================================================================
0016 
0017   struct IterationMaskIfcCmssw : public IterationMaskIfcBase {
0018     const TrackerInfo &m_trk_info;
0019     const std::vector<const std::vector<bool> *> &m_mask_vector;
0020 
0021     IterationMaskIfcCmssw(const TrackerInfo &ti, const std::vector<const std::vector<bool> *> &maskvec)
0022         : m_trk_info(ti), m_mask_vector(maskvec) {}
0023 
0024     const std::vector<bool> *get_mask_for_layer(int layer) const override {
0025       return m_trk_info.layer(layer).is_pixel() ? m_mask_vector[0] : m_mask_vector[1];
0026     }
0027   };
0028 
0029   void run_OneIteration(const TrackerInfo &trackerInfo,
0030                         const IterationConfig &itconf,
0031                         const EventOfHits &eoh,
0032                         const std::vector<const std::vector<bool> *> &hit_masks,
0033                         MkBuilder &builder,
0034                         TrackVec &seeds,
0035                         TrackVec &out_tracks,
0036                         bool do_seed_clean,
0037                         bool do_backward_fit,
0038                         bool do_remove_duplicates) {
0039     IterationMaskIfcCmssw it_mask_ifc(trackerInfo, hit_masks);
0040 
0041     MkJob job({trackerInfo, itconf, eoh, &it_mask_ifc});
0042 
0043     builder.begin_event(&job, nullptr, __func__);
0044 
0045     // Seed cleaning not done on pixelLess / tobTec iters
0046     do_seed_clean = do_seed_clean && itconf.m_requires_dupclean_tight;
0047 
0048     if (do_seed_clean)
0049       StdSeq::clean_cms_seedtracks_iter(&seeds, itconf, eoh.refBeamSpot());
0050 
0051     // Check nans in seeds -- this should not be needed when Slava fixes
0052     // the track parameter coordinate transformation.
0053     builder.seed_post_cleaning(seeds);
0054 
0055     if (itconf.m_requires_seed_hit_sorting) {
0056       for (auto &s : seeds)
0057         s.sortHitsByLayer();  // sort seed hits for the matched hits (I hope it works here)
0058     }
0059 
0060     builder.find_tracks_load_seeds(seeds, do_seed_clean);
0061 
0062     builder.findTracksCloneEngine();
0063 
0064     using Algo = TrackBase::TrackAlgorithm;
0065     if (itconf.m_requires_quality_filter && Algo(itconf.m_track_algorithm) != Algo::detachedTripletStep) {
0066       if (Algo(itconf.m_track_algorithm) == Algo::pixelPairStep) {
0067         builder.filter_comb_cands([&](const TrackCand &t) { return StdSeq::qfilter_n_hits_pixseed(t, 3); });
0068       } else if (Algo(itconf.m_track_algorithm) == Algo::pixelLessStep) {
0069         builder.filter_comb_cands(
0070             [&](const TrackCand &t) { return StdSeq::qfilter_pixelLessFwd(t, eoh.refBeamSpot(), trackerInfo); });
0071       } else {
0072         builder.filter_comb_cands(
0073             [&](const TrackCand &t) { return StdSeq::qfilter_n_hits(t, itconf.m_params.minHitsQF); });
0074       }
0075     }
0076 
0077     if (do_backward_fit) {
0078       if (itconf.m_backward_search) {
0079         builder.compactifyHitStorageForBestCand(itconf.m_backward_drop_seed_hits, itconf.m_backward_fit_min_hits);
0080       }
0081 
0082       builder.backwardFit();
0083 
0084       if (itconf.m_backward_search) {
0085         builder.beginBkwSearch();
0086         builder.findTracksCloneEngine(SteeringParams::IT_BkwSearch);
0087         builder.endBkwSearch();
0088       }
0089 
0090       if (itconf.m_requires_quality_filter && (Algo(itconf.m_track_algorithm) == Algo::detachedTripletStep ||
0091                                                Algo(itconf.m_track_algorithm) == Algo::pixelLessStep)) {
0092         if (Algo(itconf.m_track_algorithm) == Algo::detachedTripletStep) {
0093           builder.filter_comb_cands(
0094               [&](const TrackCand &t) { return StdSeq::qfilter_n_layers(t, eoh.refBeamSpot(), trackerInfo); });
0095         } else if (Algo(itconf.m_track_algorithm) == Algo::pixelLessStep) {
0096           builder.filter_comb_cands(
0097               [&](const TrackCand &t) { return StdSeq::qfilter_pixelLessBkwd(t, eoh.refBeamSpot(), trackerInfo); });
0098         }
0099       }
0100     }
0101 
0102     builder.filter_comb_cands([&](const TrackCand &t) { return StdSeq::qfilter_nan_n_silly(t); });
0103 
0104     builder.export_best_comb_cands(out_tracks, true);
0105 
0106     if (do_remove_duplicates) {
0107       StdSeq::find_and_remove_duplicates(out_tracks, itconf);
0108     }
0109 
0110     builder.end_event();
0111     builder.release_memory();
0112   }
0113 
0114 }  // end namespace mkfit