CMS 3D CMS Logo

LSTESData.cc
Go to the documentation of this file.
6 
7 #include "ModuleMethods.h"
8 
9 #include <filesystem>
10 
11 namespace {
12  std::string geometryDataDir() {
13  const char* path_lst_base = std::getenv("LST_BASE");
14  const char* path_tracklooperdir = std::getenv("TRACKLOOPERDIR");
15  std::string path_str;
16  if (path_lst_base != nullptr) {
17  path_str = path_lst_base;
18  } else if (path_tracklooperdir != nullptr) {
19  path_str = path_tracklooperdir;
20  path_str += "/../";
21  } else {
22  std::stringstream search_path(std::getenv("CMSSW_SEARCH_PATH"));
24  while (std::getline(search_path, path, ':')) {
25  if (std::filesystem::exists(path + "/RecoTracker/LSTCore/data")) {
26  path_str = path;
27  break;
28  }
29  }
30  path_str += "/RecoTracker/LSTCore";
31  }
32  return path_str;
33  }
34 
36  std::filesystem::path fullpath = std::filesystem::absolute(name);
37  if (not std::filesystem::exists(fullpath)) {
38  throw std::runtime_error("Could not find the file = " + fullpath.string());
39  }
40  return fullpath.string();
41  }
42 
43  void loadMapsHost(lst::MapPLStoLayer& pLStoLayer,
44  lst::EndcapGeometry& endcapGeometry,
45  lst::TiltedGeometry& tiltedGeometry,
46  lst::ModuleConnectionMap& moduleConnectionMap) {
47  // Module orientation information (DrDz or phi angles)
48  auto endcap_geom =
49  get_absolute_path_after_check_file_exists(geometryDataDir() + "/data/OT800_IT615_pt0.8/endcap_orientation.bin");
51  geometryDataDir() + "/data/OT800_IT615_pt0.8/tilted_barrel_orientation.bin");
52  // Module connection map (for line segment building)
54  geometryDataDir() + "/data/OT800_IT615_pt0.8/module_connection_tracing_merged.bin");
55 
56  endcapGeometry.load(endcap_geom);
57  tiltedGeometry.load(tilted_geom);
58  moduleConnectionMap.load(mappath);
59 
60  auto pLSMapDir = geometryDataDir() + "/data/OT800_IT615_pt0.8/pixelmap/pLS_map";
61  const std::array<std::string, 4> connects{
62  {"_layer1_subdet5", "_layer2_subdet5", "_layer1_subdet4", "_layer2_subdet4"}};
64 
65  static_assert(connects.size() == std::tuple_size<std::decay_t<decltype(pLStoLayer[0])>>{});
66  for (unsigned int i = 0; i < connects.size(); i++) {
67  auto connectData = connects[i].data();
68 
69  path = pLSMapDir + connectData + ".bin";
71 
72  path = pLSMapDir + "_pos" + connectData + ".bin";
74 
75  path = pLSMapDir + "_neg" + connectData + ".bin";
77  }
78  }
79 } // namespace
80 
81 std::unique_ptr<lst::LSTESData<alpaka_common::DevHost>> lst::loadAndFillESHost() {
82  uint16_t nModules;
83  uint16_t nLowerModules;
84  unsigned int nPixels;
85  MapPLStoLayer pLStoLayer;
86  EndcapGeometry endcapGeometry;
87  TiltedGeometry tiltedGeometry;
88  PixelMap pixelMapping;
89  ModuleConnectionMap moduleConnectionMap;
90  ::loadMapsHost(pLStoLayer, endcapGeometry, tiltedGeometry, moduleConnectionMap);
91 
92  auto endcapGeometryDev =
93  std::make_shared<EndcapGeometryDevHostCollection>(endcapGeometry.nEndCapMap, cms::alpakatools::host());
94  std::memcpy(endcapGeometryDev->view().geoMapDetId(),
95  endcapGeometry.geoMapDetId_buf.data(),
96  endcapGeometry.nEndCapMap * sizeof(unsigned int));
97  std::memcpy(endcapGeometryDev->view().geoMapPhi(),
98  endcapGeometry.geoMapPhi_buf.data(),
99  endcapGeometry.nEndCapMap * sizeof(float));
100 
101  auto path =
102  get_absolute_path_after_check_file_exists(geometryDataDir() + "/data/OT800_IT615_pt0.8/sensor_centroids.bin");
103  auto modulesBuffers = lst::loadModulesFromFile(pLStoLayer,
104  path.c_str(),
105  nModules,
106  nLowerModules,
107  nPixels,
108  pixelMapping,
109  endcapGeometry,
110  tiltedGeometry,
111  moduleConnectionMap);
112  auto pixelMappingPtr = std::make_shared<PixelMap>(std::move(pixelMapping));
113  return std::make_unique<LSTESData<alpaka_common::DevHost>>(nModules,
114  nLowerModules,
115  nPixels,
116  endcapGeometry.nEndCapMap,
117  std::move(modulesBuffers),
118  std::move(endcapGeometryDev),
119  pixelMappingPtr);
120 }
std::shared_ptr< ModulesHostCollection > loadModulesFromFile(MapPLStoLayer const &pLStoLayer, const char *moduleMetaDataFilePath, uint16_t &nModules, uint16_t &nLowerModules, unsigned int &nPixels, PixelMap &pixelMapping, const EndcapGeometry &endcapGeometry, const TiltedGeometry &tiltedGeometry, const ModuleConnectionMap &moduleConnectionMap)
std::vector< float > geoMapPhi_buf
std::unique_ptr< LSTESData< alpaka_common::DevHost > > loadAndFillESHost()
Definition: LSTESData.cc:81
void load(std::string const &)
TString get_absolute_path_after_check_file_exists(const std::string name)
Definition: trkCore.cc:1065
unsigned int nEndCapMap
void load(std::string const &)
alpaka::DevCpu const & host()
Definition: host.h:14
void load(std::string const &)
std::array< std::array< ModuleConnectionMap, 4 >, 3 > MapPLStoLayer
std::vector< unsigned int > geoMapDetId_buf
def move(src, dest)
Definition: eostools.py:511