SatAndLight
2.2.2-hubble
Simulation toolkit for space telescopes
|
Astrophysical source spectra and light curves. More...
#include <SpecTime.h>
Public Member Functions | |
double | DrawEnergy (const double aTime) |
Draws an energy value at a given time. More... | |
TH2D * | GetFlux (void) |
Returns a pointer to the flux TH2D object. More... | |
TH1D * | GetLightCurve (const double aEnergyMin=0.0, const double aEnergyMax=-1.0) |
Returns the source light curve between two energies. More... | |
int | GetParticleN (const ULong64_t aTime, const UInt_t aDuration, const double aCosTheta=1.0) |
Computes the number of particles generated between 2 times. More... | |
TH2D * | GetRate (void) |
Returns a pointer to the flux TH2D object. More... | |
TH1D * | GetSpectrum (const double aTimeMin=0.0, const double aTimeMax=-1.0, const bool aObserved=false) |
Returns the source energy spectrum between two times. More... | |
double | GetTimeMax (void) |
Returns the maximum time defining the SpecTime object. More... | |
double | GetTimeMin (void) |
Returns the minimum time defining the SpecTime object. More... | |
void | MakeBandLimited (const double aFlux, const double aEnergyMin, const double aEnergyMax, TGraph *aSurface=NULL) |
Makes a band-limited flux SpecTime object. More... | |
void | MakeGRBData (TH1D *aLightCurveExp, const double aE1, const double aE2, const double aPhotonIndex, const double aNint, const double aNgal, const double aZ, TGraph *aSurfaceExp, TGraph *aSurface=NULL) |
Makes a SpecTime object using GRB data. More... | |
void | MakeGRBModel1 (const double aFlux, const double aEnergy0, const double aAlpha, const double aBeta, TGraph *aSurface=NULL) |
Makes a SpecTime object using a GRB model (I). More... | |
void | MakePowerLawEnergy (const double aFlux, const double aEnergyDecay, TGraph *aSurface=NULL) |
Makes a power-law flux SpecTime object. More... | |
void | MakePowerLawTime (const double aFlux, const double aTimeDecay, const double aEnergyMin, const double aEnergyMax, TGraph *aSurface=NULL) |
Makes a power-law flux SpecTime object. More... | |
void | MakeRate (TGraph *aSurface) |
Computes the rate given an integration surface. More... | |
void | MakeUniform (const double aFlux, TGraph *aSurface=NULL) |
Makes a uniform flux SpecTime object. More... | |
void | SetFlux (TH2D *aFlux, TGraph *aSurface=NULL) |
Defines a new flux fonction. More... | |
void | SetPhotoElectricCrossSection (TGraph *aGraph) |
Sets the photo-electric cross-section. More... | |
Constructors and destructors | |
SpecTime (const int aNt, const double *aTimeBins, const int aNe, const double *aEnergyBins) | |
SpecTime class constuctor. More... | |
SpecTime (const int aNt, const double aTimeMin, const double aTimeMax, const bool aUseTimeLog, const int aNe, const double aEnergyMin, const double aEnergyMax, const bool aUseEnergyLog) | |
SpecTime class constuctor. More... | |
SpecTime (TH2D *aFlux, TH2D *aRate=NULL) | |
SpecTime class constuctor. More... | |
virtual | ~SpecTime (void) |
SpecTime class destructor. More... | |
Protected Attributes | |
TH2D * | flux |
source flux \({\cal{F}}(E,t)\). More... | |
TRandom3 * | randgen |
random generator. More... | |
TH2D * | rate |
source rate \({\cal{R}}(E,t)\). More... | |
Private Member Functions | |
void | ConstructHistos (const int aNt, const double *aTimeBins, const int aNe, const double *aEnergyBins) |
for constructors. More... | |
void | MakeCum (void) |
Computes cumulative rate. More... | |
Private Attributes | |
TGraph * | photoelectric_xsec |
photo-electric cross-section. More... | |
double ** | rate_cum |
cumulative rate (over \(E\)). More... | |
Astrophysical source spectra and light curves.
A SpecTime object is used to describe an astrophysical source spectrum as a function of time. It describes both the time and energy distributions of astro-particles. It includes 2-dimensional histograms (TH2D) to describe the particle flux, \({\cal{F}}(E,t)=\frac{d^4N}{dSdtdE}(E,t)\), and the particle rate, \({\cal{R}}(E,t)=\frac{d^2N}{dtdE}(E,t)\). A surface of interest \(S(E)\) must be provided to derive the rate from the flux:
\[ {\cal{R}}(E,t)=\frac{d^2N}{dtdE}(E,t)=\iint_S{\cal{F}}(E,t)dS=\iint_S\frac{d^4N}{dSdtdE}(E,t)dS. \]
The flux and rate functions are represented by 2-dimensional histograms (TH2D in ROOT). The x-axis is binned in time and the y-axis is binned in energy.
This class offers many methods (MakeUniform(), MakeBandLimited(), MakePowerLawTime(), MakePowerLawEnergy(), MakeGRBModel1(),...) to compute realistic (or not) flux/rate models.
Finally, the SpecTime object can be used to randomly draw particle parameters.
SpecTime::SpecTime | ( | const int | aNt, |
const double * | aTimeBins, | ||
const int | aNe, | ||
const double * | aEnergyBins | ||
) |
SpecTime class constuctor.
In this constructor TH2D objects are initialized and the binning must be provided. The binning can no longer be changed.
[in] | aNt | Number of time bins. |
[in] | aTimeBins | Pointer to an array of bin limits \([\mathrm{ms}]\). |
[in] | aNe | Number of energy bins. |
[in] | aEnergyBins | Pointer to an array of bin limits \([\mathrm{keV}]\). |
SpecTime::SpecTime | ( | const int | aNt, |
const double | aTimeMin, | ||
const double | aTimeMax, | ||
const bool | aUseTimeLog, | ||
const int | aNe, | ||
const double | aEnergyMin, | ||
const double | aEnergyMax, | ||
const bool | aUseEnergyLog | ||
) |
SpecTime class constuctor.
The flux and rate functions are represented by 2-dimensional histograms (TH2D in ROOT). The x-axis is binned in time and the y-axis is binned in energy. In this constructor TH2D objects are initialized and the binning must be provided. The binning can no longer be changed.
[in] | aNt | Number of time bins. |
[in] | aTimeMin | Minimum time \([\mathrm{ms}]\). |
[in] | aTimeMax | Maximum time \([\mathrm{ms}]\). |
[in] | aUseTimeLog | Flag to use logarithmic bins (true) or linear bins (false) for time. |
[in] | aNe | Number of energy bins. |
[in] | aEnergyMin | Minimum energy \([\mathrm{keV}]\). |
[in] | aEnergyMax | Maximum energy \([\mathrm{keV}]\). |
[in] | aUseEnergyLog | Flag to use logarithmic bins (true) or linear bins (false) for energy. |
SpecTime::SpecTime | ( | TH2D * | aFlux, |
TH2D * | aRate = NULL |
||
) |
SpecTime class constuctor.
The flux and rate functions are represented by 2-dimensional histograms (TH2D in ROOT). The x-axis is binned in time and the y-axis is binned in energy. In this constructor TH2D objects are initialized using input histograms with or without content.
[in] | aFlux | Flux histogram. |
[in] | aRate | Rate histogram. If a pointer to NULL is provided, a copy of the flux histogram is used. |
|
virtual |
SpecTime class destructor.
|
private |
for constructors.
double SpecTime::DrawEnergy | ( | const double | aTime | ) |
Draws an energy value at a given time.
The energy value is randomly drawn following the rate function, using an input time.
[in] | aTime | Time \([\mathrm{ms}]\). |
|
inline |
Returns a pointer to the flux TH2D object.
TH1D * SpecTime::GetLightCurve | ( | const double | aEnergyMin = 0.0 , |
const double | aEnergyMax = -1.0 |
||
) |
Returns the source light curve between two energies.
The light curve is defined as:
\[ {\cal{L}}(t)=\frac{dN}{dt}(t)=\int_{E_{min}}^{E_{max}}{{\cal{R}}(E,t)dE}. \]
It is obtained by integrating the rate object (TH2D) over energies.
int SpecTime::GetParticleN | ( | const ULong64_t | aTime, |
const UInt_t | aDuration, | ||
const double | aCosTheta = 1.0 |
||
) |
Computes the number of particles generated between 2 times.
The rate object is integrated over time (time range is given) and energy (full range) to get the mean number of particles. The actual number of particles is randomly drawn from a Poisson distribution with this mean value.
It is possible to correct the mean value for non-axis emission. The \(\cos\theta\) value must then be provided, where \(\theta\) is the angle between the detector axis and the source direction.
[in] | aTime | Start time [ms]. |
[in] | aDuration | Time duration [ms]. |
[in] | aCosTheta | Non-axis correction: \(\cos\theta\). |
|
inline |
Returns a pointer to the flux TH2D object.
TH1D * SpecTime::GetSpectrum | ( | const double | aTimeMin = 0.0 , |
const double | aTimeMax = -1.0 , |
||
const bool | aObserved = false |
||
) |
Returns the source energy spectrum between two times.
The energy spectrum is defined as:
\[ {\cal{S}}(E)=\frac{1}{t_{max}-t_{min}}\int_{t_{min}}^{t_{max}}{{\cal{F}}(E,t)dt} \]
It is obtained by integrating the flux object (TH2D) over time.
It is also possible to request the observed source energy spectrum by integrating the rate object:
\[ {\cal{S}}_{obs}(E)=\frac{1}{t_{max}-t_{min}}\int_{t_{min}}^{t_{max}}{{\cal{R}}(E,t)dt} \]
[in] | aTimeMin | Minimum time, \(t_{min}\), in \([\mathrm{ms}]\). Use 0.0 to use the start time of the SpecTime object. |
[in] | aTimeMax | Maximum time, \(t_{max}\), in \([\mathrm{ms}]\). Use -1.0 to use the stop time of the SpecTime object. |
[in] | aObserved | Set this to true to return the observed source energy spectrum. |
|
inline |
Returns the maximum time defining the SpecTime object.
|
inline |
Returns the minimum time defining the SpecTime object.
void SpecTime::MakeBandLimited | ( | const double | aFlux, |
const double | aEnergyMin, | ||
const double | aEnergyMax, | ||
TGraph * | aSurface = NULL |
||
) |
Makes a band-limited flux SpecTime object.
The flux is constant beween two energy values and is constant over time:
\[ {\cal{F}}(E,t) = {\cal{F}}_0 \times \Theta(E-E_{min}) \times \Theta(E_{max}-E). \]
The minimum and maximum energies must be within the energy range defined in the constructor. If not, they are adjusted to fit the original energy range.
Additionally, it is possible to provide a surface of interest to compute the associated rate. The MakeRate() function is called at the end of this function.
[in] | aFlux | Constant flux value, \({\cal{F}}_0\), in \([\mathrm{keV}^{-1}\mathrm{ms}^{-1}\mathrm{mm}^{-2}]\). |
[in] | aEnergyMin | Minimum energy \([\mathrm{keV}]\). |
[in] | aEnergyMax | Maximum energy \([\mathrm{keV}]\). |
[in] | aSurface | Surface of interest. |
|
private |
Computes cumulative rate.
void SpecTime::MakeGRBData | ( | TH1D * | aLightCurveExp, |
const double | aE1, | ||
const double | aE2, | ||
const double | aPhotonIndex, | ||
const double | aNint, | ||
const double | aNgal, | ||
const double | aZ, | ||
TGraph * | aSurfaceExp, | ||
TGraph * | aSurface = NULL |
||
) |
Makes a SpecTime object using GRB data.
The source flux is modeled as:
\[ {\cal{F}}(E,t) = f_1(t)\times f_2(E), \]
where the energy dependence includes the energy absorption due to the photo-electric effect and is described by:
\[ f_2(E) = A\times E^{-\lambda} \times \exp{\left(-N_H^{int}\sigma(E)\right)} \times \exp{\left(-N_H^{Gal}\sigma(E/(1+z))\right)}. \]
The time dependence is derived from experimental data using the light curve:
\[ {\cal{L}}_{exp}(t) = \frac{dN_{exp}}{dt}(t) = \int_{E_1}^{E_2}{{\cal{R}}_{exp}(E,t)dE} = \int_{E_1}^{E_2}{S_{exp}(E)\times {\cal{F}}(E,t) dE}. \]
Here the rate is derived from the flux using the experiment effective area \(S_{exp}(E)\) and is integrated over the energy range \(E_1\)- \(E_2\).
Then it comes:
\[ f_1(t) = \frac{{\cal{L}}_{exp}(t)}{\int_{E_1}^{E_2}{S_{exp}(E)\times f_2(E) dE}}. \]
Finally:
\[ {\cal{F}}(E,t) = {\cal{L}}_{exp}(t)\times \frac{E^{-\lambda} \times \exp{\left(-N_H^{int}\sigma(E)\right)} \times \exp{\left(-N_H^{Gal}\sigma(E/(1+z))\right)}}{\int_{E_1}^{E_2}{S_{exp}(E)\times E^{-\lambda} \times \exp{\left(-N_H^{int}\sigma(E)\right)} \times \exp{\left(-N_H^{Gal}\sigma(E/(1+z))\right)} dE}}. \]
This equation is used to compute the flux object. The integral at the denominator is calculated using the numerical precision of \(S_{exp}(E)\).
The example below shows the resulting SpecTime object obtained with GRB091020 downloaded from the Swift/XRT database. The absorption at low energies is included.
Additionally, it is possible to provide a surface of interest to compute the associated rate. The MakeRate() function is called at the end of this function.
[in] | aLightCurveExp | Experimental light curve \({\cal{L}}_{exp}(t)\). |
[in] | aE1 | Lower energy bound \(E_1\) used for \({\cal{L}}_{exp}(t)\), in \([keV]\). |
[in] | aE1 | Upper energy bound \(E_2\) used for \({\cal{L}}_{exp}(t)\), in \([keV]\). |
[in] | aPhotonIndex | Photon index \(\lambda\). |
[in] | aNint | Intrinsic column density. The unit should be consistent with the cross-section of the photo-electric effect. |
[in] | aNgal | Galactic column density. The unit should be consistent with the cross-section of the photo-electric effect. |
[in] | aZ | Absorber redshift \(z\). |
[in] | aSurfaceExp | Effective area for the experiment \(S_{exp}(E)\). The energy range of this function must entirely contain the \(E_1\)- \(E_2\) range (no extrapolation). The points are assumed to be sorted in energy. |
[in] | aSurface | Surface of interest. |
void SpecTime::MakeGRBModel1 | ( | const double | aFlux, |
const double | aEnergy0, | ||
const double | aAlpha, | ||
const double | aBeta, | ||
TGraph * | aSurface = NULL |
||
) |
Makes a SpecTime object using a GRB model (I).
The particle flux energy dependency is modeled using BATSE Observations of Gamma-Ray Burst Spectra. I. Spectral Diversity as a reference:
\[ {\cal{F}}(E,t) = {\cal{F}}_0 \times \left(\frac{E}{100\,\mathrm{keV}}\right)^\alpha \times \exp\left(-\frac{E}{E_0}\right), \; E < E_0~(\alpha-\beta), \]
and
\[ {\cal{F}}(E,t) = {\cal{F}}_0 \times \left(\frac{E_0(\alpha-\beta)}{100\,\mathrm{keV}}\right)^{(\alpha-\beta)} \times \left(\frac{E}{100\,\mathrm{keV}}\right)^\beta \times \exp(\beta-\alpha), \; E\geq E_0~(\alpha-\beta). \]
This model was constructed so that it and its derivative are continuous. The resulting flux is constant over the time range specified in the constructor and is null eslewhere.
Additionally, it is possible to provide a surface of interest to compute the associated rate. The MakeRate() function is called at the end of this function.
[in] | aFlux | Flux \({\cal{F}}_0\) value in \([\mathrm{keV}^{-1}\mathrm{ms}^{-1}\mathrm{mm}^{-2}]\). |
[in] | aEnergy0 | Energy transition, \(E_0\), in \([\mathrm{keV}]\). |
[in] | aAlpha | Spectral index, \(\alpha\), at low energy. |
[in] | aBeta | Spectral index, \(\beta\), at high energy. |
[in] | aSurface | Surface of interest. |
void SpecTime::MakePowerLawEnergy | ( | const double | aFlux, |
const double | aEnergyDecay, | ||
TGraph * | aSurface = NULL |
||
) |
Makes a power-law flux SpecTime object.
The flux is constant over time and decays in energy following an exponential distribution:
\[ {\cal{F}}(E,t) = {\cal{F}}_0 \times \exp\left(-\frac{E-E_0}{\epsilon}\right), \]
where \({\cal{F}}_0\) is the flux at the minimum energy \(E_0\), defined in the constructor, and \(\epsilon\) is the flux energy decay. The flux is only computed in the limits defined in the constructor, it is null elsewhere.
Additionally, it is possible to provide a surface of interest to compute the associated rate. The MakeRate() function is called at the end of this function.
[in] | aFlux | Flux \({\cal{F}}_0\) value in \([\mathrm{keV}^{-1}\mathrm{ms}^{-1}\mathrm{mm}^{-2}]\). |
[in] | aEnergyDecay | Flux energy decay \(\epsilon\) in \([\mathrm{keV}]\). |
[in] | aSurface | Surface of interest. |
void SpecTime::MakePowerLawTime | ( | const double | aFlux, |
const double | aTimeDecay, | ||
const double | aEnergyMin, | ||
const double | aEnergyMax, | ||
TGraph * | aSurface = NULL |
||
) |
Makes a power-law flux SpecTime object.
The flux is constant beween two energy values and decays in time following an exponential distribution:
\[ {\cal{F}}(E,t) = {\cal{F}}_0 \times \exp\left(-\frac{t-t_0}{\tau}\right) \times \Theta(E-E_{min}) \times \Theta(E_{max}-E), \]
where \({\cal{F}}_0\) is the flux at the initial time \(t_0\), defined in the constructor, and \(\tau\) is the flux time decay. The minimum and maximum energies must be within the energy range defined in the constructor. If not, they are adjusted to fit the original energy range.
Additionally, it is possible to provide a surface of interest to compute the associated rate. The MakeRate() function is called at the end of this function.
[in] | aFlux | Initial flux \({\cal{F}}_0\) value in \([\mathrm{keV}^{-1}\mathrm{ms}^{-1}\mathrm{mm}^{-2}]\). |
[in] | aTimeDecay | Flux time decay \(\tau\) in \([\mathrm{ms}]\). |
[in] | aEnergyMin | Minimum energy \([\mathrm{keV}]\). |
[in] | aEnergyMax | Maximum energy \([\mathrm{keV}]\). |
[in] | aSurface | Surface of interest. |
void SpecTime::MakeRate | ( | TGraph * | aSurface | ) |
Computes the rate given an integration surface.
The flux must be set first (e.g. SetFlux()). The flux is assumed to be uniform over the surface of interest. This surface is provided as a TGraph object to include an energy dependency: x-axis = energy in \([\mathrm{keV}]\), y-axis = surface in \([\mathrm{mm}^2]\). The rate is then computed as:
\[ {\cal{R}}(E,t)=\frac{d^2N}{dtdE}(E,t)=\iint_S{\cal{F}}(E,t)dS=S(E)\times {\cal{F}}(E,t). \]
The rate is set to 0, if the energy is not in the range of the TGraph. When within the range, a linear interpolation is performed to access the surface at a given energy.
[in] | aSurface | Surface of interest. |
void SpecTime::MakeUniform | ( | const double | aFlux, |
TGraph * | aSurface = NULL |
||
) |
Makes a uniform flux SpecTime object.
The particle flux is constant over energies and times (in the limits declared in SpecTime()):
\[ {\cal{F}}(E,t) = {\cal{F}}_0. \]
Additionally, it is possible to provide a surface of interest to compute the associated rate. The MakeRate() function is called at the end of this function.
[in] | aFlux | Constant flux \({\cal{F}}_0\) value in \([\mathrm{keV}^{-1}\mathrm{ms}^{-1}\mathrm{mm}^{-2}]\). |
[in] | aSurface | Surface of interest. |
void SpecTime::SetFlux | ( | TH2D * | aFlux, |
TGraph * | aSurface = NULL |
||
) |
Defines a new flux fonction.
The input flux histogram must comply with the definition of a SpecTime object. In particular, one must make sure to use correct Units units for all quantities.
Moreover, one must be careful with the parameters given in SpecTime(). The time and energy bins will not be modified. However the input time and energy bins will be resampled to match the resolution declared in SpecTime(). Upsampling and downsampling are supported.
Additionally, it is possible to provide a surface of interest to compute the associated rate. The MakeRate() function is called at the end of this function.
[in] | aFlux | Pointer to a valid TH2D object. It can be deleted after calling this function. |
[in] | aSurface | Pointer to a valid TGraph object to describe the surface as a function of energy. |
|
inline |
Sets the photo-electric cross-section.
This is given as a TGraph as a function of energy \([keV]\). It is locally saved.
[in] | aGraph | Pointer to a valid TGraph object to describe the photo-electric cross-section. The points are assumed to be sorted in energy. |
|
protected |
source flux \({\cal{F}}(E,t)\).
|
private |
photo-electric cross-section.
|
protected |
random generator.
|
protected |
source rate \({\cal{R}}(E,t)\).
|
private |
cumulative rate (over \(E\)).