Commit 485abe085fb3ad98b538b4e4d6264423f89dd52e

Authored by knodlseder
1 parent d3fa9b00

Remove explicit deadtime correction as this is now done in the GCTAResponse::mc …

…and GCTAModelRadialAcceptance::mc method.
Showing 1 changed file with 9 additions and 49 deletions
src/ctobssim/ctobssim.cpp
@@ -492,8 +492,6 @@ void ctobssim::set_list(GCTAObservation* obs) @@ -492,8 +492,6 @@ void ctobssim::set_list(GCTAObservation* obs)
492 * @param[in] obs Pointer on CTA observation. 492 * @param[in] obs Pointer on CTA observation.
493 * @param[in] photons Photon list. 493 * @param[in] photons Photon list.
494 * 494 *
495 - * @exception GCTAException::no_pointing  
496 - * No valid pointing found in CTA observation  
497 * @exception GCTAException::no_response 495 * @exception GCTAException::no_response
498 * No valid response found in CTA observation 496 * No valid response found in CTA observation
499 * 497 *
@@ -513,15 +511,6 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models) @@ -513,15 +511,6 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models)
513 // Continue only if observation pointer is valid 511 // Continue only if observation pointer is valid
514 if (obs != NULL) { 512 if (obs != NULL) {
515 513
516 - // Get pointer on CTA pointing. As we have no time dependent  
517 - // pointings implement we just determine the pointing from the  
518 - // beginning of the observation. Throw an exception if the pointing  
519 - // is not defined.  
520 - GCTAPointing* pnt = obs->pointing();  
521 - if (pnt == NULL) {  
522 - throw GCTAException::no_pointing(G_SIMULATE_SOURCE);  
523 - }  
524 -  
525 // Get pointer on CTA response. Throw an exception if the response 514 // Get pointer on CTA response. Throw an exception if the response
526 // is not defined. 515 // is not defined.
527 GCTAResponse* rsp = obs->response(); 516 GCTAResponse* rsp = obs->response();
@@ -607,7 +596,6 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models) @@ -607,7 +596,6 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models)
607 596
608 // Initialise cumulative photon counters 597 // Initialise cumulative photon counters
609 int nphotons = 0; 598 int nphotons = 0;
610 - int ndeadc = 0;  
611 599
612 // Loop over time slices 600 // Loop over time slices
613 while (tstart < tmax) { 601 while (tstart < tmax) {
@@ -635,20 +623,15 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models) @@ -635,20 +623,15 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models)
635 // Simulate events from photons 623 // Simulate events from photons
636 for (int i = 0; i < photons.size(); ++i) { 624 for (int i = 0; i < photons.size(); ++i) {
637 625
638 - // Apply deadtime correction  
639 - double deadc = obs->deadc(photons[i].time());  
640 - if (deadc < 1.0) {  
641 - if (m_ran.uniform() > deadc) {  
642 - ndeadc++;  
643 - continue;  
644 - }  
645 - }  
646 -  
647 // Increment photon counter 626 // Increment photon counter
648 nphotons++; 627 nphotons++;
649 628
650 - // Simulate event  
651 - GCTAEventAtom* event = rsp->mc(m_area, photons[i], *pnt, m_ran); 629 + // Simulate event. Note that this method
  630 + // includes the deadtime correction.
  631 + GCTAEventAtom* event = rsp->mc(m_area,
  632 + photons[i],
  633 + *obs,
  634 + m_ran);
652 if (event != NULL) { 635 if (event != NULL) {
653 events->append(*event); 636 events->append(*event);
654 delete event; 637 delete event;
@@ -678,12 +661,6 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models) @@ -678,12 +661,6 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models)
678 log << " [" << model->name() << "]"; 661 log << " [" << model->name() << "]";
679 } 662 }
680 log << std::endl; 663 log << std::endl;
681 - log << parformat("MC photons during deadtime");  
682 - log << str(ndeadc);  
683 - if (model->name().length() > 0) {  
684 - log << " [" << model->name() << "]";  
685 - }  
686 - log << std::endl;  
687 log << parformat("MC source events"); 664 log << parformat("MC source events");
688 log << str(events->size()); 665 log << str(events->size());
689 if (model->name().length() > 0) { 666 if (model->name().length() > 0) {
@@ -769,34 +746,19 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models) @@ -769,34 +746,19 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models)
769 // If we have a radial acceptance model then simulate events 746 // If we have a radial acceptance model then simulate events
770 if (model != NULL) { 747 if (model != NULL) {
771 748
772 - // Get simulated event list 749 + // Get simulated event list. Note that this method includes
  750 + // the deadtime correction.
773 GCTAEventList* list = model->mc(*obs, m_ran); 751 GCTAEventList* list = model->mc(*obs, m_ran);
774 752
775 // Reserves space for events 753 // Reserves space for events
776 events->reserve(list->size()+events->size()); 754 events->reserve(list->size()+events->size());
777 755
778 - // Initialise event counters  
779 - int nevents = 0;  
780 - int ndeadc = 0;  
781 -  
782 // Append events 756 // Append events
783 for (int k = 0; k < list->size(); k++) { 757 for (int k = 0; k < list->size(); k++) {
784 758
785 // Get event pointer 759 // Get event pointer
786 GCTAEventAtom* event = (*list)[k]; 760 GCTAEventAtom* event = (*list)[k];
787 761
788 - // Apply deadtime correction  
789 - double deadc = obs->deadc(event->time());  
790 - if (deadc < 1.0) {  
791 - if (m_ran.uniform() > deadc) {  
792 - ndeadc++;  
793 - continue;  
794 - }  
795 - }  
796 -  
797 - // Increment background event counter  
798 - nevents++;  
799 -  
800 // Append event 762 // Append event
801 events->append(*event); 763 events->append(*event);
802 764
@@ -805,9 +767,7 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models) @@ -805,9 +767,7 @@ void ctobssim::simulate_background(GCTAObservation* obs, const GModels&amp; models)
805 // Dump simulation results 767 // Dump simulation results
806 if (logNormal()) { 768 if (logNormal()) {
807 log << parformat("MC background events"); 769 log << parformat("MC background events");
808 - log << str(nevents) << std::endl;  
809 - log << parformat("MC events during deadtime");  
810 - log << str(ndeadc) << std::endl; 770 + log << str(list->size()) << std::endl;
811 } 771 }
812 772
813 // Free event list 773 // Free event list