diff --git a/SDL/LSTESData.cc b/SDL/LSTESData.cc index 5d2237c4..06dd4463 100644 --- a/SDL/LSTESData.cc +++ b/SDL/LSTESData.cc @@ -10,75 +10,77 @@ #include "PixelMap.h" #include "ModuleMethods.h" -std::string trackLooperDir() { - const char* path_lst_base = std::getenv("LST_BASE"); - const char* path_tracklooperdir = std::getenv("TRACKLOOPERDIR"); - std::string path_str; - if (path_lst_base != nullptr) { - path_str = path_lst_base; - } else if (path_tracklooperdir != nullptr) { - path_str = path_tracklooperdir; - } else { - // FIXME: temporary solution, will need to pass a value from FileInPath or CMSSW search path - // in the `LSTProducer` or a related ES producer - path_str = std::getenv("CMSSW_BASE"); - path_str += "/src/RecoTracker/LSTCore/TrackLooper"; +namespace { + std::string trackLooperDir() { + const char* path_lst_base = std::getenv("LST_BASE"); + const char* path_tracklooperdir = std::getenv("TRACKLOOPERDIR"); + std::string path_str; + if (path_lst_base != nullptr) { + path_str = path_lst_base; + } else if (path_tracklooperdir != nullptr) { + path_str = path_tracklooperdir; + } else { + // FIXME: temporary solution, will need to pass a value from FileInPath or CMSSW search path + // in the `LSTProducer` or a related ES producer + path_str = std::getenv("CMSSW_BASE"); + path_str += "/src/RecoTracker/LSTCore/TrackLooper"; + } + return path_str; } - return path_str; -} -std::string get_absolute_path_after_check_file_exists(const std::string name) { - std::filesystem::path fullpath = std::filesystem::absolute(name.c_str()); - if (not std::filesystem::exists(fullpath)) { - std::cout << "ERROR: Could not find the file = " << fullpath << std::endl; - exit(2); + std::string get_absolute_path_after_check_file_exists(const std::string name) { + std::filesystem::path fullpath = std::filesystem::absolute(name.c_str()); + if (not std::filesystem::exists(fullpath)) { + std::cout << "ERROR: Could not find the file = " << fullpath << std::endl; + exit(2); + } + return fullpath.string(); } - return fullpath.string(); -} -void loadMapsHost(SDL::MapPLStoLayer& pLStoLayer, - std::shared_ptr> endcapGeometry, - std::shared_ptr> tiltedGeometry, - std::shared_ptr> moduleConnectionMap) { - // Module orientation information (DrDz or phi angles) - auto endcap_geom = - get_absolute_path_after_check_file_exists(trackLooperDir() + "/data/OT800_IT615_pt0.8/endcap_orientation.bin"); - auto tilted_geom = get_absolute_path_after_check_file_exists(trackLooperDir() + - "/data/OT800_IT615_pt0.8/tilted_barrel_orientation.bin"); - // Module connection map (for line segment building) - auto mappath = get_absolute_path_after_check_file_exists( - trackLooperDir() + "/data/OT800_IT615_pt0.8/module_connection_tracing_merged.bin"); + void loadMapsHost(SDL::MapPLStoLayer& pLStoLayer, + std::shared_ptr> endcapGeometry, + std::shared_ptr> tiltedGeometry, + std::shared_ptr> moduleConnectionMap) { + // Module orientation information (DrDz or phi angles) + auto endcap_geom = + get_absolute_path_after_check_file_exists(trackLooperDir() + "/data/OT800_IT615_pt0.8/endcap_orientation.bin"); + auto tilted_geom = get_absolute_path_after_check_file_exists( + trackLooperDir() + "/data/OT800_IT615_pt0.8/tilted_barrel_orientation.bin"); + // Module connection map (for line segment building) + auto mappath = get_absolute_path_after_check_file_exists( + trackLooperDir() + "/data/OT800_IT615_pt0.8/module_connection_tracing_merged.bin"); - endcapGeometry->load(endcap_geom); - tiltedGeometry->load(tilted_geom); - moduleConnectionMap->load(mappath); + endcapGeometry->load(endcap_geom); + tiltedGeometry->load(tilted_geom); + moduleConnectionMap->load(mappath); - auto pLSMapDir = trackLooperDir() + "/data/OT800_IT615_pt0.8/pixelmap/pLS_map"; - const std::array connects{ - {"_layer1_subdet5", "_layer2_subdet5", "_layer1_subdet4", "_layer2_subdet4"}}; - std::string path; + auto pLSMapDir = trackLooperDir() + "/data/OT800_IT615_pt0.8/pixelmap/pLS_map"; + const std::array connects{ + {"_layer1_subdet5", "_layer2_subdet5", "_layer1_subdet4", "_layer2_subdet4"}}; + std::string path; - static_assert(connects.size() == std::tuple_size>{}); - for (unsigned int i = 0; i < connects.size(); i++) { - auto connectData = connects[i].data(); + static_assert(connects.size() == std::tuple_size>{}); + for (unsigned int i = 0; i < connects.size(); i++) { + auto connectData = connects[i].data(); - path = pLSMapDir + connectData + ".bin"; - pLStoLayer[0][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); + path = pLSMapDir + connectData + ".bin"; + pLStoLayer[0][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); - path = pLSMapDir + "_pos" + connectData + ".bin"; - pLStoLayer[1][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); + path = pLSMapDir + "_pos" + connectData + ".bin"; + pLStoLayer[1][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); - path = pLSMapDir + "_neg" + connectData + ".bin"; - pLStoLayer[2][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); + path = pLSMapDir + "_neg" + connectData + ".bin"; + pLStoLayer[2][i] = SDL::ModuleConnectionMap(get_absolute_path_after_check_file_exists(path)); + } } -} +} // namespace std::unique_ptr> SDL::loadAndFillESHost() { auto pLStoLayer = std::make_shared(); auto endcapGeometry = std::make_shared>(); auto tiltedGeometry = std::make_shared>(); auto moduleConnectionMap = std::make_shared>(); - loadMapsHost(*pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap); + ::loadMapsHost(*pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap); return std::make_unique>(pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap); } @@ -108,4 +110,4 @@ std::unique_ptr> SDL::loadAndFillESDevice(SDL::Qu moduleConnectionMap.get()); return std::make_unique>( nModules, nLowerModules, nPixels, modulesBuffers, endcapGeometry, pixelMapping); -} \ No newline at end of file +}