Line data Source code
1 : #include "crpropa/module/SimplePropagation.h"
2 :
3 : #include <sstream>
4 : #include <stdexcept>
5 :
6 : namespace crpropa {
7 :
8 12 : SimplePropagation::SimplePropagation(double minStep, double maxStep) :
9 12 : minStep(minStep), maxStep(maxStep) {
10 12 : if (minStep > maxStep)
11 0 : throw std::runtime_error("SimplePropagation: minStep > maxStep");
12 12 : }
13 :
14 12086 : void SimplePropagation::process(Candidate *c) const {
15 : c->previous = c->current;
16 :
17 12086 : double step = clip(c->getNextStep(), minStep, maxStep);
18 12086 : c->setCurrentStep(step);
19 12086 : Vector3d pos = c->current.getPosition();
20 12086 : Vector3d dir = c->current.getDirection();
21 12086 : c->current.setPosition(pos + dir * step);
22 12086 : c->setNextStep(maxStep);
23 12086 : }
24 :
25 0 : void SimplePropagation::setMinimumStep(double step) {
26 0 : if (step > maxStep)
27 0 : throw std::runtime_error("SimplePropagation: minStep > maxStep");
28 0 : minStep = step;
29 0 : }
30 :
31 0 : void SimplePropagation::setMaximumStep(double step) {
32 0 : if (minStep > step)
33 0 : throw std::runtime_error("SimplePropagation: minStep > maxStep");
34 0 : maxStep = step;
35 0 : }
36 :
37 0 : double SimplePropagation::getMinimumStep() const {
38 0 : return minStep;
39 : }
40 :
41 0 : double SimplePropagation::getMaximumStep() const {
42 0 : return maxStep;
43 : }
44 :
45 0 : std::string SimplePropagation::getDescription() const {
46 0 : std::stringstream s;
47 0 : s << "SimplePropagation: Step size = " << minStep / kpc
48 0 : << " - " << maxStep / kpc << " kpc";
49 0 : return s.str();
50 0 : }
51 :
52 : } // namespace crpropa
|