SatAndLight  2.2.2-hubble
Simulation toolkit for space telescopes
Source.h
Go to the documentation of this file.
1 #ifndef __Source__
2 #define __Source__
3 
9 #include <TFile.h>
10 #include <TTree.h>
11 #include "SpecTime.h"
12 
13 using namespace std;
14 
62 class Source: public SpecTime{
63 
64  public:
65 
71 
93  Source(const int aNt, const double aTimeMin, const double aTimeMax, const bool aUseTimeLog,
94  const int aNe, const double aEnergyMin, const double aEnergyMax, const bool aUseEnergyLog);
95 
97 
110  Source(TH2D* aFlux, TH2D* aRate=NULL);
111 
113 
116  virtual ~Source(void);
122 
128  type_photon_background
129  };
130 
132 
146  int GenerateAstroParticles(const int aN, const ULong64_t aTime, const UInt_t aDuration);
147 
149 
154  void SetName(const string aName);
155 
157 
160  inline string GetName(void){ return src_name; };
161 
163 
168  inline void SetType(const Source::sourcetype aType){ src_type = (int)aType; };
169 
171 
180  void SetPosition(const double aThetaPrime, const double aPhiPrime, const double aConeAngle);
181 
183 
188  inline double GetThetaPrime(const ULong64_t aTime){
189  return src_thetap->Eval((double)aTime);
190  };
191 
193 
198  inline double GetPhiPrime(const ULong64_t aTime){
199  return src_phip->Eval((double)aTime);
200  };
201 
203 
206  inline int GetType(void){ return src_type; };
207 
209 
213  inline double GetAstroPhip(void){ return astro_phip; };
214 
216 
220  inline double GetAstroThetap(void){ return astro_thetap; };
221 
223 
227  inline ULong64_t GetAstroTime(void){ return astro_time; };
228 
230 
234  inline double GetAstroEnergy(void){ return astro_energy; };
235 
237 
255  void TreeInit(void);
256 
258 
262  inline void TreeReset(void){
263  if(src_tree!=NULL) src_tree->Reset();
264  if(astro_tree!=NULL) astro_tree->Reset();
265  return;
266  };
267 
269 
275  inline int TreeWrite(void){
276  int nb=0;
277  if(src_tree!=NULL) nb+=src_tree->Write();
278  if(astro_tree!=NULL) nb+=astro_tree->Write();
279  return nb;
280  };
281 
283 
287  inline void TreeDelete(void){
288  if(src_tree!=NULL) delete src_tree;
289  if(astro_tree!=NULL) delete astro_tree;
290  src_tree=NULL;
291  astro_tree=NULL;
292  return;
293  };
294 
296 
299  inline int TreeAstroGetN(void){
300  if(astro_tree!=NULL) return astro_tree->GetEntries();
301  return 0;
302  };
303 
305 
310  inline int TreeAstroLoadEntry(const int aEntryIndex){
311  if(astro_tree!=NULL) return astro_tree->GetEntry(aEntryIndex);
312  return -1;
313  };
314 
315  private:
316 
317  // Source definition
318  string src_name;
319  TTree *src_tree;
320  int src_type;
321  TGraph *src_thetap;
322  TGraph *src_phip;
324 
325  // Astroparticles
326  TTree *astro_tree;
327  ULong64_t astro_time;
328  double astro_thetap;
329  double astro_phip;
330  double astro_energy;
331 
332  // Rotation matrix
333  TGraph *src_R[3][3];
334 
336 
353  void ComputeR(void);
354 
355  void CommonConstructor(void);
356 
357 
358  ClassDef(Source,0)
359 };
360 
361 #endif
362 
363 
This module is used to describe spectra and light curves of astrophysical sources.
Describe astrophysical sources.
Definition: Source.h:62
TGraph * src_cosconeangle
source cone angle [rad] as a function of time.
Definition: Source.h:323
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.
sourcetype
Enumerator to describe the type of astrophysical sources.
Definition: Source.h:125
@ type_photon
source of photons.
Definition: Source.h:126
@ type_cosmic
source of cosmic rays.
Definition: Source.h:127
string GetName(void)
Returns the source name.
Definition: Source.h:160
double GetAstroThetap(void)
Returns for the current astro-particle.
Definition: Source.h:220
double astro_thetap
astroparticle .
Definition: Source.h:328
double GetThetaPrime(const ULong64_t aTime)
Returns the source angle [rad] at a given time.
Definition: Source.h:188
void TreeReset(void)
Resets baskets, buffers and entries count in all branches and leaves.
Definition: Source.h:262
void SetType(const Source::sourcetype aType)
Sets the source type.
Definition: Source.h:168
int TreeWrite(void)
Writes the source/astroparticles TTree to the current directory.
Definition: Source.h:275
TTree * astro_tree
astroparticle tree.
Definition: Source.h:326
int GetType(void)
Returns the source type.
Definition: Source.h:206
int TreeAstroLoadEntry(const int aEntryIndex)
Loads a given entry in the astro-particle TTree.
Definition: Source.h:310
ULong64_t GetAstroTime(void)
Returns the time for the current astro-particle.
Definition: Source.h:227
TTree * src_tree
source parameter tree.
Definition: Source.h:319
TGraph * src_thetap
source as a function of time.
Definition: Source.h:321
string src_name
source name.
Definition: Source.h:313
ULong64_t astro_time
astroparticle time [ms].
Definition: Source.h:327
int TreeAstroGetN(void)
Returns the number of particles currently in the astro-particle TTree.
Definition: Source.h:299
double astro_energy
astroparticle energy [keV].
Definition: Source.h:330
void TreeDelete(void)
Deletes the TTree.
Definition: Source.h:287
double GetAstroEnergy(void)
Returns the energy [keV] for the current astro-particle.
Definition: Source.h:234
double astro_phip
astroparticle phi prime.
Definition: Source.h:329
double GetAstroPhip(void)
Returns for the current astro-particle.
Definition: Source.h:213
int src_type
source type, see Sources::sourcetype.
Definition: Source.h:320
TGraph * src_phip
source as a function of time.
Definition: Source.h:322
double GetPhiPrime(const ULong64_t aTime)
Returns the source angle [rad] at a given time.
Definition: Source.h:198
Astrophysical source spectra and light curves.
Definition: SpecTime.h:32