Commit ed3164c6ab444fb2a67e01738d8cfafa1ced9754

Authored by knodlseder
1 parent 39d6dd67

add ARF reading routine

inst/cta/include/GCTAResponse.hpp
... ... @@ -171,6 +171,7 @@ private:
171 171 void copy_members(const GCTAResponse& rsp);
172 172 void free_members(void);
173 173 void read_performance_table(const std::string& filename);
  174 + void read_arf(const GFitsTable* hdu);
174 175  
175 176 // Model*IRF zenith angle integration kernel
176 177 class irf_kern_rho : public GIntegrand {
... ... @@ -365,9 +366,10 @@ private:
365 366 // Private data members
366 367 std::string m_caldb; //!< Name of or path to the calibration database
367 368 std::string m_rspname; //!< Name of the instrument response
368   - GNodeArray m_nodes; //!< log(E) nodes for interpolation
  369 + GNodeArray m_psf_logE; //!< log(E) nodes for PSF interpolation
  370 + GNodeArray m_aeff_logE; //!< log(E) nodes for Aeff interpolation
369 371 std::vector<double> m_logE; //!< log(E) = log10(E/TeV) - bin centre
370   - std::vector<double> m_aeff; //!< Effective area in square metres after all cuts
  372 + std::vector<double> m_aeff; //!< Effective area in cm2 after all cuts
371 373 std::vector<double> m_r68; //!< 68% containment radius of PSF post cuts in degrees
372 374 std::vector<double> m_r80; //!< 80% containment radius of PSF post cuts in degrees
373 375 double m_eps; //!< Integration precision
... ...
inst/cta/src/GCTAResponse.cpp
... ... @@ -912,7 +912,7 @@ double GCTAResponse::aeff(const double&amp; theta,
912 912 const double& srcLogEng) const
913 913 {
914 914 // Interpolate effective area using node array
915   - double aeff = m_nodes.interpolate(srcLogEng, m_aeff);
  915 + double aeff = m_aeff_logE.interpolate(srcLogEng, m_aeff);
916 916 if (aeff < 0)
917 917 aeff = 0.0;
918 918  
... ... @@ -1198,7 +1198,7 @@ double GCTAResponse::psf_dummy_sigma(const double&amp; srcLogEng) const
1198 1198 const double conv = 0.6624 * deg2rad;
1199 1199  
1200 1200 // Determine Gaussian sigma in radians
1201   - double sigma = m_nodes.interpolate(srcLogEng, m_r68) * conv;
  1201 + double sigma = m_psf_logE.interpolate(srcLogEng, m_r68) * conv;
1202 1202  
1203 1203 // Return result
1204 1204 return sigma;
... ... @@ -1243,6 +1243,8 @@ void GCTAResponse::init_members(void)
1243 1243 // Initialise members
1244 1244 m_caldb.clear();
1245 1245 m_rspname.clear();
  1246 + m_psf_logE.clear();
  1247 + m_aeff_logE.clear();
1246 1248 m_logE.clear();
1247 1249 m_aeff.clear();
1248 1250 m_r68.clear();
... ... @@ -1265,7 +1267,8 @@ void GCTAResponse::copy_members(const GCTAResponse&amp; rsp)
1265 1267 // Copy attributes
1266 1268 m_caldb = rsp.m_caldb;
1267 1269 m_rspname = rsp.m_rspname;
1268   - m_nodes = rsp.m_nodes;
  1270 + m_psf_logE = rsp.m_psf_logE;
  1271 + m_aeff_logE = rsp.m_aeff_logE;
1269 1272 m_logE = rsp.m_logE;
1270 1273 m_aeff = rsp.m_aeff;
1271 1274 m_r68 = rsp.m_r68;
... ... @@ -1302,6 +1305,14 @@ void GCTAResponse::free_members(void)
1302 1305 ***************************************************************************/
1303 1306 void GCTAResponse::read_performance_table(const std::string& filename)
1304 1307 {
  1308 + // Clear arrays
  1309 + m_psf_logE.clear();
  1310 + m_aeff_logE.clear();
  1311 + m_logE.clear();
  1312 + m_aeff.clear();
  1313 + m_r68.clear();
  1314 + m_r80.clear();
  1315 +
1305 1316 // Allocate line buffer
1306 1317 const int n = 1000;
1307 1318 char line[n];
... ... @@ -1341,8 +1352,10 @@ void GCTAResponse::read_performance_table(const std::string&amp; filename)
1341 1352 // If we have nodes then setup node array
1342 1353 int num = m_logE.size();
1343 1354 if (num > 0) {
1344   - for (int i = 0; i < num; ++i)
1345   - m_nodes.append(m_logE.at(i));
  1355 + for (int i = 0; i < num; ++i) {
  1356 + m_psf_logE.append(m_logE.at(i));
  1357 + m_aeff_logE.append(m_logE.at(i));
  1358 + }
1346 1359 }
1347 1360  
1348 1361 // Close file
... ... @@ -1354,6 +1367,56 @@ void GCTAResponse::read_performance_table(const std::string&amp; filename)
1354 1367  
1355 1368  
1356 1369 /***********************************************************************//**
  1370 + * @brief Read CTA ARF matrix
  1371 + *
  1372 + * @param[in] hdu FITS table pointer.
  1373 + *
  1374 + * This method reads a CTA 1DC ARF matrix from the FITS HDU. Note that the
  1375 + * effective area is converted from m2 to cm2 and stored in units of cm2.
  1376 + *
  1377 + * @todo So far we expect energies in units of TeV
  1378 + * @todo So far we expect the effective area in units of m2
  1379 + ***************************************************************************/
  1380 +void GCTAResponse::read_arf(const GFitsTable* hdu)
  1381 +{
  1382 + // Clear arrays
  1383 + m_aeff_logE.clear();
  1384 + m_aeff.clear();
  1385 +
  1386 + // Get pointers to table columns
  1387 + const GFitsTableCol* energy_lo = &(*hdu)["ENERG_LO"];
  1388 + const GFitsTableCol* energy_hi = &(*hdu)["ENERG_HI"];
  1389 + const GFitsTableCol* specresp = &(*hdu)["SPECRESP"];
  1390 +
  1391 + // Extract number of energy bins
  1392 + int num = energy_lo->number();
  1393 +
  1394 + // Set nodes
  1395 + for (int i = 0; i < num; ++i) {
  1396 +
  1397 + // Compute log10 mean energy
  1398 + double e_min = energy_lo->real(i);
  1399 + double e_max = energy_hi->real(i);
  1400 + double logE = 0.5 * (log10(e_min) + log10(e_max));
  1401 +
  1402 + // Compute effective area in cm2
  1403 + double aeff = specresp->real(i) * 10000.0;
  1404 +
  1405 + // Store log10 mean energy and effective area value
  1406 + m_aeff_logE.append(logE);
  1407 + m_aeff.push_back(aeff);
  1408 +
  1409 + } // endfor: looped over nodes
  1410 +
  1411 + // Disable offset angle dependence
  1412 + m_offset_sigma = 0.0;
  1413 +
  1414 + // Return
  1415 + return;
  1416 +}
  1417 +
  1418 +
  1419 +/***********************************************************************//**
1357 1420 * @brief Kernel for model zenith angle integration of IRF
1358 1421 *
1359 1422 * @param[in] rho Zenith angle with respect to model centre [radians].
... ...