Commit 3e1c165269698a4e7926b47310a10683c6e97155

Authored by Jürgen Knödlseder
1 parent 8c30c3ff

Do not work on copies of User parameters since this does not bookkeep which para…

…meters were already queried
Showing 1 changed file with 19 additions and 41 deletions
src/support/ctool.cpp
... ... @@ -1025,32 +1025,21 @@ GEbounds ctool::get_ebounds(void)
1025 1025 // Initialise energy boundaries
1026 1026 GEbounds ebounds;
1027 1027  
1028   - // Get minimum energy from "emin" User parameter
1029   - GApplicationPar parmin = (*this)["emin"];
  1028 + // Continue only if "emin" and "emax" has a valid energy value
  1029 + if ((*this)["emin"].is_valid() && (*this)["emax"].is_valid()) {
1030 1030  
1031   - // Continue only if "emin" has a valid energy value
1032   - if (parmin.is_valid()) {
  1031 + // Read minimum and maximum energy parameters in TeV
  1032 + double e_min = (*this)["emin"].real();
  1033 + double e_max = (*this)["emax"].real();
1033 1034  
1034   - // Get maximum energy from "emax" User parameter
1035   - GApplicationPar parmax = (*this)["emax"];
  1035 + // Set energy boundaries
  1036 + GEnergy emin;
  1037 + GEnergy emax;
  1038 + emin.TeV(e_min);
  1039 + emax.TeV(e_max);
  1040 + ebounds.append(emin, emax);
1036 1041  
1037   - // Continue only if "emax" has a valid energy value
1038   - if (parmax.is_valid()) {
1039   -
1040   - // Read minimum and maximum energy parameters in TeV
1041   - double e_min = parmin.real();
1042   - double e_max = parmax.real();
1043   -
1044   - // Set energy boundaries
1045   - GEnergy emin;
1046   - GEnergy emax;
1047   - emin.TeV(e_min);
1048   - emax.TeV(e_max);
1049   - ebounds.append(emin, emax);
1050   -
1051   - } // endif: "emax" parameter was valid
1052   -
1053   - } // endif: "emin" parameter was valid
  1042 + } // endif: "emin" and "emax" parameters were valid
1054 1043  
1055 1044 // Return energy boundaries
1056 1045 return ebounds;
... ... @@ -1072,28 +1061,17 @@ GGti ctool::get_gti(void)
1072 1061 // Initialise Good Time Intervals with CTA reference time
1073 1062 GGti gti(m_cta_ref);
1074 1063  
1075   - // Get minimum time from "tmin" User parameter
1076   - GApplicationPar parmin = (*this)["tmin"];
1077   -
1078 1064 // Continue only if "tmin" has a valid time value
1079   - if (parmin.is_valid()) {
1080   -
1081   - // Get maximum time from "tmax" User parameter
1082   - GApplicationPar parmax = (*this)["tmax"];
1083   -
1084   - // Continue only if "tmax" has a valid time value
1085   - if (parmax.is_valid()) {
1086   -
1087   - // Get minimum and maximum time for CTA time reference
1088   - GTime tmin = parmin.time(m_cta_ref);
1089   - GTime tmax = parmax.time(m_cta_ref);
  1065 + if ((*this)["tmin"].is_valid() && (*this)["tmax"].is_valid()) {
1090 1066  
1091   - // Append GTI
1092   - gti.append(tmin, tmax);
  1067 + // Get minimum and maximum time for CTA time reference
  1068 + GTime tmin = (*this)["tmin"].time(m_cta_ref);
  1069 + GTime tmax = (*this)["tmax"].time(m_cta_ref);
1093 1070  
1094   - } // endif: "tmax" parameter was valid
  1071 + // Append GTI
  1072 + gti.append(tmin, tmax);
1095 1073  
1096   - } // endif: "tmin" parameter was valid
  1074 + } // endif: "tmin" and "tmax" parameters were valid
1097 1075  
1098 1076 // Return GTI
1099 1077 return gti;
... ...