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

AlbedoPSpectrum Class Reference

Calculate the earth albedo proton spectrum in low earth orbit. Uses data produced by AMS detector, preliminary graphs from web page. No angular or geographic dependence included. More...

#include <AlbedoPSpectrum.h>

Inheritance diagram for AlbedoPSpectrum::

Spectrum ISpectrum List of all members.

Public Methods

 AlbedoPSpectrum (const std::string &params)
 Constructor. Initial geographic lat and lon in degrees. More...

virtual double calculate_rate (double old_rate)
 Ask GPS where we are and find the flux at that point. More...

virtual double flux (double) const
 calculate flux for the current position. More...

virtual double solidAngle () const
 effective solid angle for the given energy. More...

virtual float flux (float lat, float lon) const
 flux as a function of latitude and longitude in 600 km orbit. More...

virtual float flux (std::pair< double, double > coords) const
 Flux for a specified position, packaged as a pair. More...

virtual float operator() (float) const
 sample a single particle energy from the spectrum. More...

virtual void setPosition (float lat, float lon)
 move to a new position and do the necessary initialization. More...

virtual void setPosition (std::pair< double, double > coords)
 Do the initialization necessary when moving to a new position. More...

int askGPS ()
 Ask the GPS where we are located. More...

virtual std::pair< float,
float > 
dir (float energy) const
 sample a solid angle pair (costh,phi) from angular distribution. More...

virtual std::string title () const
 What's my name? More...

virtual const char * particleName () const
 What kind of particle do I make? (p for proton). More...

const char * nameOf () const
void setParticleName (std::string name)
 set the particle name. (default is "p"). More...


Private Methods

void init (const std::vector< float > &params)
 Initializes parameters during construction. More...

void fitParams (const double lat, const double lon, double &alf1, double &alf2, double &emin, double &emax, double &v1, double &v2, double &Ejoin) const
 Evaluate the coefficients of the broken power law albedo proton model. More...


Private Attributes

float m_flux
 current flux (set when cutoff changes). More...

std::string m_particle_name
ObserverAdapter< AlbedoPSpectrum > m_observer

Detailed Description

Calculate the earth albedo proton spectrum in low earth orbit. Uses data produced by AMS detector, preliminary graphs from web page. No angular or geographic dependence included.

Interface: The constructor arguments specify the satellite position (latitude, longitude) in degrees. The position can be changed by use of the setPosition() member. The total flux in protons/(m^2 sec ster) is returned by the flux() member. There are 3 ways to call flux(): With no arguments it uses the current cutoff energy. If there is one argument, it is assumed to be a cutoff. Two arguments are assumed to be latitude and longitude, and the corresponding cutoff is looked up. The stored current value is not changed. The operator() function returns a sampled energy value. The argument must be a float value between 0 and 1. The dir() member returns a sampled particle's direction. The argument is the particle energy, as produced by ().

Author:
Patrick Nolan, Stanford University, 1999
$Header $

Definition at line 38 of file AlbedoPSpectrum.h.


Constructor & Destructor Documentation

AlbedoPSpectrum::AlbedoPSpectrum const std::string &    paramstring
 

Constructor. Initial geographic lat and lon in degrees.

Definition at line 39 of file AlbedoPSpectrum.cxx.

References init(), and Spectrum::parseParamList().

00039                                                              {
00040     std::vector<float> params;
00041     
00042     parseParamList(paramstring,params);
00043     
00044     init(params);
00045 }


Member Function Documentation

int AlbedoPSpectrum::askGPS  
 

Ask the GPS where we are located.

Definition at line 125 of file AlbedoPSpectrum.cxx.

References GPS::instance(), and setPosition().

Referenced by init().

00126 {
00127     setPosition(GPS::instance()->lat(), GPS::instance()->lon());
00128     return 0; // can't be void in observer pattern
00129 }

double AlbedoPSpectrum::calculate_rate double    old_rate [virtual]
 

Ask GPS where we are and find the flux at that point.

Definition at line 147 of file AlbedoPSpectrum.cxx.

References GPS::instance().

00148 {
00149     return flux(GPS::instance()->lat(), GPS::instance()->lon());
00150 }

std::pair< float, float > AlbedoPSpectrum::dir float    energy const [virtual]
 

sample a solid angle pair (costh,phi) from angular distribution.

Reimplemented from Spectrum.

Definition at line 155 of file AlbedoPSpectrum.cxx.

00156 {
00157     // Random particle direction
00158     
00159     float coszenith, earthazi,dens,v;
00160     const int try_max = 1000;
00161     static int max_tried = 0;
00162     int trial = 0;
00163     earthazi = 2. * M_PI * HepRandom::getTheGenerator()->flat();
00164     do {
00165         coszenith = 2. * HepRandom::getTheGenerator()->flat() - 1.;
00166         dens = 1. + 0.6 * sqrt(1.-coszenith*coszenith);
00167         v = 1.6 * HepRandom::getTheGenerator()->flat();
00168     } while (v > dens && trial++ < try_max);
00169     
00170     max_tried = std::max(trial, max_tried);
00171     
00172     return std::make_pair<float,float>(coszenith, earthazi);
00173 }

void AlbedoPSpectrum::fitParams const double    lat,
const double    lon,
double &    alf1,
double &    alf2,
double &    emin,
double &    emax,
double &    v1,
double &    v2,
double &    Ejoin
const [private]
 

Evaluate the coefficients of the broken power law albedo proton model.

Input: lat Magnetic latitude in degrees Output: alf1,alf2 Slopes of the two power laws emin,emax Artificial upper and lower cutoff energies v1,v2 Integrated fluxes of the two power laws Ejoin Energy at which the two power laws meet

flux (protons / m^s sec ster MeV) = a1 * (e/e1)^(-alf1) if emin < e < Ejoin a2 * (e/e2)^(-alf2> if Ejoin < e < emax when e is measured in GeV (following the AMS convention)

Definition at line 188 of file AlbedoPSpectrum.cxx.

Referenced by flux(), and operator()().

00191 {
00192     double theta = abs(Geomag::geolat(lat,lon)) * M_PI / 180.;
00193     double e1 = .2;  // pivot point of lower power law
00194     double e2 = 1.;  // pivot point of higher power law
00195     emin = .01;      
00196     emax = 10.;
00197     // normalization values of the two power laws
00198     double a1 = 0.142 + theta * (-.4809 + theta * .5517);
00199     double a2 = .0499 + theta * (-.3239 + theta * (.8077 + theta * (-.8800 + 
00200         theta * .3607)));
00201     alf1 = .4913 + theta * (2.017 + theta * (-.6941 - 1.49 * theta));
00202     alf2 = 2.85 - .875 * theta;
00203     Ejoin = pow(a1*pow(e1,alf1) / (a2*pow(e2,alf2)), 1./(alf1-alf2));
00204     v1 = 1000.*a1*pow(e1,alf1)*(pow(Ejoin,1.-alf1)-pow(emin,1.-alf1))
00205         /(1.-alf1);  // integral of lower power law
00206     v2 = 1000.*a2*pow(e2,alf2)*(pow(emax,1.-alf2)-pow(Ejoin,1.-alf2)) 
00207         /(1.-alf2);  // integral of upper power law
00208 }

float AlbedoPSpectrum::flux std::pair< double, double >    coords const [virtual]
 

Flux for a specified position, packaged as a pair.

Definition at line 100 of file AlbedoPSpectrum.cxx.

References flux().

00100                                                                 {
00101     return flux(coords.first, coords.second);
00102 }

float AlbedoPSpectrum::flux float    lat,
float    lon
const [virtual]
 

flux as a function of latitude and longitude in 600 km orbit.

Definition at line 90 of file AlbedoPSpectrum.cxx.

References fitParams().

00090                                                       {
00091     double v1,v2, alf1, alf2, emin, emax, Ejoin;
00092     fitParams(lat, lon, alf1, alf2, emin, emax, v1, v2, Ejoin);
00093     // The factor 1.47 is induced by the assumed angular dependence.
00094     return 1.47 * (v1+v2);
00095 }

double AlbedoPSpectrum::flux double    time const [virtual]
 

calculate flux for the current position.

Reimplemented from Spectrum.

Definition at line 73 of file AlbedoPSpectrum.cxx.

References m_flux.

Referenced by flux().

00073                                          {
00074     return m_flux;
00075 }

void AlbedoPSpectrum::init const std::vector< float > &    params [private]
 

Initializes parameters during construction.

Definition at line 19 of file AlbedoPSpectrum.cxx.

References askGPS(), GPS::instance(), m_observer, m_particle_name, GPS::notification(), and setPosition().

Referenced by AlbedoPSpectrum().

00019                                                          {
00020     
00021     float lat =  params.size()>0? params[0]: 0.0f;
00022     float lon =  params.size()>1? params[1]: 0.0f;
00023     setPosition(lat, lon);
00024     
00025     m_particle_name = "p";
00026     
00027     // set callback to be notified when the position changes
00028     m_observer.setAdapter( new ActionAdapter<AlbedoPSpectrum>
00029         (this, &AlbedoPSpectrum::askGPS) );
00030     
00031     GPS::instance()->notification().attach( &m_observer );
00032     
00033 }

const char* AlbedoPSpectrum::nameOf   const [inline]
 

Definition at line 69 of file AlbedoPSpectrum.h.

00069 {return "AlbedoPSpectrum";}

float AlbedoPSpectrum::operator() float    x const [virtual]
 

sample a single particle energy from the spectrum.

Reimplemented from Spectrum.

Definition at line 109 of file AlbedoPSpectrum.cxx.

References fitParams(), Spectrum::m_lat, and Spectrum::m_lon.

00109                                                {
00110     double v1,v2, alf1, alf2, emin, emax, Ejoin;
00111     fitParams(m_lat, m_lon, alf1, alf2, emin, emax, v1, v2, Ejoin);
00112     double split = v1/(v1+v2);
00113     if (x > split) {
00114         return pow((pow(Ejoin,1.-alf2)+((1.-x)/(1.-split))*(pow(emax,1.-alf2)
00115             -pow(Ejoin,1.-alf2))), 1./(1.-alf2));
00116     } else {
00117         return pow((pow(emin,1.-alf1)+(x/split)*(pow(Ejoin,1.-alf1)
00118             -pow(emin,1.-alf1))), 1./(1.-alf1));
00119     }
00120 }

const char * AlbedoPSpectrum::particleName   const [virtual]
 

What kind of particle do I make? (p for proton).

Reimplemented from Spectrum.

Definition at line 58 of file AlbedoPSpectrum.cxx.

References m_particle_name.

00058                                                  {
00059     return m_particle_name.c_str();
00060 }

void AlbedoPSpectrum::setParticleName std::string    name
 

set the particle name. (default is "p").

Definition at line 65 of file AlbedoPSpectrum.cxx.

References m_particle_name.

00066 {
00067     m_particle_name = name;
00068 }

void AlbedoPSpectrum::setPosition std::pair< double, double >    coords [virtual]
 

Do the initialization necessary when moving to a new position.

Definition at line 141 of file AlbedoPSpectrum.cxx.

00141                                                                 {
00142     AlbedoPSpectrum::setPosition(coords.first, coords.second);
00143 }

void AlbedoPSpectrum::setPosition float    lat,
float    lon
[virtual]
 

move to a new position and do the necessary initialization.

Definition at line 133 of file AlbedoPSpectrum.cxx.

Referenced by askGPS(), and init().

00133                                                       {
00134     m_lat = lat;
00135     m_lon = lon;
00136     m_flux = flux(lat, lon);
00137 }

double AlbedoPSpectrum::solidAngle   const [virtual]
 

effective solid angle for the given energy.

Reimplemented from Spectrum.

Definition at line 80 of file AlbedoPSpectrum.cxx.

00081 {
00082     return 4.*M_PI;
00083 }

std::string AlbedoPSpectrum::title   const [virtual]
 

What's my name?

Reimplemented from Spectrum.

Definition at line 51 of file AlbedoPSpectrum.cxx.

00051                                        {
00052     return "AlbedoPSpectrum";
00053 }


Member Data Documentation

float AlbedoPSpectrum::m_flux [private]
 

current flux (set when cutoff changes).

Definition at line 81 of file AlbedoPSpectrum.h.

Referenced by flux().

ObserverAdapter< AlbedoPSpectrum > AlbedoPSpectrum::m_observer [private]
 

Definition at line 84 of file AlbedoPSpectrum.h.

Referenced by init().

std::string AlbedoPSpectrum::m_particle_name [private]
 

Definition at line 83 of file AlbedoPSpectrum.h.

Referenced by init(), particleName(), and setParticleName().


The documentation for this class was generated from the following files:
Generated on Wed Oct 16 14:01:32 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001