Program Listing for File Massdistribution.h
↰ Return to documentation for file (include/crpropa/massDistribution/Massdistribution.h)
#ifndef CRPROPA_MASSDISTRIBUTION_H
#define CRPROPA_MASSDISTRIBUTION_H
#include "crpropa/massDistribution/Density.h"
#include "crpropa/Vector3.h"
#include "crpropa/Grid.h"
#include "kiss/logger.h"
#include <vector>
namespace crpropa {
class DensityList: public Density {
private:
        std::vector<ref_ptr<Density> > DensityList ;
public:
        void addDensity(ref_ptr<Density> density);
        double getDensity(const Vector3d &position) const;
        double getHIDensity(const Vector3d &position) const;
        double getHIIDensity(const Vector3d &position) const;
        double getH2Density(const Vector3d &position) const;
        double getNucleonDensity(const Vector3d &position) const;
        std::string getDescription();
};
class DensityGrid: public Density {
private:
        ref_ptr<Grid1f> grid; //< Grid with data
        bool isForHI, isForHII, isForH2;
        void checkAndWarn(); //< raise a warning if all density types are deactivated.
public:
        DensityGrid(ref_ptr<Grid1f> grid, bool isForHI = false, bool isForHII = false, bool isForH2 = false);
        double getHIDensity(const Vector3d &position) const;
        double getHIIDensity(const Vector3d &position) const;
        double getH2Density(const Vector3d &position) const;
        double getDensity(const Vector3d &position) const;
        double getNucleonDensity(const Vector3d &position) const;
        bool getIsForHI();
        bool getIsForHII();
        bool getIsForH2();
        /* set if the density is for HI type.
         @param b if True the density is used for HI
        */
        void setIsForHI(bool b);
        /* set if the density is for HII type.
         @param b if True the density is used for HII
        */
        void setIsForHII(bool b);
        /* set if the density is for H2 type.
         @param b if True the density is used for H2
        */
        void setIsForH2(bool b);
        /* Change the grid for the density
         @param grid (Grid1f) new grid for the density.
        */
        void setGrid(ref_ptr<Grid1f> grid);
        std::string getDescription();
};
}  // namespace crpropa
#endif  // CRPROPA_MASSDISTRIBUTION_H