36 #include <nlohmann/json.hpp>
38 using namespace ActsExamples;
45 throw std::invalid_argument(
"Missing tracking geometry");
49 throw std::invalid_argument(
"Could not identify the world volume");
54 return "JsonSurfacesWriter";
59 using SurfaceContainer =
62 std::shared_ptr<const Acts::Surface>>;
65 void collectSurfaces(std::vector<SurfaceContainer::InputElement>& cSurfaces,
67 bool writeApproach,
bool writeSensitive,
78 auto layerSurfacePtr =
layer->surfaceRepresentation().getSharedPtr();
79 cSurfaces.push_back(SurfaceContainer::InputElement{
80 layer->surfaceRepresentation().geometryId(), layerSurfacePtr});
83 if (writeApproach and
layer->approachDescriptor() !=
nullptr) {
84 for (
auto sf :
layer->approachDescriptor()->containedSurfaces()) {
85 cSurfaces.push_back(SurfaceContainer::InputElement{
86 sf->geometryId(), sf->getSharedPtr()});
90 if (
layer->surfaceArray() !=
nullptr and writeSensitive) {
91 for (
const auto&
surface :
layer->surfaceArray()->surfaces()) {
93 cSurfaces.push_back(SurfaceContainer::InputElement{
102 const auto& bsRep = bsurface->surfaceRepresentation();
103 cSurfaces.push_back(SurfaceContainer::InputElement{
104 bsRep.geometryId(), bsRep.getSharedPtr()});
110 for (
const auto& confined : volume.
confinedVolumes()->arrayObjects()) {
111 collectSurfaces(cSurfaces, *confined.get(), writeLayer, writeApproach,
112 writeSensitive, writeBoundary);
126 std::vector<SurfaceContainer::InputElement> cSurfaces;
129 SurfaceContainer sContainer(cSurfaces);
132 auto j = SurfaceConverter(
"surfaces").toJson(sContainer,
nullptr);
139 std::vector<std::pair<Acts::GeometryIdentifier, std::string>> namedEntries;
140 for (
size_t is = 0; is < sContainer.size(); ++is) {
142 std::stringstream geoTypeName;
143 geoTypeName << geometryId;
144 namedEntries.push_back({geometryId, geoTypeName.str()});
146 NamedContainer nContainer(namedEntries);
147 auto j = NamedConverter(
"surface_types").toJson(nContainer,
nullptr);
159 std::vector<SurfaceContainer::InputElement> cSurfaces;
162 SurfaceContainer sContainer(cSurfaces);
164 auto j = SurfaceConverter(
"surfaces").toJson(sContainer,
nullptr);