80#define G_IRF "GCTAResponseIrf::irf(GInstDir&, GEnergy&, GTime&, GSkyDir&,"\
81 " GEnergy&, GTime&, GObservation&)"
82#define G_MC "GCTAResponseIrf::mc(double&, GPhoton&, GObservation&, GRan&)"
83#define G_READ "GCTAResponseIrf::read(GXmlElement&)"
84#define G_WRITE "GCTAResponseIrf::write(GXmlElement&)"
85#define G_LOAD_AEFF "GCTAResponseIrf::load_aeff(GFilename&)"
86#define G_LOAD_PSF "GCTAResponseIrf::load_psf(GFilename&)"
87#define G_LOAD_EDISP "GCTAResponseIrf::load_edisp(GFilename&)"
88#define G_LOAD_BACKGROUND "GCTAResponseIrf::load_background(GFilename&)"
89#define G_NIRF "GCTAResponseIrf::nirf(GPhoton&, GEnergy&, GTime&,"\
91#define G_IRF_RADIAL "GCTAResponseIrf::irf_radial(GEvent&, GSource&,"\
93#define G_IRF_ELLIPTICAL "GCTAResponseIrf::irf_elliptical(GEvent&, GSource&,"\
95#define G_IRF_DIFFUSE "GCTAResponseIrf::irf_diffuse(GEvent&, GSource&,"\
97#define G_NROI_RADIAL "GCTAResponseIrf::nroi_radial(GModelSky&, GEnergy&,"\
98 " GTime&, GEnergy&, GTime&, GObservation&)"
99#define G_NROI_ELLIPTICAL "GCTAResponseIrf::nroi_elliptical(GModelSky&,"\
100 " GEnergy&, GTime&, GEnergy&, GTime&, GObservation&)"
101#define G_NROI_DIFFUSE "GCTAResponseIrf::nroi_diffuse(GModelSky&, GEnergy&,"\
102 " GTime&, GEnergy&, GTime&, GObservation&)"
103#define G_AEFF "GCTAResponseIrf::aeff(double&, double&, double&, double&,"\
105#define G_PSF "GCTAResponseIrf::psf(double&, double&, double&, double&,"\
107#define G_PSF_DELTA_MAX "GCTAResponseIrf::psf_delta_max(double&, double&,"\
108 " double&, double&, double&)"
334 const GEnergy& obsEng =
event.energy();
342 double zenith = pnt.
zenith();
343 double azimuth = pnt.
azimuth();
346 double theta = pnt.
dir().
dist(srcDir);
350 double srcLogEng = srcEng.
log10TeV();
354 double delta = obsDir.
dist(srcDir);
357 double delta_max =
psf_delta_max(theta, phi, zenith, azimuth, srcLogEng);
363 if (delta <= delta_max) {
366 irf =
aeff(theta, phi, zenith, azimuth, srcLogEng);
372 irf *=
psf(delta, theta, phi, zenith, azimuth, srcLogEng);
378 irf *=
edisp(obsEng, srcEng, theta, phi, zenith, azimuth);
390 #if defined(G_NAN_CHECK)
392 std::cout <<
"*** ERROR: GCTAResponseIrf::irf:";
393 std::cout <<
" NaN/Inf encountered";
394 std::cout <<
" (irf=" <<
irf;
395 std::cout <<
", theta=" << theta;
396 std::cout <<
", phi=" << phi <<
")";
397 std::cout << std::endl;
436 const GTime& obsTime,
440 static const int iter = 6;
446 const GTime& srcTime = obsTime;
463 if (etrue_max > etrue_min) {
466 cta_nroi_kern integrand(
this, &obs, &model, srcTime, obsEng, obsTime);
485 const GEnergy& srcEng = obsEng;
488 double nroi_spatial = this->
nroi(model, srcEng, srcTime, obsEng, obsTime, obs);
489 double nroi_spectral = model.
spectral()->
eval(srcEng, srcTime);
493 nroi = nroi_spatial * nroi_spectral * nroi_temporal;
503 #if defined(G_NAN_CHECK)
505 std::cout <<
"*** ERROR: GCTAResponseIrf::nroi:";
506 std::cout <<
" NaN/Inf encountered";
507 std::cout <<
" (nroi=" <<
nroi;
508 std::cout <<
", obsEng=" << obsEng;
509 std::cout <<
", obsTime=" << obsTime;
510 std::cout <<
")" << std::endl;
531 if (
edisp() != NULL) {
571 double zenith = pnt.
zenith();
572 double azimuth = pnt.
azimuth();
580 double effective_area =
aeff(theta, phi, zenith, azimuth, srcLogEng);
583 double ulimite = effective_area / area;
587 std::string msg =
"Effective area "+
589 " cm2 is larger than simulation surface area "+
591 " cm2 for photon energy "+
593 " TeV. Simulations are inaccurate.";
598 if ((ulimite > 0.0) && (ran.
uniform() <= ulimite)) {
602 if (deadc >= 1.0 || ran.
uniform() <= deadc) {
608 double delta =
psf()->
mc(ran, srcLogEng, theta, phi, zenith, azimuth) *
610 double alpha = 360.0 * ran.
uniform();
630 event->
dir(inst_dir);
631 event->energy(energy);
632 event->time(photon.
time());
686 if (instrument.empty()) {
699 this->
load(xml_rspname);
744 if (!filename.empty()) {
750 double thetacut = 0.0;
797 if (!filename.empty()) {
813 if (!filename.empty()) {
829 if (!filename.empty()) {
906 if (
aeff() != NULL) {
919 double thetacut = 0.0;
928 scale = arf->
scale();
929 sigma = arf->
sigma();
936 sigma = perf->
sigma();
941 if (thetacut > 0.0) {
956 if (!(
psf()->filename().is_empty())) {
964 if (
edisp() != NULL) {
965 if (!(
edisp()->filename().is_empty())) {
1010 std::string expr =
"NAME("+
rspname+
")";
1024 bool use_caldb =
true;
1107 if (!filename.
exists()) {
1108 std::string msg =
"File \""+filename+
"\" not found. Please specify "
1109 "a valid effective area response file.";
1117 GFits fits(filename);
1127 if (extname.empty()) {
1137 if (!extname.empty()) {
1175 std::string msg =
"FITS file \""+filename+
"\" does not "
1176 "contain a valid effective area table. "
1177 "Please specify a valid effective area "
1236 if (!filename.
exists()) {
1237 std::string msg =
"File \""+filename+
"\" not found. Please specify "
1238 "a valid point spread function response file.";
1246 GFits fits(filename);
1256 if (extname.empty()) {
1257 if (fits.
contains(
"POINT SPREAD FUNCTION")) {
1258 extname =
"POINT SPREAD FUNCTION";
1266 if (!extname.empty()) {
1323 std::string msg =
"FITS file \""+filename+
"\" does not "
1324 "contain a valid point spread function table. "
1325 "Please specify a valid point spread function "
1372 if (!filename.
exists()) {
1373 std::string msg =
"File \""+filename+
"\" not found. Please specify "
1374 "a valid energy dispersion response file.";
1382 GFits fits(filename);
1392 if (extname.empty()) {
1402 if (!extname.empty()) {
1433 std::string msg =
"FITS file \""+filename+
"\" does not "
1434 "contain a valid energy dispersion table. "
1435 "Please specify a valid energy dispersion "
1479 if (!filename.
exists()) {
1480 std::string msg =
"File \""+filename+
"\" not found. Please specify "
1481 "a valid background response file.";
1489 GFits fits(filename);
1495 std::string extname;
1499 if (extname.empty()) {
1513 if (!extname.empty()) {
1514 table = fits.
table(extname);
1517 table = fits.
table(1);
1602 sigma = arf->
sigma();
1608 sigma = prf->
sigma();
1631 result.append(
"=== GCTAResponseIrf ===");
1639 result.append(
"Used");
1643 result.append(
"Not available");
1646 result.append(
"Not used");
1654 result.append(
" - ");
1656 result.append(
" TeV");
1659 result.append(
"> ");
1661 result.append(
" TeV");
1664 result.append(
"< ");
1666 result.append(
" TeV");
1669 result.append(
"undefined");
1683 result.append(
"\n"+
m_aeff->
print(reduced_chatter));
1687 if (
m_psf != NULL) {
1688 result.append(
"\n"+
m_psf->
print(reduced_chatter));
1738 const double& zenith,
1739 const double& azimuth,
1740 const double& srcLogEng)
const
1744 std::string msg =
"No effective area information found in response.\n"
1745 "Please make sure that the instrument response is"
1746 " properly defined.";
1751 double aeff = (*m_aeff)(srcLogEng, theta, phi, zenith, azimuth);
1777 const double& theta,
1779 const double& zenith,
1780 const double& azimuth,
1781 const double& srcLogEng)
const
1784 if (
m_psf == NULL) {
1785 std::string msg =
"No point spread function information found in"
1787 "Please make sure that the instrument response is"
1788 " properly defined.";
1793 double psf = (*m_psf)(delta, srcLogEng, theta, phi, zenith, azimuth);
1819 const double& zenith,
1820 const double& azimuth,
1821 const double& srcLogEng)
const
1824 if (
m_psf == NULL) {
1825 std::string msg =
"No point spread function information found in"
1827 "Please make sure that the instrument response is"
1828 " properly defined.";
1833 double delta_max =
m_psf->
delta_max(srcLogEng, theta, phi, zenith, azimuth);
1853 const double& theta,
1855 const double& zenith,
1856 const double& azimuth)
const
1859 double edisp = (*m_edisp)(ereco, etrue, theta, phi, zenith, azimuth);
1894 const GTime& srcTime,
1896 const GTime& obsTime,
1903 std::string name = obs.
id() +
"::" + model.
name();
1911 if (has_free_pars ||
1966 const GTime& obsTime,
1980 double zenith = pnt.
zenith();
1981 double azimuth = pnt.
azimuth();
1984 double theta = pnt.
dir().
dist(srcDir);
1988 double srcLogEng = srcEng.
log10TeV();
1991 double nroi =
aeff(theta, phi, zenith, azimuth, srcLogEng);
1997 nroi *=
npsf(srcDir, srcLogEng, srcTime, pnt, roi);
2003 nroi *=
edisp(obsEng, srcEng, theta, phi, zenith, azimuth);
2013 #if defined(G_NAN_CHECK)
2015 std::cout <<
"*** ERROR: GCTAResponseIrf::nroi:";
2016 std::cout <<
" NaN/Inf encountered";
2017 std::cout <<
" (nroi=" <<
nroi;
2018 std::cout <<
", theta=" << theta;
2019 std::cout <<
", phi=" << phi <<
")";
2020 std::cout << std::endl;
2055 const double& srcLogEng,
2056 const GTime& srcTime,
2061 static const int iter = 6;
2067 double zenith = pnt.
zenith();
2068 double azimuth = pnt.
azimuth();
2071 double theta = pnt.
dir().
dist(srcDir);
2078 double roi_psf_distance = roi.
centre().
dir().dist(srcDir);
2079 double rmax =
psf_delta_max(theta, phi, zenith, azimuth, srcLogEng);
2083 if (roi_psf_distance + rmax <= roi_radius) {
2091 double rmin = (roi_psf_distance > roi_radius)
2092 ? roi_psf_distance - roi_radius : 0.0;
2119 if (rmax-rmin < 1.0e-12) {
2120 value = integral.
trapzd(rmin, rmax);
2123 value = integral.
romberg(rmin, rmax);
2127 #if defined(G_NAN_CHECK)
2129 std::cout <<
"*** ERROR: GCTAResponseIrf::npsf:";
2130 std::cout <<
" NaN/Inf encountered";
2131 std::cout <<
" (value=" << value;
2133 std::cout <<
", roi_psf_distance=";
2137 std::cout << std::endl;
2286 double irf = this->
irf(event, photon, obs);
2349 if (model == NULL) {
2350 std::string cls = std::string(
typeid(source.
model()).name());
2351 std::string msg =
"Invalid spatial model type \""+cls+
"\" specified. "
2352 "Please specify a \"GModelSpatialRadial\" source "
2353 "model as argument.";
2370 static const int iter_rho = 6;
2371 static const int iter_phi = 6;
2375 const GEnergy& obsEng =
event.energy();
2383 double zenith = pnt.
zenith();
2384 double azimuth = pnt.
azimuth();
2388 double zeta = centre.dist(obsDir);
2392 double eta = pnt.
dir().
dist(obsDir);
2396 double lambda = centre.dist(pnt.
dir());
2400 double omega0 = 0.0;
2401 double denom = std::sin(lambda) * std::sin(zeta);
2403 double arg = (std::cos(eta) - std::cos(lambda) * std::cos(zeta))/denom;
2408 double srcLogEng = srcEng.
log10TeV();
2421 double delta_max =
psf_delta_max(theta, phi, zenith, azimuth, srcLogEng);
2425 double rho_min = (zeta > delta_max) ? zeta - delta_max : 0.0;
2426 double rho_max = zeta + delta_max;
2427 if (rho_max > src_max) {
2435 if (rho_max > rho_min) {
2456 std::vector<double> bounds;
2457 bounds.push_back(rho_min);
2458 bounds.push_back(rho_max);
2463 double transition_point = delta_max - zeta;
2464 if (transition_point > rho_min && transition_point < rho_max) {
2465 bounds.push_back(transition_point);
2471 if (shell != NULL) {
2473 if (shell_radius > rho_min && shell_radius < rho_max) {
2474 bounds.push_back(shell_radius);
2483 if (ring_radius > rho_min && ring_radius < rho_max) {
2484 bounds.push_back(ring_radius);
2492 #if defined(G_NAN_CHECK)
2494 std::cout <<
"*** ERROR: GCTAResponseIrf::irf_radial:";
2495 std::cout <<
" NaN/Inf encountered";
2496 std::cout <<
" (irf=" <<
irf;
2497 std::cout <<
", rho_min=" << rho_min;
2498 std::cout <<
", rho_max=" << rho_max;
2499 std::cout <<
", omega0=" << omega0 <<
")";
2500 std::cout << std::endl;
2510 #if defined(G_DEBUG_IRF_RADIAL)
2511 std::cout <<
"GCTAResponseIrf::irf_radial:";
2520 std::cout <<
" obsDir=" << obsDir <<
";";
2521 std::cout <<
" modelDir=" << model->
dir() <<
";";
2522 std::cout <<
" irf=" <<
irf << std::endl;
2573 static const int iter_rho = 6;
2574 static const int iter_phi = 6;
2583 if (model == NULL) {
2584 std::string cls = std::string(
typeid(source.
model()).name());
2585 std::string msg =
"Invalid spatial model type \""+cls+
"\" specified. "
2586 "Please specify a \"GModelSpatialElliptical\" source "
2587 "model as argument.";
2593 const GEnergy& obsEng =
event.energy();
2601 double zenith = pnt.
zenith();
2602 double azimuth = pnt.
azimuth();
2607 double rho_obs = centre.dist(obsDir);
2608 double posangle_obs = centre.posang(obsDir);
2612 double rho_pnt = centre.dist(pnt.
dir());
2613 double posangle_pnt = centre.posang(pnt.
dir());
2616 double omega_pnt = posangle_pnt - posangle_obs;
2619 double srcLogEng = srcEng.
log10TeV();
2625 double theta = pnt.
dir().
dist(obsDir);
2627 double delta_max =
psf_delta_max(theta, phi, zenith, azimuth, srcLogEng);
2637 double aspect_ratio;
2639 aspect_ratio = (model->
semimajor() > 0.0) ?
2644 aspect_ratio = (model->
semiminor() > 0.0) ?
2649 semiminor = semimajor * aspect_ratio;
2652 double rho_min = (rho_obs > delta_max) ? rho_obs - delta_max : 0.0;
2653 double rho_max = rho_obs + delta_max;
2654 if (rho_max > semimajor) {
2655 rho_max = semimajor;
2662 if (rho_max > rho_min) {
2687 std::vector<double> bounds;
2688 bounds.push_back(rho_min);
2689 bounds.push_back(rho_max);
2693 if (semiminor > rho_min && semiminor < rho_max) {
2694 bounds.push_back(semiminor);
2701 #if defined(G_NAN_CHECK)
2703 std::cout <<
"*** ERROR: GCTAResponseIrf::irf_elliptical:";
2704 std::cout <<
" NaN/Inf encountered";
2705 std::cout <<
" (irf=" <<
irf;
2706 std::cout <<
", rho_min=" << rho_min;
2707 std::cout <<
", rho_max=" << rho_max <<
")";
2708 std::cout << std::endl;
2718 #if defined(G_DEBUG_IRF_ELLIPTICAL)
2719 std::cout <<
"GCTAResponseIrf::irf_elliptical:";
2720 std::cout <<
" rho_min=" << rho_min;
2721 std::cout <<
" rho_max=" << rho_max;
2722 std::cout <<
" irf=" <<
irf << std::endl;
2773 static const int min_iter_rho = 6;
2774 static const int min_iter_phi = 6;
2775 static const int max_iter_rho = 8;
2776 static const int max_iter_phi = 8;
2790 if (model == NULL) {
2791 std::string cls = std::string(
typeid(source.
model()).name());
2792 std::string msg =
"Invalid spatial model type \""+cls+
"\" specified. "
2793 "Please specify a \"GModelSpatial\" source "
2794 "model as argument.";
2802 const GEnergy& obsEng =
event.energy();
2809 double zenith = pnt.
zenith();
2810 double azimuth = pnt.
azimuth();
2817 double srcLogEng = srcEng.
log10TeV();
2830 double delta_max =
psf_delta_max(theta, phi, zenith, azimuth, srcLogEng);
2833 if (delta_max > 0.0) {
2842 GMatrix rot = (ry * rz).transpose();
2863 min_iter_rho, max_iter_rho);
2871 #if defined(G_NAN_CHECK)
2873 std::cout <<
"*** ERROR: GCTAResponseIrf::irf_diffuse:";
2874 std::cout <<
" NaN/Inf encountered";
2875 std::cout <<
" (irf=" <<
irf;
2876 std::cout <<
", delta_max=" << delta_max <<
")";
2877 std::cout << std::endl;
2886 #if defined(G_DEBUG_IRF_DIFFUSE)
2887 std::cout <<
"GCTAResponseIrf::irf_diffuse:";
2888 std::cout <<
" srcLogEng=" << srcLogEng;
2889 std::cout <<
" obsLogEng=" << obsLogEng;
2890 std::cout <<
" eta=" << eta;
2891 std::cout <<
" delta_max=" << delta_max;
2892 std::cout <<
" irf=" <<
irf << std::endl;
2928 const GTime& srcTime,
2930 const GTime& obsTime,
2941 double nroi =
nirf(photon, obsEng, obsTime, obs);
2980 const GTime& srcTime,
2982 const GTime& obsTime,
2988 static const int iter_rho = 6;
2989 static const int iter_phi = 6;
3002 if (spatial == NULL) {
3003 std::string cls = std::string(
typeid(model.
spatial()).name());
3004 std::string msg =
"Invalid spatial model type \""+cls+
"\" specified. "
3005 "Please specify a \"GModelSpatialRadial\" source "
3006 "model as argument.";
3014 double zenith = pnt.
zenith();
3015 double azimuth = pnt.
azimuth();
3018 double srcLogEng = srcEng.
log10TeV();
3025 double psf_max_radius =
psf_delta_max(0.0, 0.0, zenith, azimuth, srcLogEng);
3031 double roi_model_distance = roi.
centre().
dir().dist(centre);
3036 double roi_psf_radius = roi_radius + psf_max_radius;
3041 double rho_min = (roi_model_distance > roi_psf_radius)
3042 ? roi_model_distance - roi_psf_radius: 0.0;
3046 if (rho_max > rho_min) {
3054 GMatrix rot = (ry * rz).transpose();
3058 double omega0 = centre.posang(roi.
centre().
dir());
3079 std::vector<double> bounds;
3080 bounds.push_back(rho_min);
3081 bounds.push_back(rho_max);
3086 double transition_point = roi_psf_radius - roi_model_distance;
3087 if (transition_point > rho_min && transition_point < rho_max) {
3088 bounds.push_back(transition_point);
3094 transition_point = roi_psf_radius + roi_model_distance;
3095 if (transition_point > rho_min && transition_point < rho_max) {
3096 bounds.push_back(transition_point);
3103 if (shell != NULL) {
3105 if (shell_radius > rho_min && shell_radius < rho_max) {
3106 bounds.push_back(shell_radius);
3116 if (ring_radius > rho_min && ring_radius < rho_max) {
3117 bounds.push_back(ring_radius);
3125 #if defined(G_DEBUG_NROI_RADIAL)
3126 std::cout <<
"GCTAResponseIrf::nroi_radial:";
3127 std::cout <<
" rho_min=" << rho_min;
3128 std::cout <<
" rho_max=" << rho_max;
3129 std::cout <<
" nroi=" <<
nroi << std::endl;
3135 #if defined(G_NAN_CHECK)
3137 std::cout <<
"*** ERROR: GCTAResponseIrf::nroi_radial:";
3138 std::cout <<
" NaN/Inf encountered";
3139 std::cout <<
" (nroi=" <<
nroi;
3140 std::cout <<
", rho_min=" << rho_min;
3141 std::cout <<
", rho_max=" << rho_max;
3142 std::cout <<
")" << std::endl;
3183 const GTime& srcTime,
3185 const GTime& obsTime,
3191 static const int iter_rho = 6;
3192 static const int iter_phi = 6;
3205 if (spatial == NULL) {
3206 std::string cls = std::string(
typeid(model.
spatial()).name());
3207 std::string msg =
"Invalid spatial model type \""+cls+
"\" specified. "
3208 "Please specify a \"GModelSpatialElliptical\" source "
3209 "model as argument.";
3217 double zenith = pnt.
zenith();
3218 double azimuth = pnt.
azimuth();
3221 double srcLogEng = srcEng.
log10TeV();
3228 double psf_max_radius =
psf_delta_max(0.0, 0.0, zenith, azimuth, srcLogEng);
3236 double rho_roi = roi.
centre().
dir().dist(centre);
3246 double aspect_ratio;
3248 aspect_ratio = (spatial->
semimajor() > 0.0) ?
3253 aspect_ratio = (spatial->
semiminor() > 0.0) ?
3258 semiminor = semimajor * aspect_ratio;
3263 double rho_min = (rho_roi > radius_roi) ? rho_roi - radius_roi: 0.0;
3264 double rho_max = rho_roi + radius_roi;
3265 if (rho_max > semimajor) {
3266 rho_max = semimajor;
3270 if (rho_max > rho_min) {
3278 GMatrix rot = (ry * rz).transpose();
3282 double posangle_roi = centre.posang(roi.
centre().
dir());
3306 std::vector<double> bounds;
3307 bounds.push_back(rho_min);
3308 bounds.push_back(rho_max);
3312 if (semiminor > rho_min && semiminor < rho_max) {
3313 bounds.push_back(semiminor);
3320 #if defined(G_DEBUG_NROI_ELLIPTICAL)
3321 std::cout <<
"GCTAResponseIrf::nroi_elliptical:";
3322 std::cout <<
" rho_min=" << rho_min;
3323 std::cout <<
" rho_max=" << rho_max;
3324 std::cout <<
" nroi=" <<
nroi << std::endl;
3330 #if defined(G_NAN_CHECK)
3332 std::cout <<
"*** ERROR: GCTAResponseIrf::nroi_elliptical:";
3333 std::cout <<
" NaN/Inf encountered";
3334 std::cout <<
" (nroi=" <<
nroi;
3335 std::cout <<
", rho_min=" << rho_min;
3336 std::cout <<
", rho_max=" << rho_max;
3337 std::cout <<
")" << std::endl;
3378 const GTime& srcTime,
3380 const GTime& obsTime,
3386 static const int iter_rho = 9;
3387 static const int iter_phi = 9;
3400 if (spatial == NULL) {
3401 std::string cls = std::string(
typeid(model.
spatial()).name());
3402 std::string msg =
"Invalid spatial model type \""+cls+
"\" specified. "
3403 "Please specify a \"GModelSpatial\" source "
3404 "model as argument.";
3409 double zenith = pnt.
zenith();
3410 double azimuth = pnt.
azimuth();
3413 double srcLogEng = srcEng.
log10TeV();
3420 double psf_max_radius =
psf_delta_max(0.0, 0.0, zenith, azimuth, srcLogEng);
3428 double roi_psf_radius = roi_radius + psf_max_radius;
3431 if (roi_psf_radius > 0.0) {
3439 GMatrix rot = (ry * rz).transpose();
3458 #if defined(G_DEBUG_NROI_DIFFUSE)
3459 std::cout <<
"GCTAResponseIrf::nroi_diffuse:";
3460 std::cout <<
" roi_psf_radius=" << roi_psf_radius;
3461 std::cout <<
" nroi=" <<
nroi;
3462 std::cout <<
" Etrue=" << srcEng;
3463 std::cout <<
" Ereco=" << obsEng;
3464 std::cout <<
" id=" <<
id << std::endl;
3470 #if defined(G_NAN_CHECK)
3472 std::cout <<
"*** ERROR: GCTAResponseIrf::nroi_diffuse:";
3473 std::cout <<
" NaN/Inf encountered";
3474 std::cout <<
" (nroi=" <<
nroi;
3475 std::cout <<
", roi_psf_radius=" << roi_psf_radius;
3476 std::cout <<
")" << std::endl;
3513 const GTime& srcTime,
3515 const GTime& obsTime,
3526 for (
int i = 0; i < comp->
components(); ++i) {
3535 nroi += this->
nroi(sky, srcEng, srcTime, obsEng, obsTime, obs) *
XSPEC Auxiliary Response File class definition.
CTA 2D effective area class definition.
CTA ARF effective area class definition.
CTA performance table effective area class definition.
CTA effective area base class definition.
CTA 2D background class definition.
CTA 3D background class definition.
CTA performance table background class definition.
CTA background model base class definition.
CTA 2D energy dispersion class definition.
CTA performance table energy dispersion class definition.
CTA RMF energy dispersion class definition.
Abstract CTA energy dispersion base class definition.
CTA event atom class definition.
CTA event list class interface definition.
CTA observation class interface definition.
CTA pointing class interface definition.
CTA 2D point spread function class definition.
King profile CTA point spread function class definition.
CTA performance table point spread function class definition.
CTA point spread function table class definition.
CTA point spread function vector class definition.
CTA point spread function base class definition.
#define G_NROI_ELLIPTICAL
#define G_LOAD_BACKGROUND
CTA instrument response function class definition.
CTA response helper classes definition.
CTA region of interest class interface definition.
Definition of support function used by CTA classes.
Calibration database class interface definition.
Exception handler interface definition.
Filename class interface definition.
FITS file class interface definition.
Integration class interface definition.
Mathematical function definitions.
Sky model class interface definition.
Spatial composite model class interface definition.
Abstract elliptical spatial model base class interface definition.
Point source spatial model class interface definition.
Radial ring model class interface definition.
Radial shell model class interface definition.
Abstract radial spatial model base class interface definition.
Random number generator class definition.
@ GMODEL_SPATIAL_ELLIPTICAL
@ GMODEL_SPATIAL_COMPOSITE
@ GMODEL_SPATIAL_POINT_SOURCE
double sum(const GVector &vector)
Computes vector sum.
CTA 2D effective area class.
CTA ARF effective area class.
void sigma(const double &sigma)
Set sigma for offset angle dependence.
void scale(const double &scale)
Set effective area scaling factor.
void remove_thetacut(const GCTAResponseIrf &rsp)
Remove thetacut.
void thetacut(const double &thetacut)
Set theta cut angle.
CTA performance table effective area class.
void sigma(const double &sigma)
Set sigma for offset angle dependence.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual GFilename filename(void) const =0
virtual GCTAAeff * clone(void) const =0
Clones object.
CTA performance table background class.
void sigma(const double &sigma)
Set sigma for offset angle dependence.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual GCTABackground * clone(void) const =0
Clones object.
CTA 2D energy dispersion class.
CTA performance table energy dispersion class.
CTA Redistribution Matrix File (RMF) energy dispersion class.
virtual GEnergy mc(GRan &ran, const GEnergy &etrue, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0) const =0
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual GCTAEdisp * clone(void) const =0
Clones object.
virtual GEbounds etrue_bounds(const GEnergy &ereco, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0) const =0
const GCTAInstDir & dir(void) const
Return instrument direction.
virtual void roi(const GRoi &roi)
Set ROI.
CTA instrument direction class.
void dir(const GSkyDir &dir)
Set sky direction.
void pointing(const GCTAPointing &pointing)
Set CTA pointing.
const double & zenith(void) const
Return pointing zenith angle.
GCTAInstDir instdir(const GSkyDir &skydir) const
Get instrument direction from sky direction.
const GSkyDir & dir(void) const
Return pointing sky direction.
const double & azimuth(void) const
Return pointing azimuth angle.
CTA 2D point spread function class.
CTA point spread function class with a King profile.
CTA performance table point spread function class.
CTA point spread function table class.
CTA vector point spread function class.
virtual GCTAPsf * clone(void) const =0
Clones object.
virtual double delta_max(const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const =0
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual double mc(GRan &ran, const double &logE, const double &theta=0.0, const double &phi=0.0, const double &zenith=0.0, const double &azimuth=0.0, const bool &etrue=true) const =0
CTA instrument response function class.
const GCTAAeff * aeff(void) const
Return pointer to effective area response.
virtual bool apply_edisp(void) const
Signal if energy dispersion should be applied.
double nroi_composite(const GModelSky &model, const GEnergy &srcEng, const GTime &srcTime, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of composite source model.
void load_edisp(const GFilename &filename)
Load energy dispersion information.
double offset_sigma(void) const
Return offset angle dependence (degrees)
virtual bool use_edisp(void) const
Signal if response uses energy dispersion.
double nroi_diffuse(const GModelSky &model, const GEnergy &srcEng, const GTime &srcTime, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of diffuse source model.
GCTAAeff * m_aeff
Effective area.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA response information.
void load_psf(const GFilename &filename)
Load CTA PSF vector.
bool m_apply_edisp
Apply energy dispersion.
double irf_ptsrc(const GEvent &event, const GSource &source, const GObservation &obs) const
Return value of point source instrument response function.
GCTABackground * m_background
Background.
GCTAEventAtom * mc(const double &area, const GPhoton &photon, const GObservation &obs, GRan &ran) const
Simulate event from photon.
GFilename irf_filename(const std::string &filename) const
Return filename with appropriate extension.
double psf_delta_max(const double &theta, const double &phi, const double &zenith, const double &azimuth, const double &srcLogEng) const
Return maximum angular separation (in radians)
const GCTABackground * background(void) const
Return pointer to background model.
virtual GCTAResponseIrf * clone(void) const
Clone instance.
std::string m_xml_rspname
Response name in XML file.
const GCTAPsf * psf(void) const
Return pointer to point spread function.
void copy_members(const GCTAResponseIrf &rsp)
Copy class members.
double irf_elliptical(const GEvent &event, const GSource &source, const GObservation &obs) const
Return Irf value for elliptical source model.
virtual double nroi(const GModelSky &model, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return integral of event probability for a given sky model over ROI.
double m_lo_safe_thres
Safe low energy threshold.
void init_members(void)
Initialise class members.
GCTAEdisp * m_edisp
Energy dispersion.
void free_members(void)
Delete class members.
void load(const std::string &rspname)
Load CTA response.
void load_aeff(const GFilename &filename)
Load effective area.
double npsf(const GSkyDir &srcDir, const double &srcLogEng, const GTime &srcTime, const GCTAPointing &pnt, const GCTARoi &roi) const
Return result of PSF integration over ROI.
virtual void clear(void)
Clear instance.
virtual GEbounds ebounds(const GEnergy &obsEnergy) const
Return true energy boundaries for a specific observed energy.
virtual double irf(const GEvent &event, const GPhoton &photon, const GObservation &obs) const
Return value of instrument response function.
const GCaldb & caldb(void) const
Return calibration database.
GCaldb m_caldb
Calibration database.
double nroi_ptsrc(const GModelSky &model, const GEnergy &srcEng, const GTime &srcTime, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of point source model.
double m_hi_safe_thres
Safe high energy threshold.
const std::string & rspname(void) const
Return response name.
std::string m_xml_caldb
Calibration database string in XML file.
void load_background(const GFilename &filename)
Load background model.
double irf_radial(const GEvent &event, const GSource &source, const GObservation &obs) const
Return IRF value for radial source model.
virtual void read(const GXmlElement &xml)
Read response from XML element.
double nirf(const GPhoton &photon, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of Instrument Response Function.
GCTAResponseIrf(void)
Void constructor.
const GCTAEdisp * edisp(void) const
Return pointer to energy dispersion.
double irf_diffuse(const GEvent &event, const GSource &source, const GObservation &obs) const
Return value of diffuse source instrument response function.
double nroi_elliptical(const GModelSky &model, const GEnergy &srcEng, const GTime &srcTime, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of elliptical source model.
virtual void write(GXmlElement &xml) const
Write response information into XML element.
GCTAPsf * m_psf
Point spread function.
double nroi_radial(const GModelSky &model, const GEnergy &srcEng, const GTime &srcTime, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of radial source model.
std::string m_rspname
Name of the instrument response.
virtual ~GCTAResponseIrf(void)
Destructor.
virtual GCTAResponseIrf & operator=(const GCTAResponseIrf &rsp)
Assignment operator.
CTA instrument response function class.
void init_members(void)
Initialise class members.
virtual GCTAResponse & operator=(const GCTAResponse &rsp)
Assignment operator.
void free_members(void)
Delete class members.
Interface for the CTA region of interest class.
const double & radius(void) const
Returns radius of region of interest in degrees.
const GCTAInstDir & centre(void) const
Returns region of interest centre.
Calibration database class.
std::string rootdir(void) const
Return path to CALDB root directory.
const std::string & mission(void) const
Return mission.
const std::string & instrument(void) const
Return instrument.
GFilename filename(const std::string &detector, const std::string &filter, const std::string &codename, const std::string &date, const std::string &time, const std::string &expr)
Return calibration file name based on selection parameters.
void clear(void)
Clear calibration database.
std::string print(const GChatter &chatter=NORMAL) const
Print calibration database information.
Energy boundaries container class.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
int size(void) const
Return number of energy boundaries.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
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.
double TeV(void) const
Return energy in TeV.
Abstract interface for the event classes.
bool has_extname(void) const
Signal if filename has an extension name.
bool is_fits(void) const
Checks whether file is a FITS file.
std::string extname(const std::string &defaultname="") const
Return extension name.
bool exists(void) const
Checks whether file exists.
bool is_empty(void) const
Signal if filename is empty.
bool has_card(const int &cardno) const
Check existence of header card.
double real(const std::string &keyname) const
Return card value as double precision.
Abstract interface for FITS table.
bool contains(const std::string &colname) const
Checks the presence of a column in table.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
void close(void)
Close FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
GIntegral class interface definition.
double romberg(std::vector< double > bounds, const int &order=5)
Perform Romberg integration.
double trapzd(const double &a, const double &b, const int &n=1, double result=0.0)
Perform Trapezoidal integration.
void fixed_iter(const int &iter)
Set fixed number of iterations.
Generic matrix class definition.
void eulerz(const double &angle)
Set Euler rotation matrix around z axis.
void eulery(const double &angle)
Set Euler rotation matrix around y axis.
GModelSpectral * spectral(void) const
Return spectral model component.
GModelTemporal * temporal(void) const
Return temporal model component.
GModelSpatial * spatial(void) const
Return spatial model component.
const GModelSpatial * component(const int &index) const
Returns pointer to spatial component element.
int components(void) const
Return number of model components.
double sum_of_scales(void) const
Returns sum of all model scales.
double scale(const int &index) const
Returns scale of spatial component.
Abstract elliptical spatial model base class.
double semimajor(void) const
Return semi-major axis of ellipse.
double posangle(void) const
Return Position Angle of model.
const GSkyDir & dir(void) const
Return position of elliptical spatial model.
double semiminor(void) const
Return semi-minor axis of ellipse.
virtual double theta_max(void) const =0
Point source spatial model.
const GSkyDir & dir(void) const
Return position of point source.
double radius(void) const
Return ring inner radius.
double radius(void) const
Return shell radius.
Abstract radial spatial model base class.
virtual double theta_max(void) const =0
const GSkyDir & dir(void) const
Return position of radial spatial model.
Abstract spatial model base class.
bool has_free_pars(void) const
Checks if the spatial model has free parameters.
virtual GClassCode code(void) const =0
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const =0
virtual double eval(const GTime &srcTime, const bool &gradients=false) const =0
GModelPar & scale(const int &index)
Returns reference to scale parameter by index.
bool has_scales(void) const
Signals that model has scales.
const std::string & name(void) const
Return parameter name.
Abstract observation base class.
virtual double deadc(const GTime &time=GTime()) const =0
virtual std::string instrument(void) const =0
void id(const std::string &id)
Set observation identifier.
double value(void) const
Return parameter value.
Class that handles photons.
const GTime & time(void) const
Return photon time.
const GSkyDir & dir(void) const
Return photon sky direction.
const GEnergy & energy(void) const
Return photon energy.
Random number generator class.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
bool contains(const std::string &name, const GEnergy &ereco, const GEnergy &etrue, double *value=NULL) const
Check if cache contains a value for specific parameters.
std::string print(const GChatter &chatter=NORMAL) const
Print response cache.
void set(const std::string &name, const GEnergy &ereco, const GEnergy &etrue, const double &value)
Set cache value.
GResponseCache m_irf_cache
GResponseCache m_nroi_cache
bool m_use_nroi_cache
Control usage of nroi cache.
void init_members(void)
Initialise class members.
void free_members(void)
Delete class members.
void rotate_deg(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
double dec_deg(void) const
Returns Declination in degrees.
double ra_deg(void) const
Returns Right Ascension in degrees.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
Class that handles gamma-ray sources.
const GEnergy & energy(void) const
Return photon energy.
const GTime & time(void) const
Return photon arrival time.
const GModelSpatial * model(void) const
Return spatial model component.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
Kernel for IRF offest angle integration of the diffuse source model.
Kernel for elliptical model zenith angle integration of IRF.
Kernel for radial model zenith angle integration of IRF.
Integration kernel for npsf() method.
Kernel for Nroi offest angle integration of diffuse model.
Kernel for zenith angle Nroi integration of elliptical model.
Kernel for zenith angle Nroi integration of radial model.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
const std::string extname_rmf
const GCTAObservation & cta_obs(const std::string &origin, const GObservation &obs)
Retrieve CTA observation from generic observation.
bool is_infinite(const double &x)
Signal if argument is infinite.
const std::string extname_cta_background3d
bool is_notanumber(const double &x)
Signal if argument is not a number.
const GCTAPointing & cta_pnt(const std::string &origin, const GObservation &obs)
Retrieve CTA pointing from generic observation.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
const GXmlElement * xml_get_par(const std::string &origin, const GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
double todouble(const std::string &arg)
Convert string into double precision value.
const GCTAInstDir & cta_dir(const std::string &origin, const GEvent &event)
Retrieve CTA instrument direction from generic event.
std::string filepath(const std::string &pathname, const std::string &filename)
Build file path from path name and file name.
std::string tolower(const std::string &s)
Convert string to lower case.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
const GCTAEventList & cta_event_list(const std::string &origin, const GObservation &obs)
Retrieve CTA event list from generic observation.
const std::string extname_cta_aeff2d
const std::string extname_cta_background2d
double resolution(const GModelSpatial *model)
Determine resolution of spatial model.
const std::string extname_cta_edisp2d
const std::string extname_arf
double acos(const double &arg)
Computes acos by avoiding NaN due to rounding errors.
GChatter reduce(const GChatter &chatter)
Reduce chattiness by one level.
std::string gadf_hduclas4(const GFits &fits, const std::string &hduclas4)
Return extension name for GADF response table of given HDU class 4.
void warning(const std::string &origin, const std::string &message)
Emits warning.
bool xml_has_par(const GXmlElement &xml, const std::string &name)
Checks if parameter with given name in XML element exists.
int iter_rho(const double &rho_max, const double &resolution, const int &iter_min, const int &iter_max)
Determine number of radial Romberg iterations.