gambit is hosted by Hepforge, IPPP Durham
GAMBIT  v1.5.0-2191-ga4742ac
a Global And Modular Bsm Inference Tool
DarkBit.cpp
Go to the documentation of this file.
1 // GAMBIT: Global and Modular BSM Inference Tool
2 // *********************************************
43 
47 
48 namespace Gambit
49 {
50  namespace DarkBit
51  {
52 
54  //
55  // Simple DM property extractors
56  //
58 
60  void mwimp_generic(double &result)
61  {
62  using namespace Pipes::mwimp_generic;
63  result = Dep::TH_ProcessCatalog->getParticleProperty(*Dep::DarkMatter_ID).mass;
64  if (result < 0.0) DarkBit_error().raise(LOCAL_INFO, "Negative WIMP mass detected.");
65  }
66 
70  void sigmav_late_universe(double &result)
71  {
72  using namespace Pipes::sigmav_late_universe;
73  std::string DMid = *Dep::DarkMatter_ID;
74  std::string DMbarid = *Dep::DarkMatterConj_ID;
75  TH_Process annProc = Dep::TH_ProcessCatalog->getProcess(DMid, DMbarid);
76  result = 0.0;
77  // Add all the regular channels
78  for (std::vector<TH_Channel>::iterator it = annProc.channelList.begin();
79  it != annProc.channelList.end(); ++it)
80  {
81  if ( it->nFinalStates == 2 )
82  {
83  // (sv)(v=0) for two-body final state
84  double yield = it->genRate->bind("v")->eval(0.);
85  if (yield >= 0.) result += yield;
86  }
87  }
88  // Add invisible contributions
89  double yield = annProc.genRateMisc->bind("v")->eval(0.);
90  if (yield >= 0.) result += yield;
91  }
92 
93  void sigmav_late_universe_MicrOmegas(double &result)
94  {
96 
97  // set requested spectra to NULL since we don't need them
98  double * SpNe=NULL,*SpNm=NULL,*SpNl=NULL;
99  double * SpA=NULL,*SpE=NULL,*SpP=NULL;
100  int err;
101 
102  // TODO: Add option to choose options for calculation from MicrOmegas (right now all effects are turned on)
103  result = BEreq::calcSpectrum(byVal(3),byVal(SpA),byVal(SpE),byVal(SpP),byVal(SpNe),byVal(SpNm),byVal(SpNl) ,byVal(&err));
104 
105  if (err != 0 )
106  {
107  DarkBit_error().raise(LOCAL_INFO, "MicrOmegas spectrum calculation returned error code = " + std::to_string(err));
108  }
109 
110  }
111 
114  void DM_process_from_ProcessCatalog(std::string &result)
115  {
117 
118  // Only need to check this once.
119  static bool first = true;
120  if (first)
121  {
122  // Can we find a process that is a decay?
123  // (This logic used so that this capability does not depend on DarkMatterConj_ID)
124  const TH_Process* p = (*Dep::TH_ProcessCatalog).find(*Dep::DarkMatter_ID);
125 
126  // If not, it's an annihilation.
127  if (p == NULL) result = "annihilation";
128  else result = "decay";
129  first = false;
130  }
131 
132  }
133 
134 
136  //
137  // Extraction of local and global dark matter halo properties
138  //
140 
141 
143  double profile_gNFW(double rhos, double rs, double alpha, double beta, double gamma, double r)
144  { return pow(2, (beta-gamma)/alpha)*rhos/pow(r/rs, gamma)/pow(1+pow(r/rs, alpha), (beta-gamma)/alpha); }
145 
147  double profile_Einasto(double rhos, double rs, double alpha, double r)
148  { return rhos*exp((-2.0/alpha)*(pow(r/rs, alpha)-1)); }
149 
152  {
153  using namespace Pipes::GalacticHalo_gNFW;
154  double rhos = *Param["rhos"];
155  double rs = *Param["rs"];
156  double r_sun = *Param["r_sun"];
157  double alpha = *Param["alpha"];
158  double beta = *Param["beta"];
159  double gamma = *Param["gamma"];
160  result.DensityProfile = daFunk::func(profile_gNFW, rhos, rs, alpha, beta, gamma, daFunk::var("r"));
161  result.r_sun = r_sun;
162  }
163 
166  {
167  using namespace Pipes::GalacticHalo_Einasto;
168  double rhos = *Param["rhos"];
169  double rs = *Param["rs"];
170  double r_sun = *Param["r_sun"];
171  double alpha = *Param["alpha"];
172  result.DensityProfile = daFunk::func(profile_Einasto, rhos, rs, alpha, daFunk::var("r"));
173  result.r_sun = r_sun;
174  }
175 
178  {
179  using namespace Pipes::ExtractLocalMaxwellianHalo;
180  double rho0 = *Param["rho0"];
181  double v0 = *Param["v0"];
182  double vesc = *Param["vesc"];
183  double vrot = *Param["vrot"];
184  result.rho0 = rho0;
185  result.v0 = v0;
186  result.vesc = vesc;
187  result.vrot = vrot;
188  }
189 
190 
191 
193  //
194  // DarkBit Unit Test
195  //
197 
202  void UnitTest_DarkBit(int &result)
203  {
204  using namespace Pipes::UnitTest_DarkBit;
206  /* This function depends on all relevant DM observables (indirect and
207  * direct) and dumps them into convenient files in YAML format, which
208  * afterwards can be checked against the expectations.
209  */
210 
211  double M_DM =
212  Dep::TH_ProcessCatalog->getParticleProperty(*Dep::DarkMatter_ID).mass;
213  double Gps = (*Dep::DD_couplings).gps;
214  double Gpa = (*Dep::DD_couplings).gpa;
215  double Gns = (*Dep::DD_couplings).gns;
216  double Gna = (*Dep::DD_couplings).gna;
217  double oh2 = *Dep::RD_oh2;
218 
219  std::string DMid = *Dep::DarkMatter_ID;
220  std::string DMbarid = *Dep::DarkMatterConj_ID;
221  TH_Process annProc = (*Dep::TH_ProcessCatalog).getProcess(DMid, DMbarid);
222  daFunk::Funk spectrum = (*Dep::GA_Yield)->set("v", 0.);
223 
224  std::ostringstream filename;
225  /*
226  static unsigned int counter = 0;
227  filename << runOptions->getValueOrDef<std::string>("UnitTest_DarkBit",
228  "fileroot");
229  filename << "_" << counter << ".yml";
230  counter++;
231  */
233  filename << runOptions->getValueOrDef<std::string>("UnitTest.yaml", "filename");
234 
235  std::ofstream os;
236  os.open(filename.str());
237  if(os)
238  {
239  // Standard output.
240  os << "# Direct detection couplings\n";
241  os << "DDcouplings:\n";
242  os << " gps: " << Gps << "\n";
243  os << " gpa: " << Gpa << "\n";
244  os << " gns: " << Gns << "\n";
245  os << " gna: " << Gna << "\n";
246  os << "\n";
247  os << "# Particle masses [GeV] \n";
248  os << "ParticleMasses:\n";
249  os << " Mchi: " << M_DM << "\n";
250  os << "\n";
251  os << "# Relic density Omega h^2\n";
252  os << "RelicDensity:\n";
253  os << " oh2: " << oh2 << "\n";
254  os << "\n";
255 
256  // Output gamma-ray spectrum (grid be set in YAML file).
257  double x_min =
259  runOptions->getValueOrDef<double>(0.1, "GA_AnnYield", "Emin");
260  double x_max =
262  runOptions->getValueOrDef<double>(10000, "GA_AnnYield", "Emax");
264  int n = runOptions->getValueOrDef<double>(26, "GA_AnnYield", "nbins");
265  // from 0.1 to 500 GeV
266  std::vector<double> x = daFunk::logspace(log10(x_min), log10(x_max), n);
267  std::vector<double> y = spectrum->bind("E")->vect(x);
268  os << "# Annihilation spectrum dNdE [1/GeV]\n";
269  os << "GammaRaySpectrum:\n";
270  os << " E: [";
271  for (std::vector<double>::iterator it = x.begin(); it != x.end(); it++)
272  os << *it << ", ";
273  os << "]\n";
274  os << " dNdE: [";
275  for (std::vector<double>::iterator it = y.begin(); it != y.end(); it++)
276  os << *it << ", ";
277  os << "]\n";
278  os << std::endl;
279 
280  os << "# Annihilation rates\n";
281  os << "AnnihilationRates:\n";
282  for (std::vector<TH_Channel>::iterator it = annProc.channelList.begin();
283  it != annProc.channelList.end(); ++it)
284  {
285  os << " ";
286  for (std::vector<std::string>::iterator
287  jt = it->finalStateIDs.begin(); jt!=it->finalStateIDs.end(); jt++)
288  {
289  os << *jt << "";
290  }
291  if (it->finalStateIDs.size() == 2)
292  os << ": " << it->genRate->bind("v")->eval(0);
293  if (it->finalStateIDs.size() == 3)
294  {
295  double m1 = (*Dep::TH_ProcessCatalog).getParticleProperty(
296  it->finalStateIDs[1]).mass;
297  double m2 = (*Dep::TH_ProcessCatalog).getParticleProperty(
298  it->finalStateIDs[2]).mass;
299  double mass = M_DM;
300  daFunk::Funk E1_low = daFunk::func(gamma3bdy_limits<0>, daFunk::var("E"), mass, m1, m2);
301  daFunk::Funk E1_high = daFunk::func(gamma3bdy_limits<1>, daFunk::var("E"), mass, m1, m2);
302  daFunk::Funk dsigmavde = it->genRate->gsl_integration("E1", E1_low, E1_high)->set_epsrel(1e-3)->set("v", 0);
303  auto xgrid = daFunk::logspace(-2, 3, 1000);
304  auto ygrid = daFunk::logspace(-2, 3, 1000);
305  for ( size_t i = 0; i<xgrid.size(); i++ )
306  {
307  ygrid[i] = dsigmavde->bind("E")->eval(xgrid[i]);
308  }
309  auto interp = daFunk::interp("E", xgrid, ygrid);
310  double svTOT = interp->gsl_integration("E", 10., 20.)->set_epsabs(1e-3)->bind()->eval();
311  os << ": " << svTOT;
312  }
313  os << "\n";
314  }
315  os << std::endl;
316  }
317  else
318  {
319  logger() << "Warning: outputfile not open for writing." << EOM;
320  }
321  os.close();
322  result = 0;
323  }
324  }
325 }
std::vector< TH_Channel > channelList
List of channels.
error & DarkBit_error()
template double gamma3bdy_limits< 0 >(double, double, double, double)
double profile_Einasto(double rhos, double rs, double alpha, double r)
Einasto dark matter halo profile function.
Definition: DarkBit.cpp:147
START_MODEL beta
Definition: Axions.hpp:36
void sigmav_late_universe(double &result)
Retrieve the total thermally-averaged annihilation cross-section for indirect detection (cm^3 / s)...
Definition: DarkBit.cpp:70
START_MODEL r_sun
START_MODEL rs
#define LOCAL_INFO
Definition: local_info.hpp:34
START_MODEL v0
Funk var(std::string arg)
Definition: daFunk.hpp:921
void GalacticHalo_gNFW(GalacticHaloProperties &result)
Module function to generate GalacticHaloProperties for gNFW profile.
Definition: DarkBit.cpp:151
START_MODEL vesc
START_MODEL alpha
MATH_OPERATION(Dif,-) MATH_OPERATION(pow) MATH_OPERATION(fmin) MATH_OPERATION(fmax) class FunkInterp shared_ptr< FunkInterp > interp(T f, std::vector< double > x, std::vector< double > y)
Definition: daFunk.hpp:1349
const TH_Channel * find(std::vector< str >) const
Check for given channel. Return a pointer to it if found, NULL if not.
std::vector< double > logspace(double x0, double x1, unsigned int n)
Definition: daFunk.hpp:186
const Logging::endofmessage EOM
Explicit const instance of the end of message struct in Gambit namespace.
Definition: logger.hpp:100
Funk func(double(*f)(funcargs...), Args... args)
Definition: daFunk.hpp:768
template double gamma3bdy_limits< 1 >(double, double, double, double)
Header file that includes all GAMBIT headers required for a module source file.
EXPORT_SYMBOLS Logging::LogMaster & logger()
Function to retrieve a reference to the Gambit global log object.
Definition: logger.cpp:95
START_MODEL dNur_CMB r
double profile_gNFW(double rhos, double rs, double alpha, double beta, double gamma, double r)
Generalized NFW dark matter halo profile function.
Definition: DarkBit.cpp:143
void sigmav_late_universe_MicrOmegas(double &result)
Definition: DarkBit.cpp:93
START_MODEL vrot
daFunk::Funk genRateMisc
Additional decay rate or sigmav (in addition to above channels)
double gamma3bdy_limits(double Eg, double M_DM, double m1, double m2)
Calculate kinematical limits for three-body final states.
void UnitTest_DarkBit(int &result)
Central unit test routine.
Definition: DarkBit.cpp:202
void ExtractLocalMaxwellianHalo(LocalMaxwellianHalo &result)
Module function providing local density and velocity dispersion parameters.
Definition: DarkBit.cpp:177
Rollcall header for module DarkBit.
double pow(const double &a)
Outputs a^i.
void mwimp_generic(double &result)
Retrieve the DM mass in GeV for generic models (GeV)
Definition: DarkBit.cpp:60
A container for a single process.
T byVal(T t)
Redirection function to turn an lvalue into an rvalue, so that it is correctly passed by value when d...
void DM_process_from_ProcessCatalog(std::string &result)
Information about the nature of the DM process in question (i.e.
Definition: DarkBit.cpp:114
shared_ptr< FunkBase > Funk
Definition: daFunk.hpp:113
void GalacticHalo_Einasto(GalacticHaloProperties &result)
Module function to generate GalacticHaloProperties for Einasto profile.
Definition: DarkBit.cpp:165
TODO: see if we can use this one:
Definition: Analysis.hpp:33
Utility functions for DarkBit.