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)
556 GFits fits(filename);
585 #pragma omp critical(GCTACubePsf_save)
595 fits.
saveto(filename, clobber);
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;
void save(const GFilename &filename, const bool &clobber=false) const
Save PSF cube into FITS file.
std::string print(const GChatter &chatter=NORMAL) const
Print energy container information.
const GEnergies & energies(void) const
Return energies.
int size(void) const
Return number of nodes in node array.
void clear(void)
Clear energy container.
Abstract FITS image base class.
CTA event list class interface definition.
void read(const GFitsTable &table)
Read energies from FITS table.
GFitsTable * table(const int &extno)
Get pointer to table HDU.
double norm(const GVector &vector)
Computes vector norm.
GNodeArray m_deltas
Delta bins (deg) for the PSF cube.
void update(const double &delta, const double &logE) const
Update PSF parameter cache.
void write(GFits &file, const std::string &extname=gammalib::extname_energies) const
Write energies into FITS object.
CTA cube analysis point spread function class definition.
void load(const GFilename &filename)
Load PSF cube from FITS file.
void clear(void)
Clear instance.
GVector abs(const GVector &vector)
Computes absolute of vector elements.
void ebounds(const GEbounds &ebounds)
Set energy boundaries.
Abstract FITS extension base class.
bool overlaps(const GSkyRegion ®ion) const
Checks whether a region overlaps with this map.
GCTACubePsf & operator=(const GCTACubePsf &cube)
Assignment operator.
GEbounds ebounds(void) const
Get energy boundaries.
void free_members(void)
Delete class members.
void write(GFits &file) const
Write CTA PSF cube into FITS object.
CTA instrument response function class definition.
const double & radius(void) const
Returns radius of region of interest in degrees.
const double & wgt_left(void) const
Returns left node weight.
GNodeArray m_deltas_cache
Internal delta bins (rad)
virtual void response(const GResponse &rsp)
Set response function.
const std::string extname_deltas
void clear(void)
Clear node array.
void counts(const GSkyMap &counts)
Set event cube counts from sky map.
double log10TeV(void) const
Return log10 of energy in TeV.
Interface for the CTA region of interest class.
Interface for the circular sky region class.
GFilename m_filename
Filename.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
void pointing(const GCTAPointing &pointing)
Set CTA pointing.
int m_inx1
Index of upper left node.
void read(const GFitsHDU &hdu)
Read skymap from FITS HDU.
const std::vector< int > & shape(void) const
Returns shape of maps.
void dir(const GSkyDir &dir)
Set sky direction.
double m_wgt4
Weight of lower right node.
void id(const std::string &id)
Set observation identifier.
void write(GFits &fits, const std::string &extname="NODES") const
Write nodes into FITS object.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
std::string print(const GChatter &chatter=NORMAL) const
Print sky map.
void fill(const GObservations &obs, GLog *log=NULL)
Fill PSF cube from observation container.
Information logger interface definition.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
CTA event bin container class.
virtual double livetime(void) const
Return livetime.
double operator()(const GSkyDir &dir, const double &delta, const GEnergy &energy) const
Return point spread function (in units of sr )
const double & wgt_right(void) const
Returns right node weight.
Energy boundaries container class.
const int & nmaps(void) const
Returns number of maps.
GSkyDir inx2dir(const int &index) const
Returns sky direction of pixel.
GCTARoi roi(void) const
Get Region of Interest.
void init_members(void)
Initialise class members.
GFitsHDU * write(GFits &file, const std::string &extname="") const
Write sky map into FITS file.
double m_wgt3
Weight of upper right node.
const GCTAInstDir & centre(void) const
Returns region of interest centre.
GCTACubePsf * clone(void) const
Clone instance.
int m_inx3
Index of upper right node.
int size(void) const
Return number of energies in container.
virtual std::string instrument(void) const
Return instrument name.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
void read(const GFits &fits)
Read PSF cube from FITS object.
int m_inx2
Index of lower left node.
Abstract interface for FITS table.
void set_eng_axis(void)
Set nodes for a logarithmic (base 10) energy axis.
const int & inx_left(void) const
Returns left node index.
void clear(void)
Clear instance.
int size(void) const
Return number of observations in container.
CTA observation class interface definition.
Observation container class.
CTA instrument response function class.
const int & inx_right(void) const
Returns right node index.
GCTACubePsf(void)
Void constructor.
const std::string extname_energies
void set(const GEbounds &ebounds)
Set energies from energy boundaries.
void set_delta_axis(void)
Set nodes for delta axis in radians.
void name(const std::string &name)
Set observation name.
void set(const GCTAObservation &obs)
Set PSF cube from one CTA observation.
GFitsImage * image(const int &extno)
Get pointer to image HDU.
GEnergies m_energies
Energy values for the PSF cube.
void clear_cube(void)
Clear all pixels in the PSF cube.
Information logger class definition.
void clear(void)
Clear file name.
CTA point spread function for cube analysis.
int m_inx4
Index of lower right node.
std::string print(const GChatter &chatter=NORMAL) const
Print PSF cube information.
int size(void) const
Return number of HDUs in FITS file.
CTA event bin container class interface definition.
std::string eventtype(void) const
Return event type string.
bool is_valid(void) const
Checks if RoI is valid.
void fill_cube(const GCTAObservation &obs, GSkyMap *exposure=NULL, GLog *log=NULL)
Fill PSF cube for one observation.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
GNodeArray m_elogmeans
Mean log10TeV energy for the PSF cube.
void read(const GFitsTable &table)
Read nodes from FITS table.
void set_to_smooth(void)
Pad the last delta bins with zero.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void append(const double &node)
Append one node to array.
const int & npix(void) const
Returns number of pixels.
virtual ~GCTACubePsf(void)
Destructor.
const GFilename & filename(void) const
Return exposure cube filename.
GFitsHeaderCard & card(const int &cardno)
Return header card.
Observations container class interface definition.
void close(void)
Close FITS file.
int offset(const int &idelta, const int &iebin) const
Return map offset.
Circular sky region class interface definition.
bool m_quadratic_binning
Internal binning is linear.
double m_wgt2
Weight of lower left node.
void copy_members(const GCTACubePsf &cube)
Copy class members.
double m_wgt1
Weight of upper left node.
Mathematical function definitions.
Class that handles energies in a unit independent way.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.