Skip to content

Commit

Permalink
add trajectory length observer feature
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienDoerner committed Aug 7, 2024
1 parent fe31aca commit 19be5ff
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
11 changes: 11 additions & 0 deletions include/crpropa/module/Observer.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};


/** @} */

}
Expand Down
13 changes: 13 additions & 0 deletions src/module/Observer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 19be5ff

Please sign in to comment.