9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
50 #include <system_error>
60 using namespace Acts::UnitLiterals;
77 auto bField = std::make_shared<ConstantBField>(
Vector3(0., 0., 2_T));
84 auto propagator = std::make_shared<Propagator>(
stepper);
90 IPEstimator ipEstimator(ipEstimatorCfg);
92 std::vector<double> temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0};
101 fitterCfg.annealingTool = annealingUtility;
108 fitterCfg.doSmoothing =
true;
110 Fitter fitter(fitterCfg);
123 Finder finder(finderConfig);
127 auto tracks = std::get<TracksData>(csvData);
130 std::cout <<
"Number of tracks in event: " <<
tracks.size() << std::endl;
133 for (
const auto& trk :
tracks) {
134 std::cout << count <<
". track: " << std::endl;
135 std::cout <<
"params: " << trk << std::endl;
137 if (count == maxCout) {
143 std::vector<const BoundTrackParameters*> tracksPtr;
144 for (
const auto& trk :
tracks) {
145 tracksPtr.push_back(&trk);
153 auto t1 = std::chrono::system_clock::now();
154 auto findResult = finder.find(tracksPtr, vertexingOptions, state);
155 auto t2 = std::chrono::system_clock::now();
158 std::chrono::duration_cast<std::chrono::milliseconds>(
t2 -
t1).
count();
160 if (!findResult.ok()) {
161 std::cout << findResult.error().message() << std::endl;
164 BOOST_CHECK(findResult.ok());
166 std::vector<Vertex<BoundTrackParameters>> allVertices = *findResult;
169 std::cout <<
"Time needed: " << timediff <<
" ms." << std::endl;
170 std::cout <<
"Number of vertices reconstructed: " << allVertices.size()
174 for (
const auto& vtx : allVertices) {
176 std::cout << count <<
". Vertex at position: " << vtx.position()[0]
177 <<
", " << vtx.position()[1] <<
", " << vtx.position()[2]
179 std::cout << count <<
". Vertex with cov: " << vtx.covariance()
181 std::cout <<
"\t with n tracks: " << vtx.tracks().size() << std::endl;
187 auto verticesInfo = std::get<VerticesData>(csvData);
188 const int expNRecoVertices = verticesInfo.size();
190 BOOST_CHECK_EQUAL(allVertices.size(), expNRecoVertices);
192 for (
int i = 0;
i < expNRecoVertices;
i++) {
193 auto recoVtx = allVertices[
i];
194 auto expVtx = verticesInfo[
i];
197 BOOST_CHECK_EQUAL(recoVtx.tracks().size(), expVtx.nTracks);
198 CHECK_CLOSE_ABS(recoVtx.tracks()[0].trackWeight, expVtx.trk1Weight, 0.003);
199 CHECK_CLOSE_ABS(recoVtx.tracks()[0].vertexCompatibility, expVtx.trk1Comp,
207 : m_parameters(params), m_id(id) {}
212 int id()
const {
return m_id; }
226 auto bField = std::make_shared<ConstantBField>(
Vector3(0., 0., 2_T));
233 auto propagator = std::make_shared<Propagator>(
stepper);
237 std::function<BoundTrackParameters(InputTrack)> extractParameters =
238 [](
const InputTrack& params) {
return params.parameters(); };
244 IPEstimator ipEstimator(ipEstimatorCfg);
246 std::vector<double> temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0};
255 fitterCfg.annealingTool = annealingUtility;
262 fitterCfg.doSmoothing =
true;
264 Fitter fitter(fitterCfg, extractParameters);
277 Finder finder(finderConfig, extractParameters);
280 auto tracks = std::get<TracksData>(csvData);
282 std::vector<InputTrack> userTracks;
284 for (
const auto& trk :
tracks) {
285 userTracks.push_back(
InputTrack(trk, idCount));
290 std::cout <<
"Number of tracks in event: " << tracks.size() << std::endl;
293 for (
const auto& trk : tracks) {
294 std::cout << count <<
". track: " << std::endl;
295 std::cout <<
"params: " << trk << std::endl;
297 if (count == maxCout) {
303 std::vector<const InputTrack*> userTracksPtr;
304 for (
const auto& trk : userTracks) {
305 userTracksPtr.push_back(&trk);
315 auto findResult = finder.find(userTracksPtr, vertexingOptions, state);
317 if (!findResult.ok()) {
318 std::cout << findResult.error().message() << std::endl;
321 BOOST_CHECK(findResult.ok());
323 std::vector<Vertex<InputTrack>> allVertices = *findResult;
326 std::cout <<
"Number of vertices reconstructed: " << allVertices.size()
330 for (
const auto& vtx : allVertices) {
332 std::cout << count <<
". Vertex at position: " << vtx.position()[0]
333 <<
", " << vtx.position()[1] <<
", " << vtx.position()[2]
335 std::cout << count <<
". Vertex with cov: " << vtx.covariance()
337 std::cout <<
"\t with n tracks: " << vtx.tracks().size() << std::endl;
339 for (
auto& trk : allVertices[0].
tracks()) {
340 std::cout <<
"Track ID at first vertex: " << trk.originalParams->id()
345 auto verticesInfo = std::get<VerticesData>(csvData);
346 const int expNRecoVertices = verticesInfo.size();
348 BOOST_CHECK_EQUAL(allVertices.size(), expNRecoVertices);
350 for (
int i = 0;
i < expNRecoVertices;
i++) {
351 auto recoVtx = allVertices[
i];
352 auto expVtx = verticesInfo[
i];
355 BOOST_CHECK_EQUAL(recoVtx.tracks().size(), expVtx.nTracks);
356 CHECK_CLOSE_ABS(recoVtx.tracks()[0].trackWeight, expVtx.trk1Weight, 0.003);
357 CHECK_CLOSE_ABS(recoVtx.tracks()[0].vertexCompatibility, expVtx.trk1Comp,
367 std::cout <<
"Starting AMVF test with grid seed finder..." << std::endl;
370 auto bField = std::make_shared<ConstantBField>(
Vector3(0., 0., 2_T));
377 auto propagator = std::make_shared<Propagator>(
stepper);
383 IPEstimator ipEst(ipEstCfg);
385 std::vector<double> temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0};
394 fitterCfg.annealingTool = annealingUtility;
401 fitterCfg.doSmoothing =
true;
403 Fitter fitter(fitterCfg);
407 seedFinderCfg.cacheGridStateForTrackRemoval =
true;
416 Finder finder(finderConfig);
420 auto tracks = std::get<TracksData>(csvData);
423 std::cout <<
"Number of tracks in event: " <<
tracks.size() << std::endl;
426 for (
const auto& trk :
tracks) {
427 std::cout << count <<
". track: " << std::endl;
428 std::cout <<
"params: " << trk << std::endl;
430 if (count == maxCout) {
436 std::vector<const BoundTrackParameters*> tracksPtr;
437 for (
const auto& trk :
tracks) {
438 tracksPtr.push_back(&trk);
446 auto t1 = std::chrono::system_clock::now();
447 auto findResult = finder.find(tracksPtr, vertexingOptions, state);
448 auto t2 = std::chrono::system_clock::now();
451 std::chrono::duration_cast<std::chrono::milliseconds>(
t2 -
t1).
count();
453 if (!findResult.ok()) {
454 std::cout << findResult.error().message() << std::endl;
457 BOOST_CHECK(findResult.ok());
459 std::vector<Vertex<BoundTrackParameters>> allVertices = *findResult;
462 std::cout <<
"Time needed: " << timediff <<
" ms." << std::endl;
463 std::cout <<
"Number of vertices reconstructed: " << allVertices.size()
467 for (
const auto& vtx : allVertices) {
469 std::cout << count <<
". Vertex at position: " << vtx.position()[0]
470 <<
", " << vtx.position()[1] <<
", " << vtx.position()[2]
472 std::cout << count <<
". Vertex with cov: " << vtx.covariance()
474 std::cout <<
"\t with n tracks: " << vtx.tracks().size() << std::endl;
479 auto verticesInfo = std::get<VerticesData>(csvData);
480 const int expNRecoVertices = verticesInfo.size();
482 BOOST_CHECK_EQUAL(allVertices.size(), expNRecoVertices);
483 std::vector<bool> vtxFound(expNRecoVertices,
false);
485 for (
const auto& vtx : allVertices) {
486 double vtxZ = vtx.position()[2];
488 int foundVtxIdx = -1;
489 for (
int i = 0;
i < expNRecoVertices;
i++) {
490 if (not vtxFound[
i]) {
491 if (std::abs(vtxZ - verticesInfo[i].
position[2]) < diffZ) {
492 diffZ = std::abs(vtxZ - verticesInfo[i].position[2]);
497 if (diffZ < 0.5_mm) {
498 vtxFound[foundVtxIdx] =
true;
499 CHECK_CLOSE_ABS(vtx.tracks().size(), verticesInfo[foundVtxIdx].nTracks,
503 for (
bool found : vtxFound) {
504 BOOST_CHECK_EQUAL(found,
true);
510 adaptive_multi_vertex_finder_adaptive_grid_seed_finder_test) {
514 std::cout <<
"Starting AMVF test with adaptive grid seed finder..."
518 auto bField = std::make_shared<ConstantBField>(
Vector3(0., 0., 2_T));
525 auto propagator = std::make_shared<Propagator>(
stepper);
531 IPEstimator ipEst(ipEstCfg);
533 std::vector<double> temperatures{8.0, 4.0, 2.0, 1.4142136, 1.2247449, 1.0};
542 fitterCfg.annealingTool = annealingUtility;
549 fitterCfg.doSmoothing =
true;
551 Fitter fitter(fitterCfg);
555 seedFinderCfg.cacheGridStateForTrackRemoval =
true;
564 Finder finder(finderConfig);
568 auto tracks = std::get<TracksData>(csvData);
571 std::cout <<
"Number of tracks in event: " <<
tracks.size() << std::endl;
574 for (
const auto& trk :
tracks) {
575 std::cout << count <<
". track: " << std::endl;
576 std::cout <<
"params: " << trk << std::endl;
578 if (count == maxCout) {
584 std::vector<const BoundTrackParameters*> tracksPtr;
585 for (
const auto& trk :
tracks) {
586 tracksPtr.push_back(&trk);
593 auto t1 = std::chrono::system_clock::now();
594 auto findResult = finder.find(tracksPtr, vertexingOptions, state);
595 auto t2 = std::chrono::system_clock::now();
598 std::chrono::duration_cast<std::chrono::milliseconds>(
t2 -
t1).
count();
600 if (!findResult.ok()) {
601 std::cout << findResult.error().message() << std::endl;
604 BOOST_CHECK(findResult.ok());
606 std::vector<Vertex<BoundTrackParameters>> allVertices = *findResult;
609 std::cout <<
"Time needed: " << timediff <<
" ms." << std::endl;
610 std::cout <<
"Number of vertices reconstructed: " << allVertices.size()
614 for (
const auto& vtx : allVertices) {
616 std::cout << count <<
". Vertex at position: " << vtx.position()[0]
617 <<
", " << vtx.position()[1] <<
", " << vtx.position()[2]
619 std::cout << count <<
". Vertex with cov: " << vtx.covariance()
621 std::cout <<
"\t with n tracks: " << vtx.tracks().size() << std::endl;
626 auto verticesInfo = std::get<VerticesData>(csvData);
627 const int expNRecoVertices = verticesInfo.size();
629 BOOST_CHECK_EQUAL(allVertices.size(), expNRecoVertices);
630 std::vector<bool> vtxFound(expNRecoVertices,
false);
632 for (
const auto& vtx : allVertices) {
633 double vtxZ = vtx.position()[2];
635 int foundVtxIdx = -1;
636 for (
int i = 0;
i < expNRecoVertices;
i++) {
637 if (not vtxFound[
i]) {
638 if (std::abs(vtxZ - verticesInfo[i].
position[2]) < diffZ) {
639 diffZ = std::abs(vtxZ - verticesInfo[i].position[2]);
644 if (diffZ < 0.5_mm) {
645 vtxFound[foundVtxIdx] =
true;
646 CHECK_CLOSE_ABS(vtx.tracks().size(), verticesInfo[foundVtxIdx].nTracks,
650 for (
bool found : vtxFound) {
651 BOOST_CHECK_EQUAL(found,
true);