Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
EDM4hepUtil.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file EDM4hepUtil.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 #pragma once
9 
16 
17 #include <functional>
18 
19 #include "edm4hep/MCParticle.h"
20 #include "edm4hep/MutableMCParticle.h"
21 #include "edm4hep/MutableSimTrackerHit.h"
22 #include "edm4hep/MutableTrack.h"
23 #include "edm4hep/MutableTrackerHit.h"
24 #include "edm4hep/MutableTrackerHitPlane.h"
25 #include "edm4hep/SimTrackerHit.h"
26 #include "edm4hep/TrackerHit.h"
27 #include "edm4hep/TrackerHitCollection.h"
28 #include "edm4hep/TrackerHitPlane.h"
29 
30 namespace ActsExamples {
31 namespace EDM4hepUtil {
32 
33 using MapParticleIdFrom =
34  std::function<ActsFatras::Barcode(edm4hep::MCParticle particle)>;
35 using MapParticleIdTo =
36  std::function<edm4hep::MCParticle(ActsFatras::Barcode particleId)>;
37 
38 using MapGeometryIdFrom =
39  std::function<Acts::GeometryIdentifier(std::uint64_t cellId)>;
40 using MapGeometryIdTo =
41  std::function<std::uint64_t(Acts::GeometryIdentifier geometryId)>;
42 
48 ActsFatras::Particle readParticle(const edm4hep::MCParticle& from,
49  const MapParticleIdFrom& particleMapper);
50 
56 void writeParticle(const ActsFatras::Particle& from,
57  edm4hep::MutableMCParticle to);
58 
65 ActsFatras::Hit readSimHit(const edm4hep::SimTrackerHit& from,
66  const MapParticleIdFrom& particleMapper,
67  const MapGeometryIdFrom& geometryMapper);
68 
75 void writeSimHit(const ActsFatras::Hit& from, edm4hep::MutableSimTrackerHit to,
76  const MapParticleIdTo& particleMapper,
77  const MapGeometryIdTo& geometryMapper);
78 
89 Measurement readMeasurement(const edm4hep::TrackerHitPlane& from,
90  const edm4hep::TrackerHitCollection* fromClusters,
91  Cluster* toCluster,
92  const MapGeometryIdFrom& geometryMapper);
93 
104 void writeMeasurement(const Measurement& from,
105  edm4hep::MutableTrackerHitPlane to,
106  const Cluster* fromCluster,
107  edm4hep::TrackerHitCollection& toClusters,
108  const MapGeometryIdTo& geometryMapper);
109 
115 void writeTrajectory(const Acts::GeometryContext& gctx, double Bz,
116  const Trajectories& from, edm4hep::MutableTrack to,
117  std::size_t fromIndex,
119  const IndexMultimap<ActsFatras::Barcode>& hitParticlesMap);
120 
121 } // namespace EDM4hepUtil
122 } // namespace ActsExamples