00001
00002
00004
00005 #include "Spectrum.h"
00006 #include <cmath>
00007
00008
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
00017
00018 Spectrum::~Spectrum(){}
00019
00020
00021 double Spectrum::flux (double time ) const {
00022 return 0.;
00023 }
00024
00025 double Spectrum::solidAngle( )const
00026 {
00027 return 1.0;
00028 }
00029
00030 std::pair<float,float> Spectrum::dir(float energy)const
00031 {
00032
00033
00034
00035
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
00049 return (*this)(engine->flat());
00050 }
00051
00052
00053 std::pair<double,double> Spectrum::dir(double energy, HepRandomEngine* engine)
00054 {
00055
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 }