Commit df92d1f37e2b8ef0c515096754cca3561e8c29ab

Authored by knodlseder
1 parent 87d3fa35

Correctly handle deadtime correction also for observations that are passed in the container.

Instead of using the m_deadc member we use now the GObservation::deadc method to access the deadtime correction factor.
Showing 1 changed file with 10 additions and 5 deletions
src/ctobssim/ctobssim.cpp
... ... @@ -636,8 +636,9 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models)
636 636 for (int i = 0; i < photons.size(); ++i) {
637 637  
638 638 // Apply deadtime correction
639   - if (m_deadc < 1.0) {
640   - if (m_ran.uniform() > m_deadc) {
  639 + double deadc = obs->deadc(photons[i].time());
  640 + if (deadc < 1.0) {
  641 + if (m_ran.uniform() > deadc) {
641 642 ndeadc++;
642 643 continue;
643 644 }
... ... @@ -781,9 +782,13 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models)
781 782 // Append events
782 783 for (int k = 0; k < list->size(); k++) {
783 784  
  785 + // Get event pointer
  786 + GCTAEventAtom* event = (*list)[k];
  787 +
784 788 // Apply deadtime correction
785   - if (m_deadc < 1.0) {
786   - if (m_ran.uniform() > m_deadc) {
  789 + double deadc = obs->deadc(event->time());
  790 + if (deadc < 1.0) {
  791 + if (m_ran.uniform() > deadc) {
787 792 ndeadc++;
788 793 continue;
789 794 }
... ... @@ -793,7 +798,7 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models)
793 798 nevents++;
794 799  
795 800 // Append event
796   - events->append(*((*list)[k]));
  801 + events->append(*event);
797 802  
798 803 } // endfor: looped over all events
799 804  
... ...