43#define G_SET "GCTACubePsf::set(GCTAObservation&)"
44#define G_FILL "GCTACubePsf::fill(GObservations&, GLog*)"
45#define G_FILL_CUBE "GCTACubePsf::fill_cube(GCTAObservation&, GSkyMap*, "\
52#define G_QUADRATIC_BINNING
140 for (
int i = 0; i < ndbins; ++i) {
141 #if defined(G_QUADRATIC_BINNING)
142 double binsize = std::sqrt(dmax) / double(ndbins);
143 double delta = binsize * (double(i) + 0.5);
146 double binsize = dmax / double(ndbins);
147 double delta = binsize * (double(i) + 0.5);
195 const std::string& coords,
217 for (
int i = 0; i < ndbins; ++i) {
218 #if defined(G_QUADRATIC_BINNING)
219 double binsize = std::sqrt(dmax) / double(ndbins);
220 double delta = binsize * (double(i) + 0.5);
223 double binsize = dmax / double(ndbins);
224 double delta = binsize * (double(i) + 0.5);
378 #if defined(G_SMOOTH_PSF)
404 for (
int i = 0; i < obs.
size(); ++i) {
414 *
log << obs[i]->instrument();
415 *
log <<
" observation ";
416 *
log <<
"\"" << obs[i]->name() <<
"\"";
417 *
log <<
" (id=" << obs[i]->id() <<
")" << std::endl;
425 *
log <<
"Skipping binned ";
427 *
log <<
" observation ";
428 *
log <<
"\"" << cta->
name() <<
"\"";
429 *
log <<
" (id=" << cta->
id() <<
")" << std::endl;
440 for (
int pixel = 0; pixel <
m_cube.
npix(); ++pixel) {
442 if (exposure(pixel, iebin) > 0.0) {
443 double norm = 1.0 / exposure(pixel, iebin);
444 for (
int idelta = 0; idelta <
m_deltas.
size(); ++idelta) {
445 int imap =
offset(idelta, iebin);
450 for (
int idelta = 0; idelta <
m_deltas.
size(); ++idelta) {
451 int imap =
offset(idelta, iebin);
452 m_cube(pixel, imap) = 0.0;
459 #if defined(G_SMOOTH_PSF)
501 #if defined(G_SMOOTH_PSF)
523 if (fits.
size() > 0) {
525 hdu.
card(
"BUNIT",
"sr**(-1)",
"Unit of PSF cube");
552 #pragma omp critical(GCTACubePsf_load)
585 #pragma omp critical(GCTACubePsf_save)
625 result.append(
"=== GCTACubePsf ===");
647 result.append(
" - ");
649 result.append(
" deg");
652 result.append(
"not defined");
746 for (
int imap = 0; imap <
m_cube.
nmaps(); ++imap) {
749 for (
int pixel = 0; pixel <
m_cube.
npix(); ++pixel) {
752 m_cube(pixel, imap) = 0.0;
788 std::string msg =
"No RoI information found in "+obs.
instrument()+
789 " observation \""+obs.
name()+
"\". Run ctselect "
790 "to specify an RoI for this observation.";
801 std::string msg =
"No valid instrument response function found in "+
803 "\". Please specify the instrument response "
804 "function for this observation.";
811 *
log <<
"Skipping unbinned ";
813 *
log <<
" observation ";
814 *
log <<
"\"" << obs.
name() <<
"\"";
815 *
log <<
" (id=" << obs.
id() <<
") due to zero livetime";
823 *
log <<
"Skipping unbinned ";
825 *
log <<
" observation ";
826 *
log <<
"\"" << obs.
name() <<
"\"";
827 *
log <<
" (id=" << obs.
id() <<
") since it does not overlap ";
828 *
log <<
"with the point spread function cube.";
838 *
log <<
"Including ";
840 *
log <<
" observation \"" << obs.
name();
841 *
log <<
"\" (id=" << obs.
id() <<
")";
842 *
log <<
" in point spread function cube computation." << std::endl;
846 for (
int pixel = 0; pixel <
m_cube.
npix(); ++pixel) {
858 double theta = pnt.
dist(dir);
871 if (exposure != NULL) {
872 weight = rsp->
aeff(theta, 0.0, 0.0, 0.0, logE) *
874 (*exposure)(pixel, iebin) += weight;
878 for (
int idelta = 0; idelta <
m_deltas.
size(); ++idelta) {
884 int imap =
offset(idelta, iebin);
888 rsp->
psf(delta, theta, 0.0, 0.0, 0.0, logE) * weight;
971 for (
int i = 0; i < ndbins; ++i) {
972 double delta = binsize * (double(i) + 0.5);
1019 for (
int i = 0; i < bins; ++i) {
1044 int isrc =
offset(1, iebin);
1045 int idst =
offset(0, iebin);
1046 for (
int pixel = 0; pixel <
m_cube.
npix(); ++pixel) {
1056 int imap =
offset(idelta, iebin);
1057 for (
int pixel = 0; pixel <
m_cube.
npix(); ++pixel) {
1058 m_cube(pixel, imap) = 0.0;
CTA cube analysis point spread function class definition.
CTA event bin container class interface definition.
CTA event list class interface definition.
CTA observation class interface definition.
CTA instrument response function class definition.
Information logger class definition.
Mathematical function definitions.
Observations container class interface definition.
Circular sky region class interface definition.
double norm(const GVector &vector)
Computes vector norm.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
CTA point spread function for cube analysis.
int m_inx2
Index of lower left node.
GNodeArray m_deltas
Delta bins (deg) for the PSF cube.
void read(const GFits &fits)
Read PSF cube from FITS object.
void set(const GCTAObservation &obs)
Set PSF cube from one CTA observation.
int offset(const int &idelta, const int &iebin) const
Return map offset.
void write(GFits &file) const
Write CTA PSF cube into FITS object.
int m_inx1
Index of upper left node.
GCTACubePsf * clone(void) const
Clone instance.
double m_wgt1
Weight of upper left node.
bool m_quadratic_binning
Internal binning is linear.
GEnergies m_energies
Energy values for the PSF cube.
void fill(const GObservations &obs, GLog *log=NULL)
Fill PSF cube from observation container.
std::string print(const GChatter &chatter=NORMAL) const
Print PSF cube information.
void save(const GFilename &filename, const bool &clobber=false) const
Save PSF cube into FITS file.
double m_wgt3
Weight of upper right node.
int m_inx4
Index of lower right node.
void update(const double &delta, const double &logE) const
Update PSF parameter cache.
void fill_cube(const GCTAObservation &obs, GSkyMap *exposure=NULL, GLog *log=NULL)
Fill PSF cube for one observation.
void load(const GFilename &filename)
Load PSF cube from FITS file.
void set_delta_axis(void)
Set nodes for delta axis in radians.
void copy_members(const GCTACubePsf &cube)
Copy class members.
void init_members(void)
Initialise class members.
int m_inx3
Index of upper right node.
GFilename m_filename
Filename.
void clear_cube(void)
Clear all pixels in the PSF cube.
GCTACubePsf & operator=(const GCTACubePsf &cube)
Assignment operator.
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
void free_members(void)
Delete class members.
const GFilename & filename(void) const
Return exposure cube filename.
GNodeArray m_elogmeans
Mean log10TeV energy for the PSF cube.
double operator()(const GSkyDir &dir, const double &delta, const GEnergy &energy) const
Return point spread function (in units of sr )
virtual ~GCTACubePsf(void)
Destructor.
double m_wgt2
Weight of lower left node.
GNodeArray m_deltas_cache
Internal delta bins (rad)
void set_to_smooth(void)
Pad the last delta bins with zero.
GCTACubePsf(void)
Void constructor.
void clear(void)
Clear instance.
const GSkyMap & cube(void) const
Return psf cube sky map.
double m_wgt4
Weight of lower right node.
const GEnergies & energies(void) const
Return energies.
CTA event bin container class.
void dir(const GSkyDir &dir)
Set sky direction.
void pointing(const GCTAPointing &pointing)
Set CTA pointing.
virtual double livetime(void) const
Return livetime.
std::string eventtype(void) const
Return event type string.
virtual std::string instrument(void) const
Return instrument name.
GCTARoi roi(void) const
Get Region of Interest.
GEbounds ebounds(void) const
Get energy boundaries.
virtual void response(const GResponse &rsp)
Set response function.
CTA instrument response function class.
const GCTAAeff * aeff(void) const
Return pointer to effective area response.
const GCTAPsf * psf(void) const
Return pointer to point spread function.
Interface for the CTA region of interest class.
const double & radius(void) const
Returns radius of region of interest in degrees.
bool is_valid(void) const
Checks if RoI is valid.
const GCTAInstDir & centre(void) const
Returns region of interest centre.
Energy boundaries container class.
std::string print(const GChatter &chatter=NORMAL) const
Print energy container information.
void read(const GFitsTable &table)
Read energies from FITS table.
void clear(void)
Clear energy container.
int size(void) const
Return number of energies in container.
void set(const GEbounds &ebounds)
Set energies from energy boundaries.
void write(GFits &file, const std::string &extname=gammalib::extname_energies) const
Write energies into FITS object.
Class that handles energies in a unit independent way.
double log10TeV(void) const
Return log10 of energy in TeV.
void clear(void)
Clear file name.
Abstract FITS extension base class.
GFitsHeaderCard & card(const int &cardno)
Return header card.
Abstract FITS image base class.
Abstract interface for FITS table.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
int size(void) const
Return number of HDUs in FITS file.
GFitsImage * image(const int &extno)
Get pointer to image HDU.
void close(void)
Close FITS file.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
Information logger interface definition.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
const int & inx_right(void) const
Returns right node index.
const int & inx_left(void) const
Returns left node index.
const double & wgt_right(void) const
Returns right node weight.
const double & wgt_left(void) const
Returns left node weight.
void clear(void)
Clear node array.
int size(void) const
Return number of nodes in node array.
void write(GFits &fits, const std::string &extname="NODES") const
Write nodes into FITS object.
void append(const double &node)
Append one node to array.
void read(const GFitsTable &table)
Read nodes from FITS table.
void name(const std::string &name)
Set observation name.
void id(const std::string &id)
Set observation identifier.
Observation container class.
int size(void) const
Return number of observations in container.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
const int & nmaps(void) const
Returns number of maps.
void clear(void)
Clear instance.
GSkyDir inx2dir(const int &index) const
Returns sky direction of pixel.
void read(const GFitsHDU &hdu)
Read skymap from FITS HDU.
const int & npix(void) const
Returns number of pixels.
GNdarray counts(void) const
Returns array with total number of counts for count maps.
GFitsHDU * write(GFits &file, const std::string &extname="") const
Write sky map into FITS file.
const std::vector< int > & shape(void) const
Returns shape of maps.
bool overlaps(const GSkyRegion ®ion) const
Checks whether a region overlaps with this map.
std::string print(const GChatter &chatter=NORMAL) const
Print sky map.
Interface for the circular sky region class.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
const std::string extname_deltas
const std::string extname_energies