ATLAS Offline Software
Loading...
Searching...
No Matches
TruthToTrack.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#define TRUTHTOTRACK_IMP
7
8#include <cmath>
9#include <memory>
10
15
18
20
21
22//================================================================
23Trk::TruthToTrack::TruthToTrack(const std::string& type, const std::string& name, const IInterface* parent)
24 : ::AthAlgTool(type,name,parent)
25 , m_extrapolator("Trk::Extrapolator/AtlasExtrapolator")
26{
27 declareInterface<ITruthToTrack>(this);
28 declareProperty("Extrapolator", m_extrapolator);
29}
30
31//================================================================
33 ATH_CHECK( m_extrapolator.retrieve() );
34 return StatusCode::SUCCESS;
35}
36
37
38
39//================================================================
42
43 if(part && part->production_vertex()) {
44 HepMC::FourVector tv = part->production_vertex()->position();
45 Amg::Vector3D hv(tv.x(),tv.y(),tv.z());
46 const Amg::Vector3D& globalPos = hv;
47
48 const HepMC::FourVector& fv = part->momentum();
49 Amg::Vector3D hv2(fv.px(),fv.py(),fv.pz());
50 const Amg::Vector3D& globalMom = hv2;
51
52 const int id = part->pdg_id();
53 if (id) {
54 const double charge = MC::charge(id);
55 Amg::Translation3D tmpTransl(hv);
56 Amg::Transform3D tmpTransf = tmpTransl * Amg::RotationMatrix3D::Identity();
57 const Trk::PlaneSurface surface(tmpTransf);
58 result = new Trk::AtaPlane(globalPos, globalMom, charge, surface);
59 }
60 else {
61 ATH_MSG_WARNING("Could not get particle data for particle ID="<<id);
62 }
63 }
64
65 return result;
66}
67
68
69//================================================================
72
73 if(part && part->hasProdVtx()) {
74 Amg::Vector3D hv(part->prodVtx()->x(),part->prodVtx()->y(),part->prodVtx()->z());
75 const Amg::Vector3D& globalPos = hv;
76
77 Amg::Vector3D hv2(part->p4().Px(),part->p4().Py(),part->p4().Pz());
78 const Amg::Vector3D& globalMom = hv2;
79
80 const int id = part->pdg_id();
81 if (id) {
82 const double charge = MC::charge(id);
83 Amg::Translation3D tmpTransl(hv);
84 Amg::Transform3D tmpTransf = tmpTransl * Amg::RotationMatrix3D::Identity();
85 const Trk::PlaneSurface surface(tmpTransf);
86 result = new Trk::AtaPlane(globalPos, globalMom, charge, surface);
87 }
88 else {
89 ATH_MSG_WARNING("Could not get particle data for particle ID="<<id);
90 }
91 }
92
93 return result;
94}
95
96
97
98//================================================================
100 const Trk::TrackParameters* generatedTrackPerigee = nullptr;
101
102 if(part && part->production_vertex() && m_extrapolator) {
103
104 std::unique_ptr<const Trk::TrackParameters> productionVertexTrackParams( makeProdVertexParameters(part) );
105 if(productionVertexTrackParams) {
106
107 // Extrapolate the TrackParameters object to the perigee. Direct extrapolation,
108 // no material effects.
109 generatedTrackPerigee = m_extrapolator->extrapolateDirectly(
110 Gaudi::Hive::currentContext(),
111 *productionVertexTrackParams,
114 false,
115 Trk::nonInteracting ).release();
116 }
117 }
118
119 return generatedTrackPerigee;
120}
121
122
123
124//================================================================
126 const Trk::TrackParameters* generatedTrackPerigee = nullptr;
127
128 if(part && part->hasProdVtx() && m_extrapolator) {
129
130 std::unique_ptr<const Trk::TrackParameters> productionVertexTrackParams( makeProdVertexParameters(part) );
131 if(productionVertexTrackParams) {
132
133 // Extrapolate the TrackParameters object to the perigee. Direct extrapolation,
134 // no material effects.
135 generatedTrackPerigee = m_extrapolator->extrapolateDirectly(
136 Gaudi::Hive::currentContext(),
137 *productionVertexTrackParams,
140 false,
141 Trk::nonInteracting ).release();
142 }
143 }
144
145 return generatedTrackPerigee;
146}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
double charge(const T &p)
Definition AtlasPID.h:997
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
const GenParticle * ConstGenParticlePtr
Definition GenParticle.h:38
double charge(const T &p)
@ anyDirection
ParametersBase< TrackParametersDim, Charged > TrackParameters
ParametersT< TrackParametersDim, Charged, PlaneSurface > AtaPlane
TruthParticle_v1 TruthParticle
Typedef to implementation.