40#define G_LOAD "GCTABackgroundPerfTable::load(GFilename&)"
41#define G_MC "GCTABackgroundPerfTable::mc(GEnergy&, GTime&, GRan&)"
49#define G_LOG_INTERPOLATION
181 const double& dety)
const
189 double arg = theta * theta /
m_sigma;
190 double scale = std::exp(-0.5 * arg * arg);
259 FILE* fptr = std::fopen(
filename.
url().c_str(),
"r");
261 std::string msg =
"Unable to open file \""+
filename.
url()+
"\" for "
262 "read access. Please provide the name of a readable "
268 while (std::fgets(line, n, fptr) != NULL) {
272 for (
int i = elements.size()-1; i >= 0; i--) {
274 elements.erase(elements.begin()+i);
279 if (elements[0].find(
"log(E)") != std::string::npos) {
284 if (elements[0].find(
"----------") != std::string::npos) {
292 double emin = std::pow(10.0, logE-0.1) * 1.0e6;
293 double emax = std::pow(10.0, logE+0.1) * 1.0e6;
294 double ewidth = emax - emin;
339 #if defined(G_DEBUG_MC)
342 double sigma_max = 4.0 * std::sqrt(
sigma());
348 theta = ran.
uniform() * sigma_max;
349 double arg = theta * theta /
sigma();
350 double arg2 = arg * arg;
353 #if defined(G_DEBUG_MC)
358 #if defined(G_DEBUG_MC)
359 std::cout <<
"#=" << n_samples <<
" ";
369 detx = theta * std::cos(phi);
370 dety = theta * std::sin(phi);
410 double x1 = emin.
MeV();
416 for (
int i = 0; i <
size(); ++i) {
451 if (x1 < emax.
MeV()) {
460 double arg = theta * theta /
m_sigma;
461 double scale = std::exp(-0.5 * arg * arg);
491 result.append(
"=== GCTABackgroundPerfTable ===");
638 for (
int i = 0; i <
size(); ++i) {
644 if (total_rate > 0.0) {
670 #if defined(G_LOG_INTERPOLATION)
CTA performance table background class definition.
CTA instrument direction class interface definition.
Integration class interface definition.
Mathematical function definitions.
Random number generator class definition.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
CTA performance table background class.
double rate_ebin(const GCTAInstDir &dir, const GEnergy &emin, const GEnergy &emax) const
Returns background rate integrated over energy interval in units of events s sr .
double rate(const double &logE) const
Return background rate for a given energy (events/s/MeV/sr)
void copy_members(const GCTABackgroundPerfTable &bgd)
Copy class members.
GModelSpectralNodes m_mc_spectrum
Background spectrum.
void load(const GFilename &filename)
Load background from performance table.
std::vector< double > m_log_background
log(background rate)
GFilename filename(void) const
Return filename.
std::string print(const GChatter &chatter=NORMAL) const
Print background information.
void init_members(void)
Initialise class members.
virtual double operator()(const double &logE, const double &detx, const double &dety) const
Return background rate in units of events MeV s sr .
GCTABackgroundPerfTable & operator=(const GCTABackgroundPerfTable &bgd)
Assignment operator.
virtual ~GCTABackgroundPerfTable(void)
Destructor.
double m_sigma
Sigma for offset angle computation (0=none)
std::vector< double > m_background
Background rate.
GEnergies m_energy
Vector of energies.
void init_mc_cache(void) const
Initialise Monte Carlo cache.
GCTABackgroundPerfTable * clone(void) const
Clone background.
GCTABackgroundPerfTable(void)
Void constructor.
void clear(void)
Clear background.
GNodeArray m_log10_energy
log10(E) nodes for background interpolation
int size(void) const
Return number of node energies in response.
void free_members(void)
Delete class members.
GCTAInstDir mc(const GEnergy &energy, const GTime &time, GRan &ran) const
Returns MC instrument direction.
double solidangle(void) const
Returns integral over radial model (in steradians)
const double & sigma(void) const
Return sigma for offset angle dependence.
GFilename m_filename
Name of background response file.
Abstract base class for the CTA background model.
void init_members(void)
Initialise class members.
GCTABackground & operator=(const GCTABackground &bgd)
Assignment operator.
void free_members(void)
Delete class members.
CTA instrument direction class.
double theta(void) const
Return offset angle (in radians)
void dety(const double &y)
Set DETY coordinate (in radians)
void detx(const double &x)
Set DETX coordinate (in radians)
void clear(void)
Clear energy container.
GEnergy & append(const GEnergy &energy)
Append energy to container.
Class that handles energies in a unit independent way.
double log10TeV(void) const
Return log10 of energy in TeV.
double MeV(void) const
Return energy in MeV.
std::string url(void) const
Return Uniform Resource Locator (URL)
void clear(void)
Clear file name.
GIntegral class interface definition.
double romberg(std::vector< double > bounds, const int &order=5)
Perform Romberg integration.
virtual void clear(void)
Clear spectral nodes model.
void append(const GEnergy &energy, const double &intensity)
Append node.
double interpolate(const double &value, const std::vector< double > &vector) const
Interpolate value.
void clear(void)
Clear node array.
void append(const double &node)
Append one node to array.
Random number generator class.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
double plaw_integral(const double &x1, const double &f1, const double &x2, const double &f2)
Returns the integral of a power law.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
double todouble(const std::string &arg)
Convert string into double precision value.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
std::vector< std::string > split(const std::string &s, const std::string &sep)
Split string.