GammaLib  2.0.0.dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GCTAAeff2D.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GCTAAeff2D.cpp - CTA 2D effective area class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2012-2018 by Juergen Knoedlseder *
5  * ----------------------------------------------------------------------- *
6  * *
7  * This program is free software: you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation, either version 3 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This program is distributed in the hope that it will be useful, *
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15  * GNU General Public License for more details. *
16  * *
17  * You should have received a copy of the GNU General Public License *
18  * along with this program. If not, see <http://www.gnu.org/licenses/>. *
19  * *
20  ***************************************************************************/
21 /**
22  * @file GCTAAeff2D.hpp
23  * @brief CTA 2D effective area class implementation
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GTools.hpp"
32 #include "GMath.hpp"
33 #include "GException.hpp"
34 #include "GFilename.hpp"
35 #include "GFits.hpp"
36 #include "GFitsBinTable.hpp"
37 #include "GFitsTable.hpp"
38 #include "GCTAAeff2D.hpp"
39 #include "GCTASupport.hpp"
40 
41 /* __ Method name definitions ____________________________________________ */
42 #define G_READ "GCTAAeff2D::read(GFitsTable&)"
43 
44 /* __ Macros _____________________________________________________________ */
45 
46 /* __ Coding definitions _________________________________________________ */
47 
48 /* __ Debug definitions __________________________________________________ */
49 
50 /* __ Constants __________________________________________________________ */
51 
52 
53 /*==========================================================================
54  = =
55  = Constructors/destructors =
56  = =
57  ==========================================================================*/
58 
59 /***********************************************************************//**
60  * @brief Void constructor
61  *
62  * Constructs empty effective area.
63  ***************************************************************************/
65 {
66  // Initialise class members
67  init_members();
68 
69  // Return
70  return;
71 }
72 
73 
74 /***********************************************************************//**
75  * @brief File constructor
76  *
77  * @param[in] filename FITS file name.
78  *
79  * Constructs effective area from a FITS file.
80  ***************************************************************************/
82 {
83  // Initialise class members
84  init_members();
85 
86  // Load effective area from file
87  load(filename);
88 
89  // Return
90  return;
91 }
92 
93 
94 /***********************************************************************//**
95  * @brief Copy constructor
96  *
97  * @param[in] aeff Effective area.
98  *
99  * Constructs effective area by copying from another effective area.
100  ***************************************************************************/
102 {
103  // Initialise class members
104  init_members();
105 
106  // Copy members
107  copy_members(aeff);
108 
109  // Return
110  return;
111 }
112 
113 
114 /***********************************************************************//**
115  * @brief Destructor
116  *
117  * Destructs effective area.
118  ***************************************************************************/
120 {
121  // Free members
122  free_members();
123 
124  // Return
125  return;
126 }
127 
128 
129 /*==========================================================================
130  = =
131  = Operators =
132  = =
133  ==========================================================================*/
134 
135 /***********************************************************************//**
136  * @brief Assignment operator
137  *
138  * @param[in] aeff Effective area.
139  * @return Effective area.
140  *
141  * Assigns effective area.
142  ***************************************************************************/
144 {
145  // Execute only if object is not identical
146  if (this != &aeff) {
147 
148  // Copy base class members
149  this->GCTAAeff::operator=(aeff);
150 
151  // Free members
152  free_members();
153 
154  // Initialise private members
155  init_members();
156 
157  // Copy members
158  copy_members(aeff);
159 
160  } // endif: object was not identical
161 
162  // Return this object
163  return *this;
164 }
165 
166 
167 /***********************************************************************//**
168  * @brief Return effective area in units of cm2
169  *
170  * @param[in] logE Log10 of the true photon energy (TeV).
171  * @param[in] theta Offset angle in camera system (rad) (default: 0.0).
172  * @param[in] phi Azimuth angle in camera system (rad).
173  * @param[in] zenith Zenith angle in Earth system (rad).
174  * @param[in] azimuth Azimuth angle in Earth system (rad).
175  * @param[in] etrue Use true energy?
176  * @return Effective area in cm2.
177  *
178  * Returns the effective area in units of cm2 for a given energy and
179  * offset angle. The effective area is bi-linearly interpolated in the
180  * log10(energy) - offset angle plane. The method assures that the effective
181  * area value never becomes negative. Outside the logE - theta range covered
182  * by the response table the effective area will be set to zero.
183  *
184  * The method supports true and reconstructed energies for logE. To access
185  * the effective area as function of true energy, specify etrue=true
186  * (this is the default). The obtained the effective area as function of
187  * reconstructed energy, specify etrue=false.
188  ***************************************************************************/
189 double GCTAAeff2D::operator()(const double& logE,
190  const double& theta,
191  const double& phi,
192  const double& zenith,
193  const double& azimuth,
194  const bool& etrue) const
195 {
196  // Initialise effective area
197  double aeff = 0.0;
198 
199  // Continue only if logE and theta are in validity range
200  if ((logE >= m_logE_min) && (logE <= m_logE_max) &&
201  (theta >= m_theta_min) && (theta <= m_theta_max)) {
202 
203  // Set parameter index
204  int index = (etrue) ? m_inx_aeff : m_inx_aeff_reco;
205 
206  // Get effective area value in cm2
207  aeff = (m_inx_energy == 0) ? m_aeff(index, logE, theta) :
208  m_aeff(index, theta, logE);
209 
210  // Make sure that effective area is not negative
211  if (aeff < 0.0) {
212  aeff = 0.0;
213  }
214 
215  } // endif: logE and theta in validity range
216 
217  // Return effective area value
218  return aeff;
219 }
220 
221 
222 /*==========================================================================
223  = =
224  = Public methods =
225  = =
226  ==========================================================================*/
227 
228 /***********************************************************************//**
229  * @brief Clear effective area.
230  *
231  * Clears effective area.
232  ***************************************************************************/
234 {
235  // Free class members
236  free_members();
237  this->GCTAAeff::free_members();
238 
239  // Initialise members
240  this->GCTAAeff::init_members();
241  init_members();
242 
243  // Return
244  return;
245 }
246 
247 
248 /***********************************************************************//**
249  * @brief Clone effective area
250  *
251  * @return Deep copy of effective area.
252  *
253  * Returns a pointer to a deep copy of the effective area.
254  ***************************************************************************/
256 {
257  return new GCTAAeff2D(*this);
258 }
259 
260 
261 /***********************************************************************//**
262  * @brief Read effective area from FITS table
263  *
264  * @param[in] table FITS table.
265  *
266  * @exception GException::invalid_value
267  * Response table is not two-dimensional.
268  *
269  * Reads the effective area form the FITS @p table. The following column
270  * names are mandatory:
271  *
272  * ENERG_LO - Energy lower bin boundaries
273  * ENERG_HI - Energy upper bin boundaries
274  * THETA_LO - Offset angle lower bin boundaries
275  * THETA_HI - Offset angle upper bin boundaries
276  * EFFAREA - Effective area
277  *
278  * In addition, the following column names are optional:
279  *
280  * EFFAREA_RECO - Effective area as function of reconstructed energy
281  *
282  * The data are stored in the m_aeff member. The energy axis will be set to
283  * log10, the offset angle axis to radians.
284  *
285  * @todo Analyse the unit of the parameter axis to determine the conversion
286  * factor for the effective areas. For the moment they are hard wired.
287  ***************************************************************************/
288 void GCTAAeff2D::read(const GFitsTable& table)
289 {
290  // Clear response table
291  m_aeff.clear();
292 
293  // Read effective area table
294  m_aeff.read(table);
295 
296  // Throw an exception if the table is not two-dimensional
297  if (m_aeff.axes() != 2) {
298  std::string msg = "Expected two-dimensional effective area response "
299  "table but found "+gammalib::str(m_aeff.axes())+
300  " dimensions. Please specify a two-dimensional "
301  "effective area.";
302  throw GException::invalid_value(G_READ, msg);
303  }
304 
305  // Set table indices
306  set_indices();
307 
308  // Set energy axis to logarithmic scale
310 
311  // Set offset angle axis to radians
313 
314  // Convert effective areas from m2 to cm2
315  for (int i = 0; i < m_aeff.tables(); ++i) {
316  m_aeff.scale(i, 1.0e4);
317  }
318 
319  // Set table boundaries
320  set_boundaries();
321 
322  // Read "LO_THRES" and "HI_THRES" header keywords if they exist
323  m_lo_thres = (table.has_card("LO_THRES")) ? table.real("LO_THRES") : 0.0;
324  m_hi_thres = (table.has_card("HI_THRES")) ? table.real("HI_THRES") : 0.0;
325 
326  // Read radius cut value if it exists
327  m_rad_max = (table.has_card("RAD_MAX")) ? table.real("RAD_MAX") : 0.0;
328 
329  // Return
330  return;
331 }
332 
333 
334 /***********************************************************************//**
335  * @brief Write effective area into FITS binary table
336  *
337  * @param[in] table FITS binary table.
338  *
339  * Writes effective area into a FITS binary @p table.
340  ***************************************************************************/
342 {
343  // Create a copy of the response table
345 
346  // Convert area from cm2 to m2
347  for (int i = 0; i < aeff.tables(); ++i) {
348  aeff.scale(i, 1.0e-4);
349  }
350 
351  // Write response table
352  aeff.write(table);
353 
354  // If thresholds were specified then write them into the header
355  if (m_lo_thres > 0.0) {
356  table.card("LO_THRES", m_lo_thres, "[TeV] Lower energy threshold");
357  }
358  if (m_hi_thres > 0.0) {
359  table.card("HI_THRES", m_hi_thres, "[TeV] Upper energy threshold");
360  }
361 
362  // If a radius cut was specified then write the cut value into the header
363  if (m_rad_max > 0.0) {
364  table.card("RAD_MAX", m_rad_max, "[deg] Applied radius cut");
365  }
366 
367  // Return
368  return;
369 }
370 
371 
372 /***********************************************************************//**
373  * @brief Load effective area from FITS file
374  *
375  * @param[in] filename FITS file name.
376  *
377  * Loads the effective area from a FITS file.
378  *
379  * If no extension name is given the method scans the `HDUCLASS` keywords
380  * of all extensions and loads the effective area from the first extension
381  * for which `HDUCLAS4=AEFF_2D`.
382  *
383  * Otherwise, the effective area will be loaded from the `EFFECTIVE AREA`
384  * extension.
385  ***************************************************************************/
386 void GCTAAeff2D::load(const GFilename& filename)
387 {
388  // Open FITS file
389  GFits fits(filename);
390 
391  // Get the default extension name. If no GADF compliant name was found
392  // then set the default extension name to "EFFECTIVE AREA".
393  std::string extname = gammalib::gadf_hduclas4(fits, "AEFF_2D");
394  if (extname.empty()) {
396  }
397 
398  // Get effective area table
399  const GFitsTable& table = *fits.table(filename.extname(extname));
400 
401  // Read effective area from table
402  read(table);
403 
404  // Close FITS file
405  fits.close();
406 
407  // Store filename
409 
410  // Return
411  return;
412 }
413 
414 
415 /***********************************************************************//**
416  * @brief Save effective area into FITS file
417  *
418  * @param[in] filename FITS file name.
419  * @param[in] clobber Overwrite existing file?
420  *
421  * Saves effectiva area into a FITS file. If a file with the given
422  * @p filename does not yet exist it will be created, otherwise the method
423  * opens the existing file. The method will create a (or replace an existing)
424  * effective area extension. The extension name can be specified as part
425  * of the @p filename, or if no extension name is given, is assumed to be
426  * `EFFECTIVE AREA`.
427  *
428  * An existing file will only be modified if the @p clobber flag is set to
429  * true.
430  ***************************************************************************/
431 void GCTAAeff2D::save(const GFilename& filename, const bool& clobber) const
432 {
433  // Get extension name
434  std::string extname = filename.extname(gammalib::extname_cta_aeff2d);
435 
436  // Open or create FITS file (without extension name since the requested
437  // extension may not yet exist in the file)
438  GFits fits(filename.url(), true);
439 
440  // Remove extension if it exists already
441  if (fits.contains(extname)) {
442  fits.remove(extname);
443  }
444 
445  // Create binary table
447 
448  // Write the background table
449  write(table);
450 
451  // Set binary table extension name
452  table.extname(extname);
453 
454  // Append table to FITS file
455  fits.append(table);
456 
457  // Save to file
458  fits.save(clobber);
459 
460  // Return
461  return;
462 }
463 
464 
465 /***********************************************************************//**
466  * @brief Return maximum effective area at a given energy in cm2
467  *
468  * @param[in] logE Log10 of the true photon energy (TeV).
469  * @param[in] zenith Zenith angle in Earth system (rad).
470  * @param[in] azimuth Azimuth angle in Earth system (rad).
471  * @param[in] etrue Use true energy?
472  * @return Maximum effective area (cm2).
473  *
474  * Returns the maximum effective area for a given energy, zenith and azimuth
475  * angle in units of cm2.
476  ***************************************************************************/
477 double GCTAAeff2D::max(const double& logE,
478  const double& zenith,
479  const double& azimuth,
480  const bool& etrue) const
481 {
482  // Initialise maximum effective area
483  double max_aeff = 0.0;
484 
485  // Set parameter index
486  int index = (etrue) ? m_inx_aeff : m_inx_aeff_reco;
487 
488  // Get number of theta bins
489  int n_theta = m_aeff.axis_bins(m_inx_theta);
490 
491  // Loop over theta values
492  for (int i = 0; i < n_theta; ++i) {
493 
494  // Compute lower and upper theta bin values (radians)
495  double theta_lo = m_aeff.axis_lo(m_inx_theta, i) * gammalib::deg2rad;
496  double theta_hi = m_aeff.axis_hi(m_inx_theta, i) * gammalib::deg2rad;
497 
498  // Get effective area value in cm2
499  double aeff_lo = (m_inx_energy == 0) ? m_aeff(index, logE, theta_lo) :
500  m_aeff(index, theta_lo, logE);
501  double aeff_hi = (m_inx_energy == 0) ? m_aeff(index, logE, theta_hi) :
502  m_aeff(index, theta_hi, logE);
503 
504  // Update maximum effective area if larger than current maximum
505  // effective area
506  if (aeff_lo > max_aeff) {
507  max_aeff = aeff_lo;
508  }
509  if (aeff_hi > max_aeff) {
510  max_aeff = aeff_hi;
511  }
512 
513  } // endfor: loop over theta values
514 
515  // Return effective area value
516  return max_aeff;
517 }
518 
519 
520 /***********************************************************************//**
521  * @brief Assign response table
522  *
523  * @param[in] table Response table.
524  *
525  * Assigns the response table for an effective area. The effective area
526  * values are given in units of cm2.
527  ***************************************************************************/
529 {
530  // Assign response table
531  m_aeff = table;
532 
533  // Set indices
534  set_indices();
535 
536  // Set energy axis to logarithmic scale
538 
539  // Set offset angle axis to radians
541 
542  // Set table boundaries
543  set_boundaries();
544 
545  // Return
546  return;
547 }
548 
549 
550 /***********************************************************************//**
551  * @brief Print effective area information
552  *
553  * @param[in] chatter Chattiness.
554  * @return String containing effective area information.
555  ***************************************************************************/
556 std::string GCTAAeff2D::print(const GChatter& chatter) const
557 {
558  // Initialise result string
559  std::string result;
560 
561  // Continue only if chatter is not silent
562  if (chatter != SILENT) {
563 
564  // Append header
565  result.append("=== GCTAAeff2D ===");
566  result.append("\n"+gammalib::parformat("Filename")+m_filename);
567 
568  // Initialise information
569  int nebins = 0;
570  int nthetabins = 0;
571  double emin = 0.0;
572  double emax = 0.0;
573  double omin = 0.0;
574  double omax = 0.0;
575 
576  // Extract information if there are axes in the response table
577  if (m_aeff.axes() > 0) {
578  nebins = m_aeff.axis_bins(m_inx_energy);
579  nthetabins = m_aeff.axis_bins(m_inx_theta);
580  emin = m_aeff.axis_lo(m_inx_energy,0);
581  emax = m_aeff.axis_hi(m_inx_energy,nebins-1);
582  omin = m_aeff.axis_lo(m_inx_theta,0);
583  omax = m_aeff.axis_hi(m_inx_theta,nthetabins-1);
584  }
585 
586  // Append information
587  result.append("\n"+gammalib::parformat("Number of energy bins") +
588  gammalib::str(nebins));
589  result.append("\n"+gammalib::parformat("Number of offset bins") +
590  gammalib::str(nthetabins));
591  result.append("\n"+gammalib::parformat("Log10(Energy) range"));
592  result.append(gammalib::str(emin)+" - "+gammalib::str(emax)+" TeV");
593  result.append("\n"+gammalib::parformat("Offset angle range"));
594  result.append(gammalib::str(omin)+" - "+gammalib::str(omax)+" deg");
595 
596  // Append optional keywords
597  result.append("\n"+gammalib::parformat("Lower energy threshold"));
598  if (m_lo_thres > 0.0) {
599  result.append(gammalib::str(m_lo_thres)+" TeV");
600  }
601  else {
602  result.append("not specified");
603  }
604  result.append("\n"+gammalib::parformat("Upper energy threshold"));
605  if (m_hi_thres > 0.0) {
606  result.append(gammalib::str(m_hi_thres)+" TeV");
607  }
608  else {
609  result.append("not specified");
610  }
611  result.append("\n"+gammalib::parformat("Radius cut"));
612  if (m_rad_max > 0.0) {
613  result.append(gammalib::str(m_rad_max)+" deg");
614  }
615  else {
616  result.append("none");
617  }
618 
619  } // endif: chatter was not silent
620 
621  // Return result
622  return result;
623 }
624 
625 
626 /*==========================================================================
627  = =
628  = Private methods =
629  = =
630  ==========================================================================*/
631 
632 /***********************************************************************//**
633  * @brief Initialise class members
634  ***************************************************************************/
636 {
637  // Initialise members
638  m_filename.clear();
639  m_aeff.clear();
640  m_ebounds.clear();
641  m_inx_energy = 0;
642  m_inx_theta = 1;
643  m_inx_aeff = 0;
644  m_inx_aeff_reco = 1;
645  m_logE_min = 0.0;
646  m_logE_max = 0.0;
647  m_theta_min = 0.0;
648  m_theta_max = 0.0;
649  m_lo_thres = 0.0;
650  m_hi_thres = 0.0;
651  m_rad_max = 0.0;
652 
653  // Return
654  return;
655 }
656 
657 
658 /***********************************************************************//**
659  * @brief Copy class members
660  *
661  * @param[in] aeff Effective area.
662  ***************************************************************************/
664 {
665  // Copy members
666  m_filename = aeff.m_filename;
667  m_aeff = aeff.m_aeff;
668  m_ebounds = aeff.m_ebounds;
669  m_inx_energy = aeff.m_inx_energy;
670  m_inx_theta = aeff.m_inx_theta;
671  m_inx_aeff = aeff.m_inx_aeff;
673  m_logE_min = aeff.m_logE_min;
674  m_logE_max = aeff.m_logE_max;
675  m_theta_min = aeff.m_theta_min;
676  m_theta_max = aeff.m_theta_max;
677  m_lo_thres = aeff.m_lo_thres;
678  m_hi_thres = aeff.m_hi_thres;
679  m_rad_max = aeff.m_rad_max;
680 
681  // Return
682  return;
683 }
684 
685 
686 /***********************************************************************//**
687  * @brief Delete class members
688  ***************************************************************************/
690 {
691  // Return
692  return;
693 }
694 
695 
696 /***********************************************************************//**
697  * @brief Set table indices
698  *
699  * Sets the data members m_inx_energy, m_inx_theta, m_inx_aeff and optionally
700  * m_inx_aeff_reco.
701  ***************************************************************************/
703 {
704  // Get mandatory indices (throw exception if not found)
705  m_inx_energy = m_aeff.axis("ENERG");
706  m_inx_theta = m_aeff.axis("THETA");
707  m_inx_aeff = m_aeff.table("EFFAREA");
708 
709  // Get optional index (use "EFFAREA" if "EFFAREA_RECO" does not exist)
710  m_inx_aeff_reco = (m_aeff.has_table("EFFAREA_RECO")) ?
711  m_aeff.table("EFFAREA_RECO") : m_inx_aeff;
712 
713  // Return
714  return;
715 }
716 
717 
718 /***********************************************************************//**
719  * @brief Set effective area boundaries
720  *
721  * Sets the data members m_ebounds, m_logE_min, m_logE_max, m_theta_min
722  * and m_theta_max that define the validity range of the effective area.
723  ***************************************************************************/
725 {
726  // Clear energy boundaries
727  m_ebounds.clear();
728 
729  // Get number of energy and theta bins
730  int neng = m_aeff.axis_bins(m_inx_energy);
731  int ntheta = m_aeff.axis_bins(m_inx_theta);
732 
733  // Get energy boundaries
736  GEnergy emax(m_aeff.axis_hi(m_inx_energy, neng-1),
738 
739  // Set energy boundaries
740  m_ebounds.append(emin, emax);
741 
742  // Set logE boundaries
743  m_logE_min = emin.log10TeV();
744  m_logE_max = emax.log10TeV();
745 
746  // Compute theta boundaries
749 
750  // Return
751  return;
752 }
int m_inx_aeff
Effective area (true energy)
Definition: GCTAAeff2D.hpp:110
GFitsTable * table(const int &extno)
Get pointer to table HDU.
Definition: GFits.cpp:472
GCTAResponseTable m_aeff
Aeff response table.
Definition: GCTAAeff2D.hpp:106
bool has_card(const int &cardno) const
Check existence of header card.
Definition: GFitsHDU.hpp:233
double m_theta_max
Maximum theta (radians)
Definition: GCTAAeff2D.hpp:115
double m_hi_thres
Upper energy threshold (TeV)
Definition: GCTAAeff2D.hpp:117
double m_logE_max
Maximum logE (log10(E/TeV))
Definition: GCTAAeff2D.hpp:113
void append(const GEnergy &emin, const GEnergy &emax)
Append energy interval.
Definition: GEbounds.cpp:300
GCTAAeff2D & operator=(const GCTAAeff2D &aeff)
Assignment operator.
Definition: GCTAAeff2D.cpp:143
void copy_members(const GCTAAeff2D &aeff)
Copy class members.
Definition: GCTAAeff2D.cpp:663
std::string extname(const std::string &defaultname="") const
Return extension name.
Definition: GFilename.cpp:385
const int & tables(void) const
Return number of tables.
GEbounds m_ebounds
Energy boundaries.
Definition: GCTAAeff2D.hpp:107
double m_logE_min
Minimum logE (log10(E/TeV))
Definition: GCTAAeff2D.hpp:112
void scale(const int &table, const double &scale)
Scale table.
void set_boundaries(void)
Set effective area boundaries.
Definition: GCTAAeff2D.cpp:724
Gammalib tools definition.
FITS file class.
Definition: GFits.hpp:63
void axis_radians(const int &axis)
Set nodes for a radians axis.
FITS file class interface definition.
GCTAAeff & operator=(const GCTAAeff &aeff)
Assignment operator.
Definition: GCTAAeff.cpp:106
GCTAAeff2D(void)
Void constructor.
Definition: GCTAAeff2D.cpp:64
double m_rad_max
Radius cut (degrees)
Definition: GCTAAeff2D.hpp:118
void read(const GFitsTable &table)
Read response table from FITS table HDU.
void free_members(void)
Delete class members.
Definition: GCTAAeff.cpp:164
virtual ~GCTAAeff2D(void)
Destructor.
Definition: GCTAAeff2D.cpp:119
double m_theta_min
Minimum theta (radians)
Definition: GCTAAeff2D.hpp:114
const double & axis_lo(const int &axis, const int &bin) const
Return lower bin boundary for bin in axis.
void read(const GFitsTable &table)
Read effective area from FITS table.
Definition: GCTAAeff2D.cpp:288
Definition of support function used by CTA classes.
double real(const std::string &keyname) const
Return card value as double precision.
Definition: GFitsHDU.hpp:423
void write(GFitsTable &table) const
Write response table into FITS table HDU.
int axis(const std::string &name) const
Determine index of an axis.
const GCTAResponseTable & table(void) const
Return response table.
Definition: GCTAAeff2D.hpp:192
GFilename filename(void) const
Return filename.
Definition: GCTAAeff2D.hpp:140
const double deg2rad
Definition: GMath.hpp:43
GCTAAeff2D * clone(void) const
Clone effective area.
Definition: GCTAAeff2D.cpp:255
CTA 2D effective area class.
Definition: GCTAAeff2D.hpp:55
bool has_table(const std::string &name) const
Check whether a table exists.
double m_lo_thres
Lower energy threshold (TeV)
Definition: GCTAAeff2D.hpp:116
void remove(const int &extno)
Remove HDU from FITS file.
Definition: GFits.cpp:848
double max(const double &logE, const double &zenith, const double &azimuth, const bool &etrue=true) const
Return maximum effective area at a given energy in cm2.
Definition: GCTAAeff2D.cpp:477
std::string print(const GChatter &chatter=NORMAL) const
Print effective area information.
Definition: GCTAAeff2D.cpp:556
void clear(void)
Clear response table.
Filename class.
Definition: GFilename.hpp:62
CTA 2D effective area class definition.
void init_members(void)
Initialise class members.
Definition: GCTAAeff.cpp:142
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
void clear(void)
Clear effective area.
Definition: GCTAAeff2D.cpp:233
GChatter
Definition: GTypemaps.hpp:33
const std::string extname_cta_aeff2d
Definition: GCTAAeff2D.hpp:43
void set_indices(void)
Set table indices.
Definition: GCTAAeff2D.cpp:702
int m_inx_theta
Theta index.
Definition: GCTAAeff2D.hpp:109
void write(GFitsBinTable &table) const
Write effective area into FITS binary table.
Definition: GCTAAeff2D.cpp:341
const std::string & extname(void) const
Return extension name.
Definition: GFitsHDU.hpp:162
void axis_log10(const int &axis)
Set nodes for a logarithmic (base 10) axis.
void clear(void)
Clear energy boundaries.
Definition: GEbounds.cpp:267
int table(const std::string &name) const
Determine index of table.
std::string gadf_hduclas4(const GFits &fits, const std::string &hduclas4)
Return extension name for GADF response table of given HDU class 4.
Abstract base class for the CTA effective area.
Definition: GCTAAeff.hpp:54
void init_members(void)
Initialise class members.
Definition: GCTAAeff2D.cpp:635
#define G_READ
Definition: GCTAAeff2D.cpp:42
void save(const GFilename &filename, const bool &clobber=false) const
Save effective area into FITS file.
Definition: GCTAAeff2D.cpp:431
std::string url(void) const
Return Uniform Resource Locator (URL)
Definition: GFilename.hpp:189
int axis_bins(const int &axis) const
Return number bins in an axis.
void clear(void)
Clear file name.
Definition: GFilename.cpp:188
void free_members(void)
Delete class members.
Definition: GCTAAeff2D.cpp:689
int m_inx_energy
Energy index.
Definition: GCTAAeff2D.hpp:108
FITS binary table class.
void load(const GFilename &filename)
Load effective area from FITS file.
Definition: GCTAAeff2D.cpp:386
const double & axis_hi(const int &axis, const int &bin) const
Return upper bin boundary for bin in axis.
Exception handler interface definition.
FITS binary table class definition.
CTA response table class.
double operator()(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
Return effective area in units of cm2.
Definition: GCTAAeff2D.cpp:189
const std::string & axis_lo_unit(const int &axis) const
Return lower bin boundary unit for axis.
const std::string & axis_hi_unit(const int &axis) const
Return upper bin boundary unit for axis.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1033
GFitsHeaderCard & card(const int &cardno)
Return header card.
Definition: GFitsHDU.hpp:259
void close(void)
Close FITS file.
Definition: GFits.cpp:1314
const int & axes(void) const
Return number of axes of the tables.
int m_inx_aeff_reco
Effective area (reco. energy)
Definition: GCTAAeff2D.hpp:111
Filename class interface definition.
Mathematical function definitions.
Class that handles energies in a unit independent way.
Definition: GEnergy.hpp:48
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:415
FITS table abstract base class interface definition.
GFilename m_filename
Name of Aeff response file.
Definition: GCTAAeff2D.hpp:105