diff --git a/include/crpropa/module/Observer.h b/include/crpropa/module/Observer.h index adf7c8fc4..42234998e 100644 --- a/include/crpropa/module/Observer.h +++ b/include/crpropa/module/Observer.h @@ -281,6 +281,17 @@ class ObserverTimeEvolution: public ObserverFeature { DetectionState checkDetection(Candidate *candidate) const; std::string getDescription() const; }; + +class ObserverTrajectoryLength: public ObserverFeature { +private: + double maxLength; +public: + ObserverTrajectoryLength(double l); + + DetectionState checkDetection(Candidate *candidate) const; +}; + + /** @} */ } diff --git a/src/module/Observer.cpp b/src/module/Observer.cpp index c600dce50..3b464ed15 100644 --- a/src/module/Observer.cpp +++ b/src/module/Observer.cpp @@ -365,4 +365,17 @@ std::string ObserverSurface::getDescription() const { return ss.str(); } +// ObserverTrajectoryLength --------------------------------------------------- + +ObserverTrajectoryLength::ObserverTrajectoryLength(double l) : maxLength(l) { } + +DetectionState ObserverTrajectoryLength::checkDetection(Candidate *cand) const { + double currentLength = cand -> getTrajectoryLength(); + + if (currentLength > maxLength) + return DETECTED; + + cand -> limitNextStep(maxLength - currentLength); + return NOTHING; +} } // namespace crpropa