Commit 698f0626be7cf97fb36c56ac386423f758c259a5
1 parent
0c287215
Correct mc() method for the special case that the second and/or third Gaussian are zero.
Showing
1 changed file
with
18 additions
and
3 deletions
inst/cta/src/GCTAPsf2D.cpp
| ... | ... | @@ -317,10 +317,10 @@ double GCTAPsf2D::mc(GRan& ran, |
| 317 | 317 | double sum3 = m_sigma3 * m_norm3; |
| 318 | 318 | double sum = sum1 + sum2 + sum3; |
| 319 | 319 | double u = ran.uniform() * sum; |
| 320 | - if (u >= sum2) { | |
| 320 | + if (sum2 > 0.0 && u >= sum2) { | |
| 321 | 321 | sigma = m_sigma3; |
| 322 | 322 | } |
| 323 | - else if (u >= sum1) { | |
| 323 | + else if (sum1 > 0.0 && u >= sum1) { | |
| 324 | 324 | sigma = m_sigma2; |
| 325 | 325 | } |
| 326 | 326 | |
| ... | ... | @@ -383,12 +383,27 @@ std::string GCTAPsf2D::print(const GChatter& chatter) const |
| 383 | 383 | // Continue only if chatter is not silent |
| 384 | 384 | if (chatter != SILENT) { |
| 385 | 385 | |
| 386 | + // Compute energy boundaries in TeV | |
| 387 | + double emin = m_psf.axis_lo(0,0); | |
| 388 | + double emax = m_psf.axis_hi(0,m_psf.axis(0)-1); | |
| 389 | + | |
| 390 | + // Compute offset angle boundaries in deg | |
| 391 | + double omin = m_psf.axis_lo(1,0); | |
| 392 | + double omax = m_psf.axis_hi(1,m_psf.axis(1)-1); | |
| 393 | + | |
| 386 | 394 | // Append header |
| 387 | 395 | result.append("=== GCTAPsf2D ==="); |
| 388 | 396 | |
| 389 | 397 | // Append information |
| 390 | 398 | result.append("\n"+gammalib::parformat("Filename")+m_filename); |
| 391 | - result.append("\n"+m_psf.print(chatter)); | |
| 399 | + result.append("\n"+gammalib::parformat("Number of energy bins") + | |
| 400 | + gammalib::str(m_psf.axis(0))); | |
| 401 | + result.append("\n"+gammalib::parformat("Number of offset bins") + | |
| 402 | + gammalib::str(m_psf.axis(1))); | |
| 403 | + result.append("\n"+gammalib::parformat("Log10(Energy) range")); | |
| 404 | + result.append(gammalib::str(emin)+" - "+gammalib::str(emax)+" TeV"); | |
| 405 | + result.append("\n"+gammalib::parformat("Offset angle range")); | |
| 406 | + result.append(gammalib::str(omin)+" - "+gammalib::str(omax)+" deg"); | |
| 392 | 407 | |
| 393 | 408 | } // endif: chatter was not silent |
| 394 | 409 | ... | ... |