9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
47 #include <type_traits>
54 using namespace Acts::UnitLiterals;
59 using Linearizer = HelicalTrackLinearizer<Propagator>;
66 std::uniform_real_distribution<>
vXYDist(-0.1_mm, 0.1_mm);
68 std::uniform_real_distribution<>
vZDist(-20_mm, 20_mm);
70 std::uniform_real_distribution<>
d0Dist(-0.01_mm, 0.01_mm);
72 std::uniform_real_distribution<>
z0Dist(-0.2_mm, 0.2_mm);
74 std::uniform_real_distribution<>
pTDist(1._GeV, 30._GeV);
76 std::uniform_real_distribution<>
phiDist(-M_PI, M_PI);
78 std::uniform_real_distribution<>
thetaDist(1.0, M_PI - 1.0);
80 std::uniform_real_distribution<>
qDist(-1, 1);
82 std::uniform_real_distribution<>
resIPDist(0., 100._um);
84 std::uniform_real_distribution<>
resAngDist(0., 0.1);
86 std::uniform_real_distribution<>
resQoPDist(-0.1, 0.1);
97 std::mt19937
gen(mySeed);
100 auto bField = std::make_shared<ConstantBField>(
Vector3{0.0, 0.0, 1_T});
106 auto propagator = std::make_shared<Propagator>(
stepper);
115 IPEstimator ip3dEst(ip3dEstCfg);
131 Vector3 vtxPos1(-0.15_mm, -0.1_mm, -1.5_mm);
132 Vector3 vtxPos2(-0.1_mm, -0.15_mm, -3._mm);
133 Vector3 vtxPos3(0.2_mm, 0.2_mm, 10._mm);
135 std::vector<Vector3> vtxPosVec{vtxPos1, vtxPos2, vtxPos3};
144 std::vector<Vertex<BoundTrackParameters>> vtxList;
145 for (
auto& vtxPos : vtxPosVec) {
151 vtxList.push_back(vtx);
154 std::vector<Vertex<BoundTrackParameters>*> vtxPtrList;
157 std::cout <<
"All vertices in test case: " << std::endl;
159 for (
auto& vtx : vtxList) {
162 std::cout <<
"\t" << cv <<
". vertex ptr: " << &vtx << std::endl;
164 vtxPtrList.push_back(&vtx);
167 std::vector<BoundTrackParameters> allTracks;
169 unsigned int nTracksPerVtx = 4;
172 for (
unsigned int iTrack = 0; iTrack < nTracksPerVtx * vtxPosVec.size();
175 double q =
qDist(gen) < 0 ? -1. : 1.;
180 covMat << resD0 * resD0, 0., 0., 0., 0., 0., 0., resZ0 * resZ0, 0., 0., 0.,
181 0., 0., 0., resPh * resPh, 0., 0., 0., 0., 0., 0., resTh * resTh, 0.,
182 0., 0., 0., 0., 0., resQp * resQp, 0., 0., 0., 0., 0., 0., 1.;
185 int vtxIdx = (int)(iTrack / nTracksPerVtx);
192 std::shared_ptr<PerigeeSurface> perigeeSurface =
193 Surface::makeShared<PerigeeSurface>(vtxPosVec[vtxIdx]);
195 allTracks.emplace_back(perigeeSurface, paramVec,
std::move(covMat),
201 std::cout <<
"All tracks in test case: " << std::endl;
202 for (
auto& trk : allTracks) {
204 std::cout <<
"\t" << ct <<
". track ptr: " << &trk << std::endl;
211 for (
unsigned int iTrack = 0; iTrack < nTracksPerVtx * vtxPosVec.size();
214 int vtxIdx = (int)(iTrack / nTracksPerVtx);
215 state.
vtxInfoMap[&(vtxList[vtxIdx])].trackLinks.push_back(
216 &(allTracks[iTrack]));
218 std::make_pair(std::make_pair(&(allTracks[iTrack]), &(vtxList[vtxIdx])),
220 1., allTracks[iTrack], &(allTracks[iTrack]))));
225 state.
vtxInfoMap[&(vtxList.at(1))].trackLinks.push_back(
226 &(allTracks[iTrack]));
228 std::make_pair(std::make_pair(&(allTracks[iTrack]), &(vtxList.at(1))),
230 1., allTracks[iTrack], &(allTracks[iTrack]))));
234 for (
auto& vtx : vtxPtrList) {
237 std::cout <<
"Vertex, with ptr: " << vtx << std::endl;
238 for (
auto& trk : state.
vtxInfoMap[vtx].trackLinks) {
239 std::cout <<
"\t track ptr: " << trk << std::endl;
245 std::cout <<
"Checking all vertices linked to a single track: "
247 for (
auto& trk : allTracks) {
248 std::cout <<
"Track with ptr: " << &trk << std::endl;
250 for (
auto vtxIter = range.first; vtxIter != range.second; ++vtxIter) {
251 std::cout <<
"\t used by vertex: " << vtxIter->second << std::endl;
258 std::vector<Vertex<BoundTrackParameters>> seedListCopy = vtxList;
261 fitter.
addVtxToFit(state, vtxList.at(0), linearizer, vertexingOptions);
263 std::cout <<
"Tracks linked to each vertex AFTER fit: " << std::endl;
265 for (
auto& vtx : vtxPtrList) {
267 std::cout << c <<
". vertex, with ptr: " << vtx << std::endl;
268 for (
auto& trk : state.
vtxInfoMap[vtx].trackLinks) {
269 std::cout <<
"\t track ptr: " << trk << std::endl;
275 std::cout <<
"Checking all vertices linked to a single track AFTER fit: "
277 for (
auto& trk : allTracks) {
278 std::cout <<
"Track with ptr: " << &trk << std::endl;
280 for (
auto vtxIter = range.first; vtxIter != range.second; ++vtxIter) {
281 std::cout <<
"\t used by vertex: " << vtxIter->second << std::endl;
286 BOOST_CHECK(res1.ok());
289 std::cout <<
"Vertex positions after fit of vertex 1 and 2:" << std::endl;
290 std::cout <<
"Vtx 1, seed position:\n " << seedListCopy.at(0).fullPosition()
291 <<
"\nFitted position:\n " << vtxList.at(0).fullPosition()
293 std::cout <<
"Vtx 2, seed position:\n " << seedListCopy.at(1).fullPosition()
294 <<
"\nFitted position:\n " << vtxList.at(1).fullPosition()
296 std::cout <<
"Vtx 3, seed position:\n " << seedListCopy.at(2).fullPosition()
297 <<
"\nFitted position:\n " << vtxList.at(2).fullPosition()
303 BOOST_CHECK_NE(vtxList.at(0).fullPosition(),
304 seedListCopy.at(0).fullPosition());
305 BOOST_CHECK_NE(vtxList.at(1).fullPosition(),
306 seedListCopy.at(1).fullPosition());
307 BOOST_CHECK_EQUAL(vtxList.at(2).fullPosition(),
308 seedListCopy.at(2).fullPosition());
311 seedListCopy.at(0).fullPosition(), 1_mm);
313 seedListCopy.at(1).fullPosition(), 1_mm);
316 fitter.
addVtxToFit(state, vtxList.at(2), linearizer, vertexingOptions);
317 BOOST_CHECK(res2.ok());
320 BOOST_CHECK_NE(vtxList.at(2).fullPosition(),
321 seedListCopy.at(2).fullPosition());
323 seedListCopy.at(2).fullPosition(), 1_mm);
326 std::cout <<
"Vertex positions after fit of vertex 3:" << std::endl;
327 std::cout <<
"Vtx 1, seed position:\n " << seedListCopy.at(0).fullPosition()
328 <<
"\nFitted position:\n " << vtxList.at(0).fullPosition()
330 std::cout <<
"Vtx 2, seed position:\n " << seedListCopy.at(1).fullPosition()
331 <<
"\nFitted position:\n " << vtxList.at(1).fullPosition()
333 std::cout <<
"Vtx 3, seed position:\n " << seedListCopy.at(2).fullPosition()
334 <<
"\nFitted position:\n " << vtxList.at(2).fullPosition()
346 auto bField = std::make_shared<ConstantBField>(
Vector3{0.0, 0.0, 2_T});
353 auto propagator = std::make_shared<Propagator>(
stepper);
362 IPEstimator ip3dEst(ip3dEstCfg);
364 std::vector<double> temperatures(1, 3.);
384 Vector3 pos1a(0.5_mm, -0.5_mm, 2.4_mm);
385 Vector3 mom1a(1000_MeV, 0_MeV, -500_MeV);
386 Vector3 pos1b(0.5_mm, -0.5_mm, 3.5_mm);
387 Vector3 mom1b(0_MeV, 1000_MeV, 500_MeV);
388 Vector3 pos1c(-0.2_mm, 0.1_mm, 3.4_mm);
389 Vector3 mom1c(-50_MeV, 180_MeV, 300_MeV);
391 Vector3 pos1d(-0.1_mm, 0.3_mm, 3.0_mm);
392 Vector3 mom1d(-80_MeV, 480_MeV, -100_MeV);
393 Vector3 pos1e(-0.01_mm, 0.01_mm, 2.9_mm);
394 Vector3 mom1e(-600_MeV, 10_MeV, 210_MeV);
396 Vector3 pos1f(-0.07_mm, 0.03_mm, 2.5_mm);
397 Vector3 mom1f(240_MeV, 110_MeV, 150_MeV);
401 covMat1 << 1_mm * 1_mm, 0, 0., 0, 0., 0, 0, 1_mm * 1_mm, 0, 0., 0, 0, 0., 0,
402 0.1, 0, 0, 0, 0, 0., 0, 0.1, 0, 0, 0., 0, 0, 0, 1. / (10_GeV * 10_GeV), 0,
405 std::vector<BoundTrackParameters> params1 = {
408 mom1a.normalized(), 1_e / mom1a.norm(),
413 mom1b.normalized(), -1_e / mom1b.norm(),
418 mom1c.normalized(), 1_e / mom1c.norm(),
423 mom1d.normalized(), -1_e / mom1d.norm(),
428 mom1e.normalized(), 1_e / mom1e.norm(),
433 mom1f.normalized(), -1_e / mom1f.norm(),
439 Vector3 pos2a(0.2_mm, 0_mm, -4.9_mm);
440 Vector3 mom2a(5000_MeV, 30_MeV, 200_MeV);
441 Vector3 pos2b(-0.5_mm, 0.1_mm, -5.1_mm);
442 Vector3 mom2b(800_MeV, 1200_MeV, 200_MeV);
443 Vector3 pos2c(0.05_mm, -0.5_mm, -4.7_mm);
444 Vector3 mom2c(400_MeV, -300_MeV, -200_MeV);
449 std::vector<BoundTrackParameters> params2 = {
452 mom2a.normalized(), 1_e / mom2a.norm(),
457 mom2b.normalized(), -1_e / mom2b.norm(),
462 mom2c.normalized(), -1_e / mom2c.norm(),
466 std::vector<Vertex<BoundTrackParameters>*> vtxList;
473 covConstr = covConstr * 1
e+8;
474 covConstr(3, 3) = 0.;
477 Vector3 vtxPos1(0.15_mm, 0.15_mm, 2.9_mm);
481 vtxList.push_back(&vtx1);
490 vtxInfo1.linPoint.setZero();
491 vtxInfo1.linPoint.head<3>() = vtxPos1;
492 vtxInfo1.constraint = vtx1Constr;
493 vtxInfo1.oldPosition = vtxInfo1.linPoint;
494 vtxInfo1.seedPosition = vtxInfo1.linPoint;
496 for (
const auto& trk : params1) {
497 vtxInfo1.trackLinks.push_back(&trk);
499 std::make_pair(std::make_pair(&trk, &vtx1),
504 Vector3 vtxPos2(0.3_mm, -0.2_mm, -4.8_mm);
508 vtxList.push_back(&vtx2);
517 vtxInfo2.linPoint.setZero();
518 vtxInfo2.linPoint.head<3>() = vtxPos2;
519 vtxInfo2.constraint = vtx2Constr;
520 vtxInfo2.oldPosition = vtxInfo2.linPoint;
521 vtxInfo2.seedPosition = vtxInfo2.linPoint;
523 for (
const auto& trk : params2) {
524 vtxInfo2.trackLinks.push_back(&trk);
526 std::make_pair(std::make_pair(&trk, &vtx2),
537 fitter.
fit(state, vtxList, linearizer, vertexingOptions);
551 std::cout <<
"Vertex 1, position: " << vtx1Pos << std::endl;
552 std::cout <<
"Vertex 1, covariance: " << vtx1Cov << std::endl;
556 std::cout <<
"Vertex 1, chi2: " << vtx1FQ.first << std::endl;
557 std::cout <<
"Vertex 1, ndf: " << vtx1FQ.second << std::endl;
560 std::cout <<
"Vertex 2, position: " << vtx2Pos << std::endl;
561 std::cout <<
"Vertex 2, covariance: " << vtx2Cov << std::endl;
565 std::cout <<
"Vertex 2, chi2: " << vtx2FQ.first << std::endl;
566 std::cout <<
"Vertex 2, ndf: " << vtx2FQ.second << std::endl;
571 const Vector3 expVtx1Pos(0.077_mm, -0.189_mm, 2.924_mm);
575 expVtx1Cov << 0.329, 0.016, -0.035, 0.016, 0.250, 0.085, -0.035, 0.085, 0.242;
578 expVtx1TrkWeights << 0.8128, 0.7994, 0.8164, 0.8165, 0.8165, 0.8119;
579 const double expVtx1chi2 = 0.9812;
580 const double expVtx1ndf = 6.7474;
583 const Vector3 expVtx2Pos(-0.443_mm, -0.044_mm, -4.829_mm);
586 expVtx2Cov << 1.088, 0.028, -0.066, 0.028, 0.643, 0.073, -0.066, 0.073, 0.435;
588 const Vector3 expVtx2TrkWeights(0.8172, 0.8150, 0.8137);
589 const double expVtx2chi2 = 0.2114;
590 const double expVtx2ndf = 1.8920;
596 for (
int i = 0;
i < expVtx1TrkWeights.size();
i++) {
605 for (
int i = 0;
i < expVtx2TrkWeights.size();
i++) {