Commit 4d12cc273d1c87b8bfc980f72ca73c6300b854fc
1 parent
906dbb83
Create instance of log10(source energy) before passing the value to the cta_nedisp_kern constructor.
Before, the result of srcEng.log10TeV() was directly passed to the cta_nedisp_kern constructor, which stores only a reference to the value instead of the value. Since srcEng.log10TeV() does not return a reference but a value, it is not assured that the actual memory cell containing the value is still valid. This led to problems on CentOS 7. Now, a local copy is created. In the future we may avoid storing references and store directly the values. This should result in a negligible overhead, as the actual eval() method is called multiple times. We may still store references for large objects, but at least for simple arguments we should store by value.
Showing
1 changed file
with
4 additions
and
1 deletions
inst/cta/src/GCTAResponseIrf.cpp
| @@ -2902,9 +2902,12 @@ double GCTAResponseIrf::nedisp(const GSkyDir& srcDir, | @@ -2902,9 +2902,12 @@ double GCTAResponseIrf::nedisp(const GSkyDir& srcDir, | ||
| 2902 | double e_log_min = emin.log10TeV(); | 2902 | double e_log_min = emin.log10TeV(); |
| 2903 | double e_log_max = emax.log10TeV(); | 2903 | double e_log_max = emax.log10TeV(); |
| 2904 | 2904 | ||
| 2905 | + // Get log10 of source energy | ||
| 2906 | + double logEsrc = srcEng.log10TeV(); | ||
| 2907 | + | ||
| 2905 | // Setup integration function | 2908 | // Setup integration function |
| 2906 | cta_nedisp_kern integrand(*this, | 2909 | cta_nedisp_kern integrand(*this, |
| 2907 | - srcEng.log10TeV(), | 2910 | + logEsrc, |
| 2908 | theta, | 2911 | theta, |
| 2909 | phi, | 2912 | phi, |
| 2910 | zenith, | 2913 | zenith, |