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);
383 irf *= obs.
deadc(srcTime);
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;
456 for (
int i = 0; i < ebounds.
size(); ++i) {
459 double etrue_min = ebounds.
emin(i).
MeV();
460 double etrue_max = ebounds.
emax(i).
MeV();
463 if (etrue_max > etrue_min) {
466 cta_nroi_kern integrand(
this, &obs, &model, srcTime, obsEng, obsTime);
473 nroi += integral.
romberg(etrue_min, etrue_max);
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 ||
1918 nroi =
nroi_ptsrc(model, srcEng, srcTime, obsEng, obsTime, obs);
1921 nroi =
nroi_radial(model, srcEng, srcTime, obsEng, obsTime, obs);
1927 nroi =
nroi_diffuse(model, srcEng, srcTime, obsEng, obsTime, obs);
1930 nroi =
nroi_composite(model, srcEng, srcTime, obsEng, obsTime, obs);
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);
2008 nroi *= obs.
deadc(srcTime);
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=";
2136 std::cout <<
"," << rmax * gammalib::rad2deg <<
"])";
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.";
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;
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);
2489 irf = integral.
romberg(bounds, iter_rho);
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;
2505 irf *= obs.
deadc(srcTime);
2510 #if defined(G_DEBUG_IRF_RADIAL)
2511 std::cout <<
"GCTAResponseIrf::irf_radial:";
2513 std::cout <<
", " << rho_max*gammalib::rad2deg <<
" deg;";
2514 std::cout <<
" zeta=" << zeta*gammalib::rad2deg <<
" deg;";
2515 std::cout <<
" eta=" << eta*gammalib::rad2deg <<
" deg;";
2516 std::cout <<
" lambda=" << lambda*gammalib::rad2deg <<
" deg;";
2517 std::cout <<
" omega0=" << omega0*gammalib::rad2deg <<
" deg;";
2518 std::cout <<
" theta_max=" << src_max*gammalib::rad2deg <<
" deg;";
2519 std::cout <<
" delta_max=" << delta_max*gammalib::rad2deg <<
" deg;";
2520 std::cout <<
" obsDir=" << obsDir <<
";";
2521 std::cout <<
" modelDir=" << model->
dir() <<
";";
2522 std::cout <<
" irf=" << irf << std::endl;
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);
2698 irf = integral.
romberg(bounds, iter_rho);
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;
2713 irf *= obs.
deadc(srcTime);
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);
2868 irf = integral.
romberg(0.0, delta_max);
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;
2883 irf *= obs.
deadc(srcTime);
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,
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();
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);
3122 nroi = integral.
romberg(bounds, iter_rho);
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,
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();
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);
3317 nroi = integral.
romberg(bounds, iter_rho);
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,
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();
3455 nroi = integral.
romberg(0.0, roi_psf_radius);
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) *
CTA background model base class definition.
void load_aeff(const GFilename &filename)
Load effective area.
GCTAResponseIrf(void)
Void constructor.
void load_background(const GFilename &filename)
Load background model.
CTA response helper classes definition.
CTA 2D energy dispersion class.
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.
void remove_thetacut(const GCTAResponseIrf &rsp)
Remove thetacut.
CTA event list class interface definition.
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
GFitsTable * table(const int &extno)
Get pointer to table HDU.
virtual GCTAEdisp * clone(void) const =0
Clones object.
CTA performance table effective area class.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
Kernel for IRF offest angle integration of the diffuse source model.
bool has_card(const int &cardno) const
Check existence of header card.
double m_hi_safe_thres
Safe high energy threshold.
double dec_deg(void) const
Returns Declination in degrees.
double romberg(std::vector< double > bounds, const int &order=5)
Perform Romberg integration.
Point source spatial model class interface definition.
virtual bool apply_edisp(void) const
Signal if energy dispersion should be applied.
Radial shell model class interface definition.
const GCTAInstDir & cta_dir(const std::string &origin, const GEvent &event)
Retrieve CTA instrument direction from generic event.
CTA event atom class definition.
virtual void write(GXmlElement &xml) const
Write response information into XML element.
Abstract elliptical spatial model base class.
Random number generator class definition.
void warning(const std::string &origin, const std::string &message)
Emits warning.
double irf_elliptical(const GEvent &event, const GSource &source, const GObservation &obs) const
Return Irf value for elliptical source model.
virtual std::string instrument(void) const =0
GModelSpectral * spectral(void) const
Return spectral model component.
const GSkyDir & dir(void) const
Return position of point source.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual bool use_edisp(void) const
Signal if response uses energy dispersion.
virtual void roi(const GRoi &roi)
Set ROI.
CTA vector point spread function class.
bool has_free_pars(void) const
Checks if the spatial model has free parameters.
const GModelSpatial * component(const int &index) const
Returns pointer to spatial component element.
int size(void) const
Return number of energy boundaries.
virtual GCTAResponseIrf & operator=(const GCTAResponseIrf &rsp)
Assignment operator.
const std::string & mission(void) const
Return mission.
GVector cos(const GVector &vector)
Computes cosine of vector elements.
GCTAAeff * m_aeff
Effective area.
virtual double eval(const GEnergy &srcEng, const GTime &srcTime=GTime(), const bool &gradients=false) const =0
GModelTemporal * temporal(void) const
Return temporal model component.
Abstract radial spatial model base class interface definition.
#define G_LOAD_BACKGROUND
const GCTABackground * background(void) const
Return pointer to background model.
CTA performance table background class definition.
void free_members(void)
Delete class members.
bool is_empty(void) const
Signal if filename is empty.
CTA instrument response function class definition.
const GCTAPointing & cta_pnt(const std::string &origin, const GObservation &obs)
Retrieve CTA pointing from generic observation.
bool contains(const std::string &colname) const
Checks the presence of a column in table.
const std::string extname_cta_background3d
Abstract interface for the event classes.
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.
Kernel for zenith angle Nroi integration of elliptical model.
const double & radius(void) const
Returns radius of region of interest in degrees.
CTA pointing class interface definition.
bool has_extname(void) const
Signal if filename has an extension name.
Kernel for zenith angle Nroi integration of radial model.
const GSkyDir & dir(void) const
Return position of elliptical spatial model.
CTA point spread function class with a King profile.
CTA Redistribution Matrix File (RMF) energy dispersion class.
const double & zenith(void) const
Return pointing zenith angle.
const std::string & rspname(void) const
Return response name.
double TeV(void) const
Return energy in TeV.
double sum(const GVector &vector)
Computes vector sum.
double acos(const double &arg)
Computes acos by avoiding NaN due to rounding errors.
std::string extname(const std::string &defaultname="") const
Return extension name.
CTA ARF effective area class definition.
double log10TeV(void) const
Return log10 of energy in TeV.
Random number generator class.
void init_members(void)
Initialise class members.
double MeV(void) const
Return energy in MeV.
Interface for the CTA region of interest class.
const std::string extname_cta_background2d
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
GIntegral class interface definition.
FITS file class interface definition.
void thetacut(const double &thetacut)
Set theta cut angle.
const GCaldb & caldb(void) const
Return calibration database.
void pointing(const GCTAPointing &pointing)
Set CTA pointing.
void init_members(void)
Initialise class members.
std::string strip_whitespace(const std::string &arg)
Strip leading and trailing whitespace from string.
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 GClassCode code(void) const =0
GCTABackground * m_background
Background.
void dir(const GSkyDir &dir)
Set sky direction.
void init_members(void)
Initialise class members.
CTA 2D point spread function class.
void eulery(const double &angle)
Set Euler rotation matrix around y axis.
virtual double theta_max(void) const =0
void scale(const double &scale)
Set effective area scaling factor.
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)
std::string centre(const std::string &s, const int &n, const char &c= ' ')
Centre string to achieve a length of n characters.
void id(const std::string &id)
Set observation identifier.
const std::string & instrument(void) const
Return instrument.
GCTAEdisp * m_edisp
Energy dispersion.
CTA performance table effective area class definition.
bool is_notanumber(const double &x)
Signal if argument is not a number.
double sum_of_scales(void) const
Returns sum of all model scales.
Class that handles photons.
CTA 2D background class definition.
bool is_infinite(const double &x)
Signal if argument is infinite.
virtual GCTAResponse & operator=(const GCTAResponse &rsp)
Assignment operator.
Definition of support function used by CTA classes.
bool m_apply_edisp
Apply energy dispersion.
double real(const std::string &keyname) const
Return card value as double precision.
const GCTAPsf * psf(void) const
Return pointer to point spread function.
double radius(void) const
Return shell radius.
CTA effective area base class definition.
double semiminor(void) const
Return semi-minor axis of ellipse.
const std::string extname_arf
double m_lo_safe_thres
Safe low energy threshold.
GFilename irf_filename(const std::string &filename) const
Return filename with appropriate extension.
Calibration database class.
CTA 2D effective area class.
const GSkyDir & dir(void) const
Return position of radial spatial model.
Energy boundaries container class.
const GXmlAttribute * attribute(const int &index) const
Return attribute.
virtual double irf(const GEvent &event, const GPhoton &photon, const GObservation &obs) const
Return value of instrument response function.
CTA performance table energy dispersion class.
virtual GEbounds ebounds(const GEnergy &obsEnergy) const
Return true energy boundaries for a specific observed energy.
const std::string & name(void) const
Return parameter name.
const GCTAAeff * aeff(void) const
Return pointer to effective area response.
void rotate_deg(const double &phi, const double &theta)
Rotate sky direction by zenith and azimuth angle.
const GEnergy & emin(void) const
Return minimum energy of all intervals.
const GCTAInstDir & centre(void) const
Returns region of interest centre.
XSPEC Auxiliary Response File class definition.
double trapzd(const double &a, const double &b, const int &n=1, double result=0.0)
Perform Trapezoidal integration.
void eulerz(const double &angle)
Set Euler rotation matrix around z axis.
CTA 2D effective area class definition.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
bool has_attribute(const std::string &name) const
Check if element has a given attribute.
CTA performance table energy dispersion class definition.
GCTAInstDir instdir(const GSkyDir &skydir) const
Get instrument direction from sky direction.
GXmlElement * xml_need_par(const std::string &origin, GXmlElement &xml, const std::string &name)
Return pointer to parameter with given name in XML element.
bool exists(void) const
Checks whether file exists.
Kernel for Nroi offest angle integration of diffuse model.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
double nirf(const GPhoton &photon, const GEnergy &obsEng, const GTime &obsTime, const GObservation &obs) const
Return spatial integral of Instrument Response Function.
Radial ring model class interface definition.
double uniform(void)
Returns random double precision floating value in range 0 to 1.
void free_members(void)
Delete class members.
CTA RMF energy dispersion class definition.
virtual double deadc(const GTime &time=GTime()) const =0
const GCTAEventList & cta_event_list(const std::string &origin, const GObservation &obs)
Retrieve CTA event list from generic observation.
double ra_deg(void) const
Returns Right Ascension in degrees.
bool m_use_nroi_cache
Control usage of nroi cache.
Abstract interface for FITS table.
void load_psf(const GFilename &filename)
Load CTA PSF vector.
virtual GCTAResponseIrf * clone(void) const
Clone instance.
const GTime & time(void) const
Return photon time.
const GTime & time(void) const
Return photon arrival time.
double resolution(const GModelSpatial *model)
Determine resolution of spatial model.
Abstract CTA energy dispersion base class definition.
virtual GCTAAeff * clone(void) const =0
Clones object.
const std::string extname_cta_aeff2d
CTA 3D background class definition.
GResponseCache m_nroi_cache
CTA 2D point spread function class definition.
bool is_fits(void) const
Checks whether file is a FITS file.
virtual double eval(const GTime &srcTime, const bool &gradients=false) const =0
const GCTAObservation & cta_obs(const std::string &origin, const GObservation &obs)
Retrieve CTA observation from generic observation.
Spatial composite model class interface definition.
CTA 2D energy dispersion class definition.
const GModelSpatial * model(void) const
Return spatial model component.
Abstract observation base class.
const GEnergy & energy(void) const
Return photon energy.
King profile CTA point spread function class definition.
virtual GCTABackground * clone(void) const =0
Clones object.
GCaldb m_caldb
Calibration database.
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 GFilename filename(void) const =0
bool has_scales(void) const
Signals that model has scales.
CTA region of interest class interface definition.
CTA observation class interface definition.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
double offset_sigma(void) const
Return offset angle dependence (degrees)
GModelPar & scale(const int &index)
Returns reference to scale parameter by index.
CTA point spread function base class definition.
void load_edisp(const GFilename &filename)
Load energy dispersion information.
void load(const std::string &rspname)
Load CTA response.
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
Calibration database class interface definition.
std::string gadf_hduclas4(const GFits &fits, const std::string &hduclas4)
Return extension name for GADF response table of given HDU class 4.
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.
Point source spatial model.
CTA performance table point spread function class definition.
bool xml_has_par(const GXmlElement &xml, const std::string &name)
Checks if parameter with given name in XML element exists.
CTA instrument response function class.
virtual ~GCTAResponseIrf(void)
Destructor.
CTA instrument response function class.
void free_members(void)
Delete class members.
std::string m_xml_rspname
Response name in XML file.
Abstract elliptical spatial model base class interface definition.
const double & azimuth(void) const
Return pointing azimuth angle.
double posang(const GSkyDir &dir, const std::string &coordsys="CEL") const
Compute position angle between sky directions in radians.
int components(void) const
Return number of model components.
const std::string extname_cta_edisp2d
int iter_phi(const double &rho, const double &resolution, const int &iter_min, const int &iter_max)
Determine number of azimuthal Romberg iterations.
CTA point spread function vector class definition.
Kernel for elliptical model zenith angle integration of IRF.
std::string m_rspname
Name of the instrument response.
double irf_radial(const GEvent &event, const GSource &source, const GObservation &obs) const
Return IRF value for radial source model.
Sky model class interface definition.
virtual void clear(void)
Clear instance.
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.
double posangle(void) const
Return Position Angle of model.
#define G_NROI_ELLIPTICAL
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.
std::string m_xml_caldb
Calibration database string in XML file.
GChatter reduce(const GChatter &chatter)
Reduce chattiness by one level.
GVector sin(const GVector &vector)
Computes sine of vector elements.
const GEnergy & energy(void) const
Return photon energy.
std::string print(const GChatter &chatter=NORMAL) const
Print calibration database information.
virtual GCTAPsf * clone(void) const =0
Clones object.
Exception handler interface definition.
CTA point spread function table class definition.
virtual double theta_max(void) const =0
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
void fixed_iter(const int &iter)
Set fixed number of iterations.
Kernel for radial model zenith angle integration of IRF.
std::string tolower(const std::string &s)
Convert string to lower case.
virtual void read(const GXmlElement &xml)
Read response from XML element.
double irf_ptsrc(const GEvent &event, const GSource &source, const GObservation &obs) const
Return value of point source instrument response function.
CTA performance table background class.
GModelSpatial * spatial(void) const
Return spatial model component.
CTA instrument direction class.
const GSkyDir & dir(void) const
Return pointing sky direction.
Abstract spatial model base class.
GResponseCache m_irf_cache
Abstract radial spatial model base class.
double radius(void) const
Return ring inner radius.
Generic matrix class definition.
CTA point spread function table class.
const GEnergy & emax(void) const
Return maximum energy of all intervals.
std::string filepath(const std::string &pathname, const std::string &filename)
Build file path from path name and file name.
CTA performance table point spread function class.
void copy_members(const GCTAResponseIrf &rsp)
Copy class members.
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.
GCTAEventAtom * mc(const double &area, const GPhoton &photon, const GObservation &obs, GRan &ran) const
Simulate event from photon.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Integration kernel for npsf() method.
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.
const GCTAEdisp * edisp(void) const
Return pointer to energy dispersion.
Class that handles gamma-ray sources.
void set(const std::string &name, const GEnergy &ereco, const GEnergy &etrue, const double &value)
Set cache value.
Integration class interface definition.
int iter_rho(const double &rho_max, const double &resolution, const int &iter_min, const int &iter_max)
Determine number of radial Romberg iterations.
void close(void)
Close FITS file.
double semimajor(void) const
Return semi-major axis of ellipse.
virtual std::string print(const GChatter &chatter=NORMAL) const
Print CTA response information.
const GSkyDir & dir(void) const
Return photon sky direction.
double irf_diffuse(const GEvent &event, const GSource &source, const GObservation &obs) const
Return value of diffuse source instrument response function.
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.
void clear(void)
Clear calibration database.
double scale(const int &index) const
Returns scale of spatial component.
std::string rootdir(void) const
Return path to CALDB root directory.
const GCTAInstDir & dir(void) const
Return instrument direction.
Filename class interface definition.
std::string print(const GChatter &chatter=NORMAL) const
Print response cache.
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.
void sigma(const double &sigma)
Set sigma for offset angle dependence.
Mathematical function definitions.
void sigma(const double &sigma)
Set sigma for offset angle dependence.
CTA ARF effective area class.
double todouble(const std::string &arg)
Convert string into double precision value.
Class that handles energies in a unit independent way.
GCTAPsf * m_psf
Point spread function.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
void sigma(const double &sigma)
Set sigma for offset angle dependence.
const std::string extname_rmf