ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Tracking
TrkTools
TrkTruthToTrack
src
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
6
#include "
TrkTruthToTrack/TruthToTrack.h
"
7
8
9
10
#include "
AtlasHepMC/GenParticle.h
"
11
#include "
AtlasHepMC/GenVertex.h
"
12
#include "
AtlasHepMC/SimpleVector.h
"
13
#include "
TruthUtils/HepMCHelpers.h
"
14
15
#include "
xAODTruth/TruthParticle.h
"
16
#include "
xAODTruth/TruthVertex.h
"
17
18
#include "
TrkExInterfaces/IExtrapolator.h
"
19
20
#include <cmath>
21
#include <memory>
22
23
//================================================================
24
Trk::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
//================================================================
33
StatusCode
Trk::TruthToTrack::initialize
() {
34
ATH_CHECK
(
m_extrapolator
.retrieve() );
35
return
StatusCode::SUCCESS;
36
}
37
38
39
40
//================================================================
41
const
Trk::TrackParameters
*
Trk::TruthToTrack::makeProdVertexParameters
(
HepMC::ConstGenParticlePtr
part)
const
{
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
//================================================================
71
const
Trk::TrackParameters
*
Trk::TruthToTrack::makeProdVertexParameters
(
const
xAOD::TruthParticle
* part)
const
{
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
//================================================================
100
const
Trk::TrackParameters
*
Trk::TruthToTrack::makePerigeeParameters
(
HepMC::ConstGenParticlePtr
part)
const
{
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,
113
Trk::PerigeeSurface
(),
114
Trk::anyDirection
,
115
false
,
116
Trk::nonInteracting
).release();
117
}
118
}
119
120
return
generatedTrackPerigee;
121
}
122
123
124
125
//================================================================
126
const
Trk::TrackParameters
*
Trk::TruthToTrack::makePerigeeParameters
(
const
xAOD::TruthParticle
* part)
const
{
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,
139
Trk::PerigeeSurface
(),
140
Trk::anyDirection
,
141
false
,
142
Trk::nonInteracting
).release();
143
}
144
}
145
146
return
generatedTrackPerigee;
147
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
charge
double charge(const T &p)
Definition
AtlasPID.h:1003
TruthParticle.h
GenParticle.h
GenVertex.h
HepMCHelpers.h
ATLAS-specific HepMC functions.
IExtrapolator.h
SimpleVector.h
TruthToTrack.h
Extrapolation for HepMC particles.
TruthVertex.h
AthAlgTool::AthAlgTool
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
Definition
AthAlgTool.cxx:16
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
Trk::PerigeeSurface
Class describing the Line to which the Perigee refers to.
Definition
PerigeeSurface.h:43
Trk::PlaneSurface
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
Definition
PlaneSurface.h:64
Trk::TruthToTrack::initialize
virtual StatusCode initialize()
Definition
TruthToTrack.cxx:33
Trk::TruthToTrack::makePerigeeParameters
virtual const Trk::TrackParameters * makePerigeeParameters(HepMC::ConstGenParticlePtr part) const
This function extrapolates track to the perigee, and returns perigee parameters.
Definition
TruthToTrack.cxx:100
Trk::TruthToTrack::makeProdVertexParameters
virtual const Trk::TrackParameters * makeProdVertexParameters(HepMC::ConstGenParticlePtr part) const
This function produces a Trk::TrackParameters object corresponding to the HepMC::GenParticle at the p...
Definition
TruthToTrack.cxx:41
Trk::TruthToTrack::TruthToTrack
TruthToTrack(const std::string &type, const std::string &name, const IInterface *parent)
Definition
TruthToTrack.cxx:24
Trk::TruthToTrack::m_extrapolator
ToolHandle< Trk::IExtrapolator > m_extrapolator
Definition
TruthToTrack.h:52
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition
GeoPrimitives.h:46
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition
GeoPrimitives.h:47
Amg::Translation3D
Eigen::Translation< double, 3 > Translation3D
Definition
GeoPrimitives.h:44
HepMC::FourVector
HepMC3::FourVector FourVector
Definition
SimpleVector.h:11
HepMC::ConstGenParticlePtr
HepMC3::ConstGenParticlePtr ConstGenParticlePtr
Definition
GenParticle.h:20
MC::charge
double charge(const T &p)
Definition
HepMCHelpers.h:1004
Trk::anyDirection
@ anyDirection
Definition
PropDirection.h:22
Trk::nonInteracting
@ nonInteracting
Definition
ParticleHypothesis.h:28
Trk::TrackParameters
ParametersBase< TrackParametersDim, Charged > TrackParameters
Definition
Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:27
Trk::AtaPlane
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane
Definition
Tracking/TrkEvent/TrkParameters/TrkParameters/TrackParameters.h:34
xAOD::TruthParticle
TruthParticle_v1 TruthParticle
Typedef to implementation.
Definition
Event/xAOD/xAODTruth/xAODTruth/TruthParticle.h:15
type
Generated on
for ATLAS Offline Software by
1.17.0