9#include <simulation/dataobjects/MCParticleTrajectory.h>
10#include <Math/Vector3D.h>
26 v.SetXYZ(a.x - b.x, a.y - b.y, a.z - b.z);
36 if (distance_tolerance <= 0 ||
m_points.size() < 3)
return;
39 std::stack<std::pair<iterator, iterator>> stack;
45 iterator firstPoint, splitPoint, finalPoint;
47 ROOT::Math::XYZVector n, pa;
49 while (!stack.empty()) {
51 std::tie(firstPoint, finalPoint) = stack.top();
55 setVector(n, *firstPoint, *finalPoint,
true);
57 double maxDistance(0);
58 for (
auto nextPoint = firstPoint + 1; nextPoint != finalPoint; ++nextPoint) {
60 setVector(pa, *firstPoint, *nextPoint);
62 const double dist = (pa - (pa.Dot(n)) * n).R();
64 if (dist > maxDistance) {
65 splitPoint = nextPoint;
70 if (maxDistance > distance_tolerance) {
76 stack.push(make_pair(splitPoint, finalPoint));
77 stack.push(make_pair(firstPoint, splitPoint));
83 *(nextFreePoint++) = *finalPoint;
std::vector< MCTrajectoryPoint >::iterator iterator
iterator definition to allow iteration
iterator end()
return iterator beyond the last point
void simplify(float distanceTolerance)
Simplify the trajectory using the Ramer-Douglas-Peuker algorithm.
std::vector< MCTrajectoryPoint > m_points
Collection of points along the trajectory.
Abstract base class for different kinds of events.
Small struct to encode a position/momentum without additional overhead.