Skip to content

Commit

Permalink
fix: updated detray json surface grid conversion (#3156)
Browse files Browse the repository at this point in the history
- Updated the detray JSON converter for surface grids to the new format.
- Fixed an error by changing "detector.number_volumes()" to "detector.numberVolumes()" in detector_creation.py
  • Loading branch information
fredevb authored Apr 30, 2024
1 parent 620069e commit 41c0e87
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Examples/Scripts/Python/detector_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@
"detector",
)

# acts.examples.writeDetectorToJsonDetray(geoContext, detector, "odd-detray")
acts.examples.writeDetectorToJsonDetray(geoContext, detector, "odd-detray")
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void convert(nlohmann::json& jIndexedSurfaces,
jAccLink["type"] =
DetrayJsonHelper::accelerationLink(indexedSurfaces.casts);
jAccLink["index"] = std::numeric_limits<std::size_t>::max();
jIndexedSurfaces["acc_link"] = jAccLink;
jIndexedSurfaces["grid_link"] = jAccLink;
}
}
}
Expand Down
14 changes: 10 additions & 4 deletions Plugins/Json/src/DetectorJsonConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ nlohmann::json Acts::DetectorJsonConverter::toJsonDetray(
// (2) surface grid section
nlohmann::json jSurfaceGrids;
nlohmann::json jSurfaceGridsData;
nlohmann::json jSurfaceGridsCollection;
nlohmann::json jSurfaceGridsInfoCollection;
nlohmann::json jSurfaceGridsHeader;
for (const auto [iv, volume] : enumerate(volumes)) {
// And its surface navigation delegates
Expand All @@ -150,15 +150,21 @@ nlohmann::json Acts::DetectorJsonConverter::toJsonDetray(
continue;
}
// Colplete the grid json for detray usage
jSurfacesDelegate["volume_link"] = iv;
jSurfacesDelegate["owner_link"] = iv;
// jSurfacesDelegate["acc_link"] =
nlohmann::json jSurfaceGridsCollection;
jSurfaceGridsCollection.push_back(jSurfacesDelegate);

nlohmann::json jSurfaceGridsInfo;
jSurfaceGridsInfo["volume_link"] = iv;
jSurfaceGridsInfo["grid_data"] = jSurfaceGridsCollection;
jSurfaceGridsInfoCollection.push_back(jSurfaceGridsInfo);
}
jSurfaceGridsData["grids"] = jSurfaceGridsCollection;
jSurfaceGridsData["grids"] = jSurfaceGridsInfoCollection;

jCommonHeader["tag"] = "surface_grids";
jSurfaceGridsHeader["common"] = jCommonHeader;
jSurfaceGridsHeader["grid_count"] = jSurfaceGridsCollection.size();
jSurfaceGridsHeader["grid_count"] = jSurfaceGridsInfoCollection.size();

jSurfaceGrids["header"] = jSurfaceGridsHeader;
jSurfaceGrids["data"] = jSurfaceGridsData;
Expand Down

0 comments on commit 41c0e87

Please sign in to comment.