CMS 3D CMS Logo

fittestMPlex.cc
Go to the documentation of this file.
1 #include "Matrix.h"
2 //#define DEBUG
3 #include <Debug.h>
4 
5 #include "MkFitter.h"
6 
7 #ifndef NO_ROOT
8 #include "TFile.h"
9 #include "TTree.h"
10 #include <mutex>
11 #endif
12 
13 #include "oneapi/tbb/parallel_for.h"
14 
15 #include <iostream>
16 #include <memory>
17 
18 #if defined(USE_VTUNE_PAUSE)
19 #include "ittnotify.h"
20 #endif
21 
22 //==============================================================================
23 // runFittingTestPlex
24 //==============================================================================
25 
26 #include "Pool.h"
27 namespace {
28  struct ExecutionContext {
30 
31  void populate(int n_thr) { m_fitters.populate(n_thr - m_fitters.size()); }
32  };
33 
34  ExecutionContext g_exe_ctx;
35  auto retfitr = [](mkfit::MkFitter* mkfp) { g_exe_ctx.m_fitters.ReturnToPool(mkfp); };
36 } // namespace
37 
38 namespace mkfit {
39 
40  double runFittingTestPlex(Event& ev, std::vector<Track>& rectracks) {
42  std::vector<Track>& simtracks = ev.simTracks_;
43 
44  const int Nhits = Config::nLayers;
45  // XXX What if there's a missing / double layer?
46  // Eventually, should sort track vector by number of hits!
47  // And pass the number in on each "setup" call.
48  // Reserves should be made for maximum possible number (but this is just
49  // measurments errors, params).
50 
51  int theEnd = simtracks.size();
52  int count = (theEnd + NN - 1) / NN;
53 
54 #ifdef USE_VTUNE_PAUSE
55  __SSC_MARK(0x111); // use this to resume Intel SDE at the same point
56  __itt_resume();
57 #endif
58 
59  double time = dtime();
60 
61  tbb::parallel_for(tbb::blocked_range<int>(0, count, std::max(1, Config::numSeedsPerTask / NN)),
62  [&](const tbb::blocked_range<int>& i) {
63  std::unique_ptr<MkFitter, decltype(retfitr)> mkfp(g_exe_ctx.m_fitters.GetFromPool(), retfitr);
64  mkfp->setNhits(Nhits);
65  for (int it = i.begin(); it < i.end(); ++it) {
66  int itrack = it * NN;
67  int end = itrack + NN;
68  /*
69  * MT, trying to slurp and fit at the same time ...
70  if (theEnd < end) {
71  end = theEnd;
72  mkfp->inputTracksAndHits(simtracks, ev.layerHits_, itrack, end);
73  } else {
74  mkfp->slurpInTracksAndHits(simtracks, ev.layerHits_, itrack, end); // only safe for a full matriplex
75  }
76 
77  if (Config::cf_fitting) mkfp->ConformalFitTracks(true, itrack, end);
78  mkfp->FitTracks(end - itrack, &ev, true);
79  */
80 
81  mkfp->inputTracksForFit(simtracks, itrack, end);
82 
83  // XXXX MT - for this need 3 points in ... right
84  // XXXX if (Config::cf_fitting) mkfp->ConformalFitTracks(true, itrack, end);
85 
86  mkfp->fitTracksWithInterSlurp(ev.layerHits_, end - itrack);
87 
88  mkfp->outputFittedTracks(rectracks, itrack, end);
89  }
90  });
91 
92  time = dtime() - time;
93 
94 #ifdef USE_VTUNE_PAUSE
95  __itt_pause();
96  __SSC_MARK(0x222); // use this to pause Intel SDE at the same point
97 #endif
98 
99  if (Config::fit_val)
100  ev.validate();
101 
102  return time;
103  }
104 
105 } // end namespace mkfit
constexpr int nLayers
Definition: Config.h:38
constexpr Matriplex::idx_t NN
Definition: Matrix.h:43
size_t size() const
Definition: Pool.h:26
ExecutionContext g_exe_ctx
Definition: MkBuilder.cc:55
constexpr int numThreadsFinder
Definition: Config.h:87
void populate(int threads=Config::numThreadsFinder)
Definition: Pool.h:28
Pool< MkFitter > m_fitters
Definition: MkBuilder.cc:39
void populate(int n_thr)
Definition: MkBuilder.cc:42
double dtime()
constexpr int numSeedsPerTask
Definition: Config.h:89
double runFittingTestPlex(Event &ev, std::vector< Track > &rectracks)
Definition: fittestMPlex.cc:40