REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
TRestAxionSolarModel.cxx
1/******************** REST disclaimer ***********************************
2 * This file is part of the REST software framework. *
3 * *
4 * Copyright (C) 2016 GIFNA/TREX (University of Zaragoza) *
5 * For more information see http://gifna.unizar.es/trex *
6 * *
7 * REST is free software: you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * REST is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have a copy of the GNU General Public License along with *
18 * REST in $REST_PATH/LICENSE. *
19 * If not, see http://www.gnu.org/licenses/. *
20 * For the list of contributors see $REST_PATH/CREDITS. *
21 *************************************************************************/
22
23/***************** DOXYGEN DOCUMENTATION ********************************
56 *************************************************************************/
57
58#include "TRestAxionSolarModel.h"
59
60ClassImp(TRestAxionSolarModel);
61
62// Add basic TRest info
64 SetSectionName(this->ClassName());
65 SetLibraryVersion(LIBRARY_VERSION);
66}
67
69 Initialize();
70 sSolarModelFile = GetParameter("solarAxionModel", "SolarModel_B16-AGSS09.dat");
71 std::string fullPathName = SearchFile((std::string)sSolarModelFile);
72 if (fullPathName == "") {
73 RESTError << "File not found : " << sSolarModelFile << RESTendl;
74 } else {
75#ifdef USE_SolaxFlux
76 sol = SolarModel(fullPathName, OP, false);
77 sExternalLibraryName = sol.get_solaxlib_name_and_version();
78 sOpacityCodeName = sol.get_opacitycode_name();
79 fRefPhotonCoupling = sol.get_gagg_ref_value_in_inverse_GeV();
80 fRefElectronCoupling = sol.get_gaee_ref_value();
81 bSolarModelInitialized = sol.is_initialised();
82 if (bSolarModelInitialized) {
83 RESTDebug << "Solar model file " << sSolarModelFile << " successfully loaded!" << RESTendl;
84 } else {
85 RESTError << "Solar model initialization was not successful!" << RESTendl;
86 };
87#endif
88 };
89}
90
91// Default constructor
92TRestAxionSolarModel::TRestAxionSolarModel() : TRestMetadata() { Initialize(); }
93
94// From-file contructor
95TRestAxionSolarModel::TRestAxionSolarModel(const char* cfgFileName, std::string name)
96 : TRestMetadata(cfgFileName) {
97 RESTDebug << "Creating instance of TRestAxionSolarModel from file " + fConfigFileName + "..." << RESTendl;
98 Initialize();
101}
102
103TRestAxionSolarModel::~TRestAxionSolarModel() {} // SolarModel memory in sol will get destroyed automatically
104
107
108 RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++++++" << RESTendl;
109 RESTMetadata << " Solar model created with " << sExternalLibraryName << "." << RESTendl;
110 RESTMetadata << " - Solar model file : " << sSolarModelFile << RESTendl;
111 RESTMetadata << " - Opacity code used : " << sOpacityCodeName << RESTendl;
112 RESTMetadata << "-------------------------------------------------" << RESTendl;
113 RESTMetadata << " - Reference value of the axion-photon coupling : " << fRefPhotonCoupling / 1.0e-10
114 << " x 10^{-10} / GeV" << RESTendl;
115 RESTMetadata << " - Reference value of the axion-electron coupling : " << fRefElectronCoupling / 1.0e-13
116 << " x 10^{-13}" << RESTendl;
117 RESTMetadata << " - Units of the solar axion flux from this class : axions / cm^2 s keV" << RESTendl;
118 RESTMetadata << "+++++++++++++++++++++++++++++++++++++++++++++++++" << RESTendl;
119}
120
121std::string TRestAxionSolarModel::GetSolarModelFileName() { return sSolarModelFile; }
122
123std::vector<double> TRestAxionSolarModel::GetSolarAxionFluxGAGamma(std::vector<double> energies,
124 double r_max) {
125 std::vector<double> result;
126 if (bSolarModelInitialized) {
127 RESTWarning << "TRestAxionSolarModel::GetSolarAxionFluxGAGamma." << RESTendl;
128 RESTWarning << "This code has been commented to allow compilation and needs to be reviewed!"
129 << RESTendl;
130 RESTWarning << "The result vector will be empty!" << RESTendl;
131 // result = sol.calculate_spectral_flux_Primakoff(energies, r_max);
132 } else {
133 RESTError << "TRestAxionSolarModel not properly initialised for "
134 "RestAxionSolarModel::GetSolarAxionFluxGAGamma(...)!"
135 << RESTendl;
136 };
137 return result;
138}
139
140std::vector<double> TRestAxionSolarModel::GetSolarAxionFluxGAGamma(std::vector<double> energies,
141 double g_agamma, double r_max) {
142 std::vector<double> result = GetSolarAxionFluxGAGamma(energies);
143 for (auto flux = result.begin(); flux != result.end(); flux++) {
144 *flux *= pow(g_agamma / fRefPhotonCoupling, 2);
145 };
146 return result;
147}
148
149std::vector<double> TRestAxionSolarModel::GetSolarAxionFluxGAE(std::vector<double> energies, double r_max) {
150 std::vector<double> result;
151 if (bSolarModelInitialized) {
152 RESTWarning << "TRestAxionSolarModel::GetSolarAxionFluxGAE." << RESTendl;
153 RESTWarning << "This code has been commented to allow compilation and needs to be reviewed!"
154 << RESTendl;
155 RESTWarning << "The result vector will be empty!" << RESTendl;
156 // result = sol.calculate_spectral_flux_all_electron(energies, r_max);
157 } else {
158 RESTError << "TRestAxionSolarModel not properly initialised for "
159 "RestAxionSolarModel::GetSolarAxionFluxGAE(...)!"
160 << RESTendl;
161 };
162 return result;
163}
164
165std::vector<double> TRestAxionSolarModel::GetSolarAxionFluxGAE(std::vector<double> energies, double g_agae,
166 double r_max) {
167 std::vector<double> result = GetSolarAxionFluxGAE(energies, r_max);
168 for (auto flux = result.begin(); flux != result.end(); flux++) {
169 *flux *= pow(g_agae / fRefElectronCoupling, 2);
170 };
171 return result;
172}
A metadata class to define theoretical axion models and calculations related.
void Initialize()
Making default settings.
void PrintMetadata()
Implemented it in the derived metadata class to print out specific metadata information.
void InitFromConfigFile()
To make settings from rml file. This method must be implemented in the derived class.
A base class for any REST metadata class.
Definition: TRestMetadata.h:70
virtual void PrintMetadata()
Implemented it in the derived metadata class to print out specific metadata information.
endl_t RESTendl
Termination flag object for TRestStringOutput.
Int_t LoadConfigFromFile(const std::string &configFilename, const std::string &sectionName="")
Give the file name, find out the corresponding section. Then call the main starter.
void SetLibraryVersion(TString version)
Set the library version of this metadata class.
void SetSectionName(std::string sName)
set the section name, clear the section content
std::string SearchFile(std::string filename)
Search files in current directory and directories specified in "searchPath" section.
std::string fConfigFileName
Full name of the rml file.
std::string GetParameter(std::string parName, TiXmlElement *e, TString defaultValue=PARAMETER_NOT_FOUND_STR)
Returns the value for the parameter named parName in the given section.