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

GRBurst.h

00001 
00027 #ifndef GRB_BURST_H
00028 #define GRB_BURST_H
00029 
00030 #include "GRBobsUtilities.h"
00031 #include <vector>
00032 #include <string>
00033 #include <functional>  // for unary_function and plus
00034 #include <fstream>
00035 
00036 class HepRandomEngine;
00037 class TimeEnergy;
00038 class GlobalData;
00039 
00040 
00041 
00042 class GRBurst
00043 {
00044     friend class GRBobsSpectrum;  // to give it access to the private members
00045     friend std::ifstream &operator >> (std::ifstream &is, GRBurst &grb);
00046     
00047 public:
00051     GRBurst();
00052 
00056     GRBurst(const std::vector<std::string> &paramVector);
00057 
00061     GRBurst(HepRandomEngine *engine, const double duration, const int npuls, 
00062         const double flux, const double fraction, const double alpha, 
00063         const double beta, const double epeak, const double specnorm, 
00064         const bool flag);
00065       
00069     virtual ~GRBurst();
00070       
00074     GRBurst(const GRBurst &right);   
00075       
00079     GRBurst &operator=(const GRBurst &right);
00080     
00081     
00082 
00083     // Accessors
00084     std::pair<float,float> dir() const                 { return m_grbdir; }
00085     double univFWHM() const                            { return m_univFWHM; }
00086     const std::vector<double> &specnorm() const        { return m_specnorm; }
00087     long nphoton() const                               { return m_nphoton; } 
00088     const std::vector<TimeEnergy> &photonlist() const  { return m_photonlist; }
00089     GlobalData *globalData() const                     { return m_globalData; }
00090     
00091     void setSpecnorm(const std::vector<double> &specnorm)   { m_specnorm = specnorm; }
00092     
00093     
00094     
00101     void createGRB(HepRandomEngine *engine, const std::string &prefix, 
00102         const std::string &dir=0);
00103     
00107     void createGRB(HepRandomEngine *engine, const double duration, 
00108         const int npuls, const double flux, const double fraction, 
00109         const double alpha, const double beta, const double epeak, 
00110         const double specnorm, const bool flag);
00111     
00112 protected:
00113     // data members
00114     std::pair<float,float>   m_grbdir;             
00115     double                   m_univFWHM;           
00116     std::vector<double>      m_specnorm;           
00117     long                     m_nphoton;            
00118     std::vector<TimeEnergy>  m_photonlist;         
00119     GlobalData               *m_globalData;        
00120     
00121     
00122     
00123     // Accessors
00124     std::vector<TimeEnergy> &photonlist()  { return m_photonlist; }
00125     
00129     virtual long calcNphoton(HepRandomEngine *engine)   { return m_nphoton; }
00130 
00147     void makeTimes(HepRandomEngine *engine, const double ethres);
00148     
00149 private:
00153     std::string baseFilename(const std::string &prefix, const std::string &dir=0) const;
00154     
00158     std::string outputFilename(const std::string &base, const long isim) const;
00159     
00163     GRBurst *clone() const;
00164     
00168     std::pair<float,float> direction(HepRandomEngine *engine) const;
00169     
00173     void getTimes(HepRandomEngine *engine, const double ethres, 
00174         const long nphots, const long deltbinsleft, const long iphotoff, 
00175         const double tmax, const std::vector<double> &pulse);
00176     
00180     virtual void makeGRB(HepRandomEngine *engine)   {}
00181     
00185     void readGRB(const std::vector<std::string> &paramVector);
00186     
00190     void swap(GRBurst &other) throw();
00191 };
00192 
00193 
00194 
00198 class GlobalData
00199 {
00200 public:
00201     GlobalData()  {};
00202     
00203     inline void setDuration(const double duration)      { m_duration=duration; }
00204     inline void setFlux(const double flux)              { m_flux=flux; }
00205     inline void setFraction(const double fraction)      { m_fraction=fraction; }
00206     inline void setAlpha(const double alpha)            { m_alpha=alpha; }
00207     inline void setBeta(const double beta)                          { m_beta=beta; }
00208     inline void setEpeak(const double epeak)            { m_epeak=epeak; }
00209     inline void setSpecnorm(const double specnorm)      { m_specnorm=specnorm; }
00210     inline void setNpuls(const int npuls)               { m_npuls=npuls; }
00211     
00212     inline double duration()       { return m_duration; }
00213     inline double flux()           { return m_flux; }
00214     inline double fraction()       { return m_fraction; }
00215     inline double alpha()                  { return m_alpha; }
00216     inline double beta()                   { return m_beta; }
00217     inline double epeak()                  { return m_epeak; }
00218     inline double specnorm()       { return m_specnorm; }
00219     inline int npuls()             { return m_npuls; }
00220     
00221     GlobalData *clone() const  { return new GlobalData(*this); }
00222     
00223 private:
00224     double m_duration;    
00225     double m_flux;        
00226     double m_fraction;    
00227     double m_alpha;       
00228     double m_beta;        
00229     double m_epeak;       
00230     double m_specnorm;    
00231     int    m_npuls;       
00232 };
00233 
00234 
00235 
00239 class TimeEnergy
00240 {
00241 public:
00242     TimeEnergy() { };
00243     
00244     inline void setTime(double time)   {m_time=time;}
00245     inline void setEnergy(double energy) {m_energy=energy;}
00246     
00247     inline double time() const   {return m_time;}
00248     inline double energy() const {return m_energy;}
00249     
00250 private:
00251     double m_time;
00252     double m_energy;
00253 };
00254 
00255 
00256 
00260 class timeCmp
00261 {
00262 public:
00263     bool operator()(const TimeEnergy &data1, const TimeEnergy &data2)
00264     {
00265         return data1.time() < data2.time();    
00266     }
00267 };
00268 
00269 
00271 std::ofstream &operator<<(std::ofstream &os, const GRBurst &grb);
00272 
00273 
00274 #endif // GRB_MAKER_H

Generated on Mon Jan 27 11:43:32 2003 by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001