Commit e7c66341 authored by Goetz Gaycken's avatar Goetz Gaycken
Browse files

Avoid unnecessary creation of temporary objects.

parent b62b7869
Pipeline #4732373 passed with stage
in 0 seconds
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
/////////////////////////////////////////////////////////////////////////////////
......@@ -135,6 +135,12 @@ namespace InDet{
const Trk::PatternTrackParameters& parametersUB() const {return m_parametersUpdatedBackward;}
const Trk::PatternTrackParameters& parametersSM() const {return m_parametersSM;}
/** @brief return pattern parameters matching the status of this element
* @return nullptr or pointer to the internal pattern track parameters PF, UF, PB, UB, SM depending on m_status and m_cluster
* The returned pointer is owned by this element.
*/
const Trk::PatternTrackParameters* parameters() const;
const Trk::Surface* surface() const {return m_surface;}
const InDet::SiClusterLink_xk& linkF (int i) const {return m_linkForward[i];}
const InDet::SiClusterLink_xk& linkB (int i) const {return m_linkBackward[i];}
......
......@@ -769,3 +769,30 @@ void InDet::SiTrajectoryElement_xk::CloseClusterSeach
m_cluster = m_linkForward[0].cluster();
m_xi2Forward = m_linkForward[0].xi2 ();
}
inline const Trk::PatternTrackParameters *
InDet::SiTrajectoryElement_xk::parameters() const
{
// logic from SiTrajectoryElement_xk::trackParameters(bool, int Q) with Q==1
if (m_status == 1) {
if (m_cluster) {
return &m_parametersUpdatedForward;
} else {
return &m_parametersPredForward;
}
} else if (m_status == 2) {
if (m_cluster) {
return &m_parametersUpdatedBackward;
} else {
return &m_parametersPredBackward;
}
} else if (m_status == 3) {
if (m_cluster) {
return &m_parametersUpdatedBackward;
}
}
return nullptr;
}
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
/////////////////////////////////////////////////////////////////////////////////
......@@ -113,6 +113,13 @@ namespace InDet{
bool filterWithPreciseClustersError();
bool backwardSmoother (bool);
bool isLastPixel ();
/** @brief Return the pattern track parameters of the first element of this trajectory matching its status
* @return nullptr or a pointer to the element owned pattern track parameters matching the current status
* of the trajectory element.
*/
const Trk::PatternTrackParameters *firstParameters();
std::unique_ptr<Trk::TrackParameters> firstTrackParameters();
void getClusters(std::list<const InDet::SiCluster*>&);
......
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
#include "TrkSurfaces/PlaneSurface.h"
......@@ -70,6 +70,10 @@ inline bool InDet::SiTrajectory_xk::isLastPixel()
return false;
}
inline const Trk::PatternTrackParameters *InDet::SiTrajectory_xk::firstParameters() {
return m_elements[m_elementsMap[m_firstElement]].parameters();
}
inline std::unique_ptr<Trk::TrackParameters> InDet::SiTrajectory_xk::firstTrackParameters()
{
return m_elements[m_elementsMap[m_firstElement]].trackParameters(false,1);
......
......@@ -104,8 +104,7 @@ StatusCode InDet::SiCombinatorialTrackFinder_xk::initialize()
ATH_CHECK( m_fieldCondObjInputKey.initialize() );
ATH_CHECK( m_pixelDetElStatus.initialize( !m_pixelDetElStatus.empty() && m_usePIX) );
ATH_CHECK( m_sctDetElStatus.initialize( !m_sctDetElStatus.empty() && m_useSCT) );
auto ptCutVal = m_minPtCut.value();
m_minPt2Cut = ptCutVal * ptCutVal;
m_minPt2Cut = std::pow(m_minPtCut.value(),2);
return StatusCode::SUCCESS;
}
......@@ -803,14 +802,13 @@ InDet::SiCombinatorialTrackFinder_xk::EStat_t InDet::SiCombinatorialTrackFinder_
Trk::Track* InDet::SiCombinatorialTrackFinder_xk::convertToTrack(SiCombinatorialTrackFinderData_xk& data) const
{
std::unique_ptr<Trk::TrackParameters> param = data.trajectory().firstTrackParameters();
const Trk::PatternTrackParameters *param = data.trajectory().firstParameters();
if (param) {
auto momentum = param->momentum();
const auto pt2 = momentum.perp2();
double pt = param->transverseMomentum();
// reject tracks with small pT
// The cut should be large enough otherwise eta computation of such tracks may yield NANs.
if (pt2 < m_minPt2Cut) {
ATH_MSG_DEBUG( "Reject low pT track (pT = " << std::sqrt(pt2) << " < " << m_minPtCut.value() << ")");
if (pt < m_minPtCut.value()) {
ATH_MSG_DEBUG( "Reject low pT track (pT = " << pt << " < " << m_minPtCut.value() << ")");
return nullptr;
}
}
......
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
/////////////////////////////////////////////////////////////////////////////////
......@@ -62,6 +62,7 @@ namespace Trk {
double cosTheta () const;
double cotTheta () const;
void changeDirection () ;
double transverseMomentum() const;
virtual Amg::Vector3D position() const override final;
virtual Amg::Vector3D momentum() const override final;
......@@ -150,7 +151,8 @@ namespace Trk {
Amg::Vector3D calculatePosition(void) const;
Amg::Vector3D calculateMomentum(void) const;
double absoluteMomentum() const;
private:
std::string to_string() const;
};
......@@ -362,7 +364,7 @@ namespace Trk {
} else {
return -1.0;
}
}
}
inline double PatternTrackParameters::sinPhi () const
{
......@@ -393,6 +395,19 @@ namespace Trk {
{
return calculateMomentum();
}
inline double PatternTrackParameters::absoluteMomentum() const
{
return m_parameters[4] != 0. ? 1. / std::abs(m_parameters[4]) : 10e9;
}
inline double PatternTrackParameters::transverseMomentum() const
{
double p = absoluteMomentum();
double Se = std::sin(m_parameters[3]);
return p * Se;
}
} // end of name space
#endif // PatternTrackParameters
/*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/
/////////////////////////////////////////////////////////////////////////////////
......@@ -501,7 +501,7 @@ Amg::Vector3D Trk::PatternTrackParameters::calculatePosition(void) const {
}
Amg::Vector3D Trk::PatternTrackParameters::calculateMomentum(void) const {
double p = m_parameters[4] != 0. ? 1. / std::abs(m_parameters[4]) : 10e9;
double p = absoluteMomentum();
double Sf = std::sin(m_parameters[2]), Cf = std::cos(m_parameters[2]);
double Se = std::sin(m_parameters[3]), Ce = std::cos(m_parameters[3]);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment