CMS 3D CMS Logo

mkFit.cc
Go to the documentation of this file.
2 
3 // CCCC #include "fittestMPlex.h"
5 
11 
14 
16 
18 
19 #ifndef NO_ROOT
21 #endif
22 
23 //#define DEBUG
25 
26 #include "oneapi/tbb/task_arena.h"
27 #include "oneapi/tbb/parallel_for.h"
28 
29 #if defined(USE_VTUNE_PAUSE)
30 #include "ittnotify.h"
31 #endif
32 
33 #include <cstdlib>
34 #include <limits>
35 #include <list>
36 #include <sstream>
37 #include <memory>
38 
39 using namespace mkfit;
40 
41 //==============================================================================
42 
43 void initGeom() {
44  std::cout << "Constructing geometry '" << Config::geomPlugin << "'\n";
45 
46  // NB: we currently assume that each node is a layer, and that layers
47  // are added starting from the center
48  // NB: z is just a dummy variable, VUSolid is actually infinite in size. *** Therefore, set it to the eta of simulation ***
49 
50  /*
51  // Test CMSSW loading
52  IterationsInfo ii;
53  unsigned int algorithms[]={ 4,22,23,5,24,7,8,9,10,6 }; // 10 iterations
54  ii.resize(10);
55  for (int i = 0; i < 10; ++i) {
56  ii[i].m_track_algorithm = algorithms[i];
57  }
58  auto xx = configJson_Load_File(ii, "mkfit-phase1-initialStep.json");
59  printf("%d\n", xx->m_iteration_index);
60  */
61 
63 
65 
68 
71 
72  for (auto& fn : Config::json_load_filenames) {
73  // This is for testing only ... we drop the loaded IterationConfig
74  // as further code will always use IterationsInfo[ iter_index ].
76  }
77 
78  printf(
79  "mkFit.cc/%s--JSON-Load read %d JSON entities from %d files, replaced %d parameters.\n"
80  " NOTE that these changes were NOT APPLIED to actual configuration that is going to be used.\n",
81  __func__,
82  report.n_json_entities,
83  report.n_files,
84  report.n_replacements);
85  }
86 
89 
91 
92  printf("mkFit.cc/%s--JOSN-Patch read %d JSON entities from %d files, replaced %d parameters.\n",
93  __func__,
94  report.n_json_entities,
95  report.n_files,
96  report.n_replacements);
97  }
98 
100  cj.dump(Config::ItrInfo);
101 
103  cj.save_Iterations(
105  }
106 
107  // Test functions for ConfigJsonPatcher
108  // cj.test_Direct (Config::ItrInfo[0]);
109  // cj.test_Patcher(Config::ItrInfo[0]);
110 }
111 
112 namespace {
113  int g_start_event = 1;
114 
115  bool g_run_fit_std = false;
116 
117  bool g_run_build_all = true;
118  bool g_run_build_cmssw = false;
119  bool g_run_build_bh = false;
120  bool g_run_build_std = false;
121  bool g_run_build_ce = false;
122  bool g_run_build_mimi = false;
123 
124  std::string g_operation = "simulate_and_process";
125  ;
126  std::string g_input_file = "";
127  std::string g_output_file = "";
128 
129  seedOptsMap g_seed_opts;
130  void init_seed_opts() {
131  g_seed_opts["sim"] = {simSeeds, "Use simtracks for seeds"};
132  g_seed_opts["cmssw"] = {cmsswSeeds, "Use external CMSSW seeds"};
133  g_seed_opts["find"] = {findSeeds, "Use mplex seed finder for seeds"};
134  }
135 
136  cleanOptsMap g_clean_opts;
137  void init_clean_opts() {
138  g_clean_opts["none"] = {noCleaning, "No cleaning applied to external CMSSW seeds"};
139  g_clean_opts["n2"] = {cleanSeedsN2, "Apply N^2 cleaning by Mario to external CMSSW seeds"};
140  g_clean_opts["pure"] = {
142  "Only use external CMSSW seeds that have produced a CMSSW track \n must enable: --read-cmssw-tracks"};
143  g_clean_opts["badlabel"] = {cleanSeedsBadLabel, "Remove seeds with label()<0 in external CMSSW seeds"};
144  }
145 
146  matchOptsMap g_match_opts;
147  void init_match_opts() {
148  g_match_opts["trkparam"] = {trkParamBased,
149  "Use track parameter-based matching for validating against CMSSW tracks"};
150  g_match_opts["hits"] = {hitBased, "Use hit-based matching for validating against CMSSW tracks"};
151  g_match_opts["label"] = {labelBased, "Only allowed with pure seeds: stricter hit-based matching"};
152  }
153 
154  const char* b2a(bool b) { return b ? "true" : "false"; }
155 } // namespace
156 
157 //==============================================================================
158 
159 // Getters and setters of enum configs (from command line using anon. namespace above)
160 
161 template <typename T, typename U>
162 std::string getOpt(const T& c_opt, const U& g_opt_map) {
163  static const std::string empty("");
164 
165  for (const auto& g_opt_pair : g_opt_map) {
166  if (g_opt_pair.second.first == c_opt)
167  return g_opt_pair.first;
168  }
169  std::cerr << "No match for option " << c_opt << std::endl;
170  return empty;
171 }
172 
173 template <typename T, typename U>
174 void setOpt(const std::string& cmd_ln_str, T& c_opt, const U& g_opt_map, const std::string& ex_txt) {
175  if (g_opt_map.count(cmd_ln_str))
176  c_opt = g_opt_map.at(cmd_ln_str).first;
177  else {
178  std::cerr << cmd_ln_str << " is not a valid " << ex_txt << " option!! Exiting..." << std::endl;
179  exit(1);
180  }
181 }
182 
183 template <typename U>
184 void listOpts(const U& g_opt_map) {
185  for (const auto& g_opt_pair : g_opt_map) {
186  std::cout << " " << g_opt_pair.first.c_str() << " : " << g_opt_pair.second.second.c_str() << std::endl;
187  }
188 }
189 
190 //==============================================================================
191 
193  printf("Running test_standard(), operation=\"%s\"\n", g_operation.c_str());
194  printf(" vusize=%d, num_th_sim=%d, num_th_finder=%d\n",
195  MPT_SIZE,
198  printf(
199  " sizeof(Track)=%zu, sizeof(Hit)=%zu, sizeof(SVector3)=%zu, sizeof(SMatrixSym33)=%zu, sizeof(MCHitInfo)=%zu\n",
200  sizeof(Track),
201  sizeof(Hit),
202  sizeof(SVector3),
203  sizeof(SMatrixSym33),
204  sizeof(MCHitInfo));
205 
207  printf("- reading seeds from file\n");
208 
209  initGeom();
210 
211  DataFile data_file;
212  if (g_operation == "read") {
213  int evs_in_file = data_file.openRead(g_input_file, Config::TrkInfo.n_layers());
214  int evs_available = evs_in_file - g_start_event + 1;
215  if (Config::nEvents == -1) {
216  Config::nEvents = evs_available;
217  } else if (Config::nEvents > evs_available and not Config::loopOverFile) {
218  printf("Requested number of events %d, only %d available.\n", Config::nEvents, evs_available);
219  Config::nEvents = evs_available;
220  }
221 
222  if (g_start_event > 1) {
223  data_file.skipNEvents(g_start_event - 1);
224  }
225  }
226 
227  constexpr int NT = 5;
228  double t_sum[NT] = {0};
229  double t_skip[NT] = {0};
230  std::vector<double> t_sum_iter(Config::nItersCMSSW, 0.0);
231  std::vector<double> t_skip_iter(Config::nItersCMSSW, 0.0);
232  double time = dtime();
233 
234  std::atomic<int> nevt{g_start_event};
235  std::atomic<int> seedstot{0}, simtrackstot{0}, candstot{0};
236  std::atomic<int> maxHits_all{0}, maxLayer_all{0};
237 
239 
240  std::vector<std::unique_ptr<Event>> evs(Config::numThreadsEvents);
241  std::vector<std::unique_ptr<Validation>> vals(Config::numThreadsEvents);
242  std::vector<std::unique_ptr<MkBuilder>> mkbs(Config::numThreadsEvents);
243  std::vector<std::shared_ptr<EventOfHits>> eohs(Config::numThreadsEvents);
244  std::vector<std::shared_ptr<FILE>> fps;
245  fps.reserve(Config::numThreadsEvents);
246 
247  const std::string valfile("valtree");
248 
249  for (int i = 0; i < Config::numThreadsEvents; ++i) {
250  std::ostringstream serial;
251  if (Config::numThreadsEvents > 1) {
252  serial << "_" << i;
253  }
254  vals[i].reset(Validation::make_validation(valfile + serial.str() + ".root", &Config::TrkInfo));
256  eohs[i].reset(new EventOfHits(Config::TrkInfo));
257  evs[i].reset(new Event(*vals[i], 0, Config::TrkInfo.n_layers()));
258  if (g_operation == "read") {
259  fps.emplace_back(fopen(g_input_file.c_str(), "r"), [](FILE* fp) {
260  if (fp)
261  fclose(fp);
262  });
263  }
264  }
265 
266  tbb::task_arena arena(Config::numThreadsFinder);
267 
268  dprint("parallel_for step size " << (Config::nEvents + Config::numThreadsEvents - 1) / Config::numThreadsEvents);
269 
270  time = dtime();
271 
272  int events_per_thread = (Config::nEvents + Config::numThreadsEvents - 1) / Config::numThreadsEvents;
273 
274  arena.execute([&]() {
275  tbb::parallel_for(
276  tbb::blocked_range<int>(0, Config::numThreadsEvents, 1),
277  [&](const tbb::blocked_range<int>& threads) {
278  int thisthread = threads.begin();
279 
280  assert(threads.begin() == threads.end() - 1 && thisthread < Config::numThreadsEvents);
281 
282  // std::vector<Track> plex_tracks;
283  auto& ev = *evs[thisthread].get();
284  auto& mkb = *mkbs[thisthread].get();
285  auto& eoh = *eohs[thisthread].get();
286  auto fp = fps[thisthread].get();
287 
288  int evstart = thisthread * events_per_thread;
289  int evend = std::min(Config::nEvents, evstart + events_per_thread);
290 
291  dprint("thisthread " << thisthread << " events " << Config::nEvents << " events/thread " << events_per_thread
292  << " range " << evstart << ":" << evend);
293 
294  for (int evt = evstart; evt < evend; ++evt) {
295  ev.reset(nevt++);
296 
297  if (!Config::silent) {
298  std::lock_guard<std::mutex> printlock(Event::printmutex);
299  printf("\n");
300  printf("Processing event %d\n", ev.evtID());
301  }
302 
303  ev.read_in(data_file, fp);
304 
305  // skip events with zero seed tracks!
306  if (ev.seedTracks_.empty())
307  continue;
308 
309  // plex_tracks.resize(ev.simTracks_.size());
310 
312 
313  std::vector<DeadVec> deadvectors(ev.layerHits_.size());
316  StdSeq::loadDeads(eoh, deadvectors);
317  }
318 
319  double t_best[NT] = {0}, t_cur[NT] = {0};
320  std::vector<double> t_cur_iter;
321  simtrackstot += ev.simTracks_.size();
322  seedstot += ev.seedTracks_.size();
323 
324  int ncands_thisthread = 0;
325  int maxHits_thisthread = 0;
326  int maxLayer_thisthread = 0;
327  for (int b = 0; b < Config::finderReportBestOutOfN; ++b) {
328  t_cur[0] = 0; // t_cur[0] = (g_run_fit_std) ? runFittingTestPlex(ev, plex_tracks) : 0;
329  t_cur[1] = (g_run_build_all || g_run_build_bh) ? runBuildingTestPlexBestHit(ev, eoh, mkb) : 0;
330  t_cur[3] = (g_run_build_all || g_run_build_ce) ? runBuildingTestPlexCloneEngine(ev, eoh, mkb) : 0;
331  if (g_run_build_all || g_run_build_mimi)
332  t_cur_iter = runBtpCe_MultiIter(ev, eoh, mkb, Config::nItersCMSSW);
333  t_cur[4] = (g_run_build_all || g_run_build_mimi) ? t_cur_iter[Config::nItersCMSSW] : 0;
334  if (g_run_build_all || g_run_build_cmssw)
335  runBuildingTestPlexDumbCMSSW(ev, eoh, mkb);
336  t_cur[2] = (g_run_build_all || g_run_build_std) ? runBuildingTestPlexStandard(ev, eoh, mkb) : 0;
337  if (g_run_build_ce || g_run_build_mimi) {
338  ncands_thisthread = mkb.total_cands();
339  auto const& ln = mkb.max_hits_layer(eoh);
340  maxHits_thisthread = ln.first;
341  maxLayer_thisthread = ln.second;
342  }
343  for (int i = 0; i < NT; ++i)
344  t_best[i] = (b == 0) ? t_cur[i] : std::min(t_cur[i], t_best[i]);
345 
346  if (!Config::silent) {
347  std::lock_guard<std::mutex> printlock(Event::printmutex);
349  printf("----------------------------------------------------------------\n");
350  printf("Best-of-times:");
351  for (int i = 0; i < NT; ++i)
352  printf(" %.5f/%.5f", t_cur[i], t_best[i]);
353  printf("\n");
354  }
355  printf("----------------------------------------------------------------\n");
356  }
357  }
358 
359  candstot += ncands_thisthread;
360  if (maxHits_thisthread > maxHits_all) {
361  maxHits_all = maxHits_thisthread;
362  maxLayer_all = maxLayer_thisthread;
363  }
364  if (!Config::silent) {
365  std::lock_guard<std::mutex> printlock(Event::printmutex);
366  printf("Matriplex fit = %.5f --- Build BHMX = %.5f STDMX = %.5f CEMX = %.5f MIMI = %.5f\n",
367  t_best[0],
368  t_best[1],
369  t_best[2],
370  t_best[3],
371  t_best[4]);
372  }
373 
374  {
375  static std::mutex sum_up_lock;
376  std::lock_guard<std::mutex> locker(sum_up_lock);
377 
378  for (int i = 0; i < NT; ++i)
379  t_sum[i] += t_best[i];
380  if (evt > 0)
381  for (int i = 0; i < NT; ++i)
382  t_skip[i] += t_best[i];
383  if (g_run_build_all || g_run_build_mimi) {
384  for (int i = 0; i < Config::nItersCMSSW; ++i)
385  t_sum_iter[i] += t_cur_iter[i];
386  if (evt > 0)
387  for (int i = 0; i < Config::nItersCMSSW; ++i)
388  t_skip_iter[i] += t_cur_iter[i];
389  }
390  }
391  }
392  },
393  tbb::simple_partitioner());
394  });
395 
396  time = dtime() - time;
397 
398  printf("\n");
399  printf("================================================================\n");
400  printf("=== TOTAL for %d events\n", Config::nEvents);
401  printf("================================================================\n");
402 
403  printf("Total Matriplex fit = %.5f --- Build BHMX = %.5f STDMX = %.5f CEMX = %.5f MIMI = %.5f\n",
404  t_sum[0],
405  t_sum[1],
406  t_sum[2],
407  t_sum[3],
408  t_sum[4]);
409  printf("Total event > 1 fit = %.5f --- Build BHMX = %.5f STDMX = %.5f CEMX = %.5f MIMI = %.5f\n",
410  t_skip[0],
411  t_skip[1],
412  t_skip[2],
413  t_skip[3],
414  t_skip[4]);
415  printf("Total event loop time %.5f simtracks %d seedtracks %d builtcands %d maxhits %d on lay %d\n",
416  time,
417  simtrackstot.load(),
418  seedstot.load(),
419  candstot.load(),
420  maxHits_all.load(),
421  maxLayer_all.load());
422  //fflush(stdout);
423  if (g_run_build_all || g_run_build_mimi) {
424  printf("================================================================\n");
425  for (int i = 0; i < Config::nItersCMSSW; ++i)
426  std::cout << " Iteration " << i << " build time = " << t_sum_iter[i] << " \n";
427  printf("================================================================\n");
428  for (int i = 0; i < Config::nItersCMSSW; ++i)
429  std::cout << " Iteration " << i << " build time (event > 1) = " << t_skip_iter[i] << " \n";
430  printf("================================================================\n");
431  }
432  if (g_operation == "read") {
433  data_file.close();
434  }
435 
436  for (auto& val : vals) {
437  val->fillConfigTree();
438  val->saveTTrees();
439  }
440 }
441 
442 //==============================================================================
443 // Command line argument parsing
444 //==============================================================================
445 
446 typedef std::list<std::string> lStr_t;
447 typedef lStr_t::iterator lStr_i;
448 
450  return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
451 }
452 
453 void next_arg_or_die(lStr_t& args, lStr_i& i, bool allow_single_minus = false) {
454  lStr_i j = i;
455  if (++j == args.end() || has_suffix(*j, ".C") || ((*j)[0] == '-' && !(*j == "-" && allow_single_minus))) {
456  std::cerr << "Error: option " << *i << " requires an argument.\n";
457  exit(1);
458  }
459  i = j;
460 }
461 
462 //==============================================================================
463 // main
464 //==============================================================================
465 
466 #include <fenv.h>
467 
468 int main(int argc, const char* argv[]) {
469 #ifdef _GNU_SOURCE
471  feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); //FE_ALL_EXCEPT);
472  }
473 #endif
474 
475 #ifdef USE_VTUNE_PAUSE
476  __itt_pause();
477 #endif
478 
479  assert(sizeof(Track::Status) == 4 &&
480  "To make sure this is true for icc and gcc<6 when mixing bools/ints in bitfields.");
481 
482  // init enum maps
483  init_seed_opts();
484  init_clean_opts();
485  init_match_opts();
486 
487  lStr_t mArgs;
488  for (int i = 1; i < argc; ++i) {
489  mArgs.push_back(argv[i]);
490  }
491 
492  lStr_i i = mArgs.begin();
493  while (i != mArgs.end()) {
494  lStr_i start = i;
495 
496  if (*i == "-h" || *i == "-help" || *i == "--help") {
497  printf(
498  "\n"
499  "Usage: %s [options]\n"
500  "Options: defaults defined as (def: DEFAULT VALUE)\n"
501  "\n----------------------------------------------------------------------------------------------------------"
502  "\n\n"
503  "Generic options\n\n"
504  " --geom <str> geometry plugin to use (def: %s)\n"
505  " --silent suppress printouts inside event loop (def: %s)\n"
506  " --best-out-of <int> run test num times, report best time (def: %d)\n"
507  " --input-file file name for reading (def: %s)\n"
508  " --output-file file name for writitng (def: %s)\n"
509  " --read-cmssw-tracks read external cmssw reco tracks if available (def: %s)\n"
510  " --read-simtrack-states read in simTrackStates for pulls in validation (def: %s)\n"
511  " --num-events <int> number of events to run over or simulate (def: %d)\n"
512  " if using --input-file, must be enabled AFTER on command line\n"
513  " --start-event <int> event number to start at when reading from a file (def: %d)\n"
514  " --loop-over-file after reaching the end of the file, start over from the beginning until "
515  "<num-events> events have been processed\n"
516  "\n"
517  "If no --input-file is specified, will trigger simulation\n"
518  " --num-tracks <int> number of tracks to generate for each event (def: %d)\n"
519  "\n----------------------------------------------------------------------------------------------------------"
520  "\n\n"
521  "Threading related options\n\n"
522  " --num-thr-sim <int> number of threads for simulation (def: %d)\n"
523  " --num-thr <int> number of threads for track finding (def: %d)\n"
524  " --num-thr-ev <int> number of threads to run the event loop (def: %d)\n"
525  " --seeds-per-task <int> number of seeds to process in a tbb task (def: %d)\n"
526  " --hits-per-task <int> number of layer1 hits per task when using find seeds (def: %d)\n"
527  "\n----------------------------------------------------------------------------------------------------------"
528  "\n\n"
529  "FittingTestMPlex options\n\n"
530  " --fit-std run standard fitting test (def: %s)\n"
531  " --fit-std-only run only standard fitting test (def: %s)\n"
532  " --cf-fitting enable conformal fit before fitting tracks to get initial estimate of track "
533  "parameters and errors (def: %s)\n"
534  " --fit-val enable ROOT based validation for fittingMPlex (def: %s)\n"
535  "\n----------------------------------------------------------------------------------------------------------"
536  "\n\n"
537  "BuildingTestMPlex options\n\n"
538  " **Specify which building routine you would like to run\n"
539  " --build-cmssw run dummy validation of CMSSW tracks with MkBuilder stuff (def: %s)\n"
540  " --build-bh run best-hit building test (def: %s)\n"
541  " --build-std run standard combinatorial building test (def: %s)\n"
542  " --build-ce run clone engine combinatorial building test (def: %s)\n"
543  " --build-mimi run clone engine on multiple-iteration test (def: %s)\n"
544  " --num-iters-cmssw <int> number of mimi iterations to run (def: set to 3 when --build-mimi is in effect, "
545  "0 otherwise)\n"
546  "\n"
547  " **Seeding options\n"
548  " --seed-input <str> which seed collecion used for building (def: %s)\n"
549  " --seed-cleaning <str> which seed cleaning to apply if using cmssw seeds (def: %s)\n"
550  " --cf-seeding enable conformal fit over seeds (def: %s)\n"
551  "\n"
552  " **Duplicate removal options\n"
553  " --remove-dup run duplicate removal after building, using both hit and kinematic criteria (def: "
554  "%s)\n"
555  " --remove-dup-no-hit run duplicate removal after building, using kinematic criteria only (def: %s)\n"
556  "\n"
557  " **Dead module (strip) option\n"
558  " --use-dead-modules run duplicate removal after building, using both hit and kinematic criteria "
559  "(def: %s)\n"
560  "\n"
561  " **Additional options for building\n"
562  " --use-phiq-arr use phi-Q arrays in select hit indices (def: %s)\n"
563  " --kludge-cms-hit-errors make sure err(xy) > 15 mum, err(z) > 30 mum (def: %s)\n"
564  " --backward-fit perform backward fit during building (def: %s)\n"
565  " --no-backward-search do not do backward search after backward fit\n"
566  " (def: do search if backward-fit is enabled and available in given iteration)\n"
567  " --include-pca do the backward fit to point of closest approach, does not imply "
568  "'--backward-fit' (def: %s)\n"
569  "\n----------------------------------------------------------------------------------------------------------"
570  "\n\n"
571  "Validation options\n\n"
572  " **Text file based options\n"
573  " --quality-val enable printout validation for MkBuilder (def: %s)\n"
574  " must enable: --dump-for-plots\n"
575  " --dump-for-plots make shell printouts for plots (def: %s)\n"
576  " --mtv-like-val configure validation to emulate CMSSW MultiTrackValidator (MTV) (def: %s)\n"
577  " --mtv-require-seeds configure validation to emulate MTV but require sim tracks to be matched to "
578  "seeds (def: %s)\n"
579  "\n"
580  " **ROOT based options\n"
581  " --sim-val-for-cmssw enable ROOT based validation for CMSSW tracks with simtracks as reference [eff, "
582  "FR, DR] (def: %s)\n"
583  " --sim-val enable ROOT based validation for seeding, building, and fitting with simtracks "
584  "as reference [eff, FR, DR] (def: %s)\n"
585  " --cmssw-val enable ROOT based validation for building and fitting with CMSSW tracks as "
586  "reference [eff, FR, DR] (def: %s)\n"
587  " must enable: --geom CMS-2017 --read-cmssw-tracks\n"
588  " --cmssw-match-fw <str> which cmssw track matching routine to use if validating against CMSSW tracks, "
589  "forward built tracks only (def: %s)\n"
590  " must enable: --geom CMS-2017 --cmssw-val --read-cmssw-tracks\n"
591  " --cmssw-match-bk <str> which cmssw track matching routine to use if validating against CMSSW tracks, "
592  "backward fit tracks only (def: %s)\n"
593  " must enable: --geom CMS-2017 --cmssw-val --read-cmssw-tracks --backward-fit "
594  "--backward-fit-pca\n"
595  " --inc-shorts include short reco tracks into FR (def: %s)\n"
596  " --keep-hit-info keep vectors of hit idxs and branches in trees (def: %s)\n"
597  " --try-to-save-sim-info two options for this flag [related to validation with simtracks as reference "
598  "collection] (def: %s)\n"
599  " a) IF (--read-simtrack-states is enabled)\n"
600  " If a sim track is associated to a reco track, but it does not contain "
601  "the last found on the reco track\n"
602  " still save sim track kinematic info from generator position\n"
603  " b) ELSE (--read-simtrack-states is NOT enabled)\n"
604  " Save sim track kinematic info from generator position if matched to "
605  "reco track\n"
606  "\n----------------------------------------------------------------------------------------------------------"
607  "\n\n"
608  "Combo spaghetti, that's with cole slaw:\n\n"
609  " **Building and fitting combo options\n"
610  " --backward-fit-pca perform backward fit to point of closest approach during building\n"
611  " == --backward-fit --include-pca\n"
612  " **Seed combo options\n"
613  " --cmssw-simseeds use CMS geom with simtracks for seeds\n"
614  " == --geom CMS-2017 --seed-input %s\n"
615  " --cmssw-stdseeds use CMS geom with CMSSW seeds uncleaned\n"
616  " == --geom CMS-2017 --seed-input %s --seed-cleaning %s\n"
617  " --cmssw-n2seeds use CMS geom with CMSSW seeds cleaned with N^2 routine\n"
618  " == --geom CMS-2017 --seed-input %s --seed-cleaning %s\n"
619  " --cmssw-pureseeds use CMS geom with pure CMSSW seeds (seeds which produced CMSSW reco tracks), "
620  "enable read of CMSSW tracks\n"
621  " == --geom CMS-2017 --seed-input %s --seed-cleaning %s --read-cmssw-tracks\n"
622  " --cmssw-goodlabelseeds use CMS geom with CMSSW seeds with label() >= 0\n"
623  " == --geom CMS-2017 --seed-input %s --seed-cleaning %s\n"
624  "\n"
625  " **CMSSW validation combo options\n"
626  " --cmssw-val-fhit-bhit use CMSSW validation with hit based matching (50 percent after seed) for forward "
627  "built tracks\n"
628  " use CMSSW validation with hit based matching (50 percent after seed) for "
629  "backward fit tracks\n"
630  " == --cmssw-val --read-cmssw-tracks --cmssw-match-fw %s --cmssw-match-bk %s\n"
631  " must enable: --backward-fit-pca\n"
632  " --cmssw-val-fhit-bprm use CMSSW validation with hit based matching (50 percent after seed) for forward "
633  "built tracks\n"
634  " use CMSSW validation with track parameter based matching for backward fit "
635  "tracks\n"
636  " == --cmssw-val --read-cmssw-tracks --cmssw-match-fw %s --cmssw-match-bk %s\n"
637  " must enable: --backward-fit-pca\n"
638  " --cmssw-val-fprm-bhit use CMSSW validation with track parameter based matching for forward built "
639  "tracks\n"
640  " use CMSSW validation with hit based matching (50 percent after seed) for "
641  "backward fit tracks\n"
642  " == --cmssw-val --read-cmssw-tracks --cmssw-match-fw %s --cmssw-match-bk %s\n"
643  " must enable: --backward-fit-pca\n"
644  " --cmssw-val-fprm-bprm use CMSSW validation with track parameter based matching for forward built "
645  "tracks\n"
646  " use CMSSW validation with track parameter based matching for backward fit "
647  "tracks\n"
648  " == --cmssw-val --read-cmssw-tracks --cmssw-match-fw %s --cmssw-match-bk %s\n"
649  " must enable: --backward-fit-pca\n"
650  " --cmssw-val-label use CMSSW validation with stricter hit based matching for both forward built and "
651  "backward fit tracks, enable read of CMSSW tracks\n"
652  " == --cmssw-val --read-cmssw-tracks --cmssw-match-fw %s --cmssw-match-bk %s\n"
653  " must enable: --cmssw-pureseeds --backward-fit-pca\n"
654  "\n----------------------------------------------------------------------------------------------------------"
655  "\n\n"
656  "JSON config patcher options:\n\n"
657  " --json-load <filename> load single IterationConfig from given JSON file (def: do not load)\n"
658  " can be specified multiple times for several files\n"
659  " --json-patch <filename> patch IterationsInfo from given JSON file (def: do not patch)\n"
660  " can be specified multiple times for several files\n"
661  " --json-save-iterations <fname-fmt> save per iteration json files\n"
662  " %%d in fname-fmt gets replaced with iteration index\n"
663  " %%s in fname-fmt gets replaced with iteration algorithm name\n"
664  " exactly one of %%d and %%s must be specified\n"
665  " --json-save-iterations-include-iter-info-preamble (def: %s)\n"
666  " --json-verbose print each patch assignment as it is being made (def: %s)\n"
667  " --json-dump-before print iteration config before patching (def: %s)\n"
668  " --json-dump-after print iteration config after patching (def: %s)\n"
669  "\n----------------------------------------------------------------------------------------------------------"
670  "\n\n",
671  argv[0],
672 
673  Config::geomPlugin.c_str(),
674  b2a(Config::silent),
676  g_input_file.c_str(),
677  g_output_file.c_str(),
681  g_start_event,
683 
689 
690  b2a(g_run_fit_std),
691  b2a(g_run_fit_std &&
692  !(g_run_build_all || g_run_build_cmssw || g_run_build_bh || g_run_build_std || g_run_build_ce)),
693  b2a(Config::cf_fitting),
694  b2a(Config::fit_val),
695 
696  b2a(g_run_build_all || g_run_build_cmssw),
697  b2a(g_run_build_all || g_run_build_bh),
698  b2a(g_run_build_all || g_run_build_std),
699  b2a(g_run_build_all || g_run_build_ce),
700  b2a(g_run_build_all || g_run_build_mimi),
701 
702  getOpt(Config::seedInput, g_seed_opts).c_str(),
703  getOpt(Config::seedCleaning, g_clean_opts).c_str(),
704  b2a(Config::cf_seeding),
705 
706  b2a(Config::removeDuplicates && Config::useHitsForDuplicates),
707  b2a(Config::removeDuplicates && !Config::useHitsForDuplicates),
708 
710 
713  b2a(Config::backwardFit),
714  b2a(Config::includePCA),
715 
716  b2a(Config::quality_val),
720 
722  b2a(Config::sim_val),
723  b2a(Config::cmssw_val),
724  getOpt(Config::cmsswMatchingFW, g_match_opts).c_str(),
725  getOpt(Config::cmsswMatchingBK, g_match_opts).c_str(),
727  b2a(Config::keepHitInfo),
729 
730  getOpt(simSeeds, g_seed_opts).c_str(),
731  getOpt(cmsswSeeds, g_seed_opts).c_str(),
732  getOpt(noCleaning, g_clean_opts).c_str(),
733  getOpt(cmsswSeeds, g_seed_opts).c_str(),
734  getOpt(cleanSeedsN2, g_clean_opts).c_str(),
735  getOpt(cmsswSeeds, g_seed_opts).c_str(),
736  getOpt(cleanSeedsPure, g_clean_opts).c_str(),
737  getOpt(cmsswSeeds, g_seed_opts).c_str(),
738  getOpt(cleanSeedsBadLabel, g_clean_opts).c_str(),
739 
740  getOpt(hitBased, g_match_opts).c_str(),
741  getOpt(hitBased, g_match_opts).c_str(),
742  getOpt(hitBased, g_match_opts).c_str(),
743  getOpt(trkParamBased, g_match_opts).c_str(),
744  getOpt(trkParamBased, g_match_opts).c_str(),
745  getOpt(hitBased, g_match_opts).c_str(),
746  getOpt(trkParamBased, g_match_opts).c_str(),
747  getOpt(trkParamBased, g_match_opts).c_str(),
748  getOpt(labelBased, g_match_opts).c_str(),
749  getOpt(labelBased, g_match_opts).c_str(),
750 
755 
756  printf("List of options for string based inputs \n");
757  printf(
758  "--geom \n"
759  " CMS-2017 \n"
760  " CylCowWLids \n"
761  "\n");
762 
763  printf("--seed-input \n");
764  listOpts(g_seed_opts);
765  printf("\n");
766 
767  printf("--seed-cleaning \n");
768  listOpts(g_clean_opts);
769  printf("\n");
770 
771  printf("--cmssw-matching \n");
772  listOpts(g_match_opts);
773  printf("\n");
774 
775  exit(0);
776  } // end of "help" block
777 
778  else if (*i == "--geom") {
779  next_arg_or_die(mArgs, i);
781  } else if (*i == "--silent") {
782  Config::silent = true;
783  } else if (*i == "--best-out-of") {
784  next_arg_or_die(mArgs, i);
785  Config::finderReportBestOutOfN = atoi(i->c_str());
786  } else if (*i == "--input-file") {
787  next_arg_or_die(mArgs, i);
788  g_input_file = *i;
789  g_operation = "read";
790  Config::nEvents = -1;
791  } else if (*i == "--output-file") {
792  next_arg_or_die(mArgs, i);
793  g_output_file = *i;
794  g_operation = "write";
795  } else if (*i == "--read-cmssw-tracks") {
797  } else if (*i == "--read-simtrack-states") {
799  } else if (*i == "--num-events") {
800  next_arg_or_die(mArgs, i);
801  Config::nEvents = atoi(i->c_str());
802  } else if (*i == "--start-event") {
803  next_arg_or_die(mArgs, i);
804  g_start_event = atoi(i->c_str());
805  } else if (*i == "--loop-over-file") {
806  Config::loopOverFile = true;
807  } else if (*i == "--num-tracks") {
808  next_arg_or_die(mArgs, i);
809  Config::nTracks = atoi(i->c_str());
810  } else if (*i == "--num-thr-sim") {
811  next_arg_or_die(mArgs, i);
812  Config::numThreadsSimulation = atoi(i->c_str());
813  } else if (*i == "--num-thr") {
814  next_arg_or_die(mArgs, i);
815  Config::numThreadsFinder = atoi(i->c_str());
816  } else if (*i == "--num-thr-ev") {
817  next_arg_or_die(mArgs, i);
818  Config::numThreadsEvents = atoi(i->c_str());
819  } else if (*i == "--seeds-per-task") {
820  next_arg_or_die(mArgs, i);
821  Config::numSeedsPerTask = atoi(i->c_str());
822  } else if (*i == "--hits-per-task") {
823  next_arg_or_die(mArgs, i);
824  Config::numHitsPerTask = atoi(i->c_str());
825  } else if (*i == "--fit-std") {
826  g_run_fit_std = true;
827  } else if (*i == "--fit-std-only") {
828  g_run_fit_std = true;
829  g_run_build_all = false;
830  g_run_build_bh = false;
831  g_run_build_std = false;
832  g_run_build_ce = false;
833  } else if (*i == "--cf-fitting") {
834  Config::cf_fitting = true;
835  } else if (*i == "--fit-val") {
836  Config::fit_val = true;
837  } else if (*i == "--build-cmssw") {
838  g_run_build_all = false;
839  g_run_build_cmssw = true;
840  g_run_build_bh = false;
841  g_run_build_std = false;
842  g_run_build_ce = false;
843  } else if (*i == "--build-bh") {
844  g_run_build_all = false;
845  g_run_build_cmssw = false;
846  g_run_build_bh = true;
847  g_run_build_std = false;
848  g_run_build_ce = false;
849  } else if (*i == "--build-std") {
850  g_run_build_all = false;
851  g_run_build_cmssw = false;
852  g_run_build_bh = false;
853  g_run_build_std = true;
854  g_run_build_ce = false;
855  } else if (*i == "--build-ce") {
856  g_run_build_all = false;
857  g_run_build_cmssw = false;
858  g_run_build_bh = false;
859  g_run_build_std = false;
860  g_run_build_ce = true;
861  } else if (*i == "--build-mimi") {
862  g_run_build_all = false;
863  g_run_build_cmssw = false;
864  g_run_build_bh = false;
865  g_run_build_std = false;
866  g_run_build_ce = false;
867  g_run_build_mimi = true;
868  if (Config::nItersCMSSW == 0)
870  } else if (*i == "--num-iters-cmssw") {
871  next_arg_or_die(mArgs, i);
872  Config::nItersCMSSW = atoi(i->c_str());
873  } else if (*i == "--seed-input") {
874  next_arg_or_die(mArgs, i);
875  setOpt(*i, Config::seedInput, g_seed_opts, "seed input collection");
876  } else if (*i == "--seed-cleaning") {
877  next_arg_or_die(mArgs, i);
878  setOpt(*i, Config::seedCleaning, g_clean_opts, "seed cleaning");
879  } else if (*i == "--cf-seeding") {
880  Config::cf_seeding = true;
881  } else if (*i == "--use-phiq-arr") {
882 #ifdef CONFIG_PhiQArrays
883  Config::usePhiQArrays = true;
884 #else
885  printf("--use-phiq-arr has no effect: recompile with CONFIG_PhiQArrays\n");
886 #endif
887  } else if (*i == "--remove-dup") {
888  Config::removeDuplicates = true;
890  } else if (*i == "--remove-dup-no-hit") {
891  Config::removeDuplicates = true;
893  } else if (*i == "--use-dead-modules") {
894  Config::useDeadModules = true;
895  } else if (*i == "--kludge-cms-hit-errors") {
897  } else if (*i == "--backward-fit") {
898  Config::backwardFit = true;
899  } else if (*i == "--no-backward-search") {
900  Config::backwardSearch = false;
901  } else if (*i == "--include-pca") {
902  Config::includePCA = true;
903  } else if (*i == "--quality-val") {
904  Config::quality_val = true;
905  } else if (*i == "--dump-for-plots") {
906  Config::dumpForPlots = true;
907  } else if (*i == "--mtv-like-val") {
911  } else if (*i == "--mtv-require-seeds") {
916  } else if (*i == "--sim-val-for-cmssw") {
918  } else if (*i == "--sim-val") {
919  Config::sim_val = true;
920  } else if (*i == "--cmssw-val") {
921  Config::cmssw_val = true;
922  } else if (*i == "--cmssw-match-fw") {
923  next_arg_or_die(mArgs, i);
924  setOpt(*i, Config::cmsswMatchingFW, g_match_opts, "CMSSW validation track matching for forward built tracks");
925  } else if (*i == "--cmssw-match-bk") {
926  next_arg_or_die(mArgs, i);
927  setOpt(*i, Config::cmsswMatchingBK, g_match_opts, "CMSSW validation track matching for backward fit tracks");
928  } else if (*i == "--inc-shorts") {
930  } else if (*i == "--keep-hit-info") {
931  Config::keepHitInfo = true;
932  } else if (*i == "--try-to-save-sim-info") {
934  } else if (*i == "--backward-fit-pca") {
935  Config::backwardFit = true;
936  Config::includePCA = true;
937  } else if (*i == "--cmssw-simseeds") {
938  Config::geomPlugin = "CMS-2017";
940  } else if (*i == "--cmssw-stdseeds") {
941  Config::geomPlugin = "CMS-2017";
944  } else if (*i == "--cmssw-n2seeds") {
945  Config::geomPlugin = "CMS-2017";
948  } else if (*i == "--cmssw-pureseeds") {
949  Config::geomPlugin = "CMS-2017";
953  } else if (*i == "--cmssw-goodlabelseeds") {
954  Config::geomPlugin = "CMS-2017";
957  } else if (*i == "--cmssw-val-fhit-bhit") {
958  Config::cmssw_val = true;
962  } else if (*i == "--cmssw-val-fhit-bprm") {
963  Config::cmssw_val = true;
967  } else if (*i == "--cmssw-val-fprm-bhit") {
968  Config::cmssw_val = true;
972  } else if (*i == "--cmssw-val-fprm-bprm") {
973  Config::cmssw_val = true;
977  } else if (*i == "--cmssw-val-label") {
978  Config::cmssw_val = true;
982  } else if (*i == "--json-load") {
983  next_arg_or_die(mArgs, i);
984  Config::json_load_filenames.push_back(*i);
985  } else if (*i == "--json-patch") {
986  next_arg_or_die(mArgs, i);
987  Config::json_patch_filenames.push_back(*i);
988  } else if (*i == "--json-save-iterations") {
989  next_arg_or_die(mArgs, i);
991  } else if (*i == "--json-save-iterations-include-iter-info-preamble") {
993  } else if (*i == "--json-verbose") {
994  Config::json_verbose = true;
995  } else if (*i == "--json-dump-before") {
997  } else if (*i == "--json-dump-after") {
999  } else {
1000  fprintf(stderr, "Error: Unknown option/argument '%s'.\n", i->c_str());
1001  exit(1);
1002  }
1003 
1004  mArgs.erase(start, ++i);
1005  }
1006 
1007  // Do some checking of options before going...
1010  std::cerr << "What have you done?!? Can't mix cmssw label matching without pure seeds! Exiting..." << std::endl;
1011  exit(1);
1013  std::cerr
1014  << "What have you done?!? Short reco tracks are already accounted for in the MTV-Like Validation! Inclusive "
1015  "shorts is only an option for the standard simval, and will break the MTV-Like simval! Exiting..."
1016  << std::endl;
1017  exit(1);
1018  }
1019 
1021 
1022  printf("Running with n_threads=%d, best_out_of=%d\n", Config::numThreadsFinder, Config::finderReportBestOutOfN);
1023 
1024  test_standard();
1025 
1026  return 0;
1027 }
Definition: start.py:1
void test_standard()
Definition: mkFit.cc:192
static void populate()
Definition: MkBuilder.cc:170
int openRead(const std::string &fname, int expected_n_layers)
Definition: Event.cc:851
static std::mutex mutex
Definition: Proxy.cc:8
std::map< std::string, std::pair< seedOpts, std::string > > seedOptsMap
double runBuildingTestPlexStandard(Event &ev, const EventOfHits &eoh, MkBuilder &builder)
ROOT::Math::SVector< float, 3 > SVector3
Definition: MatrixSTypes.h:14
void initGeom()
Definition: mkFit.cc:43
void setOpt(const std::string &cmd_ln_str, T &c_opt, const U &g_opt_map, const std::string &ex_txt)
Definition: mkFit.cc:174
bool has_suffix(const std::string &str, const std::string &suffix)
Definition: mkFit.cc:449
void close()
Definition: Event.cc:972
cleanOpts seedCleaning
assert(be >=bs)
std::map< std::string, std::pair< matchOpts, std::string > > matchOptsMap
std::vector< std::string > json_patch_filenames
static Validation * make_validation(const std::string &, const TrackerInfo *)
Definition: Validation.cc:5
lStr_t::iterator lStr_i
Definition: mkFit.cc:447
void execTrackerInfoCreatorPlugin(const std::string &base, TrackerInfo &ti, IterationsInfo &ii, bool verbose)
void recalculateDependentConstants()
constexpr bool usePhiQArrays
Definition: Config.h:104
void patch_Files(IterationsInfo &its_info, const std::vector< std::string > &fnames, ConfigJsonPatcher::PatchReport *report=nullptr)
matchOpts cmsswMatchingFW
std::string getOpt(const T &c_opt, const U &g_opt_map)
Definition: mkFit.cc:162
void loadHitsAndBeamSpot(Event &ev, EventOfHits &eoh)
void skipNEvents(int n_to_skip)
Definition: Event.cc:960
matchOpts cmsswMatchingBK
void listOpts(const U &g_opt_map)
Definition: mkFit.cc:184
TrackerInfo TrkInfo
void loadDeads(EventOfHits &eoh, const std::vector< DeadVec > &deadvectors)
Definition: MkStdSeqs.cc:18
int main(int argc, const char *argv[])
Definition: mkFit.cc:468
std::unique_ptr< IterationConfig > patchLoad_File(const IterationsInfo &its_info, const std::string &fname, ConfigJsonPatcher::PatchReport *report=nullptr)
void runBuildingTestPlexDumbCMSSW(Event &ev, const EventOfHits &eoh, MkBuilder &builder)
constexpr int numThreadsFinder
Definition: Config.h:120
void save_Iterations(IterationsInfo &its_info, const std::string &fname_fmt, bool include_iter_info_preamble)
IterationsInfo ItrInfo
constexpr bool nan_etc_sigs_enable
Definition: Config.h:51
static std::mutex printmutex
Definition: Event.h:68
double runBuildingTestPlexCloneEngine(Event &ev, const EventOfHits &eoh, MkBuilder &builder)
void next_arg_or_die(lStr_t &args, lStr_i &i, bool allow_single_minus=false)
Definition: mkFit.cc:453
#define MPT_SIZE
Definition: Matrix.h:37
double b
Definition: hdecay.h:118
void dump(IterationsInfo &its_info)
double dtime()
std::map< std::string, std::pair< cleanOpts, std::string > > cleanOptsMap
bool json_save_iters_include_iter_info_preamble
std::vector< std::string > json_load_filenames
std::vector< double > runBtpCe_MultiIter(Event &ev, const EventOfHits &eoh, MkBuilder &builder, int n)
#define dprint(x)
Definition: Debug.h:90
static std::unique_ptr< MkBuilder > make_builder(bool silent=true)
Definition: MkBuilder.cc:168
constexpr int numSeedsPerTask
Definition: Config.h:122
constexpr int numThreadsEvents
Definition: Config.h:121
std::list< std::string > lStr_t
Definition: mkFit.cc:446
const bool useHitsForDuplicates
Definition: Config.h:142
std::string json_save_iters_fname_fmt
#define str(s)
ROOT::Math::SMatrix< float, 3, 3, ROOT::Math::MatRepSym< float, 3 > > SMatrixSym33
Definition: MatrixSTypes.h:13
std::string geomPlugin
long double T
double runBuildingTestPlexBestHit(Event &ev, const EventOfHits &eoh, MkBuilder &builder)
def exit(msg="")