ATLAS Offline Software
VertexKineFillerTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
14 #include "VertexKineFillerTool.h"
16 #include "Particle/TrackParticle.h"
19 
20 
21 namespace {
22 inline
23 double sq(double x) { return x*x; }
24 }
25 
26 
27 
28 namespace D3PD {
29 
30 
38  (const std::string& type,
39  const std::string& name,
40  const IInterface* parent)
41  : Base (type, name, parent)
42 {
43  book().ignore(); // Avoid coverity warnings.
44 }
45 
46 
51 {
52  CHECK( addVariable ("px", m_px) );
53  CHECK( addVariable ("py", m_py) );
54  CHECK( addVariable ("pz", m_pz) );
55  CHECK( addVariable ("E", m_E) );
56  CHECK( addVariable ("m", m_m) );
57  CHECK( addVariable ("nTracks", m_nTracks) );
58  CHECK( addVariable ("sumPt", m_sumPt) );
59 
60  return StatusCode::SUCCESS;
61 }
62 
63 
73 {
74  for (const Trk::VxTrackAtVertex* tv : *p.vxTrackAtVertex()) {
75 
76  const Trk::Perigee* perigee = 0;
77  if ( tv->perigeeAtVertex() )
78  perigee = (const Trk::Perigee*) tv->perigeeAtVertex();
79  else
80  perigee = (const Trk::Perigee*) tv->initialPerigee();
81 
82  *m_px += perigee->momentum().x();
83  *m_py += perigee->momentum().y();
84  *m_pz += perigee->momentum().z();
85  *m_E += perigee->momentum().mag();
86  *m_sumPt += hypot(perigee->momentum().x(),perigee->momentum().y());
87  }
88 
89  float vtxmass = sq(*m_E) - sq(*m_px) - sq(*m_py) - sq(*m_pz);
90  if (vtxmass>0.0)
91  vtxmass = std::sqrt(vtxmass);
92  else
93  vtxmass = 0.0;
94 
95  *m_m = vtxmass;
96  *m_nTracks = p.vxTrackAtVertex()->size();
97 
98  return StatusCode::SUCCESS;
99 }
100 
101 
111 {
112  for (const auto& tplink : p.trackParticleLinks()) {
113 
114  const Trk::Perigee& perigee = (*tplink)->perigeeParameters();
115 
116  *m_px += perigee.momentum().x();
117  *m_py += perigee.momentum().y();
118  *m_pz += perigee.momentum().z();
119  *m_E += perigee.momentum().mag();
120  *m_sumPt += hypot(perigee.momentum().x(),perigee.momentum().y());
121  }
122 
123  float vtxmass = sq(*m_E) - sq(*m_px) - sq(*m_py) - sq(*m_pz);
124  if (vtxmass>0.0)
125  vtxmass = std::sqrt(vtxmass);
126  else
127  vtxmass = 0.0;
128 
129  *m_m = vtxmass;
130  *m_nTracks = p.nTrackParticles();
131 
132  return StatusCode::SUCCESS;
133 }
134 
135 
136 } // 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:72
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
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:210
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:50
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
D3PD::VertexKineFillerTool::VertexKineFillerTool
VertexKineFillerTool(const std::string &type, const std::string &name, const IInterface *parent)
Standard Gaudi tool constructor.
Definition: VertexKineFillerTool.cxx:38
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
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
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