55// This Source Code Form is subject to the terms of the Mozilla Public
66// License, v. 2.0. If a copy of the MPL was not distributed with this
77// file, You can obtain one at http://mozilla.org/MPL/2.0/.
8-
98namespace Acts {
9+
1010template <typename spacepoint_t >
1111SpacePointBuilder<spacepoint_t >::SpacePointBuilder(
1212 const SpacePointBuilderConfig& cfg,
@@ -21,22 +21,21 @@ SpacePointBuilder<spacepoint_t>::SpacePointBuilder(
2121template <typename spacepoint_t >
2222template <template <typename ...> typename container_t >
2323void SpacePointBuilder<spacepoint_t >::buildSpacePoint(
24- const GeometryContext& gctx,
25- const std::vector<const Measurement*>& measurements,
24+ const GeometryContext& gctx, const std::vector<SourceLink>& sourceLinks,
2625 const SpacePointBuilderOptions& opt,
2726 std::back_insert_iterator<container_t <spacepoint_t >> spacePointIt) const {
28- const unsigned int num_meas = measurements .size ();
27+ const unsigned int num_slinks = sourceLinks .size ();
2928
3029 Acts::Vector3 gPos = Acts::Vector3::Zero ();
3130 Acts::Vector2 gCov = Acts::Vector2::Zero ();
3231
33- if (num_meas == 1 ) { // pixel SP formation
34-
35- auto gPosCov = m_spUtility->globalCoords (gctx, *(measurements[0 ]));
32+ if (num_slinks == 1 ) { // pixel SP formation
33+ auto slink = sourceLinks.at (0 );
34+ auto [param, cov] = opt.paramCovAccessor (sourceLinks.at (0 ));
35+ auto gPosCov = m_spUtility->globalCoords (gctx, slink, param, cov);
3636 gPos = gPosCov .first ;
3737 gCov = gPosCov .second ;
38-
39- } else if (num_meas == 2 ) { // strip SP formation
38+ } else if (num_slinks == 2 ) { // strip SP formation
4039
4140 const auto & ends1 = opt.stripEndsPair .first ;
4241 const auto & ends2 = opt.stripEndsPair .second ;
@@ -46,12 +45,11 @@ void SpacePointBuilder<spacepoint_t>::buildSpacePoint(
4645 if (!m_config.usePerpProj ) { // default strip SP building
4746
4847 auto spFound = m_spUtility->calculateStripSPPosition (
49- ends1, ends2, m_config.vertex , spParams,
50- m_config.stripLengthTolerance );
48+ ends1, ends2, opt.vertex , spParams, opt.stripLengthTolerance );
5149
5250 if (!spFound.ok ()) {
53- spFound = m_spUtility->recoverSpacePoint (
54- spParams, m_config .stripLengthGapTolerance );
51+ spFound = m_spUtility->recoverSpacePoint (spParams,
52+ opt .stripLengthGapTolerance );
5553 }
5654
5755 if (!spFound.ok ()) {
@@ -76,75 +74,59 @@ void SpacePointBuilder<spacepoint_t>::buildSpacePoint(
7674 acos (spParams.firstBtmToTop .dot (spParams.secondBtmToTop ) /
7775 (spParams.firstBtmToTop .norm () * spParams.secondBtmToTop .norm ()));
7876
79- gCov = m_spUtility->calcRhoZVars (gctx, *(measurements .at (0 )),
80- *(measurements. at ( 1 )) , gPos , theta);
77+ gCov = m_spUtility->calcRhoZVars (gctx, sourceLinks .at (0 ), sourceLinks. at ( 1 ),
78+ opt. paramCovAccessor , gPos , theta);
8179
8280 } else {
83- ACTS_ERROR (" More than 2 measurements are given for a space point." );
84- }
85-
86- boost::container::static_vector<SourceLink, 2 > slinks;
87- for (const auto & meas : measurements) {
88- const auto & slink =
89- std::visit ([](const auto & x) { return x.sourceLink (); }, *meas);
90- slinks.emplace_back (slink);
81+ ACTS_ERROR (" More than 2 sourceLinks are given for a space point." );
9182 }
83+ boost::container::static_vector<SourceLink, 2 > slinks (sourceLinks.begin (),
84+ sourceLinks.end ());
9285
9386 spacePointIt = m_spConstructor (gPos , gCov , std::move (slinks));
9487}
9588
9689template <typename spacepoint_t >
97- void SpacePointBuilder<spacepoint_t >::makeMeasurementPairs(
98- const GeometryContext& gctx,
99- const std::vector<const Measurement*>& measurementsFront,
100- const std::vector<const Measurement*>& measurementsBack,
101- std::vector<std::pair<const Measurement*, const Measurement*>>&
102- measurementPairs) const {
103- // Return if no Measurements are given in a vector
104- if (measurementsFront.empty () || measurementsBack.empty ()) {
90+ void SpacePointBuilder<spacepoint_t >::makeSourceLinkPairs(
91+ const GeometryContext& gctx, const std::vector<SourceLink>& slinksFront,
92+ const std::vector<SourceLink>& slinksBack,
93+ std::vector<std::pair<SourceLink, SourceLink>>& slinkPairs,
94+ const StripPairOptions& pairOpt) const {
95+ if (slinksFront.empty () || slinksBack.empty ()) {
10596 return ;
10697 }
107- // Declare helper variables
108- double currentDiff = 0 ;
109- double diffMin = 0 ;
110- unsigned int measurementMinDist = 0 ;
111-
112- // Walk through all Measurements on both surfaces
113- for (unsigned int iMeasurementsFront = 0 ;
114- iMeasurementsFront < measurementsFront.size (); iMeasurementsFront++) {
115- // Set the closest distance to the maximum of double
116- diffMin = std::numeric_limits<double >::max ();
117- // Set the corresponding index to an element not in the list of Measurements
118- measurementMinDist = measurementsBack.size ();
119- for (unsigned int iMeasurementsBack = 0 ;
120- iMeasurementsBack < measurementsBack.size (); iMeasurementsBack++) {
121- auto [gposFront, gcovFront] = m_spUtility->globalCoords (
122- gctx, *(measurementsFront[iMeasurementsFront]));
123- auto [gposBack, gcovBack] = m_spUtility->globalCoords (
124- gctx, *(measurementsBack[iMeasurementsBack]));
98+ double minDistance = 0 ;
99+ unsigned int closestIndex = 0 ;
100+
101+ for (unsigned int i = 0 ; i < slinksFront.size (); i++) {
102+ const auto & slinkFront = slinksFront[i];
103+ minDistance = std::numeric_limits<double >::max ();
104+ closestIndex = slinksBack.size ();
105+ for (unsigned int j = 0 ; j < slinksBack.size (); j++) {
106+ const auto & slinkBack = slinksBack[j];
107+
108+ const auto [paramFront, covFront] = pairOpt.paramCovAccessor (slinkFront);
109+ const auto [gposFront, gcovFront] =
110+ m_spUtility->globalCoords (gctx, slinkFront, paramFront, covFront);
111+
112+ const auto [paramBack, covBack] = pairOpt.paramCovAccessor (slinkBack);
113+ const auto [gposBack, gcovBack] =
114+ m_spUtility->globalCoords (gctx, slinkBack, paramBack, covBack);
125115
126116 auto res = m_spUtility->differenceOfMeasurementsChecked (
127- gposFront, gposBack, m_config .vertex , m_config .diffDist ,
128- m_config .diffPhi2 , m_config .diffTheta2 );
117+ gposFront, gposBack, pairOpt .vertex , pairOpt .diffDist ,
118+ pairOpt .diffPhi2 , pairOpt .diffTheta2 );
129119 if (!res.ok ()) {
130120 continue ;
131121 }
132-
133- currentDiff = res.value ();
134-
135- // Store the closest Measurements (distance and index) calculated so far
136- if (currentDiff < diffMin && currentDiff >= 0 .) {
137- diffMin = currentDiff;
138- measurementMinDist = iMeasurementsBack;
122+ const auto distance = res.value ();
123+ if (distance >= 0 . && distance < minDistance) {
124+ minDistance = distance;
125+ closestIndex = j;
139126 }
140127 }
141-
142- // Store the best (=closest) result
143- if (measurementMinDist < measurementsBack.size ()) {
144- std::pair<const Measurement*, const Measurement*> measurementPair =
145- std::make_pair (measurementsFront[iMeasurementsFront],
146- measurementsBack[measurementMinDist]);
147- measurementPairs.push_back (measurementPair);
128+ if (closestIndex < slinksBack.size ()) {
129+ slinkPairs.emplace_back (slinksFront[i], slinksBack[closestIndex]);
148130 }
149131 }
150132}
0 commit comments