Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

AlbedoSpectrum.cxx

Go to the documentation of this file.
00001 // $Header: /nfs/slac/g/glast/ground/cvs/flux/src/AlbedoSpectrum.cxx,v 1.8 2001/06/13 20:55:41 burnett Exp $
00002 
00003 #include "flux/AlbedoSpectrum.h"
00004 
00005 #include "facilities/error.h"
00006 #include <cmath>
00007 #include <string.h>
00008 #include <algorithm>
00009 #include "SpectrumFactory.h"
00010 
00011 static SpectrumFactory<AlbedoSpectrum> factory;
00012 const ISpectrumFactory& AlbedoSpectrumFactory = factory;
00013 
00014 // local namespace
00015 namespace {
00016 
00017     // define the fromMeV function which will convert from
00018     // MeV to GeV
00019     float   fromMeV ( float e ) { return e / 1000.; }
00020 }
00021 
00022 AlbedoSpectrum::AlbedoSpectrum(const std::string& name)
00023 {
00024     if( name == "gamma" )
00025         type_ = photon;
00026     else if( name == "n" || name=="neutron" )
00027         type_ = neutron;
00028     else
00029         FATAL(" AlbedoSpectrum:  not \"gamma\" or \"n\" ");
00030 }
00031 
00032 
00033 const char * AlbedoSpectrum::particleName()const {
00034     if (type_==photon) return "gamma";
00035     else return "neutron";
00036 }
00037 
00038 std::string AlbedoSpectrum::title()const
00039 {
00040     return std::string("albedo-")+std::string(particleName());
00041 }
00042 
00043 
00044 static double albedo_photon_energy(double);
00045 static double albedo_neutron_energy(double);
00046 
00047 
00048 float AlbedoSpectrum::operator()(float r)const
00049 {
00050     r = std::max(1e-6, 1.0-r); // make monotonic increasing, avoid problem at zero.
00051     return fromMeV((type_==photon)? albedo_photon_energy(r)
00052         : albedo_neutron_energy(r) );
00053 }
00054 
00055 
00056 // Routines which return random energies typical of the spectra
00057 // of particles produced by earth albedo.
00058 
00059 #include <math.h>
00060 
00061 // lower cutoffs
00062 static const double neutron_emin= 100.,
00063 photon_emin=10.;
00064 static const double neutronexp =(1.6 - 1.0);
00065 
00066 static double albedo_photon_energy(double r)
00067 /* gamma ray spectrum from near the horizon. */
00068 /* Ref: Thompson et al., 1981, JGR, 86, 1265 */
00069 { return photon_emin / r; }
00070 
00071 static double albedo_neutron_energy(double r)
00072 /* neutron spectrum good up to 10 GeV?  */
00073 /* Ref: Armstrong et al., 1973, JGR, 78, 2715
00074 Gehrels, 1992, NIM, A313, 513
00075 Gehrels,                                */
00076 { return neutron_emin / pow(r, 1./neutronexp); }
00077 
00078 
00079 double AlbedoSpectrum::calculate_rate(double old_rate)
00080 {
00081     return old_rate;
00082 }

Generated at Wed Nov 21 12:20:33 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000