Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JsonSurfacesReader.cpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file JsonSurfacesReader.cpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2023 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
10 
16 
17 #include <fstream>
18 #include <iostream>
19 
20 namespace ActsExamples {
21 
24  // Read the json file into a json object
25  nlohmann::json j;
26  std::ifstream in(options.inputFile);
27  in >> j;
28  in.close();
29 
30  using SurfaceHierachyMap =
32  using GeometryIdHelper = Acts::GeometryHierarchyMapJsonConverter<bool>;
33  std::vector<SurfaceHierachyMap::InputElement> surfaceElements;
34 
35  // Walk down the path to the surface entries
36  nlohmann::json jSurfaces = j;
37  for (const auto& jep : options.jsonEntryPath) {
38  jSurfaces = jSurfaces[jep];
39  }
40 
41  // Loop over the surfaces
42  surfaceElements.reserve(jSurfaces.size());
43  for (const auto& jSurface : jSurfaces) {
44  // Decode the surface identifier
46  GeometryIdHelper::decodeIdentifier(jSurface);
47  auto surface = Acts::SurfaceJsonConverter::fromJson(jSurface["value"]);
48  surfaceElements.emplace_back(geoId, surface);
49  }
50  return SurfaceHierachyMap(std::move(surfaceElements));
51 }
52 
53 } // namespace ActsExamples