46#define G_CONSTRUCTOR1 "GCTACubeEdisp(GCTAEventCube&, double&, int&)"
47#define G_CONSTRUCTOR2 "GCTACubeEdisp(std::string&, std::string&, double&, "\
48 "double&, double&, double&, int&, int&, GEbounds&, "\
50#define G_EBOUNDS "GCTACubeEdisp::ebounds(GEnergy&)"
51#define G_FILL_CUBE "GCTACubeEdisp::fill_cube(GCTAObservation&, GSkyMap*, "\
146 std::string msg =
"Number "+
gammalib::str(nmbins)+
" of migration "
147 "bins is smaller than 2. Please request at least "
152 std::string msg =
"Maximum migration "+
gammalib::str(mmax)+
" is not "
153 "positive. Please specify a positive maximum "
213 const std::string& coords,
227 std::string msg =
"Number "+
gammalib::str(nmbins)+
" of migration "
228 "bins is smaller than 2. Please request at least "
233 std::string msg =
"Maximum migration "+
gammalib::str(mmax)+
" is not "
234 "positive. Please specify a positive maximum "
423 for (
int i = 0; i < obs.
size(); ++i) {
433 *
log << obs[i]->instrument();
434 *
log <<
" observation ";
435 *
log <<
"\"" << obs[i]->name() <<
"\"";
436 *
log <<
" (id=" << obs[i]->id() <<
")" << std::endl;
444 *
log <<
"Skipping binned ";
446 *
log <<
" observation ";
447 *
log <<
"\"" << cta->
name() <<
"\"";
448 *
log <<
" (id=" << cta->
id() <<
")" << std::endl;
459 for (
int pixel = 0; pixel <
m_cube.
npix(); ++pixel) {
461 if (exposure(pixel, iebin) > 0.0) {
462 double norm = 1.0 / exposure(pixel, iebin);
463 for (
int imigra = 0; imigra <
m_migras.
size(); ++imigra) {
464 int imap =
offset(imigra, iebin);
469 for (
int imigra = 0; imigra <
m_migras.
size(); ++imigra) {
470 int imap =
offset(imigra, iebin);
471 m_cube(pixel, imap) = 0.0;
549 if (fits.
size() > 0) {
551 hdu.
card(
"BUNIT",
"MeV**(-1)",
"Unit of energy dispersion cube");
576 #pragma omp critical(GCTACubeEdisp_load)
609 #pragma omp critical(GCTACubeEdisp_save)
650 std::string msg =
"No energies defined for energy dispersion cube. "
651 "Please define the energies before calling the "
698 result.append(
"=== GCTACubeEdisp ===");
720 result.append(
" - ");
724 result.append(
"not defined");
816 for (
int imap = 0; imap <
m_cube.
nmaps(); ++imap) {
819 for (
int pixel = 0; pixel <
m_cube.
npix(); ++pixel) {
822 m_cube(pixel, imap) = 0.0;
867 std::string msg =
"No RoI information found in "+obs.
instrument()+
868 " observation \""+obs.
name()+
"\". Run ctselect "
869 "to specify an RoI for this observation.";
880 std::string msg =
"No valid instrument response function found in "+
882 "\". Please specify the instrument response "
883 "function for this observation.";
890 std::string msg =
"No energy dispersion rcomponent found in the "
891 "the instrument response of "+
893 "\". Please provide an instrument response that "
894 "comprises an energy dispersion component.";
901 *
log <<
"Skipping unbinned ";
903 *
log <<
" observation ";
904 *
log <<
"\"" << obs.
name() <<
"\"";
905 *
log <<
" (id=" << obs.
id() <<
") due to zero livetime";
913 *
log <<
"Skipping unbinned ";
915 *
log <<
" observation ";
916 *
log <<
"\"" << obs.
name() <<
"\"";
917 *
log <<
" (id=" << obs.
id() <<
") since it does not overlap ";
918 *
log <<
"with the energy dispersion cube.";
928 *
log <<
"Including ";
930 *
log <<
" observation \"" << obs.
name();
931 *
log <<
"\" (id=" << obs.
id() <<
")";
932 *
log <<
" in energy dispersion cube computation." << std::endl;
936 for (
int pixel = 0; pixel <
m_cube.
npix(); ++pixel) {
948 double theta = pnt.
dist(dir);
954 double logEsrc =
m_energies[iebin].log10TeV();
961 if (exposure != NULL) {
962 weight = rsp->
aeff(theta, 0.0, 0.0, 0.0, logEsrc) *
964 (*exposure)(pixel, iebin) += weight;
968 for (
int imigra = 0; imigra <
m_migras.
size(); ++imigra) {
982 int imap =
offset(imigra, iebin);
1021 double migra = ereco/etrue;
1076 double binsize = mmax / double(nmbins);
1077 for (
int i = 0; i < nmbins; ++i) {
1078 double migra = binsize * double(i+1);
1104 double migra_min = 0.0;
1106 bool minFound =
false;
1107 bool maxFound =
false;
1114 for (
int imap = mapmin; imap < mapmax; ++imap) {
1118 for (
int pixel = 0; pixel <
m_cube.
npix(); ++pixel) {
1119 double value =
m_cube(pixel, imap);
1120 if (value > edisp) {
1128 migra_min =
m_migras[imap - mapmin];
1135 for (
int imap = mapmax-1; imap >= mapmin; --imap) {
1139 for (
int pixel = 0; pixel <
m_cube.
npix(); ++pixel) {
1140 double value =
m_cube(pixel, imap);
1141 if (value > edisp) {
1161 if (minFound && maxFound && migra_min > 0.0 &&
migra_max > 0.0 &&
CTA cube analysis energy disperson 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.
Abstract FITS image base class definition.
FITS table abstract base class interface definition.
FITS file class interface 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 energy dispersion for stacked analysis.
void write(GFits &file) const
Write energy dispersion cube into FITS file.
void free_members(void)
Delete class members.
void clear_cube(void)
Clear all pixels in the energy dispersion cube.
void init_members(void)
Initialise class members.
int m_inx3
Index of upper right node.
void update(const GEnergy &ereco, const GEnergy &etrue) const
Update energy dispersion cube indices and weights cache.
GCTACubeEdisp & operator=(const GCTACubeEdisp &cube)
Assignment operator.
double m_wgt3
Weight of upper right node.
virtual ~GCTACubeEdisp(void)
Destructor.
std::string print(const GChatter &chatter=NORMAL) const
Print energy dispersion cube information.
GNodeArray m_migras
Migra bins for the Edisp cube.
void set(const GCTAObservation &obs)
Set energy dispersion cube for one CTA observation.
void read(const GFits &fits)
Read energy dispersion cube from FITS file.
const GFilename & filename(void) const
Return edisp cube filename.
GCTACubeEdisp * clone(void) const
Clone energy dispersion cube.
void set_migras(const double &mmax, const int &nmbins)
Set nodes for interpolation in migration.
double m_wgt2
Weight of lower left node.
void set_eng_axis(void)
Set nodes for interpolation in true energy.
void fill(const GObservations &obs, GLog *log=NULL)
Fill energy dispersion cube from observation container.
void clear(void)
Clear energy dispersion cube.
std::vector< GEbounds > m_ebounds
Energy boundaries.
void copy_members(const GCTACubeEdisp &cube)
Copy class members.
GEbounds ebounds(const GEnergy &obsEng) const
Return boundaries in true energy.
int m_inx1
Index of upper left node.
void fill_cube(const GCTAObservation &obs, GSkyMap *exposure=NULL, GLog *log=NULL)
Fill energy dispersion cube from observation container.
double migra_max(void) const
Return maximum migra value.
int offset(const int &imigra, const int &iebin) const
Return map offset.
int m_inx4
Index of lower right node.
double m_wgt1
Weight of upper left node.
GNodeArray m_elogmeans
Mean log10TeV energy for the Edisp cube.
void compute_ebounds(void) const
Compute true energy boundary vector.
double m_wgt4
Weight of lower right node.
void save(const GFilename &filename, const bool &clobber=false) const
Save energy dispersion cube into FITS file.
double operator()(const GEnergy &ereco, const GEnergy &etrue, const GSkyDir &dir) const
Return energy dispersion in units of MeV .
GSkyMap m_cube
Energy dispersion cube.
void load(const GFilename &filename)
Load energy dispersion cube from FITS file.
int m_inx2
Index of lower left node.
const GSkyMap & cube(void) const
Return energy dispersion cube sky map.
GCTACubeEdisp(void)
Void constructor.
const GEnergies & energies(void) const
Return energies for energy dispersion cub.
GFilename m_filename
Filename.
GEnergies m_energies
True energy values of cube.
Abstract base class for the CTA energy dispersion.
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 GCTAEdisp * edisp(void) const
Return pointer to energy dispersion.
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.
bool is_empty(void) const
Signals if there are no energies in container.
Class that handles energies in a unit independent way.
double log10TeV(void) const
Return log10 of energy in TeV.
void clear(void)
Clear instance.
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.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
GFitsImage * image(const int &extno)
Get pointer to image HDU.
void close(void)
Close FITS file.
void remove(const int &extno)
Remove HDU from 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_cta_migras
const std::string extname_energies