9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
33 using namespace Acts::UnitLiterals;
39 using Propagator = Propagator<EigenStepper<ConstantBField>>;
40 using Linearizer = HelicalTrackLinearizer<Propagator>;
49 std::uniform_real_distribution<>
vXYDist(-0.1_mm, 0.1_mm);
51 std::uniform_real_distribution<>
vZDist(-20_mm, 20_mm);
53 std::uniform_real_distribution<>
d0Dist(-0.01_mm, 0.01_mm);
55 std::uniform_real_distribution<>
z0Dist(-0.2_mm, 0.2_mm);
57 std::uniform_real_distribution<>
pTDist(0.4_GeV, 10_GeV);
63 std::uniform_real_distribution<>
qDist(-1, 1);
65 std::uniform_real_distribution<>
resIPDist(0., 100_um);
67 std::uniform_real_distribution<>
resAngDist(0., 0.1);
69 std::uniform_real_distribution<>
resQoPDist(-0.01, 0.01);
95 std::mt19937 gen(mySeed);
100 for (
unsigned int iEvent = 0; iEvent <
nEvents; ++iEvent) {
108 auto propagator = std::make_shared<Propagator>(
stepper);
114 using BilloirFitter =
120 BilloirFitter bFitter(vertexFitterCfg);
126 IPEstimator ipEstimator(ipEstimatorCfg);
130 static_assert(VertexFinderConcept<ZScanSeedFinder>,
131 "Vertex finder does not fulfill vertex finder concept.");
135 ZScanSeedFinder sFinder(seedFinderCfg);
140 static_assert(VertexFinderConcept<VertexFinder>,
141 "Vertex finder does not fulfill vertex finder concept.");
146 cfg.reassignTracksAfterFirstFit =
true;
152 std::vector<std::unique_ptr<const BoundTrackParameters>> tracks;
154 std::vector<const BoundTrackParameters*> tracksPtr;
157 std::vector<Vertex<BoundTrackParameters>> trueVertices;
161 for (
unsigned int iVertex = 0; iVertex < nVertices; ++iVertex) {
166 std::cout <<
"Event " << iEvent <<
", Vertex " << iVertex <<
"/"
167 << nVertices <<
" with " << nTracks <<
" tracks."
171 std::shared_ptr<PerigeeSurface> perigeeSurface =
172 Surface::makeShared<PerigeeSurface>(
Vector3D(0., 0., 0.));
181 std::vector<TrackAtVertex<BoundTrackParameters>> tracksAtTrueVtx;
184 double d0_v = sqrt(x * x + y * y);
189 for (
unsigned int iTrack = 0; iTrack < nTracks; iTrack++) {
191 double q =
qDist(gen) < 0 ? -1. : 1.;
195 double z0track = z0_v +
z0Dist(gen);
208 covMat << res_d0 * res_d0, 0., 0., 0., 0., 0., 0., res_z0 * res_z0, 0.,
209 0., 0., 0., 0., 0., res_ph * res_ph, 0., 0., 0., 0., 0., 0.,
210 res_th * res_th, 0., 0., 0., 0., 0., 0., res_qp * res_qp, 0., 0.,
215 tracks.push_back(std::make_unique<BoundTrackParameters>(params));
218 tracks.back().get());
219 tracksAtTrueVtx.push_back(trAtVt);
223 trueVertices.push_back(trueV);
228 std::shuffle(std::begin(tracks), std::end(tracks), gen);
230 for (
const auto& trk : tracks) {
231 tracksPtr.push_back(trk.get());
238 auto res = finder.find(tracksPtr, vertexingOptions, state);
240 BOOST_CHECK(res.ok());
243 std::cout << res.error().message() << std::endl;
247 auto vertexCollection = *res;
253 std::cout <<
"########## RESULT: ########## Event " << iEvent
255 std::cout <<
"Number of true vertices: " << nVertices << std::endl;
256 std::cout <<
"Number of reco vertices: " << vertexCollection.size()
260 std::cout <<
"----- True vertices -----" << std::endl;
261 for (
const auto& vertex : trueVertices) {
263 std::cout << count <<
". True Vertex:\t Position:"
264 <<
"(" << pos[
eX] <<
"," << pos[
eY] <<
"," << pos[
eZ] <<
")"
266 std::cout <<
"Number of tracks: " << vertex.tracks().size() << std::endl
270 std::cout <<
"----- Reco vertices -----" << std::endl;
272 for (
const auto& vertex : vertexCollection) {
274 std::cout << count <<
". Reco Vertex:\t Position:"
275 <<
"(" << pos[
eX] <<
"," << pos[
eY] <<
"," << pos[
eZ] <<
")"
277 std::cout <<
"Number of tracks: " << vertex.tracks().size() << std::endl
284 bool allVerticesFound =
true;
285 for (
const auto& trueVertex : trueVertices) {
286 Vector4D truePos = trueVertex.fullPosition();
287 bool currentVertexFound =
false;
288 for (
const auto& recoVertex : vertexCollection) {
289 Vector4D recoPos = recoVertex.fullPosition();
292 if (zDistance < 2_mm) {
293 currentVertexFound =
true;
296 if (!currentVertexFound) {
297 allVerticesFound =
false;
302 BOOST_CHECK(allVerticesFound);
315 std::mt19937 gen(mySeed);
320 for (
unsigned int iEvent = 0; iEvent <
nEvents; ++iEvent) {
328 auto propagator = std::make_shared<Propagator>(
stepper);
339 std::function<BoundTrackParameters(InputTrack)> extractParameters =
340 [](
InputTrack params) {
return params.parameters(); };
345 BilloirFitter bFitter(vertexFitterCfg, extractParameters);
351 IPEstimator ipEstimator(ipEstimatorCfg);
356 ZScanSeedFinder sFinder(seedFinderCfg, extractParameters);
362 cfg.reassignTracksAfterFirstFit =
true;
368 std::vector<std::unique_ptr<const InputTrack>> tracks;
370 std::vector<const InputTrack*> tracksPtr;
373 std::vector<Vertex<InputTrack>> trueVertices;
377 for (
unsigned int iVertex = 0; iVertex < nVertices; ++iVertex) {
382 std::cout <<
"Event " << iEvent <<
", Vertex " << iVertex <<
"/"
383 << nVertices <<
" with " << nTracks <<
" tracks."
387 std::shared_ptr<PerigeeSurface> perigeeSurface =
388 Surface::makeShared<PerigeeSurface>(
Vector3D(0., 0., 0.));
397 std::vector<TrackAtVertex<InputTrack>> tracksAtTrueVtx;
400 double d0_v = sqrt(x * x + y * y);
405 for (
unsigned int iTrack = 0; iTrack < nTracks; iTrack++) {
407 double q =
qDist(gen) < 0 ? -1. : 1.;
411 double z0track = z0_v +
z0Dist(gen);
425 covMat << res_d0 * res_d0, 0., 0., 0., 0., 0., 0., res_z0 * res_z0, 0.,
426 0., 0., 0., 0., 0., res_ph * res_ph, 0., 0., 0., 0., 0., 0.,
427 res_th * res_th, 0., 0., 0., 0., 0., 0., res_qp * res_qp, 0., 0.,
432 tracks.push_back(std::make_unique<InputTrack>(paramsUT));
434 auto params = extractParameters(paramsUT);
437 tracksAtTrueVtx.push_back(trAtVt);
441 trueVertices.push_back(trueV);
446 std::shuffle(std::begin(tracks), std::end(tracks), gen);
448 for (
const auto& trk : tracks) {
449 tracksPtr.push_back(trk.get());
456 auto res = finder.find(tracksPtr, vertexingOptionsUT, state);
458 BOOST_CHECK(res.ok());
461 std::cout << res.error().message() << std::endl;
465 auto vertexCollectionUT = *res;
471 std::cout <<
"########## RESULT: ########## Event " << iEvent
473 std::cout <<
"Number of true vertices: " << nVertices << std::endl;
474 std::cout <<
"Number of reco vertices: " << vertexCollectionUT.size()
478 std::cout <<
"----- True vertices -----" << std::endl;
479 for (
const auto& vertex : trueVertices) {
481 std::cout << count <<
". True Vertex:\t Position:"
482 <<
"(" << pos[
eX] <<
"," << pos[
eY] <<
"," << pos[
eZ] <<
")"
484 std::cout <<
"Number of tracks: " << vertex.tracks().size() << std::endl
488 std::cout <<
"----- Reco vertices -----" << std::endl;
490 for (
const auto& vertex : vertexCollectionUT) {
492 std::cout << count <<
". Reco Vertex:\t Position:"
493 <<
"(" << pos[
eX] <<
"," << pos[
eY] <<
"," << pos[
eZ] <<
")"
495 std::cout <<
"Number of tracks: " << vertex.tracks().size() << std::endl
502 bool allVerticesFound =
true;
503 for (
const auto& trueVertex : trueVertices) {
504 Vector4D truePos = trueVertex.fullPosition();
505 bool currentVertexFound =
false;
506 for (
const auto& recoVertex : vertexCollectionUT) {
507 Vector4D recoPos = recoVertex.fullPosition();
510 if (zDistance < 2_mm) {
511 currentVertexFound =
true;
514 if (!currentVertexFound) {
515 allVerticesFound =
false;
520 BOOST_CHECK(allVerticesFound);
535 auto propagator = std::make_shared<Propagator>(
stepper);
541 using BilloirFitter =
547 BilloirFitter bFitter(vertexFitterCfg);
553 IPEstimator ipEstimator(ipEstimatorCfg);
557 static_assert(VertexFinderConcept<ZScanSeedFinder>,
558 "Vertex finder does not fulfill vertex finder concept.");
562 ZScanSeedFinder sFinder(seedFinderCfg);
567 static_assert(VertexFinderConcept<VertexFinder>,
568 "Vertex finder does not fulfill vertex finder concept.");
573 cfg.useBeamConstraint =
true;
574 cfg.maxVertices = 200;
575 cfg.maximumChi2cutForSeeding = 49;
576 cfg.significanceCutSeeding = 12;
582 auto tracks = std::get<TracksData>(csvData);
584 std::vector<const BoundTrackParameters*> tracksPtr;
585 for (
const auto& trk : tracks) {
586 tracksPtr.push_back(&trk);
595 auto findResult = finder.find(tracksPtr, vertexingOptions, state);
599 if (!findResult.ok()) {
600 std::cout << findResult.error().message() << std::endl;