Commit d7f924cab314699840907c0fafcf25ba19b09917
1 parent
794678a8
Enhance logging information in ctobssim. Skip also source models from which no c…
…ontribution is expected.
Showing
2 changed files
with
52 additions
and
7 deletions
src/ctobssim/ctobssim.cpp
| ... | ... | @@ -773,7 +773,8 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, |
| 773 | 773 | // The photon rate is estimated from the model flux |
| 774 | 774 | // and used to set the duration of the time slice. |
| 775 | 775 | double flux = get_model_flux(model, emin, emax, |
| 776 | - dir, rad); | |
| 776 | + dir, rad, | |
| 777 | + indent, wrklog); | |
| 777 | 778 | double rate = flux * m_area; |
| 778 | 779 | double duration = 1800.0; // default: 1800 sec |
| 779 | 780 | if (rate > 0.0) { |
| ... | ... | @@ -787,10 +788,15 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, |
| 787 | 788 | } |
| 788 | 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 | 796 | // Dump photon rate |
| 791 | 797 | if (logNormal()) { |
| 792 | 798 | *wrklog << gammalib::parformat("Photon rate", indent); |
| 793 | - *wrklog << rate << " photons/sec"; | |
| 799 | + *wrklog << rate << " photons/s"; | |
| 794 | 800 | if (model->name().length() > 0) { |
| 795 | 801 | *wrklog << " [" << model->name() << "]"; |
| 796 | 802 | } |
| ... | ... | @@ -804,11 +810,11 @@ void ctobssim::simulate_source(GCTAObservation* obs, const GModels& models, |
| 804 | 810 | model->name() : "Unknown"; |
| 805 | 811 | std::string msg = "Photon rate "+ |
| 806 | 812 | gammalib::str(rate)+ |
| 807 | - " photons/sec for model \""+ | |
| 813 | + " photons/s for model \""+ | |
| 808 | 814 | modnam+"\" exceeds maximum" |
| 809 | 815 | " allowed photon rate of "+ |
| 810 | 816 | gammalib::str(m_max_rate)+ |
| 811 | - " photons/sec. Please check" | |
| 817 | + " photons/s. Please check" | |
| 812 | 818 | " the model parameters for" |
| 813 | 819 | " model \""+modnam+"\" or" |
| 814 | 820 | " increase the value of the" |
| ... | ... | @@ -984,7 +990,9 @@ double ctobssim::get_model_flux(const GModelSky* model, |
| 984 | 990 | const GEnergy& emin, |
| 985 | 991 | const GEnergy& emax, |
| 986 | 992 | const GSkyDir& centre, |
| 987 | - const double& radius) | |
| 993 | + const double& radius, | |
| 994 | + const int& indent, | |
| 995 | + GLog* wrklog) | |
| 988 | 996 | { |
| 989 | 997 | // Initialise flux |
| 990 | 998 | double flux = 0.0; |
| ... | ... | @@ -994,6 +1002,24 @@ double ctobssim::get_model_flux(const GModelSky* model, |
| 994 | 1002 | // cone. |
| 995 | 1003 | double norm = model->spatial()->mc_norm(centre, radius); |
| 996 | 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 | 1024 | // Continue only if model overlaps with simulation region |
| 999 | 1025 | if (use_model) { |
| ... | ... | @@ -1034,7 +1060,24 @@ double ctobssim::get_model_flux(const GModelSky* model, |
| 1034 | 1060 | |
| 1035 | 1061 | // Compute flux within [emin, emax] in model from spectral |
| 1036 | 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 | 1082 | // Free spectral model if required |
| 1040 | 1083 | if (free_spectral) delete spectral; | ... | ... |
src/ctobssim/ctobssim.hpp
| ... | ... | @@ -83,7 +83,9 @@ protected: |
| 83 | 83 | const GEnergy& emin, |
| 84 | 84 | const GEnergy& emax, |
| 85 | 85 | const GSkyDir& centre, |
| 86 | - const double& radius); | |
| 86 | + const double& radius, | |
| 87 | + const int& indent, | |
| 88 | + GLog* wrklog = NULL); | |
| 87 | 89 | void simulate_background(GCTAObservation* obs, |
| 88 | 90 | const GModels& models, |
| 89 | 91 | GRan& ran, | ... | ... |