7 #include "GaudiKernel/PhysicalConstants.h"
22 std::vector<const TrackParameters*> perigeeList;
23 perigeeList.reserve(vectorTrk.size());
25 for (
const Track* itrk : vectorTrk)
27 perigeeList.push_back(itrk->perigeeParameters());
41 std::unique_ptr<ITrackDensity>& density)
const
43 std::vector<const TrackParameters*> perigeeList;
44 perigeeList.reserve(vectorTrk.size());
46 for (
const Track* itrk : vectorTrk)
48 perigeeList.push_back(itrk->perigeeParameters());
71 std::unique_ptr<ITrackDensity>& density)
const
75 density = std::move(
d);
80 const std::vector<const TrackParameters*>& perigeeList)
const {
132 double firstDeriv, secondDeriv = 0;
147 double& firstDerivative,
148 double& secondDerivative)
const
151 for (
const auto & trackAndPerigeePair : m_lowerMap){
152 densityResult.
addTrack(trackAndPerigeePair.first);
154 density = densityResult.
density();
159 std::pair<double,double>
172 double maximumPosition = 0.0;
173 double maximumDensity = 0.0;
174 double maxCurvature = 0. ;
175 const std::pair<double,double> invalidResult(0.,std::numeric_limits<double>::quiet_NaN());
176 if (m_trackMap.empty())
return invalidResult;
177 for (
const auto&
entry : m_trackMap)
180 double density = 0.0;
182 double curvature = 0.0;
183 trackDensity( trialZ, density, slope, curvature );
184 if ( curvature >= 0.0 || density <= 0.0 ) {
187 updateMaximum( trialZ, density, curvature, maximumPosition, maximumDensity, maxCurvature);
188 trialZ += stepSize( density, slope, curvature );
189 trackDensity( trialZ, density, slope, curvature );
190 if ( curvature >= 0.0 || density <= 0.0 ) {
193 updateMaximum( trialZ, density, curvature, maximumPosition, maximumDensity, maxCurvature);
194 trialZ += stepSize( density, slope, curvature );
195 trackDensity( trialZ, density, slope, curvature );
196 if ( curvature >= 0.0 || density <= 0.0) {
199 updateMaximum( trialZ, density, curvature, maximumPosition, maximumDensity, maxCurvature);
201 if (maxCurvature == 0.)
return invalidResult;
202 return {maximumPosition,std::sqrt(-maximumDensity/maxCurvature)};
223 const double d0SignificanceCut,
224 const double z0SignificanceCut)
226 if (m_trackMap.count(itrk) != 0)
return;
227 const double d0 = itrk.parameters()[
Trk::d0];
228 const double z0 = itrk.parameters()[
Trk::z0];
229 const AmgSymMatrix(5) & perigeeCov = *(itrk.covariance());
231 if ( cov_dd <= 0 )
return;
232 if (
d0*
d0/cov_dd > d0SignificanceCut )
return;
234 if (cov_zz <= 0 )
return;
236 const double covDeterminant = cov_dd*cov_zz - cov_dz*cov_dz;
237 if ( covDeterminant <= 0 )
return;
238 double constantTerm = -(
d0*
d0*cov_zz +
z0*
z0*cov_dd + 2*
d0*
z0*cov_dz) / (2*covDeterminant);
239 const double linearTerm = (
d0*cov_dz +
z0*cov_dd) / covDeterminant ;
240 const double quadraticTerm = -cov_dd / (2*covDeterminant);
241 double discriminant = linearTerm*linearTerm - 4*quadraticTerm*(constantTerm + 2*z0SignificanceCut);
244 const double zMax = (-linearTerm -
discriminant)/(2*quadraticTerm);
245 const double zMin = (-linearTerm +
discriminant)/(2*quadraticTerm);
247 constantTerm -=
std::log(2*
M_PI*std::sqrt(covDeterminant));
248 m_trackMap.emplace(std::piecewise_construct,
249 std::forward_as_tuple(itrk),
250 std::forward_as_tuple(constantTerm, linearTerm, quadraticTerm, zMin, zMax));
251 m_lowerMap.emplace(std::piecewise_construct,
252 std::forward_as_tuple(constantTerm, linearTerm, quadraticTerm, zMin, zMax),
253 std::forward_as_tuple(itrk));
258 if (
entry.lowerBound < m_z &&
entry.upperBound > m_z) {
261 double deltaPrime = delta * qPrime;
263 m_firstDerivative += deltaPrime;
264 m_secondDerivative += 2*
entry.c_2*delta + qPrime*deltaPrime;