ACTS
Experiment-independent tracking
Loading...
Searching...
No Matches
Acts::TrackingGeometryJsonConverter Class Reference

Converter for tracking geometry JSON payloads. More...

#include <ActsPlugins/Json/TrackingGeometryJsonConverter.hpp>

Classes

struct  Config
 Configuration for the tracking geometry JSON converter. More...
struct  IdToPointerLikeLookup
 Generic lookup from serialized ID to pointer-like object holder. More...
struct  Options
 JSON serialization options for tracking geometry conversion. More...
struct  PointerToIdLookup
 Generic lookup from object pointer identity to serialized object ID. More...

Public Types

using NavigationPolicyDecoder
 Navigation policy decoder.
using NavigationPolicyEncoder
 Navigation policy encoder.
using PortalIdLookup = PointerToIdLookup<Portal, kPortalLookupContext>
 Portal map to its JSON ID.
using PortalLinkDecoder
 Portal link decoder.
using PortalLinkEncoder
 Portal link encoder.
using PortalPointerLookup
 JSON ID map to its portal.
using SurfaceIdLookup = PointerToIdLookup<Surface, kSurfaceLookupContext>
 Surface map to its JSON ID.
using SurfacePointerLookup
 JSON ID map to its surface.
using VolumeBoundsDecoder = JsonKindDispatcher<std::unique_ptr<VolumeBounds>>
 Volume bounds decoder.
using VolumeBoundsEncoder = TypeDispatcher<VolumeBounds, nlohmann::json()>
 Volume bounds encoder.
using VolumeIdLookup
 Tracking volume map to its JSON ID.
using VolumePointerLookup
 JSON ID map to its tracking volume.

Public Member Functions

 TrackingGeometryJsonConverter (Config config=Config::defaultConfig(), std::unique_ptr< const Acts::Logger > logger=Acts::getDefaultLogger("TrackingGeometryJsonConverter", Acts::Logging::INFO))
 Construct converter with custom or default dispatch configuration.
std::shared_ptr< TrackingGeometryfromJson (const GeometryContext &gctx, const nlohmann::json &encoded, const Options &options=Options{}) const
 Reconstruct a tracking geometry from JSON.
std::unique_ptr< Acts::INavigationPolicynavigationPolicyFromJson (const Acts::GeometryContext &gctx, const nlohmann::json &encoded, const Acts::TrackingVolume &volume, const Acts::Logger &logger) const
 Deserialize navigation policy using configured decoders.
nlohmann::json navigationPolicyToJson (const INavigationPolicy &policy) const
 Serialize navigation policy using the configured dispatcher.
std::unique_ptr< PortalLinkBaseportalLinkFromJson (const nlohmann::json &encoded, const SurfacePointerLookup &surfaces, const VolumePointerLookup &volumes) const
 Deserialize one portal link using configured decoders.
nlohmann::json portalLinkToJson (const GeometryContext &gctx, const PortalLinkBase &link, const SurfaceIdLookup &surfaceIds, const VolumeIdLookup &volumeIds) const
 Serialize one portal link using the configured dispatcher.
nlohmann::json toJson (const GeometryContext &gctx, const TrackingGeometry &geometry, const Options &options=Options{}) const
 Convert a tracking geometry to JSON.
std::shared_ptr< TrackingVolumetrackingVolumeFromJson (const GeometryContext &gctx, const nlohmann::json &encoded, const Options &options=Options{}) const
 Reconstruct a tracking volume hierarchy from JSON.
nlohmann::json trackingVolumeToJson (const GeometryContext &gctx, const TrackingVolume &world, const Options &options=Options{}) const
 Convert a tracking volume hierarchy to JSON.

Static Public Attributes

static constexpr char kPortalLookupContext [] = "portal"
 Exception context for portals.
static constexpr char kSurfaceLookupContext [] = "surface"
 Exception context for surfaces.
static constexpr char kVolumeLookupContext [] = "volume"
 Exception context for volumes.

Detailed Description

Converter for tracking geometry JSON payloads.

High-level conversion overview:

  • Serialization:
    • traverse the TrackingVolume::volumes() tree in depth-first order
    • collect unique instances of surfaces, portals, volumes and assign stable in-file IDs
    • serialize the instances into their independent top-level tables
    • encode object-to-object relationships through the assigned IDs
  • Deserialization:
    • validate schema header and collect all volume records
    • instantiate volumes, portals, surfaces and build ID->pointer lookup
    • attach child volumes to reconstruct the tree
    • attach surfaces to portals and volumes via ID lookup
    • portals to volumes via ID lookup
    • return deserialized geometry

Member Typedef Documentation

◆ NavigationPolicyDecoder

Initial value:
const TrackingVolume&, const Acts::Logger&>
This is the central definition of the Acts payload object regarding detector geometry status (e....
Definition GeometryContext.hpp:46
JSON-specific dispatcher that routes decoder functions based on a string kind tag found in the encode...
Definition JsonKindDispatcher.hpp:27
class for printing debug output
Definition Logger.hpp:696
TrackingGeometryJsonConverter(Config config=Config::defaultConfig(), std::unique_ptr< const Acts::Logger > logger=Acts::getDefaultLogger("TrackingGeometryJsonConverter", Acts::Logging::INFO))
Construct converter with custom or default dispatch configuration.
Full Volume description used in Tracking, it inherits from Volume to get the geometrical structure.
Definition TrackingVolume.hpp:100

Navigation policy decoder.

◆ NavigationPolicyEncoder

Initial value:
nlohmann::json(
Base class for all navigation policies.
Definition INavigationPolicy.hpp:181
Converter for tracking geometry JSON payloads.
Definition TrackingGeometryJsonConverter.hpp:52
Template class for type-based function dispatch.
Definition TypeDispatcher.hpp:32

Navigation policy encoder.

◆ PortalLinkDecoder

Initial value:
std::unique_ptr<PortalLinkBase>, const TrackingGeometryJsonConverter&,
IdToPointerLikeLookup< RegularSurface, std::shared_ptr< RegularSurface >, kSurfaceLookupContext > SurfacePointerLookup
JSON ID map to its surface.
Definition TrackingGeometryJsonConverter.hpp:78
IdToPointerLikeLookup< TrackingVolume, TrackingVolume *, kVolumeLookupContext > VolumePointerLookup
JSON ID map to its tracking volume.
Definition TrackingGeometryJsonConverter.hpp:93

Portal link decoder.

◆ PortalLinkEncoder

Initial value:
nlohmann::json(const GeometryContext&,
const VolumeIdLookup&)>
PointerToIdLookup< Surface, kSurfaceLookupContext > SurfaceIdLookup
Surface map to its JSON ID.
Definition TrackingGeometryJsonConverter.hpp:76
PointerToIdLookup< TrackingVolume, kVolumeLookupContext > VolumeIdLookup
Tracking volume map to its JSON ID.
Definition TrackingGeometryJsonConverter.hpp:90

Portal link encoder.

◆ PortalPointerLookup

Initial value:
static constexpr char kPortalLookupContext[]
Exception context for portals.
Definition TrackingGeometryJsonConverter.hpp:71
Generic lookup from serialized ID to pointer-like object holder.
Definition TrackingGeometryJsonConverter.hpp:66

JSON ID map to its portal.

◆ SurfacePointerLookup

Initial value:
static constexpr char kSurfaceLookupContext[]
Exception context for surfaces.
Definition TrackingGeometryJsonConverter.hpp:69

JSON ID map to its surface.

◆ VolumeIdLookup

Initial value:
Generic lookup from object pointer identity to serialized object ID.
Definition TrackingGeometryJsonConverter.hpp:59

Tracking volume map to its JSON ID.

◆ VolumePointerLookup

Initial value:
static constexpr char kVolumeLookupContext[]
Exception context for volumes.
Definition TrackingGeometryJsonConverter.hpp:73

JSON ID map to its tracking volume.

Constructor & Destructor Documentation

◆ TrackingGeometryJsonConverter()

Acts::TrackingGeometryJsonConverter::TrackingGeometryJsonConverter ( Config config = Config::defaultConfig(),
std::unique_ptr< const Acts::Logger > logger = Acts::getDefaultLogger("TrackingGeometryJsonConverter", Acts::Logging::INFO) )
explicit

Construct converter with custom or default dispatch configuration.

Parameters
configThe conversion dispatch configuration
loggerThe logger instance

Member Function Documentation

◆ fromJson()

std::shared_ptr< TrackingGeometry > Acts::TrackingGeometryJsonConverter::fromJson ( const GeometryContext & gctx,
const nlohmann::json & encoded,
const Options & options = Options{} ) const

Reconstruct a tracking geometry from JSON.

Parameters
gctxgeometry context
encodedserialized tracking geometry
optionsoptions for the conversion
Returns
pointer to deserialized geometry

◆ navigationPolicyFromJson()

std::unique_ptr< Acts::INavigationPolicy > Acts::TrackingGeometryJsonConverter::navigationPolicyFromJson ( const Acts::GeometryContext & gctx,
const nlohmann::json & encoded,
const Acts::TrackingVolume & volume,
const Acts::Logger & logger ) const

Deserialize navigation policy using configured decoders.

Parameters
gctxgeometry context
encodedserialized navigation policy
volumetracking volume to assign navigation policy to
loggerlogging instance
Returns
pointer to deserialized navigation policy

◆ navigationPolicyToJson()

nlohmann::json Acts::TrackingGeometryJsonConverter::navigationPolicyToJson ( const INavigationPolicy & policy) const

Serialize navigation policy using the configured dispatcher.

Parameters
policynavigation policy to serialize
Returns
serialized navigation policy

◆ portalLinkFromJson()

std::unique_ptr< PortalLinkBase > Acts::TrackingGeometryJsonConverter::portalLinkFromJson ( const nlohmann::json & encoded,
const SurfacePointerLookup & surfaces,
const VolumePointerLookup & volumes ) const

Deserialize one portal link using configured decoders.

Parameters
encodedserialized portal link
surfacesid-to-surface map for internal lookup
volumesid-to-volume map for internal lookup
Returns
pointer to deserialized portal link

◆ portalLinkToJson()

nlohmann::json Acts::TrackingGeometryJsonConverter::portalLinkToJson ( const GeometryContext & gctx,
const PortalLinkBase & link,
const SurfaceIdLookup & surfaceIds,
const VolumeIdLookup & volumeIds ) const

Serialize one portal link using the configured dispatcher.

Parameters
gctxgeometry context
linkportal link to serialize
surfaceIdssurface-to-id map for internal lookup
volumeIdsvolume-to-id map for internal lookup
Returns
serialized portal link

◆ toJson()

nlohmann::json Acts::TrackingGeometryJsonConverter::toJson ( const GeometryContext & gctx,
const TrackingGeometry & geometry,
const Options & options = Options{} ) const

Convert a tracking geometry to JSON.

Parameters
gctxgeometry context
geometrytracking geometry to convert
optionsoptions for the conversion
Returns
serialized tracking geometry

◆ trackingVolumeFromJson()

std::shared_ptr< TrackingVolume > Acts::TrackingGeometryJsonConverter::trackingVolumeFromJson ( const GeometryContext & gctx,
const nlohmann::json & encoded,
const Options & options = Options{} ) const

Reconstruct a tracking volume hierarchy from JSON.

Parameters
gctxgeometry context
encodedserialized tracking volume hierarchy
optionsoptions for the conversion
Returns
pointer to deserialized tracking volume hierarchy
Note
currently the geometry context is only propagated to the Portal construction and the NavigationPolicy assignment

◆ trackingVolumeToJson()

nlohmann::json Acts::TrackingGeometryJsonConverter::trackingVolumeToJson ( const GeometryContext & gctx,
const TrackingVolume & world,
const Options & options = Options{} ) const

Convert a tracking volume hierarchy to JSON.

Parameters
gctxgeometry context
worldtop tracking volume in the hierarchy
optionsoptions for the conversion
Returns
serialized tracking volume hierarchy
Note
the geometry context is applied to the transformations during the serialization