9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
51 #include <system_error>
53 #include <type_traits>
60 using namespace Acts::UnitLiterals;
67 using Linearizer = HelicalTrackLinearizer<Propagator>;
76 std::uniform_real_distribution<>
vXYDist(-0.1_mm, 0.1_mm);
78 std::uniform_real_distribution<>
vZDist(-20_mm, 20_mm);
80 std::uniform_real_distribution<>
d0Dist(-0.01_mm, 0.01_mm);
82 std::uniform_real_distribution<>
z0Dist(-0.2_mm, 0.2_mm);
84 std::uniform_real_distribution<>
pTDist(0.4_GeV, 10_GeV);
86 std::uniform_real_distribution<>
phiDist(-M_PI, M_PI);
88 std::uniform_real_distribution<>
thetaDist(1.0, M_PI - 1.0);
90 std::uniform_real_distribution<>
qDist(-1, 1);
92 std::uniform_real_distribution<>
resIPDist(0., 100_um);
94 std::uniform_real_distribution<>
resAngDist(0., 0.1);
96 std::uniform_real_distribution<>
resQoPDist(-0.01, 0.01);
100 std::uniform_int_distribution<>
nTracksDist(5, 15);
122 std::mt19937
gen(mySeed);
127 for (
unsigned int iEvent = 0; iEvent <
nEvents; ++iEvent) {
129 auto bField = std::make_shared<ConstantBField>(
Vector3{0.0, 0.0, 1_T});
135 auto propagator = std::make_shared<Propagator>(
stepper);
141 using BilloirFitter =
147 BilloirFitter bFitter(vertexFitterCfg);
153 IPEstimator ipEstimator(ipEstimatorCfg);
157 static_assert(VertexFinderConcept<ZScanSeedFinder>,
158 "Vertex finder does not fulfill vertex finder concept.");
162 ZScanSeedFinder sFinder(seedFinderCfg);
167 static_assert(VertexFinderConcept<VertexFinder>,
168 "Vertex finder does not fulfill vertex finder concept.");
173 cfg.reassignTracksAfterFirstFit =
true;
175 VertexFinder finder(cfg);
179 std::vector<std::unique_ptr<const BoundTrackParameters>>
tracks;
181 std::vector<const BoundTrackParameters*> tracksPtr;
184 std::vector<Vertex<BoundTrackParameters>> trueVertices;
188 for (
unsigned int iVertex = 0; iVertex < nVertices; ++iVertex) {
193 std::cout <<
"Event " << iEvent <<
", Vertex " << iVertex <<
"/"
194 << nVertices <<
" with " << nTracks <<
" tracks."
198 std::shared_ptr<PerigeeSurface> perigeeSurface =
199 Surface::makeShared<PerigeeSurface>(
Vector3(0., 0., 0.));
208 std::vector<TrackAtVertex<BoundTrackParameters>> tracksAtTrueVtx;
211 double d0_v = std::hypot(x, y);
216 for (
unsigned int iTrack = 0; iTrack < nTracks; iTrack++) {
218 double q =
qDist(gen) < 0 ? -1. : 1.;
222 double z0track = z0_v +
z0Dist(gen);
235 covMat << res_d0 * res_d0, 0., 0., 0., 0., 0., 0., res_z0 * res_z0, 0.,
236 0., 0., 0., 0., 0., res_ph * res_ph, 0., 0., 0., 0., 0., 0.,
237 res_th * res_th, 0., 0., 0., 0., 0., 0., res_qp * res_qp, 0., 0.,
243 tracks.push_back(std::make_unique<BoundTrackParameters>(params));
246 tracks.back().get());
247 tracksAtTrueVtx.push_back(trAtVt);
251 trueVertices.push_back(trueV);
258 for (
const auto& trk : tracks) {
259 tracksPtr.push_back(trk.get());
266 auto res = finder.find(tracksPtr, vertexingOptions, state);
268 BOOST_CHECK(res.ok());
271 std::cout << res.error().message() << std::endl;
275 auto vertexCollection = *res;
281 std::cout <<
"########## RESULT: ########## Event " << iEvent
283 std::cout <<
"Number of true vertices: " << nVertices << std::endl;
284 std::cout <<
"Number of reco vertices: " << vertexCollection.size()
288 std::cout <<
"----- True vertices -----" << std::endl;
289 for (
const auto&
vertex : trueVertices) {
291 std::cout << count <<
". True Vertex:\t Position:"
292 <<
"(" << pos[
eX] <<
"," << pos[
eY] <<
"," << pos[
eZ] <<
")"
294 std::cout <<
"Number of tracks: " <<
vertex.tracks().size() << std::endl
298 std::cout <<
"----- Reco vertices -----" << std::endl;
300 for (
const auto&
vertex : vertexCollection) {
302 std::cout << count <<
". Reco Vertex:\t Position:"
303 <<
"(" << pos[
eX] <<
"," << pos[
eY] <<
"," << pos[
eZ] <<
")"
305 std::cout <<
"Number of tracks: " <<
vertex.tracks().size() << std::endl
312 bool allVerticesFound =
true;
313 for (
const auto& trueVertex : trueVertices) {
314 Vector4 truePos = trueVertex.fullPosition();
315 bool currentVertexFound =
false;
316 for (
const auto& recoVertex : vertexCollection) {
317 Vector4 recoPos = recoVertex.fullPosition();
319 double zDistance = std::abs(truePos[
eZ] - recoPos[
eZ]);
320 if (zDistance < 2_mm) {
321 currentVertexFound =
true;
324 if (!currentVertexFound) {
325 allVerticesFound =
false;
330 BOOST_CHECK(allVerticesFound);
343 std::mt19937
gen(mySeed);
348 for (
unsigned int iEvent = 0; iEvent <
nEvents; ++iEvent) {
350 auto bField = std::make_shared<ConstantBField>(
Vector3{0.0, 0.0, 1_T});
356 auto propagator = std::make_shared<Propagator>(
stepper);
367 std::function<BoundTrackParameters(InputTrack)> extractParameters =
368 [](
const InputTrack& params) {
return params.parameters(); };
373 BilloirFitter bFitter(vertexFitterCfg, extractParameters);
379 IPEstimator ipEstimator(ipEstimatorCfg);
384 ZScanSeedFinder sFinder(seedFinderCfg, extractParameters);
390 cfg.reassignTracksAfterFirstFit =
true;
392 VertexFinder finder(cfg, extractParameters);
396 std::vector<std::unique_ptr<const InputTrack>>
tracks;
398 std::vector<const InputTrack*> tracksPtr;
401 std::vector<Vertex<InputTrack>> trueVertices;
405 for (
unsigned int iVertex = 0; iVertex < nVertices; ++iVertex) {
410 std::cout <<
"Event " << iEvent <<
", Vertex " << iVertex <<
"/"
411 << nVertices <<
" with " << nTracks <<
" tracks."
415 std::shared_ptr<PerigeeSurface> perigeeSurface =
416 Surface::makeShared<PerigeeSurface>(
Vector3(0., 0., 0.));
425 std::vector<TrackAtVertex<InputTrack>> tracksAtTrueVtx;
428 double d0_v = std::hypot(x, y);
433 for (
unsigned int iTrack = 0; iTrack < nTracks; iTrack++) {
435 double q =
qDist(gen) < 0 ? -1. : 1.;
439 double z0track = z0_v +
z0Dist(gen);
453 covMat << res_d0 * res_d0, 0., 0., 0., 0., 0., 0., res_z0 * res_z0, 0.,
454 0., 0., 0., 0., 0., res_ph * res_ph, 0., 0., 0., 0., 0., 0.,
455 res_th * res_th, 0., 0., 0., 0., 0., 0., res_qp * res_qp, 0., 0.,
461 tracks.push_back(std::make_unique<InputTrack>(paramsUT));
463 auto params = extractParameters(paramsUT);
466 tracksAtTrueVtx.push_back(trAtVt);
470 trueVertices.push_back(trueV);
477 for (
const auto& trk : tracks) {
478 tracksPtr.push_back(trk.get());
485 auto res = finder.find(tracksPtr, vertexingOptionsUT, state);
487 BOOST_CHECK(res.ok());
490 std::cout << res.error().message() << std::endl;
494 auto vertexCollectionUT = *res;
500 std::cout <<
"########## RESULT: ########## Event " << iEvent
502 std::cout <<
"Number of true vertices: " << nVertices << std::endl;
503 std::cout <<
"Number of reco vertices: " << vertexCollectionUT.size()
507 std::cout <<
"----- True vertices -----" << std::endl;
508 for (
const auto&
vertex : trueVertices) {
510 std::cout << count <<
". True Vertex:\t Position:"
511 <<
"(" << pos[
eX] <<
"," << pos[
eY] <<
"," << pos[
eZ] <<
")"
513 std::cout <<
"Number of tracks: " <<
vertex.tracks().size() << std::endl
517 std::cout <<
"----- Reco vertices -----" << std::endl;
519 for (
const auto&
vertex : vertexCollectionUT) {
521 std::cout << count <<
". Reco Vertex:\t Position:"
522 <<
"(" << pos[
eX] <<
"," << pos[
eY] <<
"," << pos[
eZ] <<
")"
524 std::cout <<
"Number of tracks: " <<
vertex.tracks().size() << std::endl
531 bool allVerticesFound =
true;
532 for (
const auto& trueVertex : trueVertices) {
533 Vector4 truePos = trueVertex.fullPosition();
534 bool currentVertexFound =
false;
535 for (
const auto& recoVertex : vertexCollectionUT) {
536 Vector4 recoPos = recoVertex.fullPosition();
538 double zDistance = std::abs(truePos[
eZ] - recoPos[
eZ]);
539 if (zDistance < 2_mm) {
540 currentVertexFound =
true;
543 if (!currentVertexFound) {
544 allVerticesFound =
false;
549 BOOST_CHECK(allVerticesFound);
558 auto bField = std::make_shared<ConstantBField>(
Vector3{0.0, 0.0, 2_T});
564 auto propagator = std::make_shared<Propagator>(
stepper);
570 using BilloirFitter =
576 BilloirFitter bFitter(vertexFitterCfg);
582 IPEstimator ipEstimator(ipEstimatorCfg);
586 static_assert(VertexFinderConcept<ZScanSeedFinder>,
587 "Vertex finder does not fulfill vertex finder concept.");
591 ZScanSeedFinder sFinder(seedFinderCfg);
596 static_assert(VertexFinderConcept<VertexFinder>,
597 "Vertex finder does not fulfill vertex finder concept.");
601 cfg.maxVertices = 200;
602 cfg.maximumChi2cutForSeeding = 49;
603 cfg.significanceCutSeeding = 12;
605 VertexFinder finder(cfg);
609 auto tracks = std::get<TracksData>(csvData);
611 std::vector<const BoundTrackParameters*> tracksPtr;
612 for (
const auto& trk :
tracks) {
613 tracksPtr.push_back(&trk);
621 auto findResult = finder.find(tracksPtr, vertexingOptions, state);
625 if (!findResult.ok()) {
626 std::cout << findResult.error().message() << std::endl;