Commit 575f12b2c1362bc66812f6ff00a332e24193e167

Authored by nkelhos
1 parent 096c1001

added analytic calculation of containment radius to GCTAPsfVector

Showing 1 changed file with 23 additions and 1 deletions
inst/cta/src/GCTAPsfVector.cpp
... ... @@ -564,6 +564,26 @@ void GCTAPsfVector::update(const double& logE) const
564 564 * @param[in] azimuth Azimuth angle in Earth system (rad). Not used.
565 565 * @param[in] etrue Use true energy (true/false). Not used.
566 566 *
  567 + * Evaluates:
  568 + *
  569 + * \f[
  570 + *
  571 + * radius = \sqrt{ \frac{\ln{\left( \frac{ fraction * m\_par\_width}
  572 + * {\pi*m\_par\_scale} +1\right)}}{m\_par\_width} }
  573 + *
  574 + * \f]
  575 + *
  576 + * which is derived from integrating
  577 + *
  578 + * \f[
  579 + *
  580 + * fraction = \int_{0}^{2\pi}\int_{0}^{radius}r *
  581 + * e^{ m\_par\_width * r^{2}}dr d\phi
  582 + *
  583 + * \f]
  584 + *
  585 + * and solving for radius.
  586 + *
567 587 * Calculate the radius from the center that contains 'fraction' percent
568 588 * of the events. fraction * 100. = Containment % .
569 589 ***************************************************************************/
... ... @@ -579,7 +599,9 @@ double GCTAPsfVector::containment_radius(const double& fraction,
579 599 update(logE);
580 600  
581 601 // Compute radius
582   - double radius = 0.0 ; // TODO implement calculation
  602 + // for gaussian
  603 + double arg = fraction * m_par_width / ( gammalib::pi * m_par_scale ) ;
  604 + double radius = std::sqrt( std::log( arg + 1 ) / m_par_width ) ;
583 605  
584 606 // Return maximum PSF radius
585 607 return radius;
... ...