Skip to content
This repository has been archived by the owner on Dec 9, 2024. It is now read-only.

Commit

Permalink
Move load functions back into an unnamed namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
ariostas committed May 23, 2024
1 parent 7bc7a71 commit f8f31c9
Showing 1 changed file with 55 additions and 53 deletions.
108 changes: 55 additions & 53 deletions SDL/LSTESData.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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<SDL::EndcapGeometryHost<SDL::Dev>> endcapGeometry,
std::shared_ptr<SDL::TiltedGeometry<SDL::Dev>> tiltedGeometry,
std::shared_ptr<SDL::ModuleConnectionMap<SDL::Dev>> 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<SDL::EndcapGeometryHost<SDL::Dev>> endcapGeometry,
std::shared_ptr<SDL::TiltedGeometry<SDL::Dev>> tiltedGeometry,
std::shared_ptr<SDL::ModuleConnectionMap<SDL::Dev>> 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<std::string, 4> 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<std::string, 4> connects{
{"_layer1_subdet5", "_layer2_subdet5", "_layer1_subdet4", "_layer2_subdet4"}};
std::string path;

static_assert(connects.size() == std::tuple_size<std::decay_t<decltype(pLStoLayer[0])>>{});
for (unsigned int i = 0; i < connects.size(); i++) {
auto connectData = connects[i].data();
static_assert(connects.size() == std::tuple_size<std::decay_t<decltype(pLStoLayer[0])>>{});
for (unsigned int i = 0; i < connects.size(); i++) {
auto connectData = connects[i].data();

path = pLSMapDir + connectData + ".bin";
pLStoLayer[0][i] = SDL::ModuleConnectionMap<SDL::Dev>(get_absolute_path_after_check_file_exists(path));
path = pLSMapDir + connectData + ".bin";
pLStoLayer[0][i] = SDL::ModuleConnectionMap<SDL::Dev>(get_absolute_path_after_check_file_exists(path));

path = pLSMapDir + "_pos" + connectData + ".bin";
pLStoLayer[1][i] = SDL::ModuleConnectionMap<SDL::Dev>(get_absolute_path_after_check_file_exists(path));
path = pLSMapDir + "_pos" + connectData + ".bin";
pLStoLayer[1][i] = SDL::ModuleConnectionMap<SDL::Dev>(get_absolute_path_after_check_file_exists(path));

path = pLSMapDir + "_neg" + connectData + ".bin";
pLStoLayer[2][i] = SDL::ModuleConnectionMap<SDL::Dev>(get_absolute_path_after_check_file_exists(path));
path = pLSMapDir + "_neg" + connectData + ".bin";
pLStoLayer[2][i] = SDL::ModuleConnectionMap<SDL::Dev>(get_absolute_path_after_check_file_exists(path));
}
}
}
} // namespace

std::unique_ptr<SDL::LSTESHostData<SDL::Dev>> SDL::loadAndFillESHost() {
auto pLStoLayer = std::make_shared<SDL::MapPLStoLayer>();
auto endcapGeometry = std::make_shared<SDL::EndcapGeometryHost<SDL::Dev>>();
auto tiltedGeometry = std::make_shared<SDL::TiltedGeometry<SDL::Dev>>();
auto moduleConnectionMap = std::make_shared<SDL::ModuleConnectionMap<SDL::Dev>>();
loadMapsHost(*pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap);
::loadMapsHost(*pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap);
return std::make_unique<LSTESHostData<SDL::Dev>>(pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap);
}

Expand Down Expand Up @@ -108,4 +110,4 @@ std::unique_ptr<SDL::LSTESDeviceData<SDL::Dev>> SDL::loadAndFillESDevice(SDL::Qu
moduleConnectionMap.get());
return std::make_unique<LSTESDeviceData<SDL::Dev>>(
nModules, nLowerModules, nPixels, modulesBuffers, endcapGeometry, pixelMapping);
}
}

0 comments on commit f8f31c9

Please sign in to comment.