9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/unit_test.hpp>
50 namespace tt = boost::test_tools;
55 using namespace UnitLiterals;
75 Vector4 mPos4(-3_m, 0., 0., 0.);
81 const std::shared_ptr<const TrackingGeometry>& geo,
83 const double stripFrac = 0.4) {
88 const auto geoId = testslink.m_geometryId;
91 const double stripLength = 40.;
92 const double end1x = lpos[0] + stripLength * stripFrac;
93 const double end1y = lpos[1];
94 const double end2x = lpos[0] - stripLength * (1 - stripFrac);
95 const double end2y = lpos[1];
96 const Vector2 lpos1(end1x, end1y);
97 const Vector2 lpos2(end2x, end2y);
99 auto gPos1 = surface->
localToGlobal(gctx, lpos1, globalFakeMom);
100 auto gPos2 = surface->
localToGlobal(gctx, lpos2, globalFakeMom);
102 return std::make_pair(gPos1, gPos2);
131 std::shared_ptr<const TrackingGeometry> geo) {
133 cfg.resolvePassive =
false;
134 cfg.resolveMaterial =
true;
135 cfg.resolveSensitive =
true;
144 std::default_random_engine
rng(42);
149 double phi = 5._degree;
150 double theta = 95._degree;
160 auto field = std::make_shared<ConstantBField>(
Vector3(0.0, 0.0, 2._T));
169 const auto sourceLinks = measurements.sourceLinks;
171 std::vector<SourceLink> frontSourceLinks;
172 std::vector<SourceLink> backSourceLinks;
173 std::vector<SourceLink> singleHitSourceLinks;
175 std::vector<const Vector3*> frontStripEnds;
176 std::vector<const Vector3*> backStripEnds;
178 for (
auto& sl : sourceLinks) {
179 const auto geoId = sl.m_geometryId;
180 const auto volumeId = geoId.volume();
182 singleHitSourceLinks.emplace_back(
SourceLink{sl});
183 }
else if (volumeId == 3) {
185 const auto layerId = geoId.layer();
187 if (layerId == 2 || layerId == 6) {
188 frontSourceLinks.emplace_back(
SourceLink{sl});
189 }
else if (layerId == 4 || layerId == 8) {
195 BOOST_CHECK_EQUAL(frontSourceLinks.size(), 2);
196 BOOST_CHECK_EQUAL(backSourceLinks.size(), 2);
201 boost::container::static_vector<SourceLink, 2> slinks)
207 spBuilderConfig.trackingGeometry =
geometry;
210 spBuilderConfig.slSurfaceAccessor
211 .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor);
218 spBuilderConfig_perp.trackingGeometry =
geometry;
219 spBuilderConfig_perp.slSurfaceAccessor
220 .connect<&TestSourceLink::SurfaceAccessor::operator()>(&surfaceAccessor);
222 spBuilderConfig_perp.usePerpProj =
true;
224 auto spBuilder_perp =
238 cov.topLeftCorner<2, 2>() = testslink.covariance;
240 return std::make_pair(param, cov);
243 for (
auto& sl : singleHitSourceLinks) {
244 std::vector<SourceLink> slinks;
245 slinks.emplace_back(sl);
249 spBuilder.buildSpacePoint(
geoCtx, slinks, spOpt,
250 std::back_inserter(spacePoints));
252 BOOST_CHECK_EQUAL(spacePoints.size(), 2);
253 std::vector<std::pair<SourceLink, SourceLink>> slinkPairs;
260 spBuilder.makeSourceLinkPairs(
tgContext, frontSourceLinks, backSourceLinks,
261 slinkPairs, pairOpt);
263 BOOST_CHECK_EQUAL(slinkPairs.size(), 2);
265 for (
auto& slinkPair : slinkPairs) {
266 const std::pair<Vector3, Vector3> end1 =
268 const std::pair<Vector3, Vector3> end2 =
271 std::shared_ptr<const TestSpacePoint> spacePoint =
nullptr;
273 auto strippair = std::make_pair(end1, end2);
274 std::vector<SourceLink> slinks;
275 slinks.emplace_back(slinkPair.first);
276 slinks.emplace_back(slinkPair.second);
281 spBuilder.buildSpacePoint(
geoCtx, slinks, spOpt,
282 std::back_inserter(spacePoints));
285 spBuilder_perp.buildSpacePoint(
geoCtx, slinks, spOpt,
286 std::back_inserter(spacePoints));
289 const std::pair<Vector3, Vector3> end3 =
291 const std::pair<Vector3, Vector3> end4 =
294 const std::pair<Vector3, Vector3> end5 =
296 const std::pair<Vector3, Vector3> end6 =
301 spBuilderConfig_badStrips.trackingGeometry =
geometry;
302 spBuilderConfig_badStrips.slSurfaceAccessor
303 .connect<&TestSourceLink::SurfaceAccessor::operator()>(
307 spBuilderConfig_badStrips, spConstructor);
311 spOpt_badStrips1.
vertex = vertex;
312 spOpt_badStrips1.stripLengthTolerance = 0.0001;
313 spOpt_badStrips1.stripLengthGapTolerance = 50.;
314 spBuilder_badStrips.buildSpacePoint(
geoCtx, slinks, spOpt_badStrips1,
315 std::back_inserter(spacePoints_extra));
319 spOpt_badStrips2.
vertex = vertex;
320 spOpt_badStrips2.stripLengthTolerance = 0.0001;
321 spOpt_badStrips2.stripLengthGapTolerance = 50.;
322 spBuilder_badStrips.buildSpacePoint(
geoCtx, slinks, spOpt_badStrips2,
323 std::back_inserter(spacePoints_extra));
326 for (
auto& sp : spacePoints) {
327 std::cout <<
"space point (" << sp.x() <<
" " << sp.y() <<
" " << sp.z()
328 <<
") var (r,z): " << sp.varianceR() <<
" " << sp.varianceZ()
331 std::cout <<
"space points produced with bad strips:" << std::endl;
332 for (
auto& sp : spacePoints_extra) {
333 std::cout <<
"space point (" << sp.x() <<
" " << sp.y() <<
" " << sp.z()
334 <<
") var (r,z): " << sp.varianceR() <<
" " << sp.varianceZ()
338 BOOST_CHECK_EQUAL(spacePoints.size(), 6);