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

Spectrum.cxx

Go to the documentation of this file.
00001 // Spectrum.cxx: implementation of the Spectrum class.
00002 //
00004 
00005 #include "Spectrum.h"
00006 #include <cmath>
00007 
00008 // CLHEP
00009 #include "CLHEP/Random/RandomEngine.h"
00010 #include "CLHEP/Random/RandGeneral.h"
00011 #include "CLHEP/Random/RandExponential.h"
00012 #include "CLHEP/Random/RandFlat.h"
00013 
00015 // Construction/Destruction
00017 
00018 Spectrum::~Spectrum(){}
00019 
00020 
00021 double Spectrum::flux (double time ) const {
00022     return 0.; // flag that we don't have a flux
00023 }
00024 
00025 double Spectrum::solidAngle( )const
00026 {
00027     return 1.0; // flag that doesn't calculate
00028 }
00029 
00030 std::pair<float,float> Spectrum::dir(float energy)const
00031 {
00032     // Purpose: return solid angle pair (costh, phi) for the given energy
00033     // Input:: the given energy.
00034     // default: random except for Earth occultation
00035     //here's an attempt at random default distributions as above:
00036     return std::make_pair(((RandFlat::shoot(1.0))*1.4)-0.4,(RandFlat::shoot(1.0))*2*M_PI);
00037     
00038 }
00039 
00040 
00041 const char * Spectrum::particleName()const{
00042     static const char x='p';
00043     return &x;
00044 }
00045 
00046 double Spectrum::energySrc(HepRandomEngine* engine, double time)
00047 {
00048     // default implementation, which works for other Spectrum objects
00049     return (*this)(engine->flat());
00050 }
00051 
00052 
00053 std::pair<double,double> Spectrum::dir(double energy, HepRandomEngine* engine)
00054 {
00055     // default that needs fixing!
00056     return dir(energy);
00057 }
00058 
00059 void Spectrum::parseParamList(std::string input, std::vector<float>& output) const
00060 {
00061     
00062     int i=0;
00063     for(;!input.empty() && i!=std::string::npos;){
00064         float f = ::atof( input.c_str() );
00065         output.push_back(f);
00066         i=input.find_first_of(",");
00067         input= input.substr(i+1);
00068     } 
00069 }
00070 
00071 
00072 double Spectrum::interval (double time)
00073 {
00074     double  r = (solidAngle()*flux(time)*6.);
00075     
00076     if (r == 0){ return -1.;
00077     }else{  
00078         double p = RandFlat::shoot(1.);
00079         return (-1.)*(log(1.-p))/r;
00080     }
00081 }

Generated on Wed Oct 16 14:01:31 2002 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001