36#include "TRestAxionSpectrum.h"
39const std::map<std::string, std::vector<double>> avail_approximations = {
40 {
"arXiv_0702006_Primakoff", {6.02e10, 1.0e-10, 2.481, 1.0 / 1.205}},
41 {
"arXiv_1302.6283_Primakoff", {2.0e22 / (3600.0 * 24.0 * 365.25 * 1.0e4), 1.0e-10, 2.450, 0.829}},
42 {
"arXiv_1302.6283_Compton", {4.2e24 / (3600.0 * 24.0 * 365.25 * 1.0e4), 1.0e-13, 2.987, 0.776}}};
55 if (sMode ==
"table") {
57 double g1ref = GetDblParameterWithUnits(
"g1ref", NAN);
58 double g2ref = GetDblParameterWithUnits(
"g2ref", NAN);
59 sTableFileName =
SearchFile((std::string)sTableFileName);
60 if (sTableFileName ==
"") {
61 RESTError <<
"File not found : " << sTableFileName <<
RESTendl;
62 }
else if (std::isnan(g1ref)) {
63 RESTError <<
"You need to supply at least one reference value 'g1ref' in 'table' mode of "
68 if (not(std::isnan(g2ref))) {
69 std::cout <<
"Check!" << std::endl;
72 spectrum = AxionSpectrum(sTableFileName, g1ref, g2ref);
81 spectrum = AxionSpectrum(sTableFileName, g1ref);
82 auto table_params = spectrum.get_table_parameters();
83 int table_submode = get<0>(table_params);
84 if (table_submode > 1) {
85 fDefaultG2 = get<2>(table_params);
87 <<
"WARNING! Your table for TRestAxionSpectrum supports two separate spectra, but you did not specify a value for coupling 'g2'.\n\
88 TRestAxionSpectrum will assume a default value of "
89 << fDefaultG2 <<
" (in appropriate units)." << std::endl;
94 }
else if (sMode ==
"analytical") {
95 std::string named_approx =
GetParameter(
"named_approx",
"n/a");
96 double norm = GetDblParameterWithUnits(
"norm", NAN);
97 double g1ref = GetDblParameterWithUnits(
"g1ref", NAN);
98 double a = GetDblParameterWithUnits(
"a", NAN);
99 double b = GetDblParameterWithUnits(
"b", NAN);
100 bool check_named_approx = not(avail_approximations.find(named_approx) == avail_approximations.end());
101 bool check_numbers = not(std::isnan(norm) || std::isnan(a) || std::isnan(b) || std::isnan(g1ref));
102 if (check_named_approx) {
103 std::vector<double> p = avail_approximations.at(named_approx);
105 spectrum = AxionSpectrum(p[0], p[1], p[2], p[3]);
108 }
else if (check_numbers) {
110 spectrum = AxionSpectrum(norm, g1ref, a, b);
114 std::string avail_approximation_names =
"";
115 for (
auto el : avail_approximations) {
116 avail_approximation_names +=
" " + el.first;
118 RESTError <<
"You want to use the 'analytical' mode of TRestAxionSpectrum but neither supplied a "
119 "known 'named_approx' OR the four required parameters 'a', 'b', 'norm', "
120 "and 'g1ref'.\n The available known approximations are:" +
121 avail_approximation_names
124 }
else if (sMode ==
"solar_model") {
126 std::string sSolarModelFile =
GetParameter(
"solarAxionModel");
127 std::string fullPathName =
SearchFile((std::string)sSolarModelFile);
129 sol = SolarModel(fullPathName, OP,
false);
130 fDefaultG1 = sol.get_gagg_ref_value_in_inverse_GeV();
131 fDefaultG2 = sol.get_gaee_ref_value();
132 spectrum = AxionSpectrum(&sol);
135 RESTError <<
"Mode for TRestAxionSpectrum not known! Choose one of 'table', 'analytical', and "
144TRestAxionSpectrum::TRestAxionSpectrum(
const char* cfgFileName, std::string name)
152TRestAxionSpectrum::~TRestAxionSpectrum() {}
157 RESTMetadata <<
"+++++++++++++++++++++++++++++++++++++++++++++++++" <<
RESTendl;
158 if (sMode !=
"none") {
159 RESTMetadata <<
" Solar spectrum created in mode '" << sMode <<
"'." <<
RESTendl;
161 RESTMetadata <<
" Solar spectrum has not yet been initialised, yet!" <<
RESTendl;
163 if (sMode ==
"solar_model") {
165 RESTMetadata <<
" - Opacity code used : " << sol.get_solaxlib_name_and_version() <<
RESTendl;
166 RESTMetadata <<
" - Solar model file : " << sol.get_solar_model_name() <<
RESTendl;
167 RESTMetadata <<
" - Opacity code used : " << sol.get_opacitycode_name() <<
RESTendl;
169 }
else if (sMode ==
"table") {
170 RESTMetadata <<
" - Tabulated spectrum file used : "
173 RESTMetadata <<
"-------------------------------------------------" <<
RESTendl;
174 RESTMetadata <<
" - Units of the solar axion flux from this class : axions / cm^2 s keV" <<
RESTendl;
175 if (not(std::isnan(fDefaultG1))) {
176 RESTMetadata <<
" - Numerical value of coupling g1 (in appropriate units): " << fDefaultG1
179 if (fDefaultG2 > 0) {
180 RESTMetadata <<
" - Numerical value of coupling g2 (in appropriate units): " << fDefaultG2
183 RESTMetadata <<
" - A second coupling, g2, is not available in this class instance." <<
RESTendl;
185 RESTMetadata <<
"+++++++++++++++++++++++++++++++++++++++++++++++++" <<
RESTendl;
188double TRestAxionSpectrum::GetSolarAxionFlux(
double erg_lo,
double erg_hi,
double erg_step_size) {
return 0; }
189double TRestAxionSpectrum::GetDifferentialSolarAxionFlux(
double erg) {
191 return spectrum.axion_flux(erg, fDefaultG1, fDefaultG2);
A metadata class to define a solar axion spectrum and functions to evaluate it.
void InitFromConfigFile()
To make settings from rml file. This method must be implemented in the derived class.
void PrintMetadata()
Implemented it in the derived metadata class to print out specific metadata information.
void Initialize()
Making default settings.