Skip to content
Snippets Groups Projects
Commit a12f7037 authored by Christos Anastopoulos's avatar Christos Anastopoulos Committed by Frank Winklmeier
Browse files

GaussianDensity : Try to avoid dynamic_cast

parent bbae0bc0
No related branches found
No related tags found
No related merge requests found
...@@ -112,14 +112,11 @@ namespace Trk ...@@ -112,14 +112,11 @@ namespace Trk
const double d0SignificanceCut = m_d0MaxSignificance * m_d0MaxSignificance; const double d0SignificanceCut = m_d0MaxSignificance * m_d0MaxSignificance;
const double z0SignificanceCut = m_z0MaxSignificance * m_z0MaxSignificance; const double z0SignificanceCut = m_z0MaxSignificance * m_z0MaxSignificance;
for (const TrackParameters* iparam : perigeeList) for (const TrackParameters* iparam : perigeeList) {
{ if (iparam && iparam->surfaceType() == Trk::Surface::Perigee) {
const Perigee* itrk = dynamic_cast<const Perigee*>(iparam); density.addTrack(*(static_cast<const Perigee*>(iparam)),
if (itrk != nullptr) d0SignificanceCut,
{ z0SignificanceCut);
density.addTrack (*itrk,
d0SignificanceCut,
z0SignificanceCut);
} }
} }
} }
...@@ -129,12 +126,12 @@ namespace Trk ...@@ -129,12 +126,12 @@ namespace Trk
GaussianTrackDensity::TrackEntry::TrackEntry(double c0, double c1, double c2, GaussianTrackDensity::TrackEntry::TrackEntry(double c0, double c1, double c2,
double zMin, double zMax) double zMin, double zMax)
: c_0(c0), c_1(c1), c_2(c2), lowerBound(zMin), upperBound(zMax) : c_0(c0), c_1(c1), c_2(c2), lowerBound(zMin), upperBound(zMax)
{ } { }
// Dummy constructor for binary search // Dummy constructor for binary search
GaussianTrackDensity::TrackEntry::TrackEntry(double z) GaussianTrackDensity::TrackEntry::TrackEntry(double z)
: c_0(0), c_1(0), c_2(0), lowerBound(z), upperBound(z) : c_0(0), c_1(0), c_2(0), lowerBound(z), upperBound(z)
{ } { }
...@@ -149,10 +146,10 @@ namespace Trk ...@@ -149,10 +146,10 @@ namespace Trk
double GaussianTrackDensity::TrackDensity::trackDensity (double z) const double GaussianTrackDensity::TrackDensity::trackDensity (double z) const
{ {
double firstDeriv, secondDeriv = 0; // unused in this case double firstDeriv, secondDeriv = 0; // unused in this case
double density = 0; double density = 0;
// use the existing trackDensity method to avoid duplication of logic // use the existing trackDensity method to avoid duplication of logic
trackDensity(z,density,firstDeriv,secondDeriv); trackDensity(z,density,firstDeriv,secondDeriv);
return density; return density;
} }
...@@ -168,14 +165,14 @@ namespace Trk ...@@ -168,14 +165,14 @@ namespace Trk
{ {
TrackDensityEval densityResult(z); TrackDensityEval densityResult(z);
for (const auto & trackAndPerigeePair : m_lowerMap){ for (const auto & trackAndPerigeePair : m_lowerMap){
densityResult.addTrack(trackAndPerigeePair.first); densityResult.addTrack(trackAndPerigeePair.first);
} }
density = densityResult.density(); density = densityResult.density();
firstDerivative = densityResult.firstDerivative(); firstDerivative = densityResult.firstDerivative();
secondDerivative = densityResult.secondDerivative(); secondDerivative = densityResult.secondDerivative();
} }
std::pair<double,double> std::pair<double,double>
GaussianTrackDensity::TrackDensity::globalMaximumWithWidth (MsgStream& msg) const GaussianTrackDensity::TrackDensity::globalMaximumWithWidth (MsgStream& msg) const
{ {
// strategy: // strategy:
...@@ -200,7 +197,7 @@ namespace Trk ...@@ -200,7 +197,7 @@ namespace Trk
double slope = 0.0; double slope = 0.0;
double curvature = 0.0; double curvature = 0.0;
trackDensity( trialZ, density, slope, curvature ); trackDensity( trialZ, density, slope, curvature );
if ( curvature >= 0.0 || density <= 0.0 ) continue; if ( curvature >= 0.0 || density <= 0.0 ) continue;
updateMaximum( trialZ, density, curvature, maximumPosition, maximumDensity, maxCurvature); updateMaximum( trialZ, density, curvature, maximumPosition, maximumDensity, maxCurvature);
trialZ += stepSize( density, slope, curvature ); trialZ += stepSize( density, slope, curvature );
trackDensity( trialZ, density, slope, curvature ); trackDensity( trialZ, density, slope, curvature );
......
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