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,8 +636,9 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models)
636 for (int i = 0; i < photons.size(); ++i) { 636 for (int i = 0; i < photons.size(); ++i) {
637 637
638 // Apply deadtime correction 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 ndeadc++; 642 ndeadc++;
642 continue; 643 continue;
643 } 644 }
@@ -781,9 +782,13 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models) @@ -781,9 +782,13 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models)
781 // Append events 782 // Append events
782 for (int k = 0; k < list->size(); k++) { 783 for (int k = 0; k < list->size(); k++) {
783 784
  785 + // Get event pointer
  786 + GCTAEventAtom* event = (*list)[k];
  787 +
784 // Apply deadtime correction 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 ndeadc++; 792 ndeadc++;
788 continue; 793 continue;
789 } 794 }
@@ -793,7 +798,7 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models) @@ -793,7 +798,7 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models)
793 nevents++; 798 nevents++;
794 799
795 // Append event 800 // Append event
796 - events->append(*((*list)[k])); 801 + events->append(*event);
797 802
798 } // endfor: looped over all events 803 } // endfor: looped over all events
799 804