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)
580 GFits fits(filename);
609 #pragma omp critical(GCTACubeEdisp_save)
619 fits.
saveto(filename, clobber);
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);
985 m_cube(pixel, imap) += rsp->edisp(Eobs,
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) {
1149 migra_max =
m_migras[imap - mapmin];
1161 if (minFound && maxFound && migra_min > 0.0 && migra_max > 0.0 &&
1162 migra_max > migra_min) {
const GFilename & filename(void) const
Return edisp cube filename.
std::string print(const GChatter &chatter=NORMAL) const
Print energy container information.
int offset(const int &imigra, const int &iebin) const
Return map offset.
int size(void) const
Return number of nodes in node array.
void clear(void)
Clear energy container.
std::string print(const GChatter &chatter=NORMAL) const
Print energy dispersion cube information.
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.
bool contains(const int &extno) const
Check if HDU exists in FITS file.
double norm(const GVector &vector)
Computes vector norm.
void write(GFits &file, const std::string &extname=gammalib::extname_energies) const
Write energies into FITS object.
std::vector< GEbounds > m_ebounds
Energy boundaries.
GFilename m_filename
Filename.
void copy_members(const GCTACubeEdisp &cube)
Copy class members.
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.
GEbounds ebounds(void) const
Get energy boundaries.
int m_inx3
Index of upper right node.
void free_members(void)
Delete class members.
CTA instrument response function class definition.
const double & radius(void) const
Returns radius of region of interest in degrees.
virtual ~GCTACubeEdisp(void)
Destructor.
const double & wgt_left(void) const
Returns left node weight.
int m_inx1
Index of upper left node.
Abstract base class for the CTA energy dispersion.
void write(GFits &file) const
Write energy dispersion cube into FITS file.
virtual void response(const GResponse &rsp)
Set response function.
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.
void fill(const GObservations &obs, GLog *log=NULL)
Fill energy dispersion cube from observation container.
void init_members(void)
Initialise class members.
const GEnergies & energies(void) const
Return energies for energy dispersion cub.
Interface for the CTA region of interest class.
void load(const GFilename &filename)
Load energy dispersion cube from FITS file.
FITS file class interface definition.
Interface for the circular sky region class.
GSkyMap m_cube
Energy dispersion cube.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
void pointing(const GCTAPointing &pointing)
Set CTA pointing.
GNodeArray m_migras
Migra bins for the Edisp cube.
void read(const GFits &fits)
Read energy dispersion cube from FITS file.
int m_inx4
Index of lower right 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.
void id(const std::string &id)
Set observation identifier.
Abstract FITS image base class definition.
const std::string extname_cta_migras
double migra_max(void) const
Return maximum migra value.
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.
GCTACubeEdisp(void)
Void constructor.
Information logger interface definition.
CTA event bin container class.
virtual double livetime(void) const
Return livetime.
double m_wgt4
Weight of lower right node.
const double & wgt_right(void) const
Returns right node weight.
Energy boundaries container class.
void remove(const int &extno)
Remove HDU from FITS file.
GEbounds ebounds(const GEnergy &obsEng) const
Return boundaries in true energy.
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 clear_cube(void)
Clear all pixels in the energy dispersion cube.
GFitsHDU * write(GFits &file, const std::string &extname="") const
Write sky map into FITS file.
const GCTAInstDir & centre(void) const
Returns region of interest centre.
void set(const GCTAObservation &obs)
Set energy dispersion cube for one CTA observation.
int size(void) const
Return number of energies in container.
virtual std::string instrument(void) const
Return instrument name.
double m_wgt3
Weight of upper right node.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
GEnergies m_energies
True energy values of cube.
Abstract interface for FITS table.
CTA energy dispersion for stacked analysis.
const int & inx_left(void) const
Returns left node index.
void clear(void)
Clear instance.
void set_migras(const double &mmax, const int &nmbins)
Set nodes for interpolation in migration.
GCTACubeEdisp & operator=(const GCTACubeEdisp &cube)
Assignment operator.
double m_wgt1
Weight of upper left node.
int size(void) const
Return number of observations in container.
void compute_ebounds(void) const
Compute true energy boundary vector.
CTA observation class interface definition.
Observation container class.
double operator()(const GEnergy &ereco, const GEnergy &etrue, const GSkyDir &dir) const
Return energy dispersion in units of MeV .
CTA instrument response function class.
const int & inx_right(void) const
Returns right node index.
void update(const GEnergy &ereco, const GEnergy &etrue) const
Update energy dispersion cube indices and weights cache.
bool is_empty(void) const
Signals if there are no energies in container.
const std::string extname_energies
void set(const GEbounds &ebounds)
Set energies from energy boundaries.
void name(const std::string &name)
Set observation name.
GFitsImage * image(const int &extno)
Get pointer to image HDU.
Information logger class definition.
void clear(void)
Clear file name.
GCTACubeEdisp * clone(void) const
Clone energy dispersion cube.
GNodeArray m_elogmeans
Mean log10TeV energy for the Edisp cube.
int size(void) const
Return number of HDUs in FITS file.
CTA event bin container class interface definition.
void set_eng_axis(void)
Set nodes for interpolation in true energy.
std::string eventtype(void) const
Return event type string.
bool is_valid(void) const
Checks if RoI is valid.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
double m_wgt2
Weight of lower left node.
void read(const GFitsTable &table)
Read nodes from FITS table.
int m_inx2
Index of lower left node.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
void clear(void)
Clear energy dispersion cube.
void append(const double &node)
Append one node to array.
const int & npix(void) const
Returns number of pixels.
void fill_cube(const GCTAObservation &obs, GSkyMap *exposure=NULL, GLog *log=NULL)
Fill energy dispersion cube from observation container.
GFitsHeaderCard & card(const int &cardno)
Return header card.
Observations container class interface definition.
void close(void)
Close FITS file.
Circular sky region class interface definition.
void save(const GFilename &filename, const bool &clobber=false) const
Save energy dispersion cube into FITS file.
void clear(void)
Clear instance.
CTA cube analysis energy disperson class definition.
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.
FITS table abstract base class interface definition.