Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-25 09:21:13

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 CERN for the benefit of the ACTS project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/EventData/SourceLink.hpp"
0012 #include "Acts/Geometry/GeometryIdentifier.hpp"
0013 #include "Acts/Geometry/TrackingGeometry.hpp"
0014 #include "Acts/Utilities/HashedString.hpp"
0015 #include "ActsPlugins/EDM4hep/PodioDynamicColumns.hpp"
0016 
0017 #include <limits>
0018 #include <memory>
0019 
0020 #include <podio/podioVersion.h>
0021 
0022 #if podio_VERSION_MAJOR >= 1 || \
0023     (podio_VERSION_MAJOR == 0 && podio_VERSION_MINOR == 99)
0024 #include <podio/ROOTReader.h>
0025 #include <podio/ROOTWriter.h>
0026 #else
0027 #include <podio/ROOTFrameReader.h>
0028 #include <podio/ROOTFrameWriter.h>
0029 #endif
0030 
0031 namespace ActsPodioEdm {
0032 class Surface;
0033 }
0034 
0035 namespace podio {
0036 class Frame;
0037 }
0038 
0039 namespace ActsPlugins {
0040 namespace PodioUtil {
0041 
0042 // We want to support podio 0.16 and 1.x for now
0043 
0044 // See https://github.com/AIDASoft/podio/pull/549
0045 #if podio_VERSION_MAJOR >= 1 || \
0046     (podio_VERSION_MAJOR == 0 && podio_VERSION_MINOR == 99)
0047 using ROOTWriter = podio::ROOTWriter;
0048 using ROOTReader = podio::ROOTReader;
0049 #else
0050 using ROOTWriter = podio::ROOTFrameWriter;
0051 using ROOTReader = podio::ROOTFrameReader;
0052 #endif
0053 
0054 // See https://github.com/AIDASoft/podio/pull/553
0055 template <typename T>
0056 decltype(auto) getDataMutable(T&& object) {
0057   if constexpr (podio::version::build_version.major >= 1) {
0058     return std::forward<T>(object).getData();
0059   } else {
0060     return std::forward<T>(object).data();
0061   }
0062 }
0063 
0064 template <typename T>
0065 decltype(auto) getReferenceSurfaceMutable(T&& object) {
0066   if constexpr (podio::version::build_version.major >= 1) {
0067     return std::forward<T>(object).getReferenceSurface();
0068   } else {
0069     return std::forward<T>(object).referenceSurface();
0070   }
0071 }
0072 
0073 using Identifier = std::uint64_t;
0074 constexpr Identifier kNoIdentifier = std::numeric_limits<Identifier>::max();
0075 constexpr int kNoSurface = -1;
0076 
0077 // @TODO: We might want to consider making this a type erased type that's not an interface
0078 class ConversionHelper {
0079  public:
0080   virtual std::optional<Identifier> surfaceToIdentifier(
0081       const Acts::Surface& surface) const = 0;
0082   virtual const Acts::Surface* identifierToSurface(
0083       Identifier identifier) const = 0;
0084 
0085   virtual Identifier sourceLinkToIdentifier(const Acts::SourceLink& sl) = 0;
0086   virtual Acts::SourceLink identifierToSourceLink(
0087       Identifier identifier) const = 0;
0088 };
0089 
0090 std::shared_ptr<const Acts::Surface> convertSurfaceFromPodio(
0091     const ConversionHelper& helper, const ActsPodioEdm::Surface& surface);
0092 
0093 ActsPodioEdm::Surface convertSurfaceToPodio(const ConversionHelper& helper,
0094                                             const Acts::Surface& surface);
0095 }  // namespace PodioUtil
0096 
0097 namespace podio_detail {
0098 /// This is used by both the track and track state container, so the
0099 /// implementation is shared here
0100 void recoverDynamicColumns(
0101     const podio::Frame& frame, const std::string& stem,
0102     std::unordered_map<Acts::HashedString,
0103                        std::unique_ptr<podio_detail::ConstDynamicColumnBase>>&
0104         dynamic);
0105 }  // namespace podio_detail
0106 }  // namespace ActsPlugins