ATLAS Offline Software
Loading...
Searching...
No Matches
TruthToTrack.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#define TRUTHTOTRACK_IMP
7
8
9
14
17
19
20#include <cmath>
21#include <memory>
22
23//================================================================
24Trk::TruthToTrack::TruthToTrack(const std::string& type, const std::string& name, const IInterface* parent)
25 : ::AthAlgTool(type,name,parent)
26 , m_extrapolator("Trk::Extrapolator/AtlasExtrapolator")
27{
28 declareInterface<ITruthToTrack>(this);
29 declareProperty("Extrapolator", m_extrapolator);
30}
31
32//================================================================
34 ATH_CHECK( m_extrapolator.retrieve() );
35 return StatusCode::SUCCESS;
36}
37
38
39
40//================================================================
42 Trk::TrackParameters *result = nullptr;
43
44 if(part && part->production_vertex()) {
45 HepMC::FourVector tv = part->production_vertex()->position();
46 Amg::Vector3D hv(tv.x(),tv.y(),tv.z());
47 const Amg::Vector3D& globalPos = hv;
48
49 const HepMC::FourVector& fv = part->momentum();
50 Amg::Vector3D hv2(fv.px(),fv.py(),fv.pz());
51 const Amg::Vector3D& globalMom = hv2;
52
53 const int id = part->pdg_id();
54 if (id) {
55 const double charge = MC::charge(id);
56 Amg::Translation3D tmpTransl(hv);
57 Amg::Transform3D tmpTransf = tmpTransl * Amg::RotationMatrix3D::Identity();
58 const Trk::PlaneSurface surface(tmpTransf);
59 result = new Trk::AtaPlane(globalPos, globalMom, charge, surface);
60 }
61 else {
62 ATH_MSG_WARNING("Could not get particle data for particle ID="<<id);
63 }
64 }
65
66 return result;
67}
68
69
70//================================================================
72 Trk::TrackParameters *result = nullptr;
73
74 if(part && part->hasProdVtx()) {
75 Amg::Vector3D hv(part->prodVtx()->x(),part->prodVtx()->y(),part->prodVtx()->z());
76 const Amg::Vector3D& globalPos = hv;
77
78 Amg::Vector3D hv2(part->p4().Px(),part->p4().Py(),part->p4().Pz());
79 const Amg::Vector3D& globalMom = hv2;
80
81 const int id = part->pdg_id();
82 if (id) {
83 const double charge = MC::charge(id);
84 Amg::Translation3D tmpTransl(hv);
85 Amg::Transform3D tmpTransf = tmpTransl * Amg::RotationMatrix3D::Identity();
86 const Trk::PlaneSurface surface(tmpTransf);
87 result = new Trk::AtaPlane(globalPos, globalMom, charge, surface);
88 }
89 else {
90 ATH_MSG_WARNING("Could not get particle data for particle ID="<<id);
91 }
92 }
93
94 return result;
95}
96
97
98
99//================================================================
101 const Trk::TrackParameters* generatedTrackPerigee = nullptr;
102
103 if(part && part->production_vertex() && m_extrapolator) {
104
105 std::unique_ptr<const Trk::TrackParameters> productionVertexTrackParams( makeProdVertexParameters(std::move(part)) );
106 if(productionVertexTrackParams) {
107
108 // Extrapolate the TrackParameters object to the perigee. Direct extrapolation,
109 // no material effects.
110 generatedTrackPerigee = m_extrapolator->extrapolateDirectly(
111 Gaudi::Hive::currentContext(),
112 *productionVertexTrackParams,
115 false,
116 Trk::nonInteracting ).release();
117 }
118 }
119
120 return generatedTrackPerigee;
121}
122
123
124
125//================================================================
127 const Trk::TrackParameters* generatedTrackPerigee = nullptr;
128
129 if(part && part->hasProdVtx() && m_extrapolator) {
130
131 std::unique_ptr<const Trk::TrackParameters> productionVertexTrackParams( makeProdVertexParameters(part) );
132 if(productionVertexTrackParams) {
133
134 // Extrapolate the TrackParameters object to the perigee. Direct extrapolation,
135 // no material effects.
136 generatedTrackPerigee = m_extrapolator->extrapolateDirectly(
137 Gaudi::Hive::currentContext(),
138 *productionVertexTrackParams,
141 false,
142 Trk::nonInteracting ).release();
143 }
144 }
145
146 return generatedTrackPerigee;
147}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
double charge(const T &p)
Definition AtlasPID.h:1003
ATLAS-specific HepMC functions.
Extrapolation for HepMC particles.
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Class describing the Line to which the Perigee refers to.
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
virtual StatusCode initialize()
virtual const Trk::TrackParameters * makePerigeeParameters(HepMC::ConstGenParticlePtr part) const
This function extrapolates track to the perigee, and returns perigee parameters.
virtual const Trk::TrackParameters * makeProdVertexParameters(HepMC::ConstGenParticlePtr part) const
This function produces a Trk::TrackParameters object corresponding to the HepMC::GenParticle at the p...
TruthToTrack(const std::string &type, const std::string &name, const IInterface *parent)
ToolHandle< Trk::IExtrapolator > m_extrapolator
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
Eigen::Translation< double, 3 > Translation3D
HepMC3::FourVector FourVector
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition GenParticle.h:20
double charge(const T &p)
@ anyDirection
ParametersBase< TrackParametersDim, Charged > TrackParameters
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane
TruthParticle_v1 TruthParticle
Typedef to implementation.