Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-11 08:04:12

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2023 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 http://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/Plugins/Podio/PodioDynamicColumns.hpp"
0015 #include "Acts/Utilities/HashedString.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 Acts {
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 Surface& surface) const = 0;
0082   virtual const Surface* identifierToSurface(Identifier identifier) const = 0;
0083 
0084   virtual Identifier sourceLinkToIdentifier(const SourceLink& sl) = 0;
0085   virtual SourceLink identifierToSourceLink(Identifier identifier) const = 0;
0086 };
0087 
0088 std::shared_ptr<const Surface> convertSurfaceFromPodio(
0089     const ConversionHelper& helper, const ActsPodioEdm::Surface& surface);
0090 
0091 ActsPodioEdm::Surface convertSurfaceToPodio(const ConversionHelper& helper,
0092                                             const Acts::Surface& surface);
0093 }  // namespace PodioUtil
0094 
0095 namespace podio_detail {
0096 /// This is used by both the track and track state container, so the
0097 /// implementation is shared here
0098 void recoverDynamicColumns(
0099     const podio::Frame& frame, const std::string& stem,
0100     std::unordered_map<HashedString,
0101                        std::unique_ptr<podio_detail::ConstDynamicColumnBase>>&
0102         dynamic);
0103 }  // namespace podio_detail
0104 }  // namespace Acts