Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2025-03-02 23:54:17

0001 #include "RecoTracker/MkFitCore/src/Matriplex/MatriplexCommon.h"
0002 
0003 // CCCC #include "fittestMPlex.h"
0004 #include "RecoTracker/MkFitCMS/standalone/buildtestMPlex.h"
0005 
0006 #include "RecoTracker/MkFitCore/interface/HitStructures.h"
0007 #include "RecoTracker/MkFitCore/interface/MkBuilder.h"
0008 #include "RecoTracker/MkFitCore/src/MkFitter.h"
0009 #include "RecoTracker/MkFitCMS/interface/MkStdSeqs.h"
0010 #include "RecoTracker/MkFitCMS/standalone/MkStandaloneSeqs.h"
0011 
0012 #include "RecoTracker/MkFitCore/interface/Config.h"
0013 #include "RecoTracker/MkFitCore/standalone/ConfigStandalone.h"
0014 
0015 #include "RecoTracker/MkFitCore/standalone/Event.h"
0016 
0017 #ifdef WITH_ROOT
0018 #include "RecoTracker/MkFitCore/standalone/Validation.h"
0019 #include "RecoTracker/MkFitCore/standalone/RntDumper/RntDumper.h"
0020 #endif
0021 
0022 //#define DEBUG
0023 #include "RecoTracker/MkFitCore/src/Debug.h"
0024 #include "RecoTracker/MkFitCMS/standalone/Shell.h"
0025 
0026 #include "oneapi/tbb/task_arena.h"
0027 #include "oneapi/tbb/parallel_for.h"
0028 #include <oneapi/tbb/global_control.h>
0029 
0030 #if defined(USE_VTUNE_PAUSE)
0031 #include "ittnotify.h"
0032 #endif
0033 
0034 #include <cstdlib>
0035 #include <limits>
0036 #include <list>
0037 #include <sstream>
0038 #include <memory>
0039 
0040 using namespace mkfit;
0041 
0042 //==============================================================================
0043 
0044 void initGeom() {
0045   std::cout << "Constructing geometry '" << Config::geomPlugin << "'\n";
0046 
0047   // NB: we currently assume that each node is a layer, and that layers
0048   // are added starting from the center
0049   // NB: z is just a dummy variable, VUSolid is actually infinite in size.  *** Therefore, set it to the eta of simulation ***
0050 
0051   /*
0052   // Test CMSSW loading
0053   IterationsInfo ii;
0054   unsigned int algorithms[]={ 4,22,23,5,24,7,8,9,10,6 }; // 10 iterations
0055   ii.resize(10);
0056   for (int i = 0; i < 10; ++i) {
0057       ii[i].m_track_algorithm = algorithms[i];
0058   }
0059   auto xx = configJson_Load_File(ii, "mkfit-phase1-initialStep.json");
0060   printf("%d\n", xx->m_iteration_index);
0061   */
0062 
0063   mkfit::execTrackerInfoCreatorPlugin(Config::geomPlugin, Config::TrkInfo, Config::ItrInfo);
0064 
0065   ConfigJson cj(Config::json_verbose);
0066 
0067   if (Config::json_dump_before)
0068     cj.dump(Config::ItrInfo);
0069 
0070   if (!Config::json_load_filenames.empty()) {
0071     ConfigJsonPatcher::PatchReport report;
0072 
0073     for (auto& fn : Config::json_load_filenames) {
0074       // This is for testing only ... we drop the loaded IterationConfig
0075       // as further code will always use IterationsInfo[ iter_index ].
0076       cj.patchLoad_File(Config::ItrInfo, fn, &report);
0077     }
0078 
0079     printf(
0080         "mkFit.cc/%s--JSON-Load read %d JSON entities from %d files, replaced %d parameters.\n"
0081         "   NOTE that these changes were NOT APPLIED to actual configuration that is going to be used.\n",
0082         __func__,
0083         report.n_json_entities,
0084         report.n_files,
0085         report.n_replacements);
0086   }
0087 
0088   if (!Config::json_patch_filenames.empty()) {
0089     ConfigJsonPatcher::PatchReport report;
0090 
0091     cj.patch_Files(Config::ItrInfo, Config::json_patch_filenames, &report);
0092 
0093     printf("mkFit.cc/%s--JOSN-Patch read %d JSON entities from %d files, replaced %d parameters.\n",
0094            __func__,
0095            report.n_json_entities,
0096            report.n_files,
0097            report.n_replacements);
0098   }
0099 
0100   if (Config::json_dump_after)
0101     cj.dump(Config::ItrInfo);
0102 
0103   if (!Config::json_save_iters_fname_fmt.empty()) {
0104     cj.save_Iterations(
0105         Config::ItrInfo, Config::json_save_iters_fname_fmt, Config::json_save_iters_include_iter_info_preamble);
0106   }
0107 
0108   Config::ItrInfo.setupStandardFunctionsFromNames();
0109 
0110   // Test functions for ConfigJsonPatcher
0111   // cj.test_Direct (Config::ItrInfo[0]);
0112   // cj.test_Patcher(Config::ItrInfo[0]);
0113 }
0114 
0115 namespace {
0116   int g_start_event = 1;
0117 
0118   bool g_run_fit_std = false;
0119 
0120   bool g_run_build_default = true;
0121   bool g_run_build_cmssw = false;
0122   bool g_run_build_bh = false;
0123   bool g_run_build_std = false;
0124   bool g_run_build_ce = false;
0125   bool g_run_build_mimi = false;
0126 
0127   std::string g_operation = "simulate_and_process";
0128   ;
0129   std::string g_input_file = "";
0130   std::string g_output_file = "";
0131 
0132   seedOptsMap g_seed_opts;
0133   void init_seed_opts() {
0134     g_seed_opts["sim"] = {simSeeds, "Use simtracks for seeds"};
0135     g_seed_opts["cmssw"] = {cmsswSeeds, "Use external CMSSW seeds"};
0136     g_seed_opts["find"] = {findSeeds, "Use mplex seed finder for seeds"};
0137   }
0138 
0139   cleanOptsMap g_clean_opts;
0140   void init_clean_opts() {
0141     g_clean_opts["none"] = {noCleaning, "No cleaning applied to external CMSSW seeds"};
0142     g_clean_opts["n2"] = {cleanSeedsN2, "Apply N^2 cleaning by Mario to external CMSSW seeds"};
0143     g_clean_opts["pure"] = {
0144         cleanSeedsPure,
0145         "Only use external CMSSW seeds that have produced a CMSSW track \n    must enable: --read-cmssw-tracks"};
0146     g_clean_opts["badlabel"] = {cleanSeedsBadLabel, "Remove seeds with label()<0 in external CMSSW seeds"};
0147   }
0148 
0149   matchOptsMap g_match_opts;
0150   void init_match_opts() {
0151     g_match_opts["trkparam"] = {trkParamBased,
0152                                 "Use track parameter-based matching for validating against CMSSW tracks"};
0153     g_match_opts["hits"] = {hitBased, "Use hit-based matching for validating against CMSSW tracks"};
0154     g_match_opts["label"] = {labelBased, "Only allowed with pure seeds: stricter hit-based matching"};
0155   }
0156 
0157   const char* b2a(bool b) { return b ? "true" : "false"; }
0158 
0159 }  // namespace
0160 
0161 //==============================================================================
0162 
0163 // Getters and setters of enum configs (from command line using anon. namespace above)
0164 
0165 template <typename T, typename U>
0166 std::string getOpt(const T& c_opt, const U& g_opt_map) {
0167   static const std::string empty("");
0168 
0169   for (const auto& g_opt_pair : g_opt_map) {
0170     if (g_opt_pair.second.first == c_opt)
0171       return g_opt_pair.first;
0172   }
0173   std::cerr << "No match for option " << c_opt << std::endl;
0174   return empty;
0175 }
0176 
0177 template <typename T, typename U>
0178 void setOpt(const std::string& cmd_ln_str, T& c_opt, const U& g_opt_map, const std::string& ex_txt) {
0179   if (g_opt_map.count(cmd_ln_str))
0180     c_opt = g_opt_map.at(cmd_ln_str).first;
0181   else {
0182     std::cerr << cmd_ln_str << " is not a valid " << ex_txt << " option!! Exiting..." << std::endl;
0183     exit(1);
0184   }
0185 }
0186 
0187 template <typename U>
0188 void listOpts(const U& g_opt_map) {
0189   for (const auto& g_opt_pair : g_opt_map) {
0190     std::cout << "  " << g_opt_pair.first.c_str() << " : " << g_opt_pair.second.second.c_str() << std::endl;
0191   }
0192 }
0193 
0194 //==============================================================================
0195 
0196 void test_standard() {
0197   printf("Running test_standard(), operation=\"%s\", best_out_of=%d\n",
0198          g_operation.c_str(),
0199          Config::finderReportBestOutOfN);
0200 
0201   if (Config::seedInput == cmsswSeeds)
0202     printf("- reading seeds from file\n");
0203 
0204   initGeom();
0205 
0206   if (Config::nEvents <= 0) {
0207     return;
0208   }
0209 
0210   DataFile data_file;
0211   if (g_operation == "read") {
0212     int evs_in_file = data_file.openRead(g_input_file, Config::TrkInfo.n_layers());
0213     int evs_available = evs_in_file - g_start_event + 1;
0214     if (Config::nEvents == -1) {
0215       Config::nEvents = evs_available;
0216     } else if (Config::nEvents > evs_available and not Config::loopOverFile) {
0217       printf("Requested number of events %d, only %d available.\n", Config::nEvents, evs_available);
0218       Config::nEvents = evs_available;
0219     }
0220 
0221     if (g_start_event > 1) {
0222       data_file.skipNEvents(g_start_event - 1);
0223     }
0224   }
0225 
0226   constexpr int NT = 5;
0227   double t_sum[NT] = {0};
0228   double t_skip[NT] = {0};
0229   std::vector<double> t_sum_iter(Config::nItersCMSSW, 0.0);
0230   std::vector<double> t_skip_iter(Config::nItersCMSSW, 0.0);
0231   double time = dtime();
0232 
0233   std::atomic<int> nevt{g_start_event};
0234   std::atomic<int> seedstot{0}, simtrackstot{0}, candstot{0};
0235   std::atomic<int> maxHits_all{0}, maxLayer_all{0};
0236 
0237   MkBuilder::populate();
0238 
0239   std::vector<std::unique_ptr<Event>> evs(Config::numThreadsEvents);
0240   std::vector<std::unique_ptr<Validation>> vals(Config::numThreadsEvents);
0241   std::vector<std::unique_ptr<MkBuilder>> mkbs(Config::numThreadsEvents);
0242   std::vector<std::shared_ptr<EventOfHits>> eohs(Config::numThreadsEvents);
0243   std::vector<std::shared_ptr<FILE>> fps;
0244   fps.reserve(Config::numThreadsEvents);
0245 
0246   const std::string valfile("valtree");
0247 
0248   for (int i = 0; i < Config::numThreadsEvents; ++i) {
0249     std::ostringstream serial;
0250     if (Config::numThreadsEvents > 1) {
0251       serial << "_" << i;
0252     }
0253     vals[i].reset(Validation::make_validation(valfile + serial.str() + ".root", &Config::TrkInfo));
0254     mkbs[i] = MkBuilder::make_builder(Config::silent);
0255     eohs[i].reset(new EventOfHits(Config::TrkInfo));
0256     evs[i].reset(new Event(*vals[i], 0, Config::TrkInfo.n_layers()));
0257     if (g_operation == "read") {
0258       fps.emplace_back(fopen(g_input_file.c_str(), "r"), [](FILE* fp) {
0259         if (fp)
0260           fclose(fp);
0261       });
0262     }
0263   }
0264 
0265   tbb::task_arena arena(Config::numThreadsFinder);
0266 
0267   dprint("parallel_for step size " << (Config::nEvents + Config::numThreadsEvents - 1) / Config::numThreadsEvents);
0268 
0269   time = dtime();
0270 
0271   int events_per_thread = (Config::nEvents + Config::numThreadsEvents - 1) / Config::numThreadsEvents;
0272 
0273   arena.execute([&]() {
0274     TBB_PARALLEL_FOR(
0275         tbb::blocked_range<int>(0, Config::numThreadsEvents, 1),
0276         [&](const tbb::blocked_range<int>& threads) {
0277           int thisthread = threads.begin();
0278 
0279           assert(threads.begin() == threads.end() - 1 && thisthread < Config::numThreadsEvents);
0280 
0281           // std::vector<Track> plex_tracks;
0282           auto& ev = *evs[thisthread].get();
0283           auto& mkb = *mkbs[thisthread].get();
0284           auto& eoh = *eohs[thisthread].get();
0285           auto fp = fps[thisthread].get();
0286 
0287           int evstart = thisthread * events_per_thread;
0288           int evend = std::min(Config::nEvents, evstart + events_per_thread);
0289 
0290           dprint("thisthread " << thisthread << " events " << Config::nEvents << " events/thread " << events_per_thread
0291                                << " range " << evstart << ":" << evend);
0292 
0293           for (int evt = evstart; evt < evend; ++evt) {
0294             ev.reset(nevt++);
0295 
0296             if (!Config::silent) {
0297               std::lock_guard<std::mutex> printlock(Event::printmutex);
0298               printf("\n");
0299               printf("Processing event %d\n", ev.evtID());
0300             }
0301 
0302             ev.read_in(data_file, fp);
0303 
0304             // skip events with zero seed tracks!
0305             if (ev.seedTracks_.empty())
0306               continue;
0307 
0308             // plex_tracks.resize(ev.simTracks_.size());
0309 
0310             StdSeq::loadHitsAndBeamSpot(ev, eoh);
0311 
0312             if (Config::useDeadModules) {
0313               StdSeq::loadDeads(eoh, mkfit::internal::deadvectors);
0314             }
0315 
0316             double t_best[NT] = {0}, t_cur[NT] = {0};
0317             std::vector<double> t_cur_iter;
0318             simtrackstot += ev.simTracks_.size();
0319             seedstot += ev.seedTracks_.size();
0320 
0321             int ncands_thisthread = 0;
0322             int maxHits_thisthread = 0;
0323             int maxLayer_thisthread = 0;
0324             for (int b = 0; b < Config::finderReportBestOutOfN; ++b) {
0325               t_cur[0] = 0;  // t_cur[0] = (g_run_fit_std) ? runFittingTestPlex(ev, plex_tracks) : 0;
0326               t_cur[1] = (g_run_build_bh) ? runBuildingTestPlexBestHit(ev, eoh, mkb) : 0;
0327               t_cur[2] = (g_run_build_default || g_run_build_std) ? runBuildingTestPlexStandard(ev, eoh, mkb) : 0;
0328               t_cur[3] = (g_run_build_default || g_run_build_ce) ? runBuildingTestPlexCloneEngine(ev, eoh, mkb) : 0;
0329               if (g_run_build_mimi)
0330                 t_cur_iter = runBtpCe_MultiIter(ev, eoh, mkb, Config::nItersCMSSW);
0331               t_cur[4] = (g_run_build_mimi) ? t_cur_iter[Config::nItersCMSSW] : 0;
0332               if (g_run_build_cmssw)
0333                 runBuildingTestPlexDumbCMSSW(ev, eoh, mkb);
0334               if (g_run_build_ce || g_run_build_mimi) {
0335                 ncands_thisthread = mkb.total_cands();
0336                 auto const& ln = mkb.max_hits_layer(eoh);
0337                 maxHits_thisthread = ln.first;
0338                 maxLayer_thisthread = ln.second;
0339               }
0340               for (int i = 0; i < NT; ++i)
0341                 t_best[i] = (b == 0) ? t_cur[i] : std::min(t_cur[i], t_best[i]);
0342 
0343               if (!Config::silent) {
0344                 std::lock_guard<std::mutex> printlock(Event::printmutex);
0345                 if (Config::finderReportBestOutOfN > 1) {
0346                   printf("----------------------------------------------------------------\n");
0347                   printf("Best-of-times:");
0348                   for (int i = 0; i < NT; ++i)
0349                     printf("  %.5f/%.5f", t_cur[i], t_best[i]);
0350                   printf("\n");
0351                 }
0352                 printf("----------------------------------------------------------------\n");
0353               }
0354             }
0355 
0356             candstot += ncands_thisthread;
0357             if (maxHits_thisthread > maxHits_all) {
0358               maxHits_all = maxHits_thisthread;
0359               maxLayer_all = maxLayer_thisthread;
0360             }
0361             if (!Config::silent) {
0362               std::lock_guard<std::mutex> printlock(Event::printmutex);
0363               printf("Matriplex fit = %.5f  --- Build  BHMX = %.5f  STDMX = %.5f  CEMX = %.5f  MIMI = %.5f\n",
0364                      t_best[0],
0365                      t_best[1],
0366                      t_best[2],
0367                      t_best[3],
0368                      t_best[4]);
0369             }
0370 
0371             {
0372               static std::mutex sum_up_lock;
0373               std::lock_guard<std::mutex> locker(sum_up_lock);
0374 
0375               for (int i = 0; i < NT; ++i)
0376                 t_sum[i] += t_best[i];
0377               if (evt > 0)
0378                 for (int i = 0; i < NT; ++i)
0379                   t_skip[i] += t_best[i];
0380               if (g_run_build_mimi) {
0381                 for (int i = 0; i < Config::nItersCMSSW; ++i)
0382                   t_sum_iter[i] += t_cur_iter[i];
0383                 if (evt > 0)
0384                   for (int i = 0; i < Config::nItersCMSSW; ++i)
0385                     t_skip_iter[i] += t_cur_iter[i];
0386               }
0387             }
0388           }
0389         },
0390         tbb::simple_partitioner());
0391   });
0392 
0393   time = dtime() - time;
0394 
0395   printf("\n");
0396   printf("================================================================\n");
0397   printf("=== TOTAL for %d events\n", Config::nEvents);
0398   printf("================================================================\n");
0399 
0400   printf("Total Matriplex fit = %.5f  --- Build  BHMX = %.5f  STDMX = %.5f  CEMX = %.5f  MIMI = %.5f\n",
0401          t_sum[0],
0402          t_sum[1],
0403          t_sum[2],
0404          t_sum[3],
0405          t_sum[4]);
0406   printf("Total event > 1 fit = %.5f  --- Build  BHMX = %.5f  STDMX = %.5f  CEMX = %.5f  MIMI = %.5f\n",
0407          t_skip[0],
0408          t_skip[1],
0409          t_skip[2],
0410          t_skip[3],
0411          t_skip[4]);
0412   printf("Total event loop time %.5f simtracks %d seedtracks %d builtcands %d maxhits %d on lay %d\n",
0413          time,
0414          simtrackstot.load(),
0415          seedstot.load(),
0416          candstot.load(),
0417          maxHits_all.load(),
0418          maxLayer_all.load());
0419   //fflush(stdout);
0420   if (g_run_build_mimi) {
0421     printf("================================================================\n");
0422     for (int i = 0; i < Config::nItersCMSSW; ++i)
0423       std::cout << " Iteration " << i << " build time = " << t_sum_iter[i] << " \n";
0424     printf("================================================================\n");
0425     for (int i = 0; i < Config::nItersCMSSW; ++i)
0426       std::cout << " Iteration " << i << " build time (event > 1) = " << t_skip_iter[i] << " \n";
0427     printf("================================================================\n");
0428   }
0429   if (Config::quality_val) {
0430     printf("Sum up of quality-val:\n");
0431     StdSeq::Quality::s_quality_sum.quality_print();
0432   }
0433   if (g_operation == "read") {
0434     data_file.close();
0435   }
0436 
0437   for (auto& val : vals) {
0438     val->fillConfigTree();
0439     val->saveTTrees();
0440   }
0441 }
0442 
0443 //==============================================================================
0444 // Command line argument parsing
0445 //==============================================================================
0446 
0447 typedef std::list<std::string> lStr_t;
0448 typedef lStr_t::iterator lStr_i;
0449 
0450 bool has_suffix(const std::string& str, const std::string& suffix) {
0451   return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0;
0452 }
0453 
0454 void next_arg_or_die(lStr_t& args, lStr_i& i, bool allow_single_minus = false) {
0455   lStr_i j = i;
0456   if (++j == args.end() || has_suffix(*j, ".C") || ((*j)[0] == '-' && !(*j == "-" && allow_single_minus))) {
0457     std::cerr << "Error: option " << *i << " requires an argument.\n";
0458     exit(1);
0459   }
0460   i = j;
0461 }
0462 
0463 //==============================================================================
0464 // main
0465 //==============================================================================
0466 
0467 #include <fenv.h>
0468 
0469 int main(int argc, const char* argv[]) {
0470 #ifdef _GNU_SOURCE
0471   if (Const::nan_etc_sigs_enable) {
0472     feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW);  //FE_ALL_EXCEPT);
0473   }
0474 #endif
0475 
0476 #ifdef USE_VTUNE_PAUSE
0477   __itt_pause();
0478 #endif
0479 
0480   assert(sizeof(Track::Status) == 4 &&
0481          "To make sure this is true for icc and gcc<6 when mixing bools/ints in bitfields.");
0482 
0483   // init enum maps
0484   init_seed_opts();
0485   init_clean_opts();
0486   init_match_opts();
0487 
0488   lStr_t mArgs;
0489   for (int i = 1; i < argc; ++i) {
0490     mArgs.push_back(argv[i]);
0491   }
0492   bool run_shell = false;
0493 
0494   lStr_i i = mArgs.begin();
0495   while (i != mArgs.end()) {
0496     lStr_i start = i;
0497 
0498     if (*i == "-h" || *i == "-help" || *i == "--help") {
0499       printf(
0500           "\n"
0501           "Usage: %s [options]\n"
0502           "Options: defaults defined as (def: DEFAULT VALUE)\n"
0503           "\n----------------------------------------------------------------------------------------------------------"
0504           "\n\n"
0505           "Generic options\n\n"
0506           "  --geom           <str>   geometry plugin to use (def: %s)\n"
0507           "  --silent                 suppress printouts inside event loop (def: %s)\n"
0508           "  --best-out-of    <int>   run test num times, report best time (def: %d)\n"
0509           "  --input-file             file name for reading (def: %s)\n"
0510           "  --output-file            file name for writitng (def: %s)\n"
0511           "  --read-cmssw-tracks      read external cmssw reco tracks if available (def: %s)\n"
0512           "  --read-simtrack-states   read in simTrackStates for pulls in validation (def: %s)\n"
0513           "  --num-events     <int>   number of events to run over or simulate (def: %d)\n"
0514           "                           if using --input-file, must be enabled AFTER on command line\n"
0515           "  --start-event    <int>   event number to start at when reading from a file (def: %d)\n"
0516           "  --loop-over-file         after reaching the end of the file, start over from the beginning until "
0517           "                           <num-events> events have been processed\n"
0518           "  --shell                  start interactive shell instead of running test_standard()\n"
0519           "\n"
0520           "If no --input-file is specified, will trigger simulation\n"
0521           "  --num-tracks     <int>   number of tracks to generate for each event (def: %d)\n"
0522           "\n----------------------------------------------------------------------------------------------------------"
0523           "\n\n"
0524           "Threading related options\n\n"
0525           "  --num-thr-sim    <int>   number of threads for simulation (def: %d)\n"
0526           "  --num-thr        <int>   number of threads for track finding (def: %d)\n"
0527           "  --num-thr-ev     <int>   number of threads to run the event loop (def: %d)\n"
0528           "  --seeds-per-task <int>   number of seeds to process in a tbb task (def: %d)\n"
0529           "  --hits-per-task  <int>   number of layer1 hits per task when using find seeds (def: %d)\n"
0530           "\n----------------------------------------------------------------------------------------------------------"
0531           "\n\n"
0532           "FittingTestMPlex options\n\n"
0533           "  --fit-std                run standard fitting test (def: %s)\n"
0534           "  --cf-fitting             enable conformal fit before fitting tracks to get initial estimate of track "
0535           "parameters and errors (def: %s)\n"
0536           "  --fit-val                enable ROOT based validation for fittingMPlex  (def: %s)\n"
0537           "\n----------------------------------------------------------------------------------------------------------"
0538           "\n\n"
0539           "BuildingTestMPlex options\n\n"
0540           " **Specify which building routine you would like to run\n"
0541           "  --build-cmssw            run dummy validation of CMSSW tracks with MkBuilder stuff (def: %s)\n"
0542           "  --build-bh               run best-hit building test (def: %s)\n"
0543           "  --build-std              run standard combinatorial building test (def: %s)\n"
0544           "  --build-ce               run clone engine combinatorial building test (def: %s)\n"
0545           "  --build-mimi             run clone engine on multiple-iteration test (def: %s)\n"
0546           "  --num-iters-cmssw <int>  number of mimi iterations to run (def: set to 3 when --build-mimi is in effect, "
0547           "0 otherwise)\n"
0548           "\n"
0549           " **Seeding options\n"
0550           "  --seed-input     <str>   which seed collecion used for building (def: %s)\n"
0551           "  --seed-cleaning  <str>   which seed cleaning to apply if using cmssw seeds (def: %s)\n"
0552           "  --cf-seeding             enable conformal fit over seeds (def: %s)\n"
0553           "\n"
0554           " **Duplicate removal options\n"
0555           "  --remove-dup            run duplicate removal after building, using both hit and kinematic criteria (def: "
0556           "%s)\n"
0557           "  --remove-dup-no-hit     run duplicate removal after building, using kinematic criteria only (def: %s)\n"
0558           "\n"
0559           " **Dead module (strip) option\n"
0560           "  --use-dead-modules          run duplicate removal after building, using both hit and kinematic criteria "
0561           "(def: %s)\n"
0562           "\n"
0563           " **Additional options for building\n"
0564           "  --use-phiq-arr           use phi-Q arrays in select hit indices (def: %s)\n"
0565           "  --backward-fit           perform backward fit during building (def: %s)\n"
0566           "  --no-backward-search     do not do backward search after backward fit\n"
0567           "                           (def: do search if backward-fit is enabled and available in given iteration)\n"
0568           "  --include-pca            do the backward fit to point of closest approach, does not imply "
0569           "'--backward-fit' (def: %s)\n"
0570           "  --use-p2p <0|1>          use prop-to-plane (def: %d)\n"
0571           "  --use-ptms <0|1>         use pT multiple scattering (def: %d)\n"
0572           "\n----------------------------------------------------------------------------------------------------------"
0573           "\n\n"
0574           "Validation options\n\n"
0575           " **Text file based options\n"
0576           "  --quality-val            enable printout validation for MkBuilder (def: %s)\n"
0577           "                             must enable: --dump-for-plots\n"
0578           "  --dump-for-plots         make shell printouts for plots (def: %s)\n"
0579           "  --mtv-like-val           configure validation to emulate CMSSW MultiTrackValidator (MTV) (def: %s)\n"
0580           "  --mtv-require-seeds      configure validation to emulate MTV but require sim tracks to be matched to "
0581           "seeds (def: %s)\n"
0582           "\n"
0583           " **ROOT based options\n"
0584           "  --sim-val-for-cmssw      enable ROOT based validation for CMSSW tracks with simtracks as reference [eff, "
0585           "FR, DR] (def: %s)\n"
0586           "  --sim-val                enable ROOT based validation for seeding, building, and fitting with simtracks "
0587           "as reference [eff, FR, DR] (def: %s)\n"
0588           "  --cmssw-val              enable ROOT based validation for building and fitting with CMSSW tracks as "
0589           "reference [eff, FR, DR] (def: %s)\n"
0590           "                             must enable: --geom CMS-phase1 --read-cmssw-tracks\n"
0591           "  --cmssw-match-fw  <str>  which cmssw track matching routine to use if validating against CMSSW tracks, "
0592           "forward built tracks only (def: %s)\n"
0593           "                             must enable: --geom CMS-phase1 --cmssw-val --read-cmssw-tracks\n"
0594           "  --cmssw-match-bk  <str>  which cmssw track matching routine to use if validating against CMSSW tracks, "
0595           "backward fit tracks only (def: %s)\n"
0596           "                             must enable: --geom CMS-phase1 --cmssw-val --read-cmssw-tracks --backward-fit "
0597           "--backward-fit-pca\n"
0598           "  --inc-shorts             include short reco tracks into FR (def: %s)\n"
0599           "  --keep-hit-info          keep vectors of hit idxs and branches in trees (def: %s)\n"
0600           "  --try-to-save-sim-info   two options for this flag [related to validation with simtracks as reference "
0601           "collection] (def: %s)\n"
0602           "                              a) IF (--read-simtrack-states is enabled)\n"
0603           "                                    If a sim track is associated to a reco track, but it does not contain "
0604           "the last found on the reco track\n"
0605           "                                    still save sim track kinematic info from generator position\n"
0606           "                              b) ELSE (--read-simtrack-states is NOT enabled)\n"
0607           "                                    Save sim track kinematic info from generator position if matched to "
0608           "reco track\n"
0609           "\n----------------------------------------------------------------------------------------------------------"
0610           "\n\n"
0611           "Combo spaghetti, that's with cole slaw:\n\n"
0612           " **Building and fitting combo options\n"
0613           "  --backward-fit-pca       perform backward fit to point of closest approach during building\n"
0614           "                             == --backward-fit --include-pca\n"
0615           " **Seed combo options\n"
0616           "  --cmssw-simseeds         use CMS geom with simtracks for seeds\n"
0617           "                             == --geom CMS-phase1 --seed-input %s\n"
0618           "  --cmssw-stdseeds         use CMS geom with CMSSW seeds uncleaned\n"
0619           "                             == --geom CMS-phase1 --seed-input %s --seed-cleaning %s\n"
0620           "  --cmssw-n2seeds          use CMS geom with CMSSW seeds cleaned with N^2 routine\n"
0621           "                             == --geom CMS-phase1 --seed-input %s --seed-cleaning %s\n"
0622           "  --cmssw-pureseeds        use CMS geom with pure CMSSW seeds (seeds which produced CMSSW reco tracks), "
0623           "enable read of CMSSW tracks\n"
0624           "                             == --geom CMS-phase1 --seed-input %s --seed-cleaning %s --read-cmssw-tracks\n"
0625           "  --cmssw-goodlabelseeds   use CMS geom with CMSSW seeds with label() >= 0\n"
0626           "                             == --geom CMS-phase1 --seed-input %s --seed-cleaning %s\n"
0627           "\n"
0628           " **CMSSW validation combo options\n"
0629           "  --cmssw-val-fhit-bhit    use CMSSW validation with hit based matching (50 percent after seed) for forward "
0630           "built tracks\n"
0631           "                           use CMSSW validation with hit based matching (50 percent after seed) for "
0632           "backward fit tracks\n"
0633           "                             == --cmssw-val --read-cmssw-tracks --cmssw-match-fw %s --cmssw-match-bk %s\n"
0634           "                             must enable: --backward-fit-pca\n"
0635           "  --cmssw-val-fhit-bprm    use CMSSW validation with hit based matching (50 percent after seed) for forward "
0636           "built tracks\n"
0637           "                           use CMSSW validation with track parameter based matching for backward fit "
0638           "tracks\n"
0639           "                             == --cmssw-val --read-cmssw-tracks --cmssw-match-fw %s --cmssw-match-bk %s\n"
0640           "                             must enable: --backward-fit-pca\n"
0641           "  --cmssw-val-fprm-bhit    use CMSSW validation with track parameter based matching for forward built "
0642           "tracks\n"
0643           "                           use CMSSW validation with hit based matching (50 percent after seed) for "
0644           "backward fit tracks\n"
0645           "                             == --cmssw-val --read-cmssw-tracks --cmssw-match-fw %s --cmssw-match-bk %s\n"
0646           "                             must enable: --backward-fit-pca\n"
0647           "  --cmssw-val-fprm-bprm    use CMSSW validation with track parameter based matching for forward built "
0648           "tracks\n"
0649           "                           use CMSSW validation with track parameter based matching for backward fit "
0650           "tracks\n"
0651           "                             == --cmssw-val --read-cmssw-tracks --cmssw-match-fw %s --cmssw-match-bk %s\n"
0652           "                             must enable: --backward-fit-pca\n"
0653           "  --cmssw-val-label        use CMSSW validation with stricter hit based matching for both forward built and "
0654           "backward fit tracks, enable read of CMSSW tracks\n"
0655           "                             == --cmssw-val --read-cmssw-tracks --cmssw-match-fw %s --cmssw-match-bk %s\n"
0656           "                             must enable: --cmssw-pureseeds --backward-fit-pca\n"
0657           "\n----------------------------------------------------------------------------------------------------------"
0658           "\n\n"
0659           "JSON config patcher options:\n\n"
0660           "  --json-load  <filename>  load single IterationConfig from given JSON file (def: do not load)\n"
0661           "                           can be specified multiple times for several files\n"
0662           "  --json-patch <filename>  patch IterationsInfo from given JSON file (def: do not patch)\n"
0663           "                           can be specified multiple times for several files\n"
0664           "  --json-save-iterations <fname-fmt> save per iteration json files\n"
0665           "                           %%d in fname-fmt gets replaced with iteration index\n"
0666           "                           %%s in fname-fmt gets replaced with iteration algorithm name\n"
0667           "                           exactly one of %%d and %%s must be specified\n"
0668           "  --json-save-iterations-include-iter-info-preamble (def: %s)\n"
0669           "  --json-verbose     print each patch assignment as it is being made (def: %s)\n"
0670           "  --json-dump-before print iteration config before patching (def: %s)\n"
0671           "  --json-dump-after  print iteration config after  patching (def: %s)\n"
0672           "\n----------------------------------------------------------------------------------------------------------"
0673           "\n\n",
0674           argv[0],
0675 
0676           Config::geomPlugin.c_str(),
0677           b2a(Config::silent),
0678           Config::finderReportBestOutOfN,
0679           g_input_file.c_str(),
0680           g_output_file.c_str(),
0681           b2a(Config::readCmsswTracks),
0682           b2a(Config::readSimTrackStates),
0683           Config::nEvents,
0684           g_start_event,
0685           Config::nTracks,
0686 
0687           Config::numThreadsSimulation,
0688           Config::numThreadsFinder,
0689           Config::numThreadsEvents,
0690           Config::numSeedsPerTask,
0691           Config::numHitsPerTask,
0692 
0693           b2a(g_run_fit_std),
0694           b2a(Config::cf_fitting),
0695           b2a(Config::fit_val),
0696 
0697           b2a(g_run_build_cmssw),
0698           b2a(g_run_build_bh),
0699           b2a(g_run_build_default || g_run_build_std),
0700           b2a(g_run_build_default || g_run_build_ce),
0701           b2a(g_run_build_mimi),
0702 
0703           getOpt(Config::seedInput, g_seed_opts).c_str(),
0704           getOpt(Config::seedCleaning, g_clean_opts).c_str(),
0705           b2a(Config::cf_seeding),
0706 
0707           b2a(Config::removeDuplicates && Config::useHitsForDuplicates),
0708           b2a(Config::removeDuplicates && !Config::useHitsForDuplicates),
0709 
0710           b2a(Config::useDeadModules),
0711 
0712           b2a(Config::usePhiQArrays),
0713           b2a(Config::backwardFit),
0714           b2a(Config::includePCA),
0715           int(Config::usePropToPlane),
0716           int(Config::usePtMultScat),
0717 
0718           b2a(Config::quality_val),
0719           b2a(Config::dumpForPlots),
0720           b2a(Config::mtvLikeValidation),
0721           b2a(Config::mtvRequireSeeds),
0722 
0723           b2a(Config::sim_val_for_cmssw),
0724           b2a(Config::sim_val),
0725           b2a(Config::cmssw_val),
0726           getOpt(Config::cmsswMatchingFW, g_match_opts).c_str(),
0727           getOpt(Config::cmsswMatchingBK, g_match_opts).c_str(),
0728           b2a(Config::inclusiveShorts),
0729           b2a(Config::keepHitInfo),
0730           b2a(Config::tryToSaveSimInfo),
0731 
0732           getOpt(simSeeds, g_seed_opts).c_str(),
0733           getOpt(cmsswSeeds, g_seed_opts).c_str(),
0734           getOpt(noCleaning, g_clean_opts).c_str(),
0735           getOpt(cmsswSeeds, g_seed_opts).c_str(),
0736           getOpt(cleanSeedsN2, g_clean_opts).c_str(),
0737           getOpt(cmsswSeeds, g_seed_opts).c_str(),
0738           getOpt(cleanSeedsPure, g_clean_opts).c_str(),
0739           getOpt(cmsswSeeds, g_seed_opts).c_str(),
0740           getOpt(cleanSeedsBadLabel, g_clean_opts).c_str(),
0741 
0742           getOpt(hitBased, g_match_opts).c_str(),
0743           getOpt(hitBased, g_match_opts).c_str(),
0744           getOpt(hitBased, g_match_opts).c_str(),
0745           getOpt(trkParamBased, g_match_opts).c_str(),
0746           getOpt(trkParamBased, g_match_opts).c_str(),
0747           getOpt(hitBased, g_match_opts).c_str(),
0748           getOpt(trkParamBased, g_match_opts).c_str(),
0749           getOpt(trkParamBased, g_match_opts).c_str(),
0750           getOpt(labelBased, g_match_opts).c_str(),
0751           getOpt(labelBased, g_match_opts).c_str(),
0752 
0753           b2a(Config::json_verbose),
0754           b2a(Config::json_save_iters_include_iter_info_preamble),
0755           b2a(Config::json_dump_before),
0756           b2a(Config::json_dump_after));
0757 
0758       printf("List of options for string based inputs \n");
0759       printf(
0760           "--geom \n"
0761           "  CMS-phase1 \n"
0762           "  CMS-phase2 \n"
0763           "  CylCowWLids \n"
0764           "\n");
0765 
0766       printf("--seed-input \n");
0767       listOpts(g_seed_opts);
0768       printf("\n");
0769 
0770       printf("--seed-cleaning \n");
0771       listOpts(g_clean_opts);
0772       printf("\n");
0773 
0774       printf("--cmssw-matching \n");
0775       listOpts(g_match_opts);
0776       printf("\n");
0777 
0778       exit(0);
0779     }  // end of "help" block
0780 
0781     else if (*i == "--geom") {
0782       next_arg_or_die(mArgs, i);
0783       Config::geomPlugin = *i;
0784     } else if (*i == "--silent") {
0785       Config::silent = true;
0786     } else if (*i == "--best-out-of") {
0787       next_arg_or_die(mArgs, i);
0788       Config::finderReportBestOutOfN = atoi(i->c_str());
0789     } else if (*i == "--input-file") {
0790       next_arg_or_die(mArgs, i);
0791       g_input_file = *i;
0792       g_operation = "read";
0793       Config::nEvents = -1;
0794     } else if (*i == "--output-file") {
0795       next_arg_or_die(mArgs, i);
0796       g_output_file = *i;
0797       g_operation = "write";
0798     } else if (*i == "--read-cmssw-tracks") {
0799       Config::readCmsswTracks = true;
0800     } else if (*i == "--read-simtrack-states") {
0801       Config::readSimTrackStates = true;
0802     } else if (*i == "--num-events") {
0803       next_arg_or_die(mArgs, i);
0804       Config::nEvents = atoi(i->c_str());
0805     } else if (*i == "--start-event") {
0806       next_arg_or_die(mArgs, i);
0807       g_start_event = atoi(i->c_str());
0808     } else if (*i == "--loop-over-file") {
0809       Config::loopOverFile = true;
0810     } else if (*i == "--shell") {
0811 #ifndef WITH_ROOT
0812       std::cerr << "--shell option is only supported when compiled with ROOT.\n";
0813       exit(1);
0814 #endif
0815       run_shell = true;
0816     } else if (*i == "--num-tracks") {
0817       next_arg_or_die(mArgs, i);
0818       Config::nTracks = atoi(i->c_str());
0819     } else if (*i == "--num-thr-sim") {
0820       next_arg_or_die(mArgs, i);
0821       Config::numThreadsSimulation = atoi(i->c_str());
0822     } else if (*i == "--num-thr") {
0823       next_arg_or_die(mArgs, i);
0824       Config::numThreadsFinder = atoi(i->c_str());
0825     } else if (*i == "--num-thr-ev") {
0826       next_arg_or_die(mArgs, i);
0827       Config::numThreadsEvents = atoi(i->c_str());
0828     } else if (*i == "--seeds-per-task") {
0829       next_arg_or_die(mArgs, i);
0830       Config::numSeedsPerTask = atoi(i->c_str());
0831     } else if (*i == "--hits-per-task") {
0832       next_arg_or_die(mArgs, i);
0833       Config::numHitsPerTask = atoi(i->c_str());
0834     } else if (*i == "--fit-std") {
0835       g_run_build_default = false;
0836       g_run_fit_std = true;
0837     } else if (*i == "--cf-fitting") {
0838       Config::cf_fitting = true;
0839     } else if (*i == "--fit-val") {
0840       Config::fit_val = true;
0841     } else if (*i == "--build-cmssw") {
0842       g_run_build_default = false;
0843       g_run_build_cmssw = true;
0844     } else if (*i == "--build-bh") {
0845       g_run_build_default = false;
0846       g_run_build_bh = true;
0847     } else if (*i == "--build-std") {
0848       g_run_build_default = false;
0849       g_run_build_std = true;
0850     } else if (*i == "--build-ce") {
0851       g_run_build_default = false;
0852       g_run_build_ce = true;
0853     } else if (*i == "--build-mimi") {
0854       g_run_build_default = false;
0855       g_run_build_mimi = true;
0856       if (Config::nItersCMSSW == 0)
0857         Config::nItersCMSSW = 3;
0858     } else if (*i == "--num-iters-cmssw") {
0859       next_arg_or_die(mArgs, i);
0860       Config::nItersCMSSW = atoi(i->c_str());
0861     } else if (*i == "--seed-input") {
0862       next_arg_or_die(mArgs, i);
0863       setOpt(*i, Config::seedInput, g_seed_opts, "seed input collection");
0864     } else if (*i == "--seed-cleaning") {
0865       next_arg_or_die(mArgs, i);
0866       setOpt(*i, Config::seedCleaning, g_clean_opts, "seed cleaning");
0867     } else if (*i == "--cf-seeding") {
0868       Config::cf_seeding = true;
0869     } else if (*i == "--use-phiq-arr") {
0870 #ifdef CONFIG_PhiQArrays
0871       Config::usePhiQArrays = true;
0872 #else
0873       printf("--use-phiq-arr has no effect: recompile with CONFIG_PhiQArrays\n");
0874 #endif
0875     } else if (*i == "--remove-dup") {
0876       Config::removeDuplicates = true;
0877       Config::useHitsForDuplicates = true;
0878     } else if (*i == "--remove-dup-no-hit") {
0879       Config::removeDuplicates = true;
0880       Config::useHitsForDuplicates = false;
0881     } else if (*i == "--use-dead-modules") {
0882       Config::useDeadModules = true;
0883     } else if (*i == "--backward-fit") {
0884       Config::backwardFit = true;
0885     } else if (*i == "--no-backward-search") {
0886       Config::backwardSearch = false;
0887     } else if (*i == "--include-pca") {
0888       Config::includePCA = true;
0889     } else if (*i == "--use-p2p") {
0890       next_arg_or_die(mArgs, i);
0891       Config::usePropToPlane = (bool)atoi(i->c_str());
0892     } else if (*i == "--use-ptms") {
0893       next_arg_or_die(mArgs, i);
0894       Config::usePtMultScat = (bool)atoi(i->c_str());
0895     } else if (*i == "--quality-val") {
0896       Config::quality_val = true;
0897     } else if (*i == "--dump-for-plots") {
0898       Config::dumpForPlots = true;
0899     } else if (*i == "--mtv-like-val") {
0900       Config::mtvLikeValidation = true;
0901       Config::cmsSelMinLayers = 0;
0902       Config::nMinFoundHits = 0;
0903     } else if (*i == "--mtv-require-seeds") {
0904       Config::mtvLikeValidation = true;
0905       Config::cmsSelMinLayers = 0;
0906       Config::nMinFoundHits = 0;
0907       Config::mtvRequireSeeds = true;
0908     } else if (*i == "--sim-val-for-cmssw") {
0909       Config::sim_val_for_cmssw = true;
0910     } else if (*i == "--sim-val") {
0911       Config::sim_val = true;
0912     } else if (*i == "--cmssw-val") {
0913       Config::cmssw_val = true;
0914     } else if (*i == "--cmssw-match-fw") {
0915       next_arg_or_die(mArgs, i);
0916       setOpt(*i, Config::cmsswMatchingFW, g_match_opts, "CMSSW validation track matching for forward built tracks");
0917     } else if (*i == "--cmssw-match-bk") {
0918       next_arg_or_die(mArgs, i);
0919       setOpt(*i, Config::cmsswMatchingBK, g_match_opts, "CMSSW validation track matching for backward fit tracks");
0920     } else if (*i == "--inc-shorts") {
0921       Config::inclusiveShorts = true;
0922     } else if (*i == "--keep-hit-info") {
0923       Config::keepHitInfo = true;
0924     } else if (*i == "--try-to-save-sim-info") {
0925       Config::tryToSaveSimInfo = true;
0926     } else if (*i == "--backward-fit-pca") {
0927       Config::backwardFit = true;
0928       Config::includePCA = true;
0929     } else if (*i == "--cmssw-simseeds") {
0930       Config::geomPlugin = "CMS-phase1";
0931       Config::seedInput = simSeeds;
0932     } else if (*i == "--cmssw-stdseeds") {
0933       Config::geomPlugin = "CMS-phase1";
0934       Config::seedInput = cmsswSeeds;
0935       Config::seedCleaning = noCleaning;
0936     } else if (*i == "--cmssw-n2seeds") {
0937       Config::geomPlugin = "CMS-phase1";
0938       Config::seedInput = cmsswSeeds;
0939       Config::seedCleaning = cleanSeedsN2;
0940     } else if (*i == "--cmssw-pureseeds") {
0941       Config::geomPlugin = "CMS-phase1";
0942       Config::seedInput = cmsswSeeds;
0943       Config::seedCleaning = cleanSeedsPure;
0944       Config::readCmsswTracks = true;
0945     } else if (*i == "--cmssw-goodlabelseeds") {
0946       Config::geomPlugin = "CMS-phase1";
0947       Config::seedInput = cmsswSeeds;
0948       Config::seedCleaning = cleanSeedsBadLabel;
0949     } else if (*i == "--cmssw-val-fhit-bhit") {
0950       Config::cmssw_val = true;
0951       Config::readCmsswTracks = true;
0952       Config::cmsswMatchingFW = hitBased;
0953       Config::cmsswMatchingBK = hitBased;
0954     } else if (*i == "--cmssw-val-fhit-bprm") {
0955       Config::cmssw_val = true;
0956       Config::readCmsswTracks = true;
0957       Config::cmsswMatchingFW = hitBased;
0958       Config::cmsswMatchingBK = trkParamBased;
0959     } else if (*i == "--cmssw-val-fprm-bhit") {
0960       Config::cmssw_val = true;
0961       Config::readCmsswTracks = true;
0962       Config::cmsswMatchingFW = trkParamBased;
0963       Config::cmsswMatchingBK = hitBased;
0964     } else if (*i == "--cmssw-val-fprm-bprm") {
0965       Config::cmssw_val = true;
0966       Config::readCmsswTracks = true;
0967       Config::cmsswMatchingFW = trkParamBased;
0968       Config::cmsswMatchingBK = trkParamBased;
0969     } else if (*i == "--cmssw-val-label") {
0970       Config::cmssw_val = true;
0971       Config::readCmsswTracks = true;
0972       Config::cmsswMatchingFW = labelBased;
0973       Config::cmsswMatchingBK = labelBased;
0974     } else if (*i == "--json-load") {
0975       next_arg_or_die(mArgs, i);
0976       Config::json_load_filenames.push_back(*i);
0977     } else if (*i == "--json-patch") {
0978       next_arg_or_die(mArgs, i);
0979       Config::json_patch_filenames.push_back(*i);
0980     } else if (*i == "--json-save-iterations") {
0981       next_arg_or_die(mArgs, i);
0982       Config::json_save_iters_fname_fmt = *i;
0983     } else if (*i == "--json-save-iterations-include-iter-info-preamble") {
0984       Config::json_save_iters_include_iter_info_preamble = true;
0985     } else if (*i == "--json-verbose") {
0986       Config::json_verbose = true;
0987     } else if (*i == "--json-dump-before") {
0988       Config::json_dump_before = true;
0989     } else if (*i == "--json-dump-after") {
0990       Config::json_dump_after = true;
0991     } else {
0992       fprintf(stderr, "Error: Unknown option/argument '%s'.\n", i->c_str());
0993       exit(1);
0994     }
0995 
0996     mArgs.erase(start, ++i);
0997   }
0998 
0999   // clang-format off
1000 
1001   // Do some checking of options before going...
1002   if (Config::seedCleaning != cleanSeedsPure &&
1003       (Config::cmsswMatchingFW == labelBased || Config::cmsswMatchingBK == labelBased)) {
1004     std::cerr << "What have you done?!? Can't mix cmssw label matching without pure seeds! Exiting...\n";
1005     exit(1);
1006   } else if (Config::mtvLikeValidation && Config::inclusiveShorts) {
1007     std::cerr << "What have you done?!? Short reco tracks are already accounted for in the MTV-Like Validation! Inclusive "
1008                  "shorts is only an option for the standard simval, and will break the MTV-Like simval! Exiting...\n";
1009     exit(1);
1010   }
1011 
1012   Config::recalculateDependentConstants();
1013 
1014   printf("mkFit configuration complete.\n"
1015          "  vusize=%d, num_thr_events=%d, num_thr_finder=%d\n"
1016          "  sizeof(Track)=%zu, sizeof(Hit)=%zu, sizeof(SVector3)=%zu, sizeof(SMatrixSym33)=%zu, sizeof(MCHitInfo)=%zu\n",
1017          MPT_SIZE, Config::numThreadsEvents, Config::numThreadsFinder,
1018          sizeof(Track), sizeof(Hit), sizeof(SVector3), sizeof(SMatrixSym33), sizeof(MCHitInfo));
1019 
1020 #ifdef WITH_ROOT
1021   Shell *shell = nullptr;
1022 #endif
1023   if (run_shell) {
1024 #ifdef WITH_ROOT
1025     tbb::global_control global_limit(tbb::global_control::max_allowed_parallelism, Config::numThreadsFinder);
1026 
1027     initGeom();
1028     shell = new Shell(mkfit::internal::deadvectors, g_input_file, g_start_event);
1029     shell->Run();
1030 #else
1031     std::cerr << "shell selected on a non-ROOT build.\n";
1032 #endif
1033   } else {
1034     test_standard();
1035   }
1036 
1037 #ifdef WITH_ROOT
1038   RntDumper::FinalizeAll();
1039   if (run_shell) {
1040     delete shell;
1041   }
1042 #endif
1043 
1044   // clang-format on
1045 
1046   return 0;
1047 }