31 auto ti = std::localtime(&tt);
33 nlohmann::json jDetector;
35 std::size_t nSurfaces = 0;
36 std::vector<const Experimental::Portal*> portals;
38 for (
const auto* volume : detector.
volumes()) {
39 nSurfaces += volume->surfaces().size();
40 for (
const auto& portal : volume->portals()) {
41 if (std::find(portals.begin(), portals.end(), portal) == portals.end()) {
42 portals.push_back(portal);
49 jData[
"name"] = detector.
name();
53 nlohmann::json jPortals;
55 for (
const auto& portal : portals) {
58 jPortals.push_back(jPortal);
60 jData[
"portals"] = jPortals;
64 nlohmann::json jVolumes;
65 for (
const auto& volume :
volumes) {
68 jVolumes.push_back(jVolume);
70 jData[
"volumes"] = jVolumes;
73 nlohmann::json jHeader;
74 jHeader[
"detector"] = detector.
name();
75 jHeader[
"type"] =
"acts";
76 jHeader[
"date"] = std::asctime(ti);
77 jHeader[
"surface_count"] = nSurfaces;
78 jHeader[
"portal_count"] = portals.size();
79 jHeader[
"volume_count"] = detector.
volumes().size();
80 jDetector[
"header"] = jHeader;
81 jDetector[
"data"] = jData;
91 auto ti = std::localtime(&tt);
93 nlohmann::json jDetector;
96 std::size_t nSurfaces = 0;
101 nlohmann::json jVolumes;
102 for (
const auto& volume :
volumes) {
105 jVolumes.push_back(jVolume);
106 if (jVolume.find(
"surfaces") != jVolume.end() and
107 jVolume[
"surfaces"].is_array()) {
108 nSurfaces += jVolume[
"surfaces"].size();
111 jData[
"volumes"] = jVolumes;
114 nlohmann::json jVolumeGridParent;
115 nlohmann::json jVolumeGrid;
116 nlohmann::json jVolumeGridAxes;
117 jVolumeGrid[
"axes"] = jVolumeGridAxes;
118 jVolumeGrid[
"entries"] = std::vector<std::size_t>{};
119 jVolumeGridParent[
"grid"] = jVolumeGrid;
120 jData[
"volume_grid"] = jVolumeGridParent;
124 nlohmann::json jHeader;
125 jHeader[
"detector"] = detector.
name();
126 jHeader[
"date"] = std::asctime(ti);
127 jHeader[
"volume_count"] = detector.
volumes().size();
131 jHeader[
"type"] =
"detray";
132 jHeader[
"surface_count"] = nSurfaces;
133 jDetector[
"header"] = jHeader;
134 jDetector[
"data"] = jData;
139 std::shared_ptr<Acts::Experimental::Detector>
141 const nlohmann::json& jDetector) {
143 auto jData = jDetector[
"data"];
144 auto jVolumes = jData[
"volumes"];
145 auto jPortals = jData[
"portals"];
148 std::vector<std::shared_ptr<Experimental::DetectorVolume>>
volumes;
149 std::vector<std::shared_ptr<Experimental::Portal>> portals;
151 for (
const auto& jVolume : jVolumes) {
153 volumes.push_back(volume);
156 for (
const auto& jPortal : jPortals) {
158 portals.push_back(portal);
164 auto jVolume = jVolumes[iv];
165 std::vector<std::size_t> portalLinks = jVolume[
"portal_links"];
166 for (
auto [ip, ipl] :
enumerate(portalLinks)) {
167 auto portal = portals[ipl];
168 v->updatePortal(portal, ip);
171 return Experimental::Detector::makeShared(name, volumes,