Skip to content
Snippets Groups Projects
Commit 55fa313f authored by Christos Anastopoulos's avatar Christos Anastopoulos Committed by Adam Edward Barton
Browse files

static thread checker for TrkParameters and TrkParametersBase, avoid...

static thread checker for TrkParameters and TrkParametersBase, avoid const_cast and remove a static.
parent f009f388
No related branches found
No related tags found
No related merge requests found
Tracking/TrkEvent/TrkParameters
Tracking/TrkEvent/TrkParametersBase
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -43,7 +43,6 @@ namespace Trk
@author andreas.salzburger@cern.ch
*/
template<int DIM,class T, class S>
class CurvilinearParametersT : public ParametersT<DIM,T,S>
{
......@@ -80,7 +79,7 @@ namespace Trk
CurvilinearParametersT(CurvilinearParametersT<DIM,T,S>&&);
/** Destructor */
virtual ~CurvilinearParametersT() = default;
virtual ~CurvilinearParametersT()=default;
/** Assignment operator*/
CurvilinearParametersT<DIM,T,S> &operator=(const CurvilinearParametersT<DIM,T,S>&);
......@@ -89,22 +88,18 @@ namespace Trk
CurvilinearParametersT<DIM,T,S> &operator=(CurvilinearParametersT<DIM,T,S>&&);
/** equality operator */
virtual bool operator==(const ParametersBase<DIM,T>& rhs) const override;
virtual bool operator==(const ParametersBase<DIM,T>& rhs) const override final;
/** Pseudo constructor */
virtual CurvilinearParametersT<DIM,T,S>* clone() const override {return new CurvilinearParametersT<DIM,T,S>(*this);}
virtual CurvilinearParametersT<DIM,T,S>* clone() const override final
{return new CurvilinearParametersT<DIM,T,S>(*this);}
/** Return the ParametersType enum */
virtual ParametersType type() const override {return Trk::Curvilinear;}
virtual ParametersType type() const override
{return Trk::Curvilinear;}
/** Access to the Surface method */
virtual const S& associatedSurface() const override;
/** Test to see if there's a surface there. */
virtual bool hasSurface() const override { return true; }
/** Return the measurementFrame of the parameters */
virtual const Amg::RotationMatrix3D measurementFrame() const override;
virtual const Amg::RotationMatrix3D measurementFrame() const override final;
/**Dumps relevant information about the track parameters into the ostream.*/
virtual MsgStream& dump(MsgStream& out) const override;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -17,12 +17,13 @@ namespace Trk
template <int DIM,class T,class S>
Trk::CurvilinearParametersT<DIM,T,S>::CurvilinearParametersT(const AmgVector(DIM+2)& parameters,
AmgSymMatrix(DIM)* covariance,
unsigned int cIdentifier) :
unsigned int cIdentifier):
ParametersT<DIM,T,S>(Amg::Vector3D(parameters[x],parameters[y],parameters[z]),
Amg::Vector3D(parameters[3],parameters[4],parameters[5]),
covariance),
Amg::Vector3D(parameters[3],parameters[4],parameters[5]),
covariance),
m_cIdentifier(cIdentifier)
{
// flip the charge according to qOverP
if (parameters[6] < 0.) this->m_chargeDef.setCharge(-1);
// assign the parameters
......@@ -32,6 +33,9 @@ namespace Trk
this->m_parameters[phi] = this->momentum().phi();
this->m_parameters[theta] = this->momentum().theta();
this->m_parameters[qOverP] = parameters[6]/this->momentum().mag();
/* we need all the above to be there for the surfac*/
this->m_surface=new S(this->m_position,curvilinearFrame());
}
// Constructor with TP arguments
......@@ -43,11 +47,10 @@ namespace Trk
AmgSymMatrix(DIM)* cov,
unsigned int cIdentifier):
ParametersT<DIM,T,S>(),
m_cIdentifier(cIdentifier)
m_cIdentifier(cIdentifier)
{
this->m_position = pos;
this->m_covariance = cov;
this->m_covariance =cov;
this->m_position=pos;
// flip the charge according to qOverP
if(tqOverP < 0.)
this->m_chargeDef.setCharge(-1.);
......@@ -65,6 +68,8 @@ namespace Trk
double p = fabs(1./tqOverP);
this->m_momentum = Amg::Vector3D(p*cos(tphi)*sin(ttheta),p*sin(tphi)*sin(ttheta),p*cos(ttheta));
/* we need all the above for the surface*/
this->m_surface=new S(this->m_position,curvilinearFrame());
}
// full global constructor
......@@ -92,6 +97,9 @@ namespace Trk
this->m_parameters[Trk::qOverP] = charge/mom.mag();
this->m_position = pos;
this->m_momentum = mom;
/* we need all the above to be there for the surfac*/
this->m_surface=new S(this->m_position,curvilinearFrame());
}
// copy constructor
......@@ -170,19 +178,7 @@ namespace Trk
// compare equality of base class parts
return ParametersT<DIM,T,S>::operator==(rhs);
}
template<int DIM,class T,class S>
const S& CurvilinearParametersT<DIM,T,S>::associatedSurface() const
{
if(!this->m_surface)
{
// create the surface for global position and global rotation
const_cast<S*&>(this->m_surface) = new S(this->position(),curvilinearFrame());
}
return (*this->m_surface);
}
// Screen output dump
template<int DIM,class T,class S>
MsgStream& CurvilinearParametersT<DIM,T,S>::dump(MsgStream& out) const
......@@ -208,7 +204,7 @@ namespace Trk
template <int DIM,class T,class S>
const Amg::RotationMatrix3D CurvilinearParametersT<DIM,T,S>::measurementFrame() const
{
static Amg::RotationMatrix3D mFrame;
Amg::RotationMatrix3D mFrame;
// the columnes
CurvilinearUVT local_curvilinearFrame=curvilinearFrame();
mFrame.col(0) = local_curvilinearFrame.curvU();
......@@ -240,7 +236,7 @@ namespace Trk
if (updatedCovariance)
{
if (updatedCovariance != this->m_covariance)
delete this->m_covariance;
delete this->m_covariance;
this->m_covariance = updatedCovariance;
}
......
......@@ -118,6 +118,10 @@ namespace Trk
/** Return the ParametersType enum */
virtual ParametersType type() const = 0;
/** Test to see if there's a surface there. */
virtual bool hasSurface() const = 0 ;
/** Returns charge of concrete type (i.e. must be implemented in inheriting classes) */
virtual double charge() const = 0;
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -108,25 +108,25 @@ namespace Trk
virtual ParametersType type() const override {return Trk::AtaSurface;}
/** Returns charge of track */
virtual double charge() const override {return m_chargeDef.charge();}
virtual double charge() const override final {return m_chargeDef.charge();}
/** Access method for the parameters */
virtual const AmgVector(DIM)& parameters() const final {return m_parameters;}
virtual const AmgVector(DIM)& parameters() const override final {return m_parameters;}
/** Access method for the covariance matrix - 0 if no covariance matrix is given */
virtual const AmgSymMatrix(DIM)* covariance() const final {return m_covariance;}
virtual const AmgSymMatrix(DIM)* covariance() const override final {return m_covariance;}
/** Access to the Surface method */
virtual const S& associatedSurface() const override {return *m_surface;}
virtual const S& associatedSurface() const override final {return *m_surface;}
/** Test to see if there's a surface there. */
virtual bool hasSurface() const { return m_surface != nullptr; }
virtual bool hasSurface() const override final { return m_surface != nullptr; }
/** Access method for the position */
virtual const Amg::Vector3D& position() const final {return m_position;}
virtual const Amg::Vector3D& position() const override final {return m_position;}
/** Access method for the momentum */
virtual const Amg::Vector3D& momentum() const final {return m_momentum;}
virtual const Amg::Vector3D& momentum() const override final {return m_momentum;}
/** Return the measurementFrame of the parameters */
const Amg::RotationMatrix3D measurementFrame() const override;
......@@ -138,7 +138,7 @@ namespace Trk
template <class SURFACE_CNV, class ATA_SURFACE>
friend class ::AtaSurfaceCnv_p1;
/** --- PRIVATE CONSTRUCTOR : for persistency purpose only */
/** --- Protected constructors : for persistency purpose only */
ParametersT (const AmgVector(DIM)& parameters,
const S* surface,
AmgSymMatrix(DIM)* covariance = 0);
......
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
///////////////////////////////////////////////////////////////////
......@@ -76,8 +76,8 @@ namespace Trk
// Constructor with local arguments - uses global <-> local for parameters
template<int DIM,class T,class S>
ParametersT<DIM,T,S>::ParametersT(const AmgVector(DIM)& parameters,
const S& surface,
AmgSymMatrix(DIM)* cov):
const S& surface,
AmgSymMatrix(DIM)* cov):
ParametersBase<DIM,T>(),
m_parameters(parameters),
m_covariance(cov),
......@@ -278,52 +278,7 @@ namespace Trk
}
}
// PROTECTED Constructor with local arguments - persistency only, ownership of surface given
template <int DIM,class T,class S>
Trk::ParametersT<DIM,T,S>::ParametersT(const AmgVector(DIM)& pars,
const S* surface,
AmgSymMatrix(DIM)* cov) :
ParametersBase<DIM,T>(),
m_parameters(pars),
m_covariance(cov),
m_surface(surface)
{
float qop = m_parameters[Trk::qOverP];
// decide the sign of the charge
if (qop<0.) m_chargeDef.setCharge(-1);
double p=0.0;
if (qop!=0.) {
p = fabs(1./qop);
} else {
// qop is unphysical. No momentum measurement.
p = INVALID_P;
qop = INVALID_QOP;
}
// fill momentum & then position using the surface
m_momentum = Amg::Vector3D(p*cos(m_parameters[Trk::phi])*sin(m_parameters[Trk::theta]),
p*sin(m_parameters[Trk::phi])*sin(m_parameters[Trk::theta]),
p*cos(m_parameters[Trk::theta]));
if (m_surface)
m_surface->localToGlobal(this->localPosition(),m_momentum,m_position);
else {
m_momentum.setZero();
m_position.setZero();
}
}
template <int DIM,class T,class S>
Trk::ParametersT<DIM,T,S>::ParametersT(const Amg::Vector3D& pos,
const Amg::Vector3D& mom,
AmgSymMatrix(DIM)* cov):
m_parameters(),
m_covariance(cov),
m_position(pos),
m_momentum(mom),
m_surface(0),
m_chargeDef()
{}
/** equality operator */
template<int DIM,class T,class S>
bool ParametersT<DIM,T,S>::operator==(const ParametersBase<DIM,T>& rhs) const
......@@ -383,17 +338,17 @@ namespace Trk
ParametersT<DIM,T,S>::ParametersT():
ParametersBase<DIM,T>(),
m_parameters(),
m_covariance(0),
m_covariance(nullptr),
m_position(),
m_momentum(),
m_surface(0),
m_surface(nullptr),
m_chargeDef()
{}
// protected update function
template<int DIM,class T,class S>
void ParametersT<DIM,T,S>::updateParameters(const AmgVector(DIM)& updatedParameters,
AmgSymMatrix(DIM)* updatedCovariance)
AmgSymMatrix(DIM)* updatedCovariance)
{
// valid to use != here, because value is either copied or modified,
bool updatePosition = (updatedParameters[Trk::loc1] != m_parameters[Trk::loc1]) || (updatedParameters[Trk::loc2] != m_parameters[Trk::loc2]);
......@@ -406,17 +361,17 @@ namespace Trk
// update the covariance
if (updatedCovariance){
if (updatedCovariance != m_covariance)
delete m_covariance;
delete m_covariance;
m_covariance = updatedCovariance;
}
//position or momentum update needed
if (updatePosition){
if(m_surface)
m_surface->localToGlobal(this->localPosition(),m_momentum,m_position);
m_surface->localToGlobal(this->localPosition(),m_momentum,m_position);
else
{
m_momentum.setZero();
m_position.setZero();
m_momentum.setZero();
m_position.setZero();
}
}
// momentum update is needed
......@@ -429,4 +384,53 @@ namespace Trk
m_momentum = Amg::Vector3D(p*cos(phi)*sin(theta),p*sin(phi)*sin(theta),p*cos(theta));
}
}
//special C-tor used by the curvilinear parameters
template <int DIM,class T,class S>
Trk::ParametersT<DIM,T,S>::ParametersT(const Amg::Vector3D& pos,
const Amg::Vector3D& mom,
AmgSymMatrix(DIM)* cov):
m_parameters(),
m_covariance(cov),
m_position(pos),
m_momentum(mom),
m_surface(nullptr),
m_chargeDef()
{}
// Protected Constructor with local arguments - persistency only, ownership of surface given
template <int DIM,class T,class S>
Trk::ParametersT<DIM,T,S>::ParametersT(const AmgVector(DIM)& pars,
const S* surface,
AmgSymMatrix(DIM)* cov) :
ParametersBase<DIM,T>(),
m_parameters(pars),
m_covariance(cov),
m_surface(surface)
{
float qop = m_parameters[Trk::qOverP];
// decide the sign of the charge
if (qop<0.) m_chargeDef.setCharge(-1);
double p=0.0;
if (qop!=0.) {
p = fabs(1./qop);
} else {
// qop is unphysical. No momentum measurement.
p = INVALID_P;
qop = INVALID_QOP;
}
// fill momentum & then position using the surface
m_momentum = Amg::Vector3D(p*cos(m_parameters[Trk::phi])*sin(m_parameters[Trk::theta]),
p*sin(m_parameters[Trk::phi])*sin(m_parameters[Trk::theta]),
p*cos(m_parameters[Trk::theta]));
if (m_surface)
m_surface->localToGlobal(this->localPosition(),m_momentum,m_position);
else {
m_momentum.setZero();
m_position.setZero();
}
}
} // end of namespace Trk
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment