File indexing completed on 2025-01-18 09:11:52
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010 #include "Acts/Geometry/GeometryContext.hpp"
0011 #include "Acts/Plugins/EDM4hep/TrackerHitCompatibility.hpp"
0012 #include "ActsExamples/EventData/Cluster.hpp"
0013 #include "ActsExamples/EventData/Measurement.hpp"
0014 #include "ActsExamples/EventData/SimParticle.hpp"
0015 #include "ActsExamples/EventData/Trajectories.hpp"
0016 #include "ActsFatras/EventData/Hit.hpp"
0017
0018 #include <functional>
0019
0020 #include <edm4hep/MCParticle.h>
0021 #include <edm4hep/MutableMCParticle.h>
0022 #include <edm4hep/MutableSimTrackerHit.h>
0023 #include <edm4hep/MutableTrack.h>
0024 #include <edm4hep/MutableTrackerHitPlane.h>
0025 #include <edm4hep/SimTrackerHit.h>
0026 #include <edm4hep/TrackerHitPlane.h>
0027
0028 namespace ActsExamples::EDM4hepUtil {
0029
0030 using MapParticleIdFrom =
0031 std::function<ActsFatras::Barcode(const edm4hep::MCParticle& particle)>;
0032 using MapParticleIdTo =
0033 std::function<edm4hep::MCParticle(ActsFatras::Barcode particleId)>;
0034
0035 inline ActsFatras::Barcode zeroParticleMapper(
0036 const edm4hep::MCParticle& ) {
0037 return 0;
0038 }
0039
0040 using MapGeometryIdFrom =
0041 std::function<Acts::GeometryIdentifier(std::uint64_t cellId)>;
0042 using MapGeometryIdTo =
0043 std::function<std::uint64_t(Acts::GeometryIdentifier geometryId)>;
0044
0045
0046
0047
0048
0049
0050 SimParticle readParticle(
0051 const edm4hep::MCParticle& from,
0052 const MapParticleIdFrom& particleMapper = zeroParticleMapper);
0053
0054
0055
0056
0057
0058
0059 void writeParticle(const SimParticle& from, edm4hep::MutableMCParticle to);
0060
0061
0062
0063
0064
0065
0066
0067 ActsFatras::Hit readSimHit(const edm4hep::SimTrackerHit& from,
0068 const MapParticleIdFrom& particleMapper,
0069 const MapGeometryIdFrom& geometryMapper);
0070
0071
0072
0073
0074
0075
0076
0077 void writeSimHit(const ActsFatras::Hit& from, edm4hep::MutableSimTrackerHit to,
0078 const MapParticleIdTo& particleMapper,
0079 const MapGeometryIdTo& geometryMapper);
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091 VariableBoundMeasurementProxy readMeasurement(
0092 MeasurementContainer& container, const edm4hep::TrackerHitPlane& from,
0093 const edm4hep::TrackerHit3DCollection* fromClusters, Cluster* toCluster,
0094 const MapGeometryIdFrom& geometryMapper);
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106 void writeMeasurement(const ConstVariableBoundMeasurementProxy& from,
0107 edm4hep::MutableTrackerHitPlane to,
0108 const Cluster* fromCluster,
0109 edm4hep::TrackerHit3DCollection& toClusters,
0110 const MapGeometryIdTo& geometryMapper);
0111
0112
0113
0114
0115
0116
0117 void writeTrajectory(const Acts::GeometryContext& gctx, double Bz,
0118 const Trajectories& from, edm4hep::MutableTrack to,
0119 std::size_t fromIndex,
0120 const Acts::ParticleHypothesis& particleHypothesis,
0121 const IndexMultimap<ActsFatras::Barcode>& hitParticlesMap);
0122
0123
0124
0125
0126
0127
0128 template <typename T>
0129 std::uint64_t podioObjectIDToInteger(T&& o) {
0130 if constexpr (!std::is_same_v<T, podio::ObjectID>) {
0131 return o;
0132 } else {
0133 return o.index;
0134 }
0135 }
0136
0137 }