ATLAS Offline Software
VertexKineFillerTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
12 #include "VertexKineFillerTool.h"
14 #include "Particle/TrackParticle.h"
17 
18 
19 namespace {
20 inline
21 double sq(double x) { return x*x; }
22 }
23 
24 
25 
26 namespace 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
TrackParameters.h
Trk::VxTrackAtVertex
The VxTrackAtVertex is a common class for all present TrkVertexFitters The VxTrackAtVertex is designe...
Definition: VxTrackAtVertex.h:77
TrackParticle.h
Trk::ParametersT
Dummy class used to allow special convertors to be called for surfaces owned by a detector element.
Definition: EMErrorDetail.h:25
D3PD::VertexKineFillerTool::fill
virtual StatusCode fill(const Trk::VxCandidate &p) override
Fill one block — type-safe version.
Definition: VertexKineFillerTool.cxx:70
D3PD::AddVariable::addVariable
virtual StatusCode addVariable(const std::string &name, const std::type_info &ti, void *&ptr, const std::string &docstring="", const void *defval=0)
Add a variable to the tuple.
Definition: AddVariable.cxx:85
x
#define x
python.CaloAddPedShiftConfig.type
type
Definition: CaloAddPedShiftConfig.py:42
D3PD::VertexKineFillerTool::m_nTracks
int * m_nTracks
Definition: VertexKineFillerTool.h:78
D3PD
Block filler tool for noisy FEB information.
Definition: CaloCellDetailsFillerTool.cxx:29
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:209
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
sq
#define sq(x)
Definition: CurvedSegmentFinder.cxx:6
test_pyathena.parent
parent
Definition: test_pyathena.py:15
D3PD::VertexKineFillerTool::m_E
float * m_E
Definition: VertexKineFillerTool.h:76
D3PD::BlockFillerTool< Types< Trk::VxCandidate, xAOD::Vertex > >
CHECK
#define CHECK(...)
Evaluate an expression and check for errors.
Definition: Control/AthenaKernel/AthenaKernel/errorcheck.h:422
D3PD::VertexKineFillerTool::m_sumPt
float * m_sumPt
Definition: VertexKineFillerTool.h:79
VertexKineFillerTool.h
Block filler tool for vertex kinematics, from attached tracks.
D3PD::VertexKineFillerTool::book
virtual StatusCode book() final
Book variables for this block.
Definition: VertexKineFillerTool.cxx:48
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:240
D3PD::VertexKineFillerTool::VertexKineFillerTool
VertexKineFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: VertexKineFillerTool.cxx:36
errorcheck.h
Helpers for checking error return status codes and reporting errors.
D3PD::VertexKineFillerTool::m_py
float * m_py
Definition: VertexKineFillerTool.h:74
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
Trk::VxCandidate
Definition: VxCandidate.h:27
D3PD::VertexKineFillerTool::m_m
float * m_m
Definition: VertexKineFillerTool.h:77
D3PD::VertexKineFillerTool::m_px
float * m_px
Variables: Vertex position.
Definition: VertexKineFillerTool.h:73
D3PD::VertexKineFillerTool::m_pz
float * m_pz
Definition: VertexKineFillerTool.h:75
TrackParticleContainer.h