ATLAS Offline Software
Loading...
Searching...
No Matches
VertexKineFillerTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
10
11
17
18
19namespace {
20inline
21double sq(double x) { return x*x; }
22}
23
24
25
26namespace D3PD {
27
28
36 (const std::string& type,
37 const std::string& name,
38 const IInterface* parent)
39 : Base (type, name, parent)
40{
41 book().ignore(); // Avoid coverity warnings.
42}
43
44
49{
50 CHECK( addVariable ("px", m_px) );
51 CHECK( addVariable ("py", m_py) );
52 CHECK( addVariable ("pz", m_pz) );
53 CHECK( addVariable ("E", m_E) );
54 CHECK( addVariable ("m", m_m) );
55 CHECK( addVariable ("nTracks", m_nTracks) );
56 CHECK( addVariable ("sumPt", m_sumPt) );
57
58 return StatusCode::SUCCESS;
59}
60
61
71{
72 for (const Trk::VxTrackAtVertex* tv : *p.vxTrackAtVertex()) {
73
74 const Trk::Perigee* perigee = 0;
75 if ( tv->perigeeAtVertex() )
76 perigee = static_cast<const Trk::Perigee*> (tv->perigeeAtVertex());
77 else
78 perigee = static_cast<const Trk::Perigee*> (tv->initialPerigee());
79
80 *m_px += perigee->momentum().x();
81 *m_py += perigee->momentum().y();
82 *m_pz += perigee->momentum().z();
83 *m_E += perigee->momentum().mag();
84 *m_sumPt += hypot(perigee->momentum().x(),perigee->momentum().y());
85 }
86
87 float vtxmass = sq(*m_E) - sq(*m_px) - sq(*m_py) - sq(*m_pz);
88 if (vtxmass>0.0)
89 vtxmass = std::sqrt(vtxmass);
90 else
91 vtxmass = 0.0;
92
93 *m_m = vtxmass;
94 *m_nTracks = p.vxTrackAtVertex()->size();
95
96 return StatusCode::SUCCESS;
97}
98
99
109{
110 for (const auto& tplink : p.trackParticleLinks()) {
111
112 const Trk::Perigee& perigee = (*tplink)->perigeeParameters();
113
114 *m_px += perigee.momentum().x();
115 *m_py += perigee.momentum().y();
116 *m_pz += perigee.momentum().z();
117 *m_E += perigee.momentum().mag();
118 *m_sumPt += hypot(perigee.momentum().x(),perigee.momentum().y());
119 }
120
121 float vtxmass = sq(*m_E) - sq(*m_px) - sq(*m_py) - sq(*m_pz);
122 if (vtxmass>0.0)
123 vtxmass = std::sqrt(vtxmass);
124 else
125 vtxmass = 0.0;
126
127 *m_m = vtxmass;
128 *m_nTracks = p.nTrackParticles();
129
130 return StatusCode::SUCCESS;
131}
132
133
134} // namespace D3PD
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
#define sq(x)
#define x
Block filler tool for vertex kinematics, from attached tracks.
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
VertexKineFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
virtual StatusCode fill(const Trk::VxCandidate &p) override
Fill one block — type-safe version.
float * m_px
Variables: Vertex position.
virtual StatusCode book() final
Book variables for this block.
BlockFillerTool< Types< Trk::VxCandidate, xAOD::Vertex > > Base
const Amg::Vector3D & momentum() const
Access method for the momentum.
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
Block filler tool for noisy FEB information.
ParametersT< TrackParametersDim, Charged, PerigeeSurface > Perigee
Vertex_v1 Vertex
Define the latest version of the vertex class.