Commit 63da1bf728959b6a09522756afc3b1c9fff0facf

Authored by Jürgen Knödlseder
1 parent 6b3dbe76

Add information about flux and normalization in ctobssim log file.

src/ctobssim/ctobssim.cpp
@@ -773,7 +773,8 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, @@ -773,7 +773,8 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models,
773 // The photon rate is estimated from the model flux 773 // The photon rate is estimated from the model flux
774 // and used to set the duration of the time slice. 774 // and used to set the duration of the time slice.
775 double flux = get_model_flux(model, emin, emax, 775 double flux = get_model_flux(model, emin, emax,
776 - dir, rad); 776 + dir, rad,
  777 + indent, wrklog);
777 double rate = flux * m_area; 778 double rate = flux * m_area;
778 double duration = 1800.0; // default: 1800 sec 779 double duration = 1800.0; // default: 1800 sec
779 if (rate > 0.0) { 780 if (rate > 0.0) {
@@ -787,10 +788,15 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, @@ -787,10 +788,15 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models,
787 } 788 }
788 GTime tslice(duration, "sec"); 789 GTime tslice(duration, "sec");
789 790
  791 + // Skip model if photon rate is 0
  792 + if (rate <= 0.0) {
  793 + continue;
  794 + }
  795 +
790 // Dump photon rate 796 // Dump photon rate
791 if (logNormal()) { 797 if (logNormal()) {
792 *wrklog << gammalib::parformat("Photon rate", indent); 798 *wrklog << gammalib::parformat("Photon rate", indent);
793 - *wrklog << rate << " photons/sec"; 799 + *wrklog << rate << " photons/s";
794 if (model->name().length() > 0) { 800 if (model->name().length() > 0) {
795 *wrklog << " [" << model->name() << "]"; 801 *wrklog << " [" << model->name() << "]";
796 } 802 }
@@ -804,11 +810,11 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models, @@ -804,11 +810,11 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels&amp; models,
804 model->name() : "Unknown"; 810 model->name() : "Unknown";
805 std::string msg = "Photon rate "+ 811 std::string msg = "Photon rate "+
806 gammalib::str(rate)+ 812 gammalib::str(rate)+
807 - " photons/sec for model \""+ 813 + " photons/s for model \""+
808 modnam+"\" exceeds maximum" 814 modnam+"\" exceeds maximum"
809 " allowed photon rate of "+ 815 " allowed photon rate of "+
810 gammalib::str(m_max_rate)+ 816 gammalib::str(m_max_rate)+
811 - " photons/sec. Please check" 817 + " photons/s. Please check"
812 " the model parameters for" 818 " the model parameters for"
813 " model \""+modnam+"\" or" 819 " model \""+modnam+"\" or"
814 " increase the value of the" 820 " increase the value of the"
@@ -984,7 +990,9 @@ double ctobssim::get_model_flux(const GModelSky* model, @@ -984,7 +990,9 @@ double ctobssim::get_model_flux(const GModelSky* model,
984 const GEnergy& emin, 990 const GEnergy& emin,
985 const GEnergy& emax, 991 const GEnergy& emax,
986 const GSkyDir& centre, 992 const GSkyDir& centre,
987 - const double& radius) 993 + const double& radius,
  994 + const int& indent,
  995 + GLog* wrklog)
988 { 996 {
989 // Initialise flux 997 // Initialise flux
990 double flux = 0.0; 998 double flux = 0.0;
@@ -994,6 +1002,24 @@ double ctobssim::get_model_flux(const GModelSky* model, @@ -994,6 +1002,24 @@ double ctobssim::get_model_flux(const GModelSky* model,
994 // cone. 1002 // cone.
995 double norm = model->spatial()->mc_norm(centre, radius); 1003 double norm = model->spatial()->mc_norm(centre, radius);
996 bool use_model = (norm > 0.0) ? true : false; 1004 bool use_model = (norm > 0.0) ? true : false;
  1005 + if (logNormal()) {
  1006 + if (use_model) {
  1007 + *wrklog << gammalib::parformat("Use model", indent);
  1008 + }
  1009 + else {
  1010 + *wrklog << gammalib::parformat("Skip model", indent);
  1011 + }
  1012 + if (model->name().length() > 0) {
  1013 + *wrklog << model->name();
  1014 + }
  1015 + *wrklog << std::endl;
  1016 + *wrklog << gammalib::parformat("Normalization", indent);
  1017 + *wrklog << norm;
  1018 + if (model->name().length() > 0) {
  1019 + *wrklog << " [" << model->name() << "]";
  1020 + }
  1021 + *wrklog << std::endl;
  1022 + }
997 1023
998 // Continue only if model overlaps with simulation region 1024 // Continue only if model overlaps with simulation region
999 if (use_model) { 1025 if (use_model) {
@@ -1034,7 +1060,24 @@ double ctobssim::get_model_flux(const GModelSky* model, @@ -1034,7 +1060,24 @@ double ctobssim::get_model_flux(const GModelSky* model,
1034 1060
1035 // Compute flux within [emin, emax] in model from spectral 1061 // Compute flux within [emin, emax] in model from spectral
1036 // component (units: ph/cm2/s) 1062 // component (units: ph/cm2/s)
1037 - flux = spectral->flux(emin, emax) * norm; 1063 + double flux0 = spectral->flux(emin, emax);
  1064 + flux = flux0 * norm;
  1065 +
  1066 + // Dump flux
  1067 + if (logNormal()) {
  1068 + *wrklog << gammalib::parformat("Flux", indent);
  1069 + *wrklog << flux0;
  1070 + if (model->name().length() > 0) {
  1071 + *wrklog << " [" << model->name() << "]";
  1072 + }
  1073 + *wrklog << " photons/cm2/s" << std::endl;
  1074 + *wrklog << gammalib::parformat("Normalized flux", indent);
  1075 + *wrklog << flux;
  1076 + if (model->name().length() > 0) {
  1077 + *wrklog << " [" << model->name() << "]";
  1078 + }
  1079 + *wrklog << " photons/cm2/s" << std::endl;
  1080 + }
1038 1081
1039 // Free spectral model if required 1082 // Free spectral model if required
1040 if (free_spectral) delete spectral; 1083 if (free_spectral) delete spectral;
src/ctobssim/ctobssim.hpp
@@ -83,7 +83,9 @@ protected: @@ -83,7 +83,9 @@ protected:
83 const GEnergy& emin, 83 const GEnergy& emin,
84 const GEnergy& emax, 84 const GEnergy& emax,
85 const GSkyDir& centre, 85 const GSkyDir& centre,
86 - const double& radius); 86 + const double& radius,
  87 + const int& indent,
  88 + GLog* wrklog = NULL);
87 void simulate_background(GCTAObservation* obs, 89 void simulate_background(GCTAObservation* obs,
88 const GModels& models, 90 const GModels& models,
89 GRan& ran, 91 GRan& ran,