Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:28:22

0001 #include "Matrix.h"
0002 //#define DEBUG
0003 #include <Debug.h>
0004 
0005 #include "MkFitter.h"
0006 
0007 #ifndef NO_ROOT
0008 #include "TFile.h"
0009 #include "TTree.h"
0010 #include <mutex>
0011 #endif
0012 
0013 #include "oneapi/tbb/parallel_for.h"
0014 
0015 #include <iostream>
0016 #include <memory>
0017 
0018 #if defined(USE_VTUNE_PAUSE)
0019 #include "ittnotify.h"
0020 #endif
0021 
0022 //==============================================================================
0023 // runFittingTestPlex
0024 //==============================================================================
0025 
0026 #include "Pool.h"
0027 namespace {
0028   struct ExecutionContext {
0029     mkfit::Pool<mkfit::MkFitter> m_fitters;
0030 
0031     void populate(int n_thr) { m_fitters.populate(n_thr - m_fitters.size()); }
0032   };
0033 
0034   ExecutionContext g_exe_ctx;
0035   auto retfitr = [](mkfit::MkFitter* mkfp) { g_exe_ctx.m_fitters.ReturnToPool(mkfp); };
0036 }  // namespace
0037 
0038 namespace mkfit {
0039 
0040   double runFittingTestPlex(Event& ev, std::vector<Track>& rectracks) {
0041     g_exe_ctx.populate(Config::numThreadsFinder);
0042     std::vector<Track>& simtracks = ev.simTracks_;
0043 
0044     const int Nhits = Config::nLayers;
0045     // XXX What if there's a missing / double layer?
0046     // Eventually, should sort track vector by number of hits!
0047     // And pass the number in on each "setup" call.
0048     // Reserves should be made for maximum possible number (but this is just
0049     // measurments errors, params).
0050 
0051     int theEnd = simtracks.size();
0052     int count = (theEnd + NN - 1) / NN;
0053 
0054 #ifdef USE_VTUNE_PAUSE
0055     __SSC_MARK(0x111);  // use this to resume Intel SDE at the same point
0056     __itt_resume();
0057 #endif
0058 
0059     double time = dtime();
0060 
0061     tbb::parallel_for(tbb::blocked_range<int>(0, count, std::max(1, Config::numSeedsPerTask / NN)),
0062                       [&](const tbb::blocked_range<int>& i) {
0063                         std::unique_ptr<MkFitter, decltype(retfitr)> mkfp(g_exe_ctx.m_fitters.GetFromPool(), retfitr);
0064                         mkfp->setNhits(Nhits);
0065                         for (int it = i.begin(); it < i.end(); ++it) {
0066                           int itrack = it * NN;
0067                           int end = itrack + NN;
0068                           /*
0069          * MT, trying to slurp and fit at the same time ...
0070       if (theEnd < end) {
0071         end = theEnd;
0072         mkfp->inputTracksAndHits(simtracks, ev.layerHits_, itrack, end);
0073       } else {
0074         mkfp->slurpInTracksAndHits(simtracks, ev.layerHits_, itrack, end); // only safe for a full matriplex
0075       }
0076       
0077       if (Config::cf_fitting) mkfp->ConformalFitTracks(true, itrack, end);
0078       mkfp->FitTracks(end - itrack, &ev, true);
0079         */
0080 
0081                           mkfp->inputTracksForFit(simtracks, itrack, end);
0082 
0083                           // XXXX MT - for this need 3 points in ... right
0084                           // XXXX if (Config::cf_fitting) mkfp->ConformalFitTracks(true, itrack, end);
0085 
0086                           mkfp->fitTracksWithInterSlurp(ev.layerHits_, end - itrack);
0087 
0088                           mkfp->outputFittedTracks(rectracks, itrack, end);
0089                         }
0090                       });
0091 
0092     time = dtime() - time;
0093 
0094 #ifdef USE_VTUNE_PAUSE
0095     __itt_pause();
0096     __SSC_MARK(0x222);  // use this to pause Intel SDE at the same point
0097 #endif
0098 
0099     if (Config::fit_val)
0100       ev.validate();
0101 
0102     return time;
0103   }
0104 
0105 }  // end namespace mkfit