LCOV - code coverage report
Current view: top level - include/crpropa/module - PhotoDisintegration.h (source / functions) Coverage Total Hit
Test: coverage.info.cleaned Lines: 100.0 % 2 2
Test Date: 2026-06-18 09:49:19 Functions: - 0 0

            Line data    Source code
       1              : #ifndef CRPROPA_PHOTODISINTEGRATION_H
       2              : #define CRPROPA_PHOTODISINTEGRATION_H
       3              : 
       4              : #include "crpropa/Module.h"
       5              : #include "crpropa/PhotonBackground.h"
       6              : 
       7              : #include <vector>
       8              : #include <map>
       9              : 
      10              : namespace crpropa {
      11              : /**
      12              :  * \addtogroup EnergyLosses
      13              :  * @{
      14              :  */
      15              :  
      16              : /**
      17              :  @class PhotoDisintegration
      18              :  @brief Photodisintegration of nuclei by background photons.
      19              :  */
      20              : class PhotoDisintegration: public Module {
      21              : private:
      22              :         ref_ptr<PhotonField> photonField;
      23              :         double limit; // fraction of mean free path for limiting the next step
      24              :         bool havePhotons;
      25              :         std::string interactionTag = "PD";
      26              : 
      27       155122 :         struct Branch {
      28              :                 int channel; // number of emitted (n, p, H2, H3, He3, He4)
      29              :                 std::vector<double> branchingRatio; // branching ratio as function of nucleus Lorentz factor
      30              :         };
      31              : 
      32       649440 :         struct PhotonEmission {
      33              :                 double energy; // energy of emitted photon [J]
      34              :                 std::vector<double> emissionProbability; // emission probability as function of nucleus Lorentz factor
      35              :         };
      36              : 
      37              :         std::vector<std::vector<double> > pdRate; // pdRate[Z * 31 + N] = total interaction rate
      38              :         std::vector<std::vector<Branch> > pdBranch; // pdTable[Z * 31 + N] = branching ratios
      39              :         mutable std::map<int, std::vector<PhotonEmission> > pdPhoton; // map of emitted photon energies and photon emission probabilities
      40              : 
      41              :         static const double lgmin; // minimum log10(Lorentz-factor)
      42              :         static const double lgmax; // maximum log10(Lorentz-factor)
      43              :         static const size_t nlg; // number of Lorentz-factor steps
      44              : 
      45              : public:
      46              :         /** Constructor.
      47              :          @param photonField             target photon field
      48              :          @param havePhotons             if true, add secondary photons as candidates
      49              :          @param limit                   step size limit as fraction of mean free path
      50              :          */
      51              :         PhotoDisintegration(ref_ptr<PhotonField> photonField, bool havePhotons = false, double limit = 0.1);
      52              : 
      53              :         // set the target photon field
      54              :         void setPhotonField(ref_ptr<PhotonField> photonField);
      55              : 
      56              :         // decide if secondary photons are added to the simulation
      57              :         void setHavePhotons(bool havePhotons);
      58              : 
      59              :         /** Limit the propagation step to a fraction of the mean free path
      60              :          * @param limit fraction of the mean free path
      61              :          */
      62              :         void setLimit(double limit);
      63              : 
      64              :         /** set a custom interaction tag to trace back this interaction
      65              :          * @param tag string that will be added to the candidate and output
      66              :          */
      67              :         void setInteractionTag(std::string tag);
      68              :         std::string getInteractionTag() const;
      69              : 
      70              :         void initRate(std::string filename);
      71              :         void initBranching(std::string filename);
      72              :         void initPhotonEmission(std::string filename);
      73              : 
      74              :         void process(Candidate *candidate) const;
      75              :         void performInteraction(Candidate *candidate, int channel) const;
      76              : 
      77              :         /**
      78              :          Calculates the loss length E dx/dE in [m] physical distance.
      79              :          This is not used in the simulation.
      80              :          @param id              PDG particle id
      81              :          @param gamma   Lorentz factor of particle
      82              :          @param z               redshift
      83              :          @returns E dx/dE [in meters]
      84              :          */
      85              :         double lossLength(int id, double gamma, double z = 0);
      86              : };
      87              : 
      88              : /** @}*/
      89              : } // namespace crpropa
      90              : 
      91              : #endif // CRPROPA_PHOTODISINTEGRATION_H
        

Generated by: LCOV version 2.0-1