Bug #1988
CTA event simulation for energy range with zero effective area throws an exception
Status: | Closed | Start date: | 04/05/2017 | |
---|---|---|---|---|
Priority: | High | Due date: | ||
Assigned To: | Eschbach Stefan | % Done: | 100% | |
Category: | - | |||
Target version: | 1.3.0 | |||
Duration: |
Description
If CTA events are simulated for an energy range where the effective area is zero the GModelSpectralNodes::append()
method throws an exception.
The reason is that the code in GCTAModelAeffBackground::mc
GModelSpectralNodes spectral;
for (int i = 0; i < spectral_ebounds.size(); ++i) {
GEnergy energy = spectral_ebounds.elogmean(i);
double intensity = aeff_integral(obs, energy.log10TeV());
double norm = m_spectral->eval(energy, events->tstart());
spectral.append(energy, norm * intensity);
}
does not check whether the product norm * intensity
is positive, which leads to the exception. A test should be added that appends only positive nodes.
The side effect is that the GModelSpectralNodes
object may be empty, which later poses a problem in GModelSpectralNodes::flux
that returns an exception if there are no nodes. Instead, the method should simply return zero.
Recurrence
No recurrence.
History
#1 Updated by Eschbach Stefan over 7 years ago
- Status changed from New to Pull request
- % Done changed from 0 to 50
I implemented a statement to check if “norm*intensity>0” and only appends if this is true.
The missing aeff-entry leads to getting stuck in a do-loop later in the code, because the variable “value” will be zero then.
I fixed this by adding another statement that breaks the loop if there were 100 trys and value still stays zero.
I’m not a 100% sure if this leads to further problems in specific cases, in my case it seems to work now.
Changes are implemented in seschbach/gammalib 1988-Change-Effective-Area
#2 Updated by Knödlseder Jürgen over 7 years ago
- Status changed from Pull request to Closed
- Assigned To set to Eschbach Stefan
- % Done changed from 50 to 100
Code merged into devel
.