Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "RecoTracker/MkFitCore/standalone/ConfigStandalone.h"
0002 #include "RecoTracker/MkFitCore/interface/TrackerInfo.h"
0003 #include "RecoTracker/MkFitCore/interface/IterationConfig.h"
0004 
0005 // For plugin loader
0006 #include <dlfcn.h>
0007 #include <sys/stat.h>
0008 #include <cstdlib>
0009 
0010 namespace mkfit {
0011 
0012   namespace Config {
0013 
0014     TrackerInfo TrkInfo;
0015     IterationsInfo ItrInfo;
0016 
0017     std::string geomPlugin = "CylCowWLids";
0018 
0019     int nTracks = 10000;
0020     int nEvents = 20;
0021     int nItersCMSSW = 0;
0022     bool loopOverFile = false;
0023 
0024     seedOpts seedInput = simSeeds;
0025     cleanOpts seedCleaning = noCleaning;
0026 
0027     bool readCmsswTracks = false;
0028 
0029     bool dumpForPlots = false;
0030 
0031     bool cf_seeding = false;
0032     bool cf_fitting = false;
0033 
0034     bool quality_val = false;
0035     bool sim_val_for_cmssw = false;
0036     bool sim_val = false;
0037     bool cmssw_val = false;
0038     bool fit_val = false;
0039     bool readSimTrackStates = false;
0040     bool inclusiveShorts = false;
0041     bool keepHitInfo = false;
0042     bool tryToSaveSimInfo = false;
0043     matchOpts cmsswMatchingFW = hitBased;
0044     matchOpts cmsswMatchingBK = trkParamBased;
0045 
0046     bool useDeadModules = false;
0047 
0048     // number of hits per task for finding seeds
0049     int numHitsPerTask = 32;
0050 
0051     bool mtvLikeValidation = false;
0052     bool mtvRequireSeeds = false;
0053     int cmsSelMinLayers = 12;
0054     int nMinFoundHits = 10;
0055 
0056     bool backwardFit = false;
0057     bool backwardSearch = true;
0058 
0059     int numThreadsSimulation = 12;
0060 
0061     int finderReportBestOutOfN = 1;
0062 
0063     bool includePCA = false;
0064 
0065     // ================================================================
0066 
0067     bool silent = false;
0068     bool json_verbose = false;
0069     bool json_dump_before = false;
0070     bool json_dump_after = false;
0071     std::vector<std::string> json_patch_filenames;
0072     std::vector<std::string> json_load_filenames;
0073     std::string json_save_iters_fname_fmt;
0074     bool json_save_iters_include_iter_info_preamble = false;
0075 
0076     // ================================================================
0077 
0078     void recalculateDependentConstants() {}
0079 
0080   }  // namespace Config
0081 
0082   //==============================================================================
0083   // Geometry / Configuration Plugin Loader
0084   //==============================================================================
0085 
0086   namespace {
0087     const char *search_path[] = {"", "../Geoms/", "Geoms/", "../", nullptr};
0088     typedef void (*TrackerInfoCreator_foo)(TrackerInfo &, IterationsInfo &, bool verbose);
0089   }  // namespace
0090 
0091   void execTrackerInfoCreatorPlugin(const std::string &base, TrackerInfo &ti, IterationsInfo &ii, bool verbose) {
0092     const std::string soname = base + ".so";
0093     const std::string binname = base + ".bin";
0094     struct stat st;
0095 
0096     int si = 0;
0097     while (search_path[si]) {
0098       std::string path;
0099       const char *envpath = std::getenv("MKFIT_BASE");
0100       if (envpath != nullptr) {
0101         path += envpath;
0102         path += "/";
0103       }
0104       path += search_path[si];
0105       std::string sopath = path + soname;
0106       if (stat(sopath.c_str(), &st) == 0) {
0107         printf("execTrackerInfoCreatorPlugin processing '%s'\n", sopath.c_str());
0108 
0109         void *h = dlopen(sopath.c_str(), RTLD_LAZY);
0110         if (!h) {
0111           perror("dlopen failed");
0112           fprintf(stderr, "dlerror:\n%s\n", dlerror());
0113           exit(2);
0114         }
0115 
0116         long long *p2f = (long long *)dlsym(h, "TrackerInfoCreator_ptr");
0117         if (!p2f) {
0118           perror("dlsym failed");
0119           exit(2);
0120         }
0121 
0122         std::string binpath = path + binname;
0123         int binsr = stat(binpath.c_str(), &st);
0124         printf("execTrackerInfoCreatorPlugin has%s found TrackerInfo binary file '%s'\n",
0125                binsr ? " NOT" : "",
0126                binpath.c_str());
0127         if (binsr == 0)
0128           ti.read_bin_file(binpath);
0129 
0130         TrackerInfoCreator_foo foo = (TrackerInfoCreator_foo)(*p2f);
0131         foo(ti, ii, verbose);
0132 
0133         // level 2: print shapes and modules, precision 8
0134         // ti.print_tracker(2, 8);
0135 
0136         return;
0137       }
0138 
0139       ++si;
0140     }
0141 
0142     fprintf(stderr, "TrackerInfo plugin '%s' not found in search path.\n", soname.c_str());
0143     exit(2);
0144   }
0145 
0146   namespace internal {
0147     std::vector<DeadVec> deadvectors;
0148   }
0149 
0150 }  // namespace mkfit