GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GLATResponseTable.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  * GLATResponseTable.cpp - Fermi/LAT Response table class *
3  * ----------------------------------------------------------------------- *
4  * copyright (C) 2008-2021 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 GLATResponseTable.cpp
23  * @brief Fermi/LAT response table class implementation
24  * @author Juergen Knoedlseder
25  */
26 
27 /* __ Includes ___________________________________________________________ */
28 #ifdef HAVE_CONFIG_H
29 #include <config.h>
30 #endif
31 #include "GLATResponseTable.hpp"
32 #include "GTools.hpp"
33 #include "GException.hpp"
34 #include "GFitsTableFloatCol.hpp"
35 
36 /* __ Method name definitions ____________________________________________ */
37 #define G_READ "GLATResponseTable::read(GFitsTable&)"
38 #define G_INDEX "GLATResponseTable::index(int&, int&)"
39 #define G_ENERGY "GLATResponseTable::energy(int&)"
40 #define G_ENERGY_LO "GLATResponseTable::energy_lo(int&)"
41 #define G_ENERGY_HI "GLATResponseTable::energy_hi(int&)"
42 #define G_COSTHETA_LO "GLATResponseTable::costheta_lo(int&)"
43 #define G_COSTHETA_HI "GLATResponseTable::costheta_hi(int&)"
44 
45 /* __ Macros _____________________________________________________________ */
46 
47 /* __ Coding definitions _________________________________________________ */
48 
49 /* __ Debug definitions __________________________________________________ */
50 
51 /* __ Constants __________________________________________________________ */
52 
53 
54 /*==========================================================================
55  = =
56  = Constructors/destructors =
57  = =
58  ==========================================================================*/
59 
60 /***********************************************************************//**
61  * @brief Void constructor
62  ***************************************************************************/
64 {
65  // Initialise class members
66  init_members();
67 
68  // Return
69  return;
70 }
71 
72 
73 /***********************************************************************//**
74  * @brief Copy constructor
75  *
76  * @param table Response table.
77  ***************************************************************************/
79 {
80  // Initialise class members
81  init_members();
82 
83  // Copy members
84  copy_members(table);
85 
86  // Return
87  return;
88 }
89 
90 
91 /***********************************************************************//**
92  * @brief Destructor
93  ***************************************************************************/
95 {
96  // Free members
97  free_members();
98 
99  // Return
100  return;
101 }
102 
103 
104 /*==========================================================================
105  = =
106  = Operators =
107  = =
108  ==========================================================================*/
109 
110 /***********************************************************************//**
111  * @brief Assignment operator
112  *
113  * @param table Response table.
114  * @return Response table.
115  ***************************************************************************/
117 {
118  // Execute only if object is not identical
119  if (this != &table) {
120 
121  // Free members
122  free_members();
123 
124  // Initialise private members
125  init_members();
126 
127  // Copy members
128  copy_members(table);
129 
130  } // endif: object was not identical
131 
132  // Return this object
133  return *this;
134 }
135 
136 
137 /*==========================================================================
138  = =
139  = Public methods =
140  = =
141  ==========================================================================*/
142 
143 /***********************************************************************//**
144  * @brief Clear instance
145  *
146  * This method properly resets the object to an initial state.
147  ***************************************************************************/
149 {
150  // Free class members
151  free_members();
152 
153  // Initialise members
154  init_members();
155 
156  // Return
157  return;
158 }
159 
160 
161 /***********************************************************************//**
162  * @brief Clone instance
163  ***************************************************************************/
165 {
166  return new GLATResponseTable(*this);
167 }
168 
169 
170 /***********************************************************************//**
171  * @brief Read response table from FITS table HDU
172  *
173  * @param[in] hdu Response table HDU.
174  *
175  * The response table definition is assumed to be stored in 4 vector columns
176  * with names
177  * ENERG_LO (energy bins lower boundary)
178  * ENERG_HI (energy bins upper boundary)
179  * CTHETA_LO (cos theta bins lower boundary)
180  * CTHETA_HI (cos theta bins upper boundary)
181  ***************************************************************************/
183 {
184  // Clear instance
185  clear();
186 
187  // Get pointers to table columns
188  const GFitsTableCol* energy_lo = hdu["ENERG_LO"];
189  const GFitsTableCol* energy_hi = hdu["ENERG_HI"];
190  const GFitsTableCol* ctheta_lo = hdu["CTHETA_LO"];
191  const GFitsTableCol* ctheta_hi = hdu["CTHETA_HI"];
192 
193  // Extract number of bins
194  m_energy_num = energy_lo->number();
195  m_ctheta_num = ctheta_lo->number();
196 
197  // Allocate memory
198  if (m_energy_num > 0) {
199  m_energy_lo = new double[m_energy_num];
200  m_energy_hi = new double[m_energy_num];
201  }
202  if (m_ctheta_num > 0) {
203  m_ctheta_lo = new double[m_ctheta_num];
204  m_ctheta_hi = new double[m_ctheta_num];
205  }
206 
207  // Transfer data
208  for (int i = 0; i < m_energy_num; ++i) {
209  m_energy_lo[i] = energy_lo->real(0,i);
210  m_energy_hi[i] = energy_hi->real(0,i);
211  }
212  for (int i = 0; i < m_ctheta_num; ++i) {
213  m_ctheta_lo[i] = ctheta_lo->real(0,i);
214  m_ctheta_hi[i] = ctheta_hi->real(0,i);
215  }
216 
217  // Set energy nodes (log10 of energy)
218  if (m_energy_num > 0) {
219  double *logE = new double[m_energy_num];
220  for (int i = 0; i < m_energy_num; ++i) {
221  logE[i] = 0.5 * (log10(m_energy_lo[i]) + log10(m_energy_hi[i]));
222 //ST method logE[i] = log10(sqrt(m_energy_lo[i]*m_energy_hi[i]));
223  m_energy.push_back(std::pow(10.0, logE[i]));
224  }
225  m_logE.nodes(m_energy_num, logE);
226  delete [] logE;
227  }
228 
229  // Set cos theta nodes
230  if (m_ctheta_num > 0) {
231  double *ctheta = new double[m_ctheta_num];
232  for (int i = 0; i < m_ctheta_num; ++i) {
233  ctheta[i] = 0.5 * (m_ctheta_lo[i] + m_ctheta_hi[i]);
234  }
235  m_ctheta.nodes(m_ctheta_num, ctheta);
236  delete [] ctheta;
237  }
238 
239  // Return
240  return;
241 }
242 
243 
244 /***********************************************************************//**
245  * @brief Write response table into FITS table
246  *
247  * @param[in] hdu Fits table HDU.
248  ***************************************************************************/
250 {
251  // Allocate floating point vector columns
252  GFitsTableFloatCol col_energy_lo = GFitsTableFloatCol("ENERG_LO", 1, m_energy_num);
253  GFitsTableFloatCol col_energy_hi = GFitsTableFloatCol("ENERG_HI", 1, m_energy_num);
254  GFitsTableFloatCol col_ctheta_lo = GFitsTableFloatCol("CTHETA_LO", 1, m_ctheta_num);
255  GFitsTableFloatCol col_ctheta_hi = GFitsTableFloatCol("CTHETA_HI", 1, m_ctheta_num);
256 
257  // Set column values
258  for (int i = 0; i < m_energy_num; ++i) {
259  col_energy_lo(0,i) = m_energy_lo[i];
260  col_energy_hi(0,i) = m_energy_hi[i];
261  }
262  for (int i = 0; i < m_ctheta_num; ++i) {
263  col_ctheta_lo(0,i) = m_ctheta_lo[i];
264  col_ctheta_hi(0,i) = m_ctheta_hi[i];
265  }
266 
267  // Append columns to boundary table
268  hdu.append(col_energy_lo);
269  hdu.append(col_energy_hi);
270  hdu.append(col_ctheta_lo);
271  hdu.append(col_ctheta_hi);
272 
273  // Return
274  return;
275 }
276 
277 
278 /***********************************************************************//**
279  * @brief Return table index
280  *
281  * @param[in] ie Energy bin [0,...,m_energy_num[
282  * @param[in] ic cos theta bin [0,...,m_ctheta_num[
283  *
284  * @exception GException::out_of_range
285  * Energy or cos theta bin index out of range
286  *
287  * Computes table index from energy and cos theta bin indices.
288  ***************************************************************************/
289 int GLATResponseTable::index(const int& ie, const int& ic) const
290 {
291  // Optionally check if the index is valid
292  #if defined(G_RANGE_CHECK)
293  if (ie < 0 || ie >= m_energy_num) {
294  throw GException::out_of_range(G_INDEX, "Energy bin index",
295  ie, m_energy_num);
296  }
297  if (ic < 0 || ic >= m_ctheta_num) {
298  throw GException::out_of_range(G_INDEX, "cos theta bin index",
299  ic, m_ctheta_num);
300  }
301  #endif
302 
303  // Compute index
304  int index = ic * m_energy_num + ie;
305 
306  // Return index
307  return index;
308 }
309 
310 
311 /***********************************************************************//**
312  * @brief Return mean energy of bin (units: MeV)
313  *
314  * @param[in] ie Index of energy bin [0,...,m_energy_num[
315  *
316  * @exception GException::out_of_range
317  * Energy bin index out of range
318  *
319  * The mean energy is actually computed from the logarithmic average of
320  * lower and upper boundaries:
321  * \f$E=10^{0.5 \times (\log{E_{\rm min}} + \log{E_{\rm max}})}\f$
322  * Note that this energy is stored in the m_energy array, hence to convert
323  * to MeV we simply have to the it to the power of 10.
324  *
325  * @todo Store also linear energies to avoid conversion.
326  ***************************************************************************/
327 double GLATResponseTable::energy(const int& ie) const
328 {
329  // Optionally check if the index is valid
330  #if defined(G_RANGE_CHECK)
331  if (ie < 0 || ie >= m_energy_num) {
332  throw GException::out_of_range(G_ENERGY, "Energy bin index",
333  ie, m_energy_num);
334  }
335  #endif
336 
337  // Determine mean energy of bin
338  //double mean = 0.5 * (log10(m_energy_lo[ie]) + log10(m_energy_hi[ie]));
339  //double mean = m_logE[ie];
340  //double energy = pow(10.0, mean);
341 
342  // Return mean energy
343  return (m_energy[ie]);
344 }
345 
346 
347 /***********************************************************************//**
348  * @brief Set indices and weighting for bi-linear interpolation of 2D array
349  *
350  * @param[in] logE Base 10 logarithm of the energy (MeV).
351  * @param[in] ctheta Cosine of zenith angle.
352  *
353  * Bi-linear interpolation is performed in log10 of energy and in cos theta.
354  ***************************************************************************/
355 void GLATResponseTable::set(const double& logE, const double& ctheta)
356 {
357  // Flag no change of values
358  bool change = false;
359 
360  // Set energy interpolation
361  if (logE != m_last_energy) {
362  m_logE.set_value(logE);
363  m_last_energy = logE;
364  change = true;
365  }
366 
367  // Set cos(theta) interpolation
368  if (ctheta != m_last_ctheta) {
369  m_ctheta.set_value(ctheta);
370  m_last_ctheta = ctheta;
371  change = true;
372  }
373 
374  // If change occured then update interpolation indices and weighting
375  // factors
376  if (change) {
377 
378  // Set array indices for bi-linear interpolation
379  int inx_ctheta_left = m_ctheta.inx_left() * m_energy_num;
380  int inx_ctheta_right = m_ctheta.inx_right() * m_energy_num;
381  m_inx1 = m_logE.inx_left() + inx_ctheta_left;
382  m_inx2 = m_logE.inx_left() + inx_ctheta_right;
383  m_inx3 = m_logE.inx_right() + inx_ctheta_left;
384  m_inx4 = m_logE.inx_right() + inx_ctheta_right;
385 
386  // Set weighting factors for bi-linear interpolation
391 
392  } // endif: logE or ctheta changed
393 
394  // Return
395  return;
396 }
397 
398 
399 /***********************************************************************//**
400  * @brief Perform bi-linear interpolation of 2D array
401  *
402  * @param[in] logE Base 10 logarithm of the energy (MeV).
403  * @param[in] ctheta Cosine of zenith angle.
404  * @param[in] array Array to be interpolated.
405  *
406  * Bi-linear interpolation is performed in log10 of energy and in cos theta.
407  * The array is stored in a std::vector object with the logE axis varying
408  * more rapidely.
409  ***************************************************************************/
410 double GLATResponseTable::interpolate(const double& logE,
411  const double& ctheta,
412  const std::vector<double>& array)
413 {
414  // Set interpolation indices and weights
415  set(logE, ctheta);
416 
417  // Perform bi-linear interpolation
418  double value = m_wgt1 * array[m_inx1] +
419  m_wgt2 * array[m_inx2] +
420  m_wgt3 * array[m_inx3] +
421  m_wgt4 * array[m_inx4];
422 
423  // Return bi-linear interpolated value
424  return value;
425 }
426 
427 
428 /***********************************************************************//**
429  * @brief Perform bi-linear interpolation of 3D array
430  *
431  * @param[in] logE Base 10 logarithm of the energy (MeV).
432  * @param[in] ctheta Cosine of zenith angle.
433  * @param[in] array Array to be interpolated.
434  * @param[in] offset Offset if 3D array in 1st dimension.
435  * @param[in] size Size of 3D array in 1st dimension.
436  *
437  * Bi-linear interpolation is performed in log10 of energy and in cos theta.
438  * The array is stored in a std::vector object.
439  ***************************************************************************/
440 double GLATResponseTable::interpolate(const double& logE,
441  const double& ctheta,
442  const std::vector<double>& array,
443  const int& offset,
444  const int& size)
445 {
446  // Set interpolation indices and weights
447  set(logE, ctheta);
448 
449  // Perform bi-linear interpolation
450  double value = m_wgt1 * array[m_inx1*size+offset] +
451  m_wgt2 * array[m_inx2*size+offset] +
452  m_wgt3 * array[m_inx3*size+offset] +
453  m_wgt4 * array[m_inx4*size+offset];
454 
455  // Return bi-linear interpolated value
456  return value;
457 }
458 
459 
460 /***********************************************************************//**
461  * @brief Return lower bin energy (units: MeV)
462  *
463  * @param[in] inx Index of energy bin [0,...,m_energy_num[
464  *
465  * @exception GException::out_of_range
466  * Energy bin index out of range
467  ***************************************************************************/
468 double GLATResponseTable::energy_lo(const int& inx) const
469 {
470  // Optionally check if the index is valid
471  #if defined(G_RANGE_CHECK)
472  if (inx < 0 || inx >= m_energy_num) {
473  throw GException::out_of_range(G_ENERGY_LO, "Energy bin index",
474  inx, m_energy_num);
475  }
476  #endif
477 
478  // Return mean energy
479  return m_energy_lo[inx];
480 }
481 
482 
483 /***********************************************************************//**
484  * @brief Return upper bin energy (units: MeV)
485  *
486  * @param[in] inx Index of energy bin [0,...,m_energy_num[
487  *
488  * @exception GException::out_of_range
489  * Energy bin index out of range
490  ***************************************************************************/
491 double GLATResponseTable::energy_hi(const int& inx) const
492 {
493  // Optionally check if the index is valid
494  #if defined(G_RANGE_CHECK)
495  if (inx < 0 || inx >= m_energy_num) {
496  throw GException::out_of_range(G_ENERGY_HI, "Energy bin index",
497  inx, m_energy_num);
498  }
499  #endif
500 
501  // Return mean energy
502  return m_energy_hi[inx];
503 }
504 
505 
506 /***********************************************************************//**
507  * @brief Return lower bin cos theta
508  *[
509  * @param[in] inx Index of cos theta bin [0,...,m_ctheta_num[
510  *
511  * @exception GException::out_of_range
512  * Cos theta bin index out of range
513  ***************************************************************************/
514 double GLATResponseTable::costheta_lo(const int& inx) const
515 {
516  // Optionally check if the index is valid
517  #if defined(G_RANGE_CHECK)
518  if (inx < 0 || inx >= m_ctheta_num) {
519  throw GException::out_of_range(G_COSTHETA_LO, "cos thera bin index",
520  inx, m_ctheta_num);
521  }
522  #endif
523 
524  // Return mean energy
525  return m_ctheta_lo[inx];
526 }
527 
528 
529 /***********************************************************************//**
530  * @brief Return upper bin cos theta
531  *
532  * @param[in] inx Index of cos theta bin (starting from 0)
533  *
534  * @exception GException::out_of_range
535  * Cos theta bin index out of range
536  ***************************************************************************/
537 double GLATResponseTable::costheta_hi(const int& inx) const
538 {
539  // Optionally check if the index is valid
540  #if defined(G_RANGE_CHECK)
541  if (inx < 0 || inx >= m_ctheta_num) {
542  throw GException::out_of_range(G_COSTHETA_HI, "cos thera bin index",
543  inx, m_ctheta_num);
544  }
545  #endif
546 
547  // Return mean energy
548  return m_ctheta_hi[inx];
549 }
550 
551 
552 /***********************************************************************//**
553  * @brief Return indices of 4 corners used for interpolation
554  ***************************************************************************/
555 std::vector<int> GLATResponseTable::indices(void) const
556 {
557  // Define vector
558  std::vector<int> incides;
559 
560  // Push indices on vector
561  incides.push_back(m_inx1);
562  incides.push_back(m_inx2);
563  incides.push_back(m_inx3);
564  incides.push_back(m_inx4);
565 
566  // Return vector
567  return incides;
568 }
569 
570 
571 /***********************************************************************//**
572  * @brief Return energies of 4 corners used for interpolation
573  ***************************************************************************/
574 std::vector<double> GLATResponseTable::energies(void) const
575 {
576  // Define vector
577  std::vector<double> energies;
578 
579  // Push energies on vector
580  if (m_energy_num > 0) {
581  energies.push_back(m_energy[m_logE.inx_left()]);
582  energies.push_back(m_energy[m_logE.inx_left()]);
583  energies.push_back(m_energy[m_logE.inx_right()]);
584  energies.push_back(m_energy[m_logE.inx_right()]);
585  }
586 
587  // Return vector
588  return energies;
589 }
590 
591 
592 /***********************************************************************//**
593  * @brief Return weights of 4 corners used for interpolation
594  ***************************************************************************/
595 std::vector<double> GLATResponseTable::weights(void) const
596 {
597  // Define vector
598  std::vector<double> weights;
599 
600  // Push indices on vector
601  weights.push_back(m_wgt1);
602  weights.push_back(m_wgt2);
603  weights.push_back(m_wgt3);
604  weights.push_back(m_wgt4);
605 
606  // Return vector
607  return weights;
608 }
609 
610 
611 /***********************************************************************//**
612  * @brief Print response table information
613  *
614  * @param[in] chatter Chattiness (defaults to NORMAL).
615  * @return String containing response table information.
616  ***************************************************************************/
617 std::string GLATResponseTable::print(const GChatter& chatter) const
618 {
619  // Initialise result string
620  std::string result;
621 
622  // Continue only if chatter is not silent
623  if (chatter != SILENT) {
624 
625  // Append header
626  result.append("=== GLATResponseTable ===");
627 
628  // Append information
629  result.append("\n"+gammalib::parformat("Number of energy bins") +
631  result.append("\n"+gammalib::parformat("Number of cos theta bins") +
633 
634  } // endif: chatter was not silent
635 
636  // Return result
637  return result;
638 }
639 
640 
641 /*==========================================================================
642  = =
643  = Private methods =
644  = =
645  ==========================================================================*/
646 
647 /***********************************************************************//**
648  * @brief Initialise class members
649  ***************************************************************************/
651 {
652  // Initialise members
653  m_energy_num = 0;
654  m_ctheta_num = 0;
655  m_energy.clear();
656  m_logE.clear();
657  m_ctheta.clear();
658  m_energy_lo = NULL;
659  m_energy_hi = NULL;
660  m_ctheta_lo = NULL;
661  m_ctheta_hi = NULL;
662  m_last_energy = -1.0;
663  m_last_ctheta = -1.0;
664  m_inx1 = 0;
665  m_inx2 = 0;
666  m_inx3 = 0;
667  m_inx4 = 0;
668  m_wgt1 = 0.0;
669  m_wgt2 = 0.0;
670  m_wgt3 = 0.0;
671  m_wgt4 = 0.0;
672 
673  // Return
674  return;
675 }
676 
677 
678 /***********************************************************************//**
679  * @brief Copy class members
680  *
681  * @param[in] table Response table.
682  ***************************************************************************/
684 {
685  // Copy number of bins
686  m_energy_num = table.m_energy_num;
687  m_ctheta_num = table.m_ctheta_num;
688  m_energy = table.m_energy;
689  m_logE = table.m_logE;
690  m_ctheta = table.m_ctheta;
693  m_inx1 = table.m_inx1;
694  m_inx2 = table.m_inx2;
695  m_inx3 = table.m_inx3;
696  m_inx4 = table.m_inx4;
697  m_wgt1 = table.m_wgt1;
698  m_wgt2 = table.m_wgt2;
699  m_wgt3 = table.m_wgt3;
700  m_wgt4 = table.m_wgt4;
701 
702  // Copy energy bins
703  if (m_energy_num > 0) {
704  m_energy_lo = new double[m_energy_num];
705  m_energy_hi = new double[m_energy_num];
706  for (int i=0; i < m_energy_num; ++i) {
707  m_energy_lo[i] = table.m_energy_lo[i];
708  m_energy_hi[i] = table.m_energy_hi[i];
709  }
710  }
711 
712  // Copy cos theta bins
713  if (m_ctheta_num > 0) {
714  m_ctheta_lo = new double[m_ctheta_num];
715  m_ctheta_hi = new double[m_ctheta_num];
716  for (int i=0; i < m_ctheta_num; ++i) {
717  m_ctheta_lo[i] = table.m_ctheta_lo[i];
718  m_ctheta_hi[i] = table.m_ctheta_hi[i];
719  }
720  }
721 
722  // Return
723  return;
724 }
725 
726 
727 /***********************************************************************//**
728  * @brief Delete class members
729  ***************************************************************************/
731 {
732  // Free memory
733  if (m_energy_lo != NULL) delete [] m_energy_lo;
734  if (m_energy_hi != NULL) delete [] m_energy_hi;
735  if (m_ctheta_lo != NULL) delete [] m_ctheta_lo;
736  if (m_ctheta_hi != NULL) delete [] m_ctheta_hi;
737 
738  // Signal that memory is free
739  m_energy_lo = NULL;
740  m_energy_hi = NULL;
741  m_ctheta_lo = NULL;
742  m_ctheta_hi = NULL;
743 
744  // Return
745  return;
746 }
int m_ctheta_num
Number of cos theta bins in table.
void number(const int &number)
Set number of elements in column.
double costheta_hi(const int &inx) const
Return upper bin cos theta.
void read(const GFitsTable &hdu)
Read response table from FITS table HDU.
#define G_INDEX
double m_wgt4
Weighting factor 4.
std::vector< double > energies(void) const
Return energies of 4 corners used for interpolation.
const double & wgt_left(void) const
Returns left node weight.
Definition: GNodeArray.hpp:264
void clear(void)
Clear node array.
Definition: GNodeArray.cpp:235
Fermi-LAT response table class definition.
void clear(void)
Clear instance.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
Definition: GFitsTable.hpp:147
void write(GFitsTable &hdu) const
Write response table into FITS table.
GNodeArray m_logE
Energy nodes (log10 mean energy)
GLATResponseTable(void)
Void constructor.
Gammalib tools definition.
FITS table float column class interface definition.
void set_value(const double &value) const
Set indices and weighting factors for interpolation.
Definition: GNodeArray.cpp:587
void init_members(void)
Initialise class members.
GNodeArray m_ctheta
cos(theta) nodes
#define G_ENERGY
double m_last_ctheta
Last requested cos(theta) for interpolation.
virtual ~GLATResponseTable(void)
Destructor.
double interpolate(const double &logE, const double &ctheta, const std::vector< double > &array)
Perform bi-linear interpolation of 2D array.
double energy_hi(const int &inx) const
Return upper bin energy (units: MeV)
void free_members(void)
Delete class members.
std::string print(const GChatter &chatter=NORMAL) const
Print response table information.
const double & wgt_right(void) const
Returns right node weight.
Definition: GNodeArray.hpp:279
const int & nenergies(void) const
Return number of energies in response table.
#define G_COSTHETA_HI
GLATResponseTable * clone(void) const
Clone instance.
#define G_COSTHETA_LO
Abstract interface for FITS table column.
Interface for the Fermi LAT Response table class.
void copy_members(const GLATResponseTable &table)
Copy class members.
const int & ncostheta(void) const
Return number of cosine theta bins in response table.
Abstract interface for FITS table.
Definition: GFitsTable.hpp:44
#define G_ENERGY_HI
GChatter
Definition: GTypemaps.hpp:33
const int & inx_left(void) const
Returns left node index.
Definition: GNodeArray.hpp:235
GLATResponseTable & operator=(const GLATResponseTable &table)
Assignment operator.
int m_energy_num
Number of energy bins in table.
#define G_ENERGY_LO
void nodes(const int &num, const double *array)
Set node array.
Definition: GNodeArray.cpp:325
const int & inx_right(void) const
Returns right node index.
Definition: GNodeArray.hpp:249
double * m_ctheta_lo
cos(theta) bins lower boundary
double * m_energy_hi
Energy bins upper boundary (MeV)
std::vector< double > m_energy
Energy nodes (MeV)
void set(const double &logE, const double &ctheta)
Set indices and weighting for bi-linear interpolation of 2D array.
int index(const int &ie, const int &ic) const
Return table index.
virtual double real(const int &row, const int &inx=0) const =0
double m_wgt1
Weighting factor 1.
GVector pow(const GVector &vector, const double &power)
Computes tanh of vector elements.
Definition: GVector.cpp:1422
Exception handler interface definition.
double costheta_lo(const int &inx) const
Return lower bin cos theta [.
FITS table float column.
double * m_energy_lo
Energy bins lower boundary (MeV)
double m_wgt2
Weighting factor 2.
double energy_lo(const int &inx) const
Return lower bin energy (units: MeV)
double * m_ctheta_hi
cos(theta) bins upper boundary
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
Definition: GTools.cpp:1143
double energy(const int &ie) const
Return mean energy of bin (units: MeV)
double m_last_energy
Last requested energy for interpolation.
std::vector< double > weights(void) const
Return weights of 4 corners used for interpolation.
GVector log10(const GVector &vector)
Computes base10 logarithm of vector elements.
Definition: GVector.cpp:1295
std::vector< int > indices(void) const
Return indices of 4 corners used for interpolation.
double m_wgt3
Weighting factor 3.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
Definition: GTools.cpp:489