9 #include <boost/test/unit_test.hpp>
26 double x()
const {
return m_x; }
27 double y()
const {
return m_y; }
28 double z()
const {
return m_z; }
38 return gen() / 4294967296. * (to - from) + from;
47 return (
int)(
gen() / 4294967296. * (to - from) + from);
63 double delta = -1. * abg.dot(a);
66 return {abg[0], abg[1], abg[2], delta};
100 std::vector<std::vector<double>>
positions = {
101 {10.8, 0., 7.}, {20.9, 0.7, 4.},
103 {2.1, 10.6, 15.2}, {2.7, 19.36666, 19.5},
105 {-6.25, -7.9, 10.5}, {-12.8, -15.08, 11.},
107 {-6., 8., 2.4}, {-12., 15., -3.4},
109 {7.8, 7.8, 16.0}, {14.8, 15., 17.},
111 {-5.1, 8.1, -10.}, {-1.3, 9., -10.4},
114 std::vector<SpacePoint4SSVFT> inputSpacepoints;
115 for (
auto pos : positions) {
116 inputSpacepoints.emplace_back(
pos[0],
pos[1],
pos[2]);
119 auto t1 = std::chrono::high_resolution_clock::now();
120 auto vtx = SingleSeedVertexFinder.
findVertex(inputSpacepoints);
121 auto t2 = std::chrono::high_resolution_clock::now();
123 bool vtxFound =
false;
125 std::cout <<
"Found a vertex in the event in " << (
t2 -
t1).
count() / 1e6
126 <<
" ms at x = " << vtx.value()[0] <<
"mm, y = " << vtx.value()[1]
127 <<
"mm, z = " << vtx.value()[2] <<
"mm" << std::endl;
128 std::cout <<
"Truth vertex was at x = " << vtxX <<
"mm, y = " << vtxY
129 <<
"mm, z = " << vtxZ <<
"mm" << std::endl;
131 if (std::abs(vtxX - vtx.value()[0]) < 1
e-3 &&
132 std::abs(vtxY - vtx.value()[1]) < 1
e-3 &&
133 std::abs(vtxZ - vtx.value()[2]) < 1
e-3) {
137 std::cout <<
"Not found a vertex in the event after "
138 << (
t2 -
t1).
count() / 1e6 <<
" ms" << std::endl;
139 std::cout <<
"Truth vertex was at x = " << vtxX <<
"mm, y = " << vtxY
140 <<
"mm, z = " << vtxZ <<
"mm" << std::endl;
144 BOOST_CHECK(vtxFound);
178 std::vector<std::vector<double>>
positions = {
179 {11., 0., 7.}, {21., 1., 4.},
181 {2., 9., 15.}, {3., 19., 20.},
183 {-6., -8., 10.5}, {-13., -15., 11.},
185 {7., 7., 16.0}, {14., 14., 17.},
187 {-5., 8., -10.}, {-1.5, 9., -10.5},
190 std::vector<SpacePoint4SSVFT> inputSpacepoints;
191 for (
auto pos : positions) {
192 inputSpacepoints.emplace_back(
pos[0],
pos[1],
pos[2]);
195 auto t1 = std::chrono::high_resolution_clock::now();
196 auto vtx = SingleSeedVertexFinder.
findVertex(inputSpacepoints);
197 auto t2 = std::chrono::high_resolution_clock::now();
199 bool vtxFound =
false;
201 std::cout <<
"Found a vertex in the event in " << (
t2 -
t1).
count() / 1e6
202 <<
" ms at x = " << vtx.value()[0] <<
"mm, y = " << vtx.value()[1]
203 <<
"mm, z = " << vtx.value()[2] <<
"mm" << std::endl;
204 std::cout <<
"Truth vertex was at x = " << vtxX <<
"mm, y = " << vtxY
205 <<
"mm, z = " << vtxZ <<
"mm" << std::endl;
207 if (std::abs(vtxX - vtx.value()[0]) < 1
e-3 &&
208 std::abs(vtxY - vtx.value()[1]) < 1
e-3 &&
209 std::abs(vtxZ - vtx.value()[2]) < 1
e-3) {
213 std::cout <<
"Not found a vertex in the event after "
214 << (
t2 -
t1).
count() / 1e6 <<
" ms" << std::endl;
215 std::cout <<
"Truth vertex was at x = " << vtxX <<
"mm, y = " << vtxY
216 <<
"mm, z = " << vtxZ <<
"mm" << std::endl;
220 BOOST_CHECK(vtxFound);
250 std::mt19937
gen(299792458);
259 std::vector<SpacePoint4SSVFT> inputSpacepoints;
263 for (
int track = 0; track < nTracks; ++track) {
278 for (
int i = 1;
i <= 3; ++
i) {
281 double dirXtmp = cos(theta) * dirX - sin(theta) * dirY;
282 double dirYtmp = sin(theta) * dirX + cos(theta) * dirY;
288 double dirR2 = dirX * dirX + dirY * dirY;
289 double D = posX * (posY + dirY) - posY * (posX + dirX);
295 (D * dirY + sgn * dirX * std::sqrt(r * r * dirR2 - D * D)) / dirR2;
297 (-D * dirX + std::fabs(dirY) * std::sqrt(r * r * dirR2 - D * D)) /
300 double zDist = std::fabs((x1 - posX) / dirX);
306 posZ += zDist * dirZ;
311 inputSpacepoints.rbegin()[1],
312 inputSpacepoints.rbegin()[0]);
313 posZ = -1. * (abgd[0] * posX + abgd[1] * posY + abgd[3]) / abgd[2];
316 inputSpacepoints.emplace_back(posX, posY, posZ);
320 auto t1 = std::chrono::high_resolution_clock::now();
321 auto vtx = SingleSeedVertexFinder.
findVertex(inputSpacepoints);
322 auto t2 = std::chrono::high_resolution_clock::now();
325 std::cout <<
"Found a vertex in the event in " << (
t2 -
t1).
count() / 1e6
326 <<
" ms at x = " << vtx.value()[0]
327 <<
"mm, y = " << vtx.value()[1] <<
"mm, z = " << vtx.value()[2]
328 <<
"mm" << std::endl;
329 std::cout <<
"Truth vertex was at x = " << vtxX <<
"mm, y = " << vtxY
330 <<
"mm, z = " << vtxZ <<
"mm" << std::endl;
331 std::cout <<
"Difference is in x = " << std::abs(vtxX - vtx.value()[0])
332 <<
"mm, y = " << std::abs(vtxY - vtx.value()[1])
333 <<
"mm, z = " << std::abs(vtxZ - vtx.value()[2]) <<
"mm"
335 if (std::abs(vtxX - vtx.value()[0]) < 2.0 &&
336 std::abs(vtxY - vtx.value()[1]) < 2.0 &&
337 std::abs(vtxZ - vtx.value()[2]) < 0.3) {
341 std::cout <<
"Not found a vertex in the event after "
342 << (
t2 -
t1).
count() / 1e6 <<
" ms" << std::endl;
343 std::cout <<
"Truth vertex was at x = " << vtxX <<
"mm, y = " << vtxY
344 <<
"mm, z = " << vtxZ <<
"mm" << std::endl;
348 std::cout <<
"Found " << vtxFound <<
" out of " << nEvents <<
" vertices"
352 BOOST_CHECK(vtxFound == nEvents);
382 std::mt19937
gen(299792458);
391 std::vector<SpacePoint4SSVFT> inputSpacepoints;
395 for (
int track = 0; track < nTracks; ++track) {
403 for (
int rIndx = 1; rIndx <= 3; rIndx += 1) {
405 double dirR2 = dirX * dirX + dirY * dirY;
406 double D = vtxX * (vtxY + dirY) - vtxY * (vtxX + dirX);
412 (D * dirY + part * sgn * dirX * std::sqrt(r * r * dirR2 - D * D)) /
414 double y1 = (-D * dirX + part * std::fabs(dirY) *
415 std::sqrt(r * r * dirR2 - D * D)) /
418 double zDist = std::fabs((x1 - vtxX) / dirX);
420 inputSpacepoints.emplace_back(x1, y1, zDist * dirZ + vtxZ);
424 auto t1 = std::chrono::high_resolution_clock::now();
425 auto vtx = SingleSeedVertexFinder.
findVertex(inputSpacepoints);
426 auto t2 = std::chrono::high_resolution_clock::now();
429 std::cout <<
"Found a vertex in the event in " << (
t2 -
t1).
count() / 1e6
430 <<
" ms at x = " << vtx.value()[0]
431 <<
"mm, y = " << vtx.value()[1] <<
"mm, z = " << vtx.value()[2]
432 <<
"mm" << std::endl;
433 std::cout <<
"Truth vertex was at x = " << vtxX <<
"mm, y = " << vtxY
434 <<
"mm, z = " << vtxZ <<
"mm" << std::endl;
435 std::cout <<
"Difference is in x = " << std::abs(vtxX - vtx.value()[0])
436 <<
"mm, y = " << std::abs(vtxY - vtx.value()[1])
437 <<
"mm, z = " << std::abs(vtxZ - vtx.value()[2]) <<
"mm"
439 if (std::abs(vtxX - vtx.value()[0]) < 0.3 &&
440 std::abs(vtxY - vtx.value()[1]) < 0.3 &&
441 std::abs(vtxZ - vtx.value()[2]) < 0.3) {
445 std::cout <<
"Not found a vertex in the event after "
446 << (
t2 -
t1).
count() / 1e6 <<
" ms" << std::endl;
447 std::cout <<
"Truth vertex was at x = " << vtxX <<
"mm, y = " << vtxY
448 <<
"mm, z = " << vtxZ <<
"mm" << std::endl;
452 std::cout <<
"Found " << vtxFound <<
" out of " << nEvents <<
" vertices"
456 BOOST_CHECK(vtxFound == nEvents);