From bfe8ec6098ee7cf55b9b37592864e6c98c55d88c Mon Sep 17 00:00:00 2001
From: Niels Van Eldik <niels.van.eldik@cern.ch>
Date: Wed, 13 Nov 2013 22:04:08 +0100
Subject: [PATCH] remove pointers (TrkVertexOnTrack-02-00-02)

---
 .../TrkVertexOnTrack/TrkVertexOnTrackDict.h   |  12 ++
 .../TrkVertexOnTrack/VertexOnTrack.h          | 104 +++++++++++++++
 .../TrkVertexOnTrack/selection.xml            |   5 +
 .../TrkVertexOnTrack/cmt/requirements         |  28 ++++
 .../TrkEvent/TrkVertexOnTrack/doc/mainpage.h  |  30 +++++
 .../TrkVertexOnTrack/src/VertexOnTrack.cxx    | 124 ++++++++++++++++++
 6 files changed, 303 insertions(+)
 create mode 100755 Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/TrkVertexOnTrackDict.h
 create mode 100755 Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/VertexOnTrack.h
 create mode 100755 Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/selection.xml
 create mode 100755 Tracking/TrkEvent/TrkVertexOnTrack/cmt/requirements
 create mode 100755 Tracking/TrkEvent/TrkVertexOnTrack/doc/mainpage.h
 create mode 100755 Tracking/TrkEvent/TrkVertexOnTrack/src/VertexOnTrack.cxx

diff --git a/Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/TrkVertexOnTrackDict.h b/Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/TrkVertexOnTrackDict.h
new file mode 100755
index 00000000000..e025aa761f8
--- /dev/null
+++ b/Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/TrkVertexOnTrackDict.h
@@ -0,0 +1,12 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+#ifndef TRKVERTEXONTRACKDICT_H
+#define TRKVERTEXONTRACKDICT_H
+
+#include "TrkVertexOnTrack/VertexOnTrack.h"
+
+//#include "TrkVertexOnTrack/VertexOnTrackMap.h"
+
+#endif
diff --git a/Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/VertexOnTrack.h b/Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/VertexOnTrack.h
new file mode 100755
index 00000000000..aa5ec9890ec
--- /dev/null
+++ b/Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/VertexOnTrack.h
@@ -0,0 +1,104 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+///////////////////////////////////////////////////////////////////
+// VertexOnTrack.h, (c) ATLAS Detector software
+///////////////////////////////////////////////////////////////////
+
+#ifndef TRKVERTEXONTRACK_VERTEXONTRACK_H
+#define TRKVERTEXONTRACK_VERTEXONTRACK_H
+
+// Trk
+#include "TrkMeasurementBase/MeasurementBase.h"
+#include "TrkSurfaces/PerigeeSurface.h"
+#include <ostream>
+
+#include "GeoPrimitives/GeoPrimitives.h"
+#include "EventPrimitives/EventPrimitives.h"
+#include "TrkParameters/TrackParameters.h"
+
+#include "GaudiKernel/GaudiException.h"
+
+class MsgStream;
+class TrackCollectionCnv;
+
+namespace Trk{
+
+  class RecVertex;
+
+/** @class VertexOnTrack
+
+  Class to handle Vertex On Tracks,
+  it inherits from the common MeasurementBase. 
+
+  @author haertel@mppmu.mpg.de
+
+ */
+
+  class VertexOnTrack : public MeasurementBase {
+
+    friend class ::TrackCollectionCnv;
+
+    public:
+      /** Default Constructor for POOL */
+      VertexOnTrack();
+      /** Copy Constructor */
+      VertexOnTrack(const VertexOnTrack& vot);
+      /** Assignment operator */
+      VertexOnTrack& operator=(const VertexOnTrack& vot);
+
+      /** Constructor with (LocalParameters&, LocalErrorMatrix&, PerigeeSurface&)
+      The associated PerigeeSurface is cloned*/
+      VertexOnTrack( const LocalParameters& locpars,
+                     const Amg::MatrixX& locerr,
+                     const PerigeeSurface& assocSurf);
+
+      /** Constructor from: RedVertex, Perigee - the perigee is needed for the measurement frame */
+      VertexOnTrack( const Trk::RecVertex& rvertex, const Trk::Perigee& mperigee) throw (GaudiException);
+
+      /** Destructor */
+      virtual ~VertexOnTrack();
+
+      /** Pseudo-constructor, needed to avoid excessive RTTI*/
+      VertexOnTrack* clone() const;
+
+      /** returns the surface for the local to global transformation 
+      - interface from MeasurementBase */
+      const PerigeeSurface& associatedSurface() const;
+
+      /**Interface method to get the global Position
+      - interface from MeasurementBase */
+      const Amg::Vector3D& globalPosition() const;
+
+      /**returns the some information about this VertexOnTrack. */
+      virtual MsgStream&    dump( MsgStream& out ) const;
+      /**returns the some information about this VertexOnTrack. */
+      virtual std::ostream& dump( std::ostream& out ) const;
+
+     // perhaps return Vertex Object
+
+    protected:
+      /** Perigee surface of the VoT*/
+      mutable const PerigeeSurface* m_associatedSurface;
+
+      /** Global position of the VoT*/
+      mutable const Amg::Vector3D*  m_globalPosition;
+  };
+
+  inline VertexOnTrack* VertexOnTrack::clone() const 
+  { return new VertexOnTrack(*this); }
+
+  inline const PerigeeSurface& VertexOnTrack::associatedSurface() const
+  { return *m_associatedSurface; }
+
+  inline const Amg::Vector3D& VertexOnTrack::globalPosition() const
+  {
+    if (m_globalPosition == 0) {m_globalPosition = new Amg::Vector3D();}
+    return *m_globalPosition;
+  }
+
+}
+
+#endif // TRKVERTEXONTRACK_VERTEXONTRACK_H
+
diff --git a/Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/selection.xml b/Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/selection.xml
new file mode 100755
index 00000000000..1045bb4641b
--- /dev/null
+++ b/Tracking/TrkEvent/TrkVertexOnTrack/TrkVertexOnTrack/selection.xml
@@ -0,0 +1,5 @@
+<lcgdict>
+  <class name="Trk::VertexOnTrack" >
+    <field name="m_globalPosition"       transient="false" />
+  </class>
+</lcgdict>
diff --git a/Tracking/TrkEvent/TrkVertexOnTrack/cmt/requirements b/Tracking/TrkEvent/TrkVertexOnTrack/cmt/requirements
new file mode 100755
index 00000000000..c9acef546a9
--- /dev/null
+++ b/Tracking/TrkEvent/TrkVertexOnTrack/cmt/requirements
@@ -0,0 +1,28 @@
+package TrkVertexOnTrack
+
+author Roland Haertel <haertel -at- mppmu.mpg.de>
+author Manuel Kayl <Manuel.Kayl -at- cern.ch>
+author Andreas Salzburger < Andreas.Salzburger -at- cern.ch >
+
+use AtlasPolicy          AtlasPolicy-* 
+use TrkMeasurementBase   TrkMeasurementBase-*     Tracking/TrkEvent
+use TrkSurfaces          TrkSurfaces-*            Tracking/TrkDetDescr
+use GaudiInterface       GaudiInterface-*         External
+use TrkParameters	 	 TrkParameters-*	  	  Tracking/TrkEvent
+use GeoPrimitives GeoPrimitives-* DetectorDescription
+use EventPrimitives EventPrimitives-* Event
+
+apply_pattern installed_library
+library TrkVertexOnTrack *.cxx
+
+private
+#use AtlasReflex          AtlasReflex-*            External -no_auto_imports
+use VxVertex		     VxVertex-*		  		  Tracking/TrkEvent
+
+# Pattern to build the dict lib. User should create a single header
+# file: <package>Dict.h which includes all other .h files. See MissingETDict
+# A selection file must be created by hand. This file lists the
+# classes to be added to the dictionary, and which fields are
+# transient. It should be put in ../<package> dir and is conventionally called
+# selection.xml.
+#apply_pattern lcgdict dict=TrkVertexOnTrack selectionfile=selection.xml headerfiles="../TrkVertexOnTrack/TrkVertexOnTrackDict.h"
diff --git a/Tracking/TrkEvent/TrkVertexOnTrack/doc/mainpage.h b/Tracking/TrkEvent/TrkVertexOnTrack/doc/mainpage.h
new file mode 100755
index 00000000000..6be65797141
--- /dev/null
+++ b/Tracking/TrkEvent/TrkVertexOnTrack/doc/mainpage.h
@@ -0,0 +1,30 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+/**
+@mainpage The VertexOnTrack class 
+@author haertel@mppmu.mpg.de
+
+@section introductionTrkVertexOnTrack Introduction
+
+Class to handle vertices as measurements in fitters and on track objects, it inherits from the common MeasurementBase.
+Typically a VertexFinder is run to get the best possible VertexCandidates. A VertexOnTrack instance then needs to be
+created for every track assoziated to a give VertexCandidate. Together with the hits from a track the VertexOnTrack 
+can then be used to fit a new track which has the vertex as constraining measurement.
+
+This mechanism is e.g. used by the InnerDetector alignment approaches as one way to get vertexing information into
+the alignment procedures.
+
+
+
+@section used_packagesTrkVertexOnTrack Used Packages
+@htmlinclude used_packages.html
+
+@section requirements Requirements
+@include requirements
+
+@namespace Trk
+A namespace to enclose the Tracking classes.
+*/
+
diff --git a/Tracking/TrkEvent/TrkVertexOnTrack/src/VertexOnTrack.cxx b/Tracking/TrkEvent/TrkVertexOnTrack/src/VertexOnTrack.cxx
new file mode 100755
index 00000000000..da0283708fa
--- /dev/null
+++ b/Tracking/TrkEvent/TrkVertexOnTrack/src/VertexOnTrack.cxx
@@ -0,0 +1,124 @@
+/*
+  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+*/
+
+///////////////////////////////////////////////////////////////////
+// VertexOnTrack.cxx, (c) ATLAS Detector software
+///////////////////////////////////////////////////////////////////
+
+//Trk
+#include "TrkVertexOnTrack/VertexOnTrack.h"
+#include "VxVertex/RecVertex.h"
+
+// Gaudi & AthenaCommon
+#include "GaudiKernel/MsgStream.h"
+#include <string>
+#include <typeinfo>
+
+ 
+// Constructor with parameters:
+Trk::VertexOnTrack::VertexOnTrack( const LocalParameters& locpars,
+                                   const Amg::MatrixX& locerr,
+                                   const PerigeeSurface& assocSurf) :
+  Trk::MeasurementBase(locpars,locerr),
+  m_associatedSurface(assocSurf.clone()),
+  m_globalPosition(0)
+{
+}
+
+
+// Constructor with parameters:
+Trk::VertexOnTrack::VertexOnTrack( const Trk::RecVertex& rvertex,
+                                   const Trk::Perigee& perigee ) throw (GaudiException) :
+  Trk::MeasurementBase(),
+  m_associatedSurface(perigee.associatedSurface().clone()),
+  m_globalPosition(new Amg::Vector3D(perigee.position()))
+{
+  if ( (rvertex.position()-perigee.associatedSurface().center()).mag() > 10e-5 )
+    throw GaudiException("Inconsistent input data, Perigee not expressed at vertex!","Trk::VertexOnTrack", StatusCode::RECOVERABLE);
+    
+  // the local parameters are by definition at (0,0)
+  Amg::Vector2D localPosition(0,0);
+  m_localParams = Trk::LocalParameters(localPosition);
+  
+  // transform Cartesian (x,y,z) to perigee (d0,z0)
+  Amg::MatrixX jacobian(2,3);
+  jacobian.setZero();
+  double ptInv                               =  1./perigee.momentum().perp();
+  jacobian(0,0)                              = -ptInv*perigee.momentum().y();
+  jacobian(0,1)                              =  ptInv*perigee.momentum().x();
+  jacobian(1,2)                              =  1.0;
+  // the covariance on matrix of the vertex
+  const Amg::MatrixX& vtxCov = rvertex.covariancePosition();
+  // the local coordinate
+  m_localCovariance = vtxCov.similarity(jacobian);
+}
+
+// Destructor:
+Trk::VertexOnTrack::~VertexOnTrack()
+{
+  delete m_associatedSurface;
+  delete m_globalPosition;
+}
+
+// default constructor:
+Trk::VertexOnTrack::VertexOnTrack() :
+  Trk::MeasurementBase(),
+  m_associatedSurface(0),
+  m_globalPosition(0)
+{}
+
+// copy constructor:
+Trk::VertexOnTrack::VertexOnTrack( const Trk::VertexOnTrack& vot) :
+  Trk::MeasurementBase(vot),
+  m_associatedSurface( new Trk::PerigeeSurface(*vot.m_associatedSurface) ),
+  m_globalPosition(0)
+{}
+
+// assignment operator:
+Trk::VertexOnTrack& Trk::VertexOnTrack::operator=(const VertexOnTrack& vot)
+{
+  if ( &vot != this) {
+    delete m_associatedSurface;
+    delete m_globalPosition;
+    Trk::MeasurementBase::operator=(vot);
+    m_globalPosition = 0;
+    m_associatedSurface  = new Trk::PerigeeSurface(*vot.m_associatedSurface);
+  }
+  return *this;
+}
+
+
+MsgStream& Trk::VertexOnTrack::dump( MsgStream& sl ) const
+{
+  std::string name(typeid(*this).name());
+  sl << "Concrete dump method not implemented - using base class" << std::endl;
+  sl << name << "\t  local position = "<< this->localParameters() << std::endl;
+  sl << name << "\t  global position ( " << this->globalPosition().x() << " , "
+                                         << this->globalPosition().y() << " , "
+                                         << this->globalPosition().z() << " ) " << std::endl;
+  sl << name << "\t  has Error Matrix: " << std::endl;
+  sl << this->localCovariance() << std::endl;
+  sl << name << "\t  has associated surface:" << std::endl;
+  sl<< this->associatedSurface() << std::endl;
+  return sl;
+}
+
+std::ostream& Trk::VertexOnTrack::dump( std::ostream& sl ) const
+{
+  std::string name(typeid(*this).name());
+  sl << "Concrete dump method not implemented - using base class" << std::endl;
+  sl << name << "\t  local position = "<< this->localParameters() << std::endl;
+  sl << name << "\t  global position ( " << this->globalPosition().x() << " , "
+                                         << this->globalPosition().y() << " , "
+                                         << this->globalPosition().z() << " ) " << std::endl;
+  sl << name << "\t  has Error Matrix: " << std::endl;
+  sl << this->localCovariance() << std::endl;
+  sl << name << "\t  has associated surface:" << std::endl;
+  sl<< this->associatedSurface() << std::endl;
+  return sl;
+}
+
+
+
+
-- 
GitLab