ATLAS Offline Software
DummyVertexSmoother.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /*********************************************************************
6  DummyVertexSmoother.cxx - Description in header file
7 *********************************************************************/
8 
14 
15 namespace Trk
16 {
17 
18  DummyVertexSmoother::DummyVertexSmoother(const std::string& t, const std::string& n, const IInterface* p) :
19  AthAlgTool(t,n,p), m_extrapolator(nullptr), m_extrapolatorName("Trk::Extrapolator"), m_extrapolatorInstance("InDetExtrapolator")
20  {
21  declareProperty("ExtrapolatorName", m_extrapolatorName);
22  declareProperty("ExtrapolatorInstance", m_extrapolatorInstance);
23  declareInterface<IVertexSmoother>(this);
24  }
25 
27 
29  {
31  sc = toolSvc()->retrieveTool(m_extrapolatorName, m_extrapolatorInstance, m_extrapolator);
32  if (sc.isFailure())
33  {
34  msg(MSG::FATAL)<<"Could not find extrapolator tool." << endmsg;
35  return sc;
36  }
37  msg(MSG::INFO) << "Initialize successful" << endmsg;
38  return StatusCode::SUCCESS;
39  }
40 
42  {
43  msg(MSG::INFO) << "Initialize successful" << endmsg;
44  return StatusCode::SUCCESS;
45  }
46 
47  // Had to make the vtx non-const because xAOD::Vertex stores
48  // Trk::VxTrackAtVertex and not Trk::VxTrackAtVertex*
50  {
51 
52  //vector of associated tracks at vertex:
53  if( vtx.vxTrackAtVertexAvailable() ) //TODO: is this the right thing to check?
54  {
55  std::vector<Trk::VxTrackAtVertex> & tracks = vtx.vxTrackAtVertex();
56 
57  if(!tracks.empty())
58  {
59  //iteratively updating private members of VxTrackAtVertex
60  std::vector<Trk::VxTrackAtVertex>::iterator t_it = tracks.begin();
62  for( ;t_it != te;++t_it)
63  {
64 
65  //TODO: There were previously null pointer checks on both the contents and vector itself
66  // of std::vector<Trk::VxTrackAtVertex*>* in VxCandidate
67  // but now in xAOD::Vertex, there is only a std::vector<Trk::VxTrackAtVertex> so
68  // pointer checks are not possible
69  //
70  // -David S.
71 
72  //now the extrapolation will happen anyway, creating the surface
73  PerigeeSurface perigeeSurface(vtx.position());
74  const Trk::TrackParameters * initPar = (*t_it).initialPerigee();
75 
76  if(initPar != nullptr)
77  {
78  //Either we should return non-const parameters from the extrapolator
79  //as the owner here has to delete them
80  //Or we need to clone
81  auto extrapolatedPerigee =
82  std::unique_ptr<const Trk::TrackParameters>(m_extrapolator->extrapolate(Gaudi::Hive::currentContext(),
83  *initPar,
84  perigeeSurface));
85  if (extrapolatedPerigee != nullptr) {
86  (*t_it).setPerigeeAtVertex(extrapolatedPerigee->clone());
87  } else {
88  msg(MSG::ERROR) << " Extrapolation failed; VxTrackAtertex will not be updated" << endmsg;
89  } // end of successfull extrapolation check
90  } else {
91  msg(MSG::WARNING) << " The VxTrackAtVertex passed has no initial Parameters? This track will not be refitted" << endmsg;
92  }//end of initial parameters protection check
93 
94  }//end of loop over all fitted tracks
95  } else {
96  msg(MSG::ERROR) << "xAOD::Vertex with empty vector of tracks is passed to the Vertex Smoother" << endmsg;
97  msg(MSG::ERROR) << "No action taken; Input xAOD::Vertex stays unchanged " << endmsg;
98  }//end of empty vector check
99 
100  } else {
101  msg(MSG::ERROR) << "Vertex to be smoothed has no vxTrackAtVertices available!" << endmsg;
102  msg(MSG::ERROR) << "No action taken; Initial xAOD::Vertex returned." << endmsg;
103  }//end of protection check whether vxTrackAtVertices are attached to the object
104  }//end of smooth method
105 
106 }//end of namespace definitions
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
Trk::DummyVertexSmoother::smooth
void smooth(xAOD::Vertex &vtx) const
Actual smooth method.
Definition: DummyVertexSmoother.cxx:51
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
PerigeeSurface.h
Trk::PerigeeSurface
Definition: PerigeeSurface.h:43
initialize
void initialize()
Definition: run_EoverP.cxx:894
Trk::DummyVertexSmoother::initialize
StatusCode initialize()
Athena default methods.
Definition: DummyVertexSmoother.cxx:30
IExtrapolator.h
Trk::DummyVertexSmoother::m_extrapolatorInstance
std::string m_extrapolatorInstance
Definition: DummyVertexSmoother.h:68
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Trk::DummyVertexSmoother::~DummyVertexSmoother
~DummyVertexSmoother()
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
Trk::DummyVertexSmoother::DummyVertexSmoother
DummyVertexSmoother(const std::string &t, const std::string &n, const IInterface *p)
Constructor and destructor.
Definition: DummyVertexSmoother.cxx:20
beamspotman.n
n
Definition: beamspotman.py:731
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Trk::IExtrapolator::extrapolate
virtual std::unique_ptr< NeutralParameters > extrapolate(const NeutralParameters &parameters, const Surface &sf, PropDirection dir=anyDirection, const BoundaryCheck &bcheck=true) const =0
Main extrapolation Interface starting from neutral parameters and aiming at surface.
VxTrackAtVertex.h
Trk::ParametersBase
Definition: ParametersBase.h:55
Trk::DummyVertexSmoother::m_extrapolator
Trk::IExtrapolator * m_extrapolator
Definition: DummyVertexSmoother.h:66
DummyVertexSmoother.h
Trk::DummyVertexSmoother::finalize
StatusCode finalize()
Definition: DummyVertexSmoother.cxx:43
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
LinearizedTrack.h
xAOD::Vertex_v1::vxTrackAtVertex
std::vector< Trk::VxTrackAtVertex > & vxTrackAtVertex()
Non-const access to the VxTrackAtVertex vector.
Definition: Vertex_v1.cxx:181
AthAlgTool
Definition: AthAlgTool.h:26
xAOD::Vertex_v1::vxTrackAtVertexAvailable
bool vxTrackAtVertexAvailable() const
Check if VxTrackAtVertices are attached to the object.
Definition: Vertex_v1.cxx:209
Trk::DummyVertexSmoother::m_extrapolatorName
std::string m_extrapolatorName
Definition: DummyVertexSmoother.h:67