SatAndLight  2.2.2-hubble
Simulation toolkit for space telescopes
Source Class Reference

Describe astrophysical sources. More...

#include <Source.h>

Inheritance diagram for Source:
Collaboration diagram for Source:

Public Types

enum  sourcetype { type_photon , type_cosmic , type_photon_background }
 Enumerator to describe the type of astrophysical sources. More...
 

Public Member Functions

int GenerateAstroParticles (const int aN, const ULong64_t aTime, const UInt_t aDuration)
 Generates N astro-particles from this source. More...
 
double GetAstroEnergy (void)
 Returns the energy [keV] for the current astro-particle. More...
 
double GetAstroPhip (void)
 Returns \(\varphi'\) for the current astro-particle. More...
 
double GetAstroThetap (void)
 Returns \(\cos\theta'\) for the current astro-particle. More...
 
ULong64_t GetAstroTime (void)
 Returns the time for the current astro-particle. More...
 
string GetName (void)
 Returns the source name. More...
 
double GetPhiPrime (const ULong64_t aTime)
 Returns the source \(\varphi'_{S}\) angle [rad] at a given time. More...
 
double GetThetaPrime (const ULong64_t aTime)
 Returns the source \(\theta'_{S}\) angle [rad] at a given time. More...
 
int GetType (void)
 Returns the source type. More...
 
void SetName (const string aName)
 Sets the source name. More...
 
void SetPosition (const double aThetaPrime, const double aPhiPrime, const double aConeAngle)
 Sets a fix source sky location. More...
 
void SetType (const Source::sourcetype aType)
 Sets the source type. More...
 
int TreeAstroGetN (void)
 Returns the number of particles currently in the astro-particle TTree. More...
 
int TreeAstroLoadEntry (const int aEntryIndex)
 Loads a given entry in the astro-particle TTree. More...
 
void TreeDelete (void)
 Deletes the TTree. More...
 
void TreeInit (void)
 Initialize Source TTrees. More...
 
void TreeReset (void)
 Resets baskets, buffers and entries count in all branches and leaves. More...
 
int TreeWrite (void)
 Writes the source/astroparticles TTree to the current directory. More...
 
Constructors and destructors
 Source (const int aNt, const double aTimeMin, const double aTimeMax, const bool aUseTimeLog, const int aNe, const double aEnergyMin, const double aEnergyMax, const bool aUseEnergyLog)
 Source class constuctor. More...
 
 Source (TH2D *aFlux, TH2D *aRate=NULL)
 Source class constuctor. More...
 
virtual ~Source (void)
 Source class destructor. More...
 
- Public Member Functions inherited from SpecTime
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...
 
 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...
 

Private Member Functions

void CommonConstructor (void)
 Common constructor. More...
 
void ComputeR (void)
 Computes the rotation matrix to transform \(\vec{k'}\) in \(\vec{s}\). More...
 

Private Attributes

double astro_energy
 astroparticle energy [keV]. More...
 
double astro_phip
 astroparticle phi prime. More...
 
double astro_thetap
 astroparticle \(\theta'\). More...
 
ULong64_t astro_time
 astroparticle time [ms]. More...
 
TTree * astro_tree
 astroparticle tree. More...
 
TGraph * src_cosconeangle
 source cone angle [rad] as a function of time. More...
 
string src_name
 source name. More...
 
TGraph * src_phip
 source \(\varphi'_{S}\) as a function of time. More...
 
TGraph * src_R [3][3]
 rotation matrix. More...
 
TGraph * src_thetap
 source \(\theta'_{S}\) as a function of time. More...
 
TTree * src_tree
 source parameter tree. More...
 
int src_type
 source type, see Sources::sourcetype. More...
 

Additional Inherited Members

- Protected Attributes inherited from SpecTime
TH2D * flux
 source flux \({\cal{F}}(E,t)\). More...
 
TRandom3 * randgen
 random generator. More...
 
TH2D * rate
 source rate \({\cal{R}}(E,t)\). More...
 

Detailed Description

Describe astrophysical sources.

Description

An astrophysical source is described by a set of parameters:

  • a unique name (SetName())
  • a type: see Source::sourcetype (SetType())
  • a sky position, \(\theta'_S\), \(\varphi'_S\) (SetPosition()) given in spherical coordinates in the Earth celestial reference frame as represented below:
    Source sky position. The Earth celestial reference frame is represented in black and the associated coordinates are primed.
  • a cone angle centered on the sky position (SetPosition()).

In addition, the particle emission is driven by the SpecTime class from which this class inherits.

Astro-particles

Once a source object is parameterized, this class can be used to generate astro-particles. Astro-particles are generated using a random generator. Each particle is given a set of parameters:

  • a time in \([\mathrm{ms}]\), \(t_p\).
  • a sky position given in spherical coordinates in the Earth celestial reference frame, \((\theta'_p,\varphi'_p)\).
  • an energy in \([\mathrm{keV}]\), \(E_p\).

Astro-particles are generated with GenerateAstroParticles(). The particle parameters are randomly drawn according to the source parameters. Refer to GenerateAstroParticles() to get a full description.

Time dependency

A source is a dynamical object, meaning that its parameters can change with time. The time validity of the source is defined in the constructor via the SpecTime object. After that, the time range of the SpecTime object can no longer be changed. One must make sure that this time range covers the entire experiment. The source does not exist outside the time range specified in the SpecTime object.

The time evolution of the source cannot be changed on the fly. It must be configured from the beginning with specific function:

  • Use the SpecTime configuration functions to configure the time dependency of the source flux.
  • Use SetPosition() to configure the time dependency of the source geometry (like the position and the extension).

Saving the source

After configuration, the source object as well as its astro-particles can be saved to disk in a ROOT file. After opening a TFile, the following functions should be called:

  1. TreeInit(): intialize the TTrees:
    • src_tree: source definition (one single entry)
    • astro_tree: list of astro-particles
  2. Generate particles with GenerateAstroParticles().
  3. TreeWrite(): write the TTrees in the TFile.
  4. TreeDelete(): delete TTrees.
  5. Close the file.
See also
The SatAndLight file structure for source objects.
Author
Florent Robinet

Member Enumeration Documentation

◆ sourcetype

Enumerator to describe the type of astrophysical sources.

Enumerator
type_photon 

source of photons.

type_cosmic 

source of cosmic rays.

type_photon_background 

source of background photons.

Constructor & Destructor Documentation

◆ Source() [1/2]

Source::Source ( const int  aNt,
const double  aTimeMin,
const double  aTimeMax,
const bool  aUseTimeLog,
const int  aNe,
const double  aEnergyMin,
const double  aEnergyMax,
const bool  aUseEnergyLog 
)

Source class constuctor.

By default, the source object is given the following parameters:

  • name = "SRC"
  • type = photons
  • \(\theta'=0\) [rad] (fix value)
  • \(\varphi'=0\) [rad] (fix value)
  • cone angle = 0 [rad] (fix value)
See also
CommonConstructor().

The SpecTime object is also constructed to describe the particle emission. This is done using this constructor arguments: see SpecTime::SpecTime() for a description.

Parameters
[in]aNtNumber of time bins.
[in]aTimeMinMinimum time \([\mathrm{ms}]\).
[in]aTimeMaxMaximum time \([\mathrm{ms}]\).
[in]aUseTimeLogFlag to use logarithmic bins (true) or linear bins (false) for time.
[in]aNeNumber of energy bins.
[in]aEnergyMinMinimum energy \([\mathrm{keV}]\).
[in]aEnergyMaxMaximum energy \([\mathrm{keV}]\).
[in]aUseEnergyLogFlag to use logarithmic bins (true) or linear bins (false) for energy.

◆ Source() [2/2]

Source::Source ( TH2D *  aFlux,
TH2D *  aRate = NULL 
)

Source class constuctor.

By default, the source object is given the following parameters:

  • name = "SRC"
  • type = photons
  • \(\theta'=0\) [rad] (fix value)
  • \(\varphi'=0\) [rad] (fix value)
  • cone angle = 0 [rad] (fix value)

The SpecTime object is also constructed to describe the particle emission. This is done using this constructor arguments: see SpecTime::SpecTime() for a description.

Parameters
[in]aFluxFlux histogram.
[in]aRateRate histogram. If a pointer to NULL is provided, a copy of the flux histogram is used.

◆ ~Source()

Source::~Source ( void  )
virtual

Source class destructor.

Member Function Documentation

◆ CommonConstructor()

void Source::CommonConstructor ( void  )
private

Common constructor.

◆ ComputeR()

void Source::ComputeR ( void  )
private

Computes the rotation matrix to transform \(\vec{k'}\) in \(\vec{s}\).

\(\vec{k'}=(0,0,1)\) and \(\vec{s}=(\sin\theta'_S\cos\varphi'_S, \sin\theta'_S\sin\varphi'_S, \cos\theta'_S)\). The rotation axis is given by the unit vector \(\vec{n}=\frac{\vec{k'}\times\vec{s}}{||\vec{k'}\times\vec{s}||} = (-\sin\varphi'_S, \cos\varphi'_S, 0)\). The rotation matrix \(R\) is defined as the rotation by an angle \(\theta'_S\) about an axis in the direction of \(\vec{n}\) is:

\[ R= \left[ {\begin{array}{ccc} c_\theta+s^2_\varphi(1-c_\theta) & -s_\varphi c_\varphi(1-c_\theta) & s_\theta c_\varphi \\ -s_\varphi c_\varphi(1-c_\theta) & c_\theta+c^2_\varphi(1-c_\theta) & s_\theta s_\varphi \\ -s_\theta c_\varphi & -s_\theta s_\varphi & c_\theta \\ \end{array} } \right] \]

where \(c_\theta=\cos\theta'_S\) and \(s_\theta=\sin\theta'_S\) and the same for \(\varphi'_S\).

Note
The rotation matrix coefficients are functions of time.

◆ GenerateAstroParticles()

int Source::GenerateAstroParticles ( const int  aN,
const ULong64_t  aTime,
const UInt_t  aDuration 
)

Generates N astro-particles from this source.

Once the source object is fully parameterized, you can generate astro-particles from this source with this function. The parameters of the particles are drawn randomly:

  • the particle time [ms] is drawn from a flat distribution in the given time range.
  • the particle energy is drawn following the source spectrum for this time [keV].
  • the particle sky location is randomly drawn in a cone centered on the source location \((\theta'_S, \varphi'_S)\). The algorithm to do that works in 2 steps:
    • draw a position in a cone centered on the Earth north pole.
    • perform a rotation to the source position using the rotation matrix defined in ComputeR().
Parameters
[in]aNNumber of particles to generate.
[in]aTimeStart time [ms].
[in]aDurationTime duration [ms].
Returns
The number of particles which are actually generated. This number can be smaller than the requested one if the requested time range does not match the source time range.

◆ GetAstroEnergy()

double Source::GetAstroEnergy ( void  )
inline

Returns the energy [keV] for the current astro-particle.

The current astro-particle is the last particle generated with GenerateAstroParticles(). To load a previously-generated particle, TreeAstroLoadEntry() should be called first.

◆ GetAstroPhip()

double Source::GetAstroPhip ( void  )
inline

Returns \(\varphi'\) for the current astro-particle.

The current astro-particle is the last particle generated with GenerateAstroParticles(). To load a previously-generated particle, TreeAstroLoadEntry() should be called first.

◆ GetAstroThetap()

double Source::GetAstroThetap ( void  )
inline

Returns \(\cos\theta'\) for the current astro-particle.

The current astro-particle is the last particle generated with GenerateAstroParticles(). To load a previously-generated particle, TreeAstroLoadEntry() should be called first.

◆ GetAstroTime()

ULong64_t Source::GetAstroTime ( void  )
inline

Returns the time for the current astro-particle.

The current astro-particle is the last particle generated with GenerateAstroParticles(). To load a previously-generated particle, TreeAstroLoadEntry() should be called first.

◆ GetName()

string Source::GetName ( void  )
inline

Returns the source name.

◆ GetPhiPrime()

double Source::GetPhiPrime ( const ULong64_t  aTime)
inline

Returns the source \(\varphi'_{S}\) angle [rad] at a given time.

Parameters
[in]aTimeTime [ms].
Precondition
aTime must be a valid time in the range defined in the constructor.

◆ GetThetaPrime()

double Source::GetThetaPrime ( const ULong64_t  aTime)
inline

Returns the source \(\theta'_{S}\) angle [rad] at a given time.

Parameters
[in]aTimeTime [ms].
Precondition
aTime must be a valid time in the range defined in the constructor.

◆ GetType()

int Source::GetType ( void  )
inline

Returns the source type.

◆ SetName()

void Source::SetName ( const string  aName)

Sets the source name.

The source name must be unique if more than one source are used in the same time.

Parameters
[in]aNameSource name.

◆ SetPosition()

void Source::SetPosition ( const double  aThetaPrime,
const double  aPhiPrime,
const double  aConeAngle 
)

Sets a fix source sky location.

The source sky coordinates are set to a fix location: \(\theta'_S\) and \(\varphi'_S\). Moreover, the source can be given an extension centered on the source position and described by a spherical cap on the sphere. This is parameterized by a cone angle, defined from the cone axis. The astro-particles sky location is randomly drawn inside this cone.

The rotation matrix is also updated with the new parameter (see ComputeR()).

Parameters
[in]aThetaPrime\(\theta'_S\) in the Earth celestial reference frame [rad].
[in]aPhiPrime\(\varphi'_S\) in the Earth celestial reference frame [rad].
[in]aConeAngleCone angle [rad], defined from the central position.

◆ SetType()

void Source::SetType ( const Source::sourcetype  aType)
inline

Sets the source type.

See Source::sourcetype for a definition.

Parameters
[in]aTypeSource type.

◆ TreeAstroGetN()

int Source::TreeAstroGetN ( void  )
inline

Returns the number of particles currently in the astro-particle TTree.

◆ TreeAstroLoadEntry()

int Source::TreeAstroLoadEntry ( const int  aEntryIndex)
inline

Loads a given entry in the astro-particle TTree.

Returns
The number of bytes which are loaded. TBC.
Parameters
[in]aEntryIndexAstro-particle TTree index.

◆ TreeDelete()

void Source::TreeDelete ( void  )
inline

Deletes the TTree.

Both the source and astro-particle trees are deleted.

◆ TreeInit()

void Source::TreeInit ( void  )

Initialize Source TTrees.

Two TTrees are created: one to parameterize the source (one single entry) and one to save the astro-particles produced by the source.

The source TTree is named after the source and is given the following branches:

  • 'src_type/I' = source type, see Sources::sourcetype.
  • 'src_thetap/TGraph' = source \(\theta'_{S}\) as a function of time.
  • 'src_phip/TGraph' = source \(\varphi'_{S}\) as a function of time.
  • 'src_cosconeangle/TGraph' = source cone angle [rad] as a function of time.
  • 'src_flux/TH2D' = source particle flux.
  • 'src_rate/TH2D' = source particle rate.

The astro-particle tree is given the following branches:

  • 'astro_time/l' = particle time.
  • 'astro_thetap/D' = particle \(\theta'\).
  • 'astro_phip/D' = particle \(\cos\varphi'\).
  • 'astro_energy/D' = particle energy [keV].

◆ TreeReset()

void Source::TreeReset ( void  )
inline

Resets baskets, buffers and entries count in all branches and leaves.

Calls the TTree Reset function.

◆ TreeWrite()

int Source::TreeWrite ( void  )
inline

Writes the source/astroparticles TTree to the current directory.

Both the source and astro-particle trees are writtento disk. Calls the TTree Write function.

Returns
The total number of bytes written to the file. It returns 0 if the object cannot be written.
Todo:
Sort TTree indices to have particle sorted in time.

Member Data Documentation

◆ astro_energy

double Source::astro_energy
private

astroparticle energy [keV].

◆ astro_phip

double Source::astro_phip
private

astroparticle phi prime.

◆ astro_thetap

double Source::astro_thetap
private

astroparticle \(\theta'\).

◆ astro_time

ULong64_t Source::astro_time
private

astroparticle time [ms].

◆ astro_tree

TTree* Source::astro_tree
private

astroparticle tree.

◆ src_cosconeangle

TGraph* Source::src_cosconeangle
private

source cone angle [rad] as a function of time.

◆ src_name

string Source::src_name
private

source name.

◆ src_phip

TGraph* Source::src_phip
private

source \(\varphi'_{S}\) as a function of time.

◆ src_R

TGraph* Source::src_R[3][3]
private

rotation matrix.

◆ src_thetap

TGraph* Source::src_thetap
private

source \(\theta'_{S}\) as a function of time.

◆ src_tree

TTree* Source::src_tree
private

source parameter tree.

◆ src_type

int Source::src_type
private

source type, see Sources::sourcetype.


The documentation for this class was generated from the following files: