9 #include <boost/test/data/test_case.hpp>
10 #include <boost/test/tools/output_test_stream.hpp>
11 #include <boost/test/unit_test.hpp>
27 using namespace Acts::UnitLiterals;
30 using Propagator = Propagator<EigenStepper<ConstantBField>>;
31 using Linearizer = HelicalTrackLinearizer<Propagator>;
42 std::uniform_real_distribution<>
d0Dist(-0.01
_mm, 0.01
_mm);
44 std::uniform_real_distribution<>
z0Dist(-0.2
_mm, 0.2
_mm);
52 std::uniform_real_distribution<>
qDist(-1, 1);
56 std::uniform_real_distribution<>
resAngDist(0., 0.1);
58 std::uniform_real_distribution<>
resQoPDist(-0.1, 0.1);
69 std::mt19937 gen(mySeed);
78 auto propagator = std::make_shared<Propagator>(
stepper);
87 IPEstimator ip3dEst(ip3dEstCfg);
107 std::vector<Vector3D> vtxPosVec{vtxPos1, vtxPos2, vtxPos3};
116 std::vector<Vertex<BoundParameters>> vtxList;
117 for (
auto& vtxPos : vtxPosVec) {
123 vtxList.push_back(vtx);
126 std::vector<Vertex<BoundParameters>*> vtxPtrList;
129 std::cout <<
"All vertices in test case: " << std::endl;
131 for (
auto& vtx : vtxList) {
134 std::cout <<
"\t" << cv <<
". vertex ptr: " << &vtx << std::endl;
136 vtxPtrList.push_back(&vtx);
139 std::vector<BoundParameters> allTracks;
141 unsigned int nTracksPerVtx = 4;
144 for (
unsigned int iTrack = 0; iTrack < nTracksPerVtx * vtxPosVec.size();
147 double q =
qDist(gen) < 0 ? -1. : 1.;
152 covMat << resD0 * resD0, 0., 0., 0., 0., 0., 0., resZ0 * resZ0, 0., 0., 0.,
153 0., 0., 0., resPh * resPh, 0., 0., 0., 0., 0., 0., resTh * resTh, 0.,
154 0., 0., 0., 0., 0., resQp * resQp, 0., 0., 0., 0., 0., 0., 1.;
157 int vtxIdx = (
int)(iTrack / nTracksPerVtx);
164 std::shared_ptr<PerigeeSurface> perigeeSurface =
165 Surface::makeShared<PerigeeSurface>(vtxPosVec[vtxIdx]);
173 std::cout <<
"All tracks in test case: " << std::endl;
174 for (
auto& trk : allTracks) {
176 std::cout <<
"\t" << ct <<
". track ptr: " << &trk << std::endl;
182 for (
unsigned int iTrack = 0; iTrack < nTracksPerVtx * vtxPosVec.size();
185 int vtxIdx = (
int)(iTrack / nTracksPerVtx);
186 state.
vtxInfoMap[&(vtxList[vtxIdx])].trackLinks.push_back(
187 &(allTracks[iTrack]));
189 std::make_pair(std::make_pair(&(allTracks[iTrack]), &(vtxList[vtxIdx])),
191 &(allTracks[iTrack]))));
196 state.
vtxInfoMap[&(vtxList.at(1))].trackLinks.push_back(
197 &(allTracks[iTrack]));
199 std::make_pair(std::make_pair(&(allTracks[iTrack]), &(vtxList.at(1))),
201 &(allTracks[iTrack]))));
205 for (
auto& vtx : vtxPtrList) {
208 std::cout <<
"Vertex, with ptr: " << vtx << std::endl;
209 for (
auto& trk : state.
vtxInfoMap[vtx].trackLinks) {
210 std::cout <<
"\t track ptr: " << trk << std::endl;
216 std::cout <<
"Checking all vertices linked to a single track: "
218 for (
auto& trk : allTracks) {
219 std::cout <<
"Track with ptr: " << &trk << std::endl;
221 for (
auto vtxIter = range.first; vtxIter != range.second; ++vtxIter) {
222 std::cout <<
"\t used by vertex: " << vtxIter->second << std::endl;
229 std::vector<Vertex<BoundParameters>> seedListCopy = vtxList;
232 fitter.
addVtxToFit(state, vtxList.at(0), linearizer, vertexingOptions);
234 std::cout <<
"Tracks linked to each vertex AFTER fit: " << std::endl;
236 for (
auto& vtx : vtxPtrList) {
238 std::cout << c <<
". vertex, with ptr: " << vtx << std::endl;
239 for (
auto& trk : state.
vtxInfoMap[vtx].trackLinks) {
240 std::cout <<
"\t track ptr: " << trk << std::endl;
246 std::cout <<
"Checking all vertices linked to a single track AFTER fit: "
248 for (
auto& trk : allTracks) {
249 std::cout <<
"Track with ptr: " << &trk << std::endl;
251 for (
auto vtxIter = range.first; vtxIter != range.second; ++vtxIter) {
252 std::cout <<
"\t used by vertex: " << vtxIter->second << std::endl;
257 BOOST_CHECK(res1.ok());
260 std::cout <<
"Vertex positions after fit of vertex 1 and 2:" << std::endl;
261 std::cout <<
"Vtx 1, seed position:\n " << seedListCopy.at(0).fullPosition()
262 <<
"\nFitted position:\n " << vtxList.at(0).fullPosition()
264 std::cout <<
"Vtx 2, seed position:\n " << seedListCopy.at(1).fullPosition()
265 <<
"\nFitted position:\n " << vtxList.at(1).fullPosition()
267 std::cout <<
"Vtx 3, seed position:\n " << seedListCopy.at(2).fullPosition()
268 <<
"\nFitted position:\n " << vtxList.at(2).fullPosition()
274 BOOST_CHECK_NE(vtxList.at(0).fullPosition(),
275 seedListCopy.at(0).fullPosition());
276 BOOST_CHECK_NE(vtxList.at(1).fullPosition(),
277 seedListCopy.at(1).fullPosition());
278 BOOST_CHECK_EQUAL(vtxList.at(2).fullPosition(),
279 seedListCopy.at(2).fullPosition());
282 seedListCopy.at(0).fullPosition(), 1
_mm);
284 seedListCopy.at(1).fullPosition(), 1
_mm);
287 fitter.
addVtxToFit(state, vtxList.at(2), linearizer, vertexingOptions);
288 BOOST_CHECK(res2.ok());
291 BOOST_CHECK_NE(vtxList.at(2).fullPosition(),
292 seedListCopy.at(2).fullPosition());
294 seedListCopy.at(2).fullPosition(), 1
_mm);
297 std::cout <<
"Vertex positions after fit of vertex 3:" << std::endl;
298 std::cout <<
"Vtx 1, seed position:\n " << seedListCopy.at(0).fullPosition()
299 <<
"\nFitted position:\n " << vtxList.at(0).fullPosition()
301 std::cout <<
"Vtx 2, seed position:\n " << seedListCopy.at(1).fullPosition()
302 <<
"\nFitted position:\n " << vtxList.at(1).fullPosition()
304 std::cout <<
"Vtx 3, seed position:\n " << seedListCopy.at(2).fullPosition()
305 <<
"\nFitted position:\n " << vtxList.at(2).fullPosition()
324 auto propagator = std::make_shared<Propagator>(
stepper);
333 IPEstimator ip3dEst(ip3dEstCfg);
335 std::vector<double> temperatures(1, 3.);
371 covMat1 << 1
_mm * 1
_mm, 0, 0., 0, 0., 0, 0, 1_mm * 1
_mm, 0, 0., 0, 0, 0., 0,
372 0.1, 0, 0, 0, 0, 0., 0, 0.1, 0, 0, 0., 0, 0, 0, 1. / (10
_GeV * 10
_GeV), 0,
375 std::vector<BoundParameters> params1;
378 Surface::makeShared<PerigeeSurface>(pos1a)));
381 Surface::makeShared<PerigeeSurface>(pos1b)));
384 Surface::makeShared<PerigeeSurface>(pos1c)));
387 Surface::makeShared<PerigeeSurface>(pos1d)));
390 Surface::makeShared<PerigeeSurface>(pos1e)));
393 Surface::makeShared<PerigeeSurface>(pos1f)));
396 Vector3D pos2a(0.2_mm, 0_mm, -4.9_mm);
398 Vector3D pos2b(-0.5_mm, 0.1_mm, -5.1_mm);
400 Vector3D pos2c(0.05_mm, -0.5_mm, -4.7_mm);
406 std::vector<BoundParameters> params2;
409 Surface::makeShared<PerigeeSurface>(pos2a)));
412 Surface::makeShared<PerigeeSurface>(pos2b)));
415 Surface::makeShared<PerigeeSurface>(pos2c)));
417 std::vector<Vertex<BoundParameters>*> vtxList;
423 covConstr = covConstr * 1
e+8;
424 covConstr(3, 3) = 0.;
427 Vector3D vtxPos1(0.15_mm, 0.15_mm, 2.9_mm);
431 vtxList.push_back(&vtx1);
441 vtxInfo1.
linPoint.head<3>() = vtxPos1;
446 for (
const auto& trk : params1) {
449 std::make_pair(std::make_pair(&trk, &vtx1),
454 Vector3D vtxPos2(0.3_mm, -0.2_mm, -4.8_mm);
458 vtxList.push_back(&vtx2);
468 vtxInfo2.
linPoint.head<3>() = vtxPos2;
473 for (
const auto& trk : params2) {
476 std::make_pair(std::make_pair(&trk, &vtx2),
480 state.
vtxInfoMap[&vtx1] = std::move(vtxInfo1);
481 state.
vtxInfoMap[&vtx2] = std::move(vtxInfo2);
487 fitter.
fit(state, vtxList, linearizer, vertexingOptions);
501 std::cout <<
"Vertex 1, position: " << vtx1Pos << std::endl;
502 std::cout <<
"Vertex 1, covariance: " << vtx1Cov << std::endl;
506 std::cout <<
"Vertex 1, chi2: " << vtx1FQ.first << std::endl;
507 std::cout <<
"Vertex 1, ndf: " << vtx1FQ.second << std::endl;
510 std::cout <<
"Vertex 2, position: " << vtx2Pos << std::endl;
511 std::cout <<
"Vertex 2, covariance: " << vtx2Cov << std::endl;
515 std::cout <<
"Vertex 2, chi2: " << vtx2FQ.first << std::endl;
516 std::cout <<
"Vertex 2, ndf: " << vtx2FQ.second << std::endl;
521 const Vector3D expVtx1Pos(0.077_mm, -0.189_mm, 2.924_mm);
525 expVtx1Cov << 0.329, 0.016, -0.035, 0.016, 0.250, 0.085, -0.035, 0.085, 0.242;
528 expVtx1TrkWeights << 0.8128, 0.7994, 0.8164, 0.8165, 0.8165, 0.8119;
529 const double expVtx1chi2 = 0.9812;
530 const double expVtx1ndf = 6.7474;
533 const Vector3D expVtx2Pos(-0.443_mm, -0.044_mm, -4.829_mm);
536 expVtx2Cov << 1.088, 0.028, -0.066, 0.028, 0.643, 0.073, -0.066, 0.073, 0.435;
538 const Vector3D expVtx2TrkWeights(0.8172, 0.8150, 0.8137);
539 const double expVtx2chi2 = 0.2114;
540 const double expVtx2ndf = 1.8920;
546 for (
int i = 0; i < expVtx1TrkWeights.size(); i++) {
555 for (
int i = 0; i < expVtx2TrkWeights.size(); i++) {