9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
28 using namespace Acts::UnitLiterals;
32 using Propagator = Propagator<EigenStepper<ConstantBField>>;
33 using Linearizer = HelicalTrackLinearizer<Propagator>;
40 std::uniform_real_distribution<>
vXYDist(-0.1_mm, 0.1_mm);
42 std::uniform_real_distribution<>
vZDist(-20_mm, 20_mm);
44 std::uniform_real_distribution<>
d0Dist(-0.01_mm, 0.01_mm);
46 std::uniform_real_distribution<>
z0Dist(-0.2_mm, 0.2_mm);
48 std::uniform_real_distribution<>
pTDist(1._GeV, 30._GeV);
54 std::uniform_real_distribution<>
qDist(-1, 1);
56 std::uniform_real_distribution<>
resIPDist(0., 100._um);
58 std::uniform_real_distribution<>
resAngDist(0., 0.1);
60 std::uniform_real_distribution<>
resQoPDist(-0.1, 0.1);
71 std::mt19937 gen(mySeed);
80 auto propagator = std::make_shared<Propagator>(
stepper);
89 IPEstimator ip3dEst(ip3dEstCfg);
105 Vector3D vtxPos1(-0.15_mm, -0.1_mm, -1.5_mm);
106 Vector3D vtxPos2(-0.1_mm, -0.15_mm, -3._mm);
107 Vector3D vtxPos3(0.2_mm, 0.2_mm, 10._mm);
109 std::vector<Vector3D> vtxPosVec{vtxPos1, vtxPos2, vtxPos3};
118 std::vector<Vertex<BoundTrackParameters>> vtxList;
119 for (
auto& vtxPos : vtxPosVec) {
122 SymMatrix4D posCovariance(SymMatrix4D::Identity());
125 vtxList.push_back(vtx);
128 std::vector<Vertex<BoundTrackParameters>*> vtxPtrList;
131 std::cout <<
"All vertices in test case: " << std::endl;
133 for (
auto&
vtx : vtxList) {
136 std::cout <<
"\t" << cv <<
". vertex ptr: " << &
vtx << std::endl;
138 vtxPtrList.push_back(&
vtx);
141 std::vector<BoundTrackParameters> allTracks;
143 unsigned int nTracksPerVtx = 4;
146 for (
unsigned int iTrack = 0; iTrack < nTracksPerVtx * vtxPosVec.size();
149 double q =
qDist(gen) < 0 ? -1. : 1.;
154 covMat << resD0 * resD0, 0., 0., 0., 0., 0., 0., resZ0 * resZ0, 0., 0., 0.,
155 0., 0., 0., resPh * resPh, 0., 0., 0., 0., 0., 0., resTh * resTh, 0.,
156 0., 0., 0., 0., 0., resQp * resQp, 0., 0., 0., 0., 0., 0., 1.;
159 int vtxIdx = (int)(iTrack / nTracksPerVtx);
166 std::shared_ptr<PerigeeSurface> perigeeSurface =
167 Surface::makeShared<PerigeeSurface>(vtxPosVec[vtxIdx]);
169 allTracks.emplace_back(perigeeSurface, paramVec, std::move(covMat));
174 std::cout <<
"All tracks in test case: " << std::endl;
175 for (
auto& trk : allTracks) {
177 std::cout <<
"\t" << ct <<
". track ptr: " << &trk << std::endl;
184 for (
unsigned int iTrack = 0; iTrack < nTracksPerVtx * vtxPosVec.size();
187 int vtxIdx = (int)(iTrack / nTracksPerVtx);
188 state.
vtxInfoMap[&(vtxList[vtxIdx])].trackLinks.push_back(
189 &(allTracks[iTrack]));
191 std::make_pair(std::make_pair(&(allTracks[iTrack]), &(vtxList[vtxIdx])),
193 1., allTracks[iTrack], &(allTracks[iTrack]))));
198 state.
vtxInfoMap[&(vtxList.at(1))].trackLinks.push_back(
199 &(allTracks[iTrack]));
201 std::make_pair(std::make_pair(&(allTracks[iTrack]), &(vtxList.at(1))),
203 1., allTracks[iTrack], &(allTracks[iTrack]))));
207 for (
auto&
vtx : vtxPtrList) {
210 std::cout <<
"Vertex, with ptr: " <<
vtx << std::endl;
212 std::cout <<
"\t track ptr: " << trk << std::endl;
218 std::cout <<
"Checking all vertices linked to a single track: "
220 for (
auto& trk : allTracks) {
221 std::cout <<
"Track with ptr: " << &trk << std::endl;
223 for (
auto vtxIter = range.first; vtxIter != range.second; ++vtxIter) {
224 std::cout <<
"\t used by vertex: " << vtxIter->second << std::endl;
231 std::vector<Vertex<BoundTrackParameters>> seedListCopy = vtxList;
234 fitter.
addVtxToFit(state, vtxList.at(0), linearizer, vertexingOptions);
236 std::cout <<
"Tracks linked to each vertex AFTER fit: " << std::endl;
238 for (
auto&
vtx : vtxPtrList) {
240 std::cout << c <<
". vertex, with ptr: " <<
vtx << std::endl;
242 std::cout <<
"\t track ptr: " << trk << std::endl;
248 std::cout <<
"Checking all vertices linked to a single track AFTER fit: "
250 for (
auto& trk : allTracks) {
251 std::cout <<
"Track with ptr: " << &trk << std::endl;
253 for (
auto vtxIter = range.first; vtxIter != range.second; ++vtxIter) {
254 std::cout <<
"\t used by vertex: " << vtxIter->second << std::endl;
259 BOOST_CHECK(res1.ok());
262 std::cout <<
"Vertex positions after fit of vertex 1 and 2:" << std::endl;
263 std::cout <<
"Vtx 1, seed position:\n " << seedListCopy.at(0).fullPosition()
264 <<
"\nFitted position:\n " << vtxList.at(0).fullPosition()
266 std::cout <<
"Vtx 2, seed position:\n " << seedListCopy.at(1).fullPosition()
267 <<
"\nFitted position:\n " << vtxList.at(1).fullPosition()
269 std::cout <<
"Vtx 3, seed position:\n " << seedListCopy.at(2).fullPosition()
270 <<
"\nFitted position:\n " << vtxList.at(2).fullPosition()
276 BOOST_CHECK_NE(vtxList.at(0).fullPosition(),
277 seedListCopy.at(0).fullPosition());
278 BOOST_CHECK_NE(vtxList.at(1).fullPosition(),
279 seedListCopy.at(1).fullPosition());
280 BOOST_CHECK_EQUAL(vtxList.at(2).fullPosition(),
281 seedListCopy.at(2).fullPosition());
284 seedListCopy.at(0).fullPosition(), 1_mm);
286 seedListCopy.at(1).fullPosition(), 1_mm);
289 fitter.
addVtxToFit(state, vtxList.at(2), linearizer, vertexingOptions);
290 BOOST_CHECK(res2.ok());
293 BOOST_CHECK_NE(vtxList.at(2).fullPosition(),
294 seedListCopy.at(2).fullPosition());
296 seedListCopy.at(2).fullPosition(), 1_mm);
299 std::cout <<
"Vertex positions after fit of vertex 3:" << std::endl;
300 std::cout <<
"Vtx 1, seed position:\n " << seedListCopy.at(0).fullPosition()
301 <<
"\nFitted position:\n " << vtxList.at(0).fullPosition()
303 std::cout <<
"Vtx 2, seed position:\n " << seedListCopy.at(1).fullPosition()
304 <<
"\nFitted position:\n " << vtxList.at(1).fullPosition()
306 std::cout <<
"Vtx 3, seed position:\n " << seedListCopy.at(2).fullPosition()
307 <<
"\nFitted position:\n " << vtxList.at(2).fullPosition()
326 auto propagator = std::make_shared<Propagator>(
stepper);
335 IPEstimator ip3dEst(ip3dEstCfg);
337 std::vector<double> temperatures(1, 3.);
356 Vector3D pos1a(0.5_mm, -0.5_mm, 2.4_mm);
357 Vector3D mom1a(1000_MeV, 0_MeV, -500_MeV);
358 Vector3D pos1b(0.5_mm, -0.5_mm, 3.5_mm);
359 Vector3D mom1b(0_MeV, 1000_MeV, 500_MeV);
360 Vector3D pos1c(-0.2_mm, 0.1_mm, 3.4_mm);
361 Vector3D mom1c(-50_MeV, 180_MeV, 300_MeV);
363 Vector3D pos1d(-0.1_mm, 0.3_mm, 3.0_mm);
364 Vector3D mom1d(-80_MeV, 480_MeV, -100_MeV);
365 Vector3D pos1e(-0.01_mm, 0.01_mm, 2.9_mm);
366 Vector3D mom1e(-600_MeV, 10_MeV, 210_MeV);
368 Vector3D pos1f(-0.07_mm, 0.03_mm, 2.5_mm);
369 Vector3D mom1f(240_MeV, 110_MeV, 150_MeV);
373 covMat1 << 1_mm * 1_mm, 0, 0., 0, 0., 0, 0, 1_mm * 1_mm, 0, 0., 0, 0, 0., 0,
374 0.1, 0, 0, 0, 0, 0., 0, 0.1, 0, 0, 0., 0, 0, 0, 1. / (10_GeV * 10_GeV), 0,
377 std::vector<BoundTrackParameters> params1 = {
380 mom1a.norm(), 1, covMat1),
383 mom1b.norm(), -1, covMat1),
386 mom1c.norm(), 1, covMat1),
389 mom1d.norm(), -1, covMat1),
392 mom1e.norm(), 1, covMat1),
395 mom1f.norm(), -1, covMat1),
399 Vector3D pos2a(0.2_mm, 0_mm, -4.9_mm);
400 Vector3D mom2a(5000_MeV, 30_MeV, 200_MeV);
401 Vector3D pos2b(-0.5_mm, 0.1_mm, -5.1_mm);
402 Vector3D mom2b(800_MeV, 1200_MeV, 200_MeV);
403 Vector3D pos2c(0.05_mm, -0.5_mm, -4.7_mm);
404 Vector3D mom2c(400_MeV, -300_MeV, -200_MeV);
409 std::vector<BoundTrackParameters> params2 = {
412 mom2a.norm(), 1, covMat2),
415 mom2b.norm(), -1, covMat2),
418 mom2c.norm(), -1, covMat2),
420 std::vector<Vertex<BoundTrackParameters>*> vtxList;
427 covConstr = covConstr * 1
e+8;
428 covConstr(3, 3) = 0.;
431 Vector3D vtxPos1(0.15_mm, 0.15_mm, 2.9_mm);
435 vtxList.push_back(&vtx1);
444 vtxInfo1.linPoint.setZero();
445 vtxInfo1.linPoint.head<3>() = vtxPos1;
446 vtxInfo1.constraintVertex = vtx1Constr;
447 vtxInfo1.oldPosition = vtxInfo1.linPoint;
448 vtxInfo1.seedPosition = vtxInfo1.linPoint;
450 for (
const auto& trk : params1) {
451 vtxInfo1.trackLinks.push_back(&trk);
453 std::make_pair(std::make_pair(&trk, &vtx1),
458 Vector3D vtxPos2(0.3_mm, -0.2_mm, -4.8_mm);
462 vtxList.push_back(&vtx2);
471 vtxInfo2.linPoint.setZero();
472 vtxInfo2.linPoint.head<3>() = vtxPos2;
473 vtxInfo2.constraintVertex = vtx2Constr;
474 vtxInfo2.oldPosition = vtxInfo2.linPoint;
475 vtxInfo2.seedPosition = vtxInfo2.linPoint;
477 for (
const auto& trk : params2) {
478 vtxInfo2.trackLinks.push_back(&trk);
480 std::make_pair(std::make_pair(&trk, &vtx2),
484 state.
vtxInfoMap[&vtx1] = std::move(vtxInfo1);
485 state.
vtxInfoMap[&vtx2] = std::move(vtxInfo2);
491 fitter.
fit(state, vtxList, linearizer, vertexingOptions);
505 std::cout <<
"Vertex 1, position: " << vtx1Pos << std::endl;
506 std::cout <<
"Vertex 1, covariance: " << vtx1Cov << std::endl;
510 std::cout <<
"Vertex 1, chi2: " << vtx1FQ.first << std::endl;
511 std::cout <<
"Vertex 1, ndf: " << vtx1FQ.second << std::endl;
514 std::cout <<
"Vertex 2, position: " << vtx2Pos << std::endl;
515 std::cout <<
"Vertex 2, covariance: " << vtx2Cov << std::endl;
519 std::cout <<
"Vertex 2, chi2: " << vtx2FQ.first << std::endl;
520 std::cout <<
"Vertex 2, ndf: " << vtx2FQ.second << std::endl;
525 const Vector3D expVtx1Pos(0.077_mm, -0.189_mm, 2.924_mm);
529 expVtx1Cov << 0.329, 0.016, -0.035, 0.016, 0.250, 0.085, -0.035, 0.085, 0.242;
532 expVtx1TrkWeights << 0.8128, 0.7994, 0.8164, 0.8165, 0.8165, 0.8119;
533 const double expVtx1chi2 = 0.9812;
534 const double expVtx1ndf = 6.7474;
537 const Vector3D expVtx2Pos(-0.443_mm, -0.044_mm, -4.829_mm);
540 expVtx2Cov << 1.088, 0.028, -0.066, 0.028, 0.643, 0.073, -0.066, 0.073, 0.435;
542 const Vector3D expVtx2TrkWeights(0.8172, 0.8150, 0.8137);
543 const double expVtx2chi2 = 0.2114;
544 const double expVtx2ndf = 1.8920;
550 for (
int i = 0; i < expVtx1TrkWeights.size(); i++) {
559 for (
int i = 0; i < expVtx2TrkWeights.size(); i++) {