LCOV - code coverage report
Current view: top level - src/module - SimplePropagation.cpp (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 12 33 36.4 %
Date: 2024-04-29 14:43:01 Functions: 2 7 28.6 %

          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       44252 : void SimplePropagation::process(Candidate *c) const {
      15             :         c->previous = c->current;
      16             : 
      17       44252 :         double step = clip(c->getNextStep(), minStep, maxStep);
      18       44252 :         c->setCurrentStep(step);
      19       44252 :         Vector3d pos = c->current.getPosition();
      20       44252 :         Vector3d dir = c->current.getDirection();
      21       44252 :         c->current.setPosition(pos + dir * step);
      22       44252 :         c->setNextStep(maxStep);
      23       44252 : }
      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

Generated by: LCOV version 1.14