IAP GITLAB

Skip to content
Snippets Groups Projects
Commit ac396934 authored by Marvin Gottowik's avatar Marvin Gottowik
Browse files

Merge branch '622-tweak-frequency-of-print-outs-in-stackinspector' into 'master'

Resolve "tweak frequency of print outs in StackInspector"

Closes #622

See merge request !647
parents af4659cd 59e4dd2c
No related branches found
No related tags found
1 merge request!647Resolve "tweak frequency of print outs in StackInspector"
Pipeline #14339 passed
...@@ -58,51 +58,60 @@ namespace corsika { ...@@ -58,51 +58,60 @@ namespace corsika {
if ((E0_ - Etot) < dE_threshold_) return; if ((E0_ - Etot) < dE_threshold_) return;
std::chrono::system_clock::time_point const now = std::chrono::system_clock::now(); // limit number of printouts
std::chrono::duration<double> const elapsed_seconds = now - StartTime_; // seconds if (PrintoutCounter_ < MaxNumberOfPrintouts_) {
std::chrono::system_clock::time_point const now = std::chrono::system_clock::now();
// Select reference times and energies using either the true start std::chrono::duration<double> const elapsed_seconds = now - StartTime_; // seconds
// or the delayed start to avoid counting overhead in ETA
bool const usePostVals = (energyPostInit_ != HEPEnergyType::zero()); // Select reference times and energies using either the true start
auto const dE = (usePostVals ? energyPostInit_ : E0_) - Etot; // or the delayed start to avoid counting overhead in ETA
std::chrono::duration<double> const usedSeconds = now - timePostInit_; bool const usePostVals = (energyPostInit_ != HEPEnergyType::zero());
double const dT = usedSeconds.count(); auto const dE = (usePostVals ? energyPostInit_ : E0_) - Etot;
std::chrono::duration<double> const usedSeconds = now - timePostInit_;
double const progress = (E0_ - Etot) / E0_; double const dT = usedSeconds.count();
// for printout
std::time_t const now_time = std::chrono::system_clock::to_time_t(now); double const progress = (E0_ - Etot) / E0_;
// for printout
double const ETA_seconds = (1.0 - progress) * dT * (E0_ / dE); std::time_t const now_time = std::chrono::system_clock::to_time_t(now);
std::chrono::system_clock::time_point const ETA =
now + std::chrono::seconds((int)ETA_seconds); double const ETA_seconds = (1.0 - progress) * dT * (E0_ / dE);
std::chrono::system_clock::time_point const ETA =
// for printout now + std::chrono::seconds((int)ETA_seconds);
std::time_t const ETA_time = std::chrono::system_clock::to_time_t(ETA);
std::time_t const ETA_time = std::chrono::system_clock::to_time_t(ETA);
int const yday0 = std::localtime(&now_time)->tm_yday;
int const yday1 = std::localtime(&ETA_time)->tm_yday; int const yday0 = std::localtime(&now_time)->tm_yday;
int const dyday = yday1 - yday0; int const yday1 = std::localtime(&ETA_time)->tm_yday;
int const dyday = yday1 - yday0;
std::stringstream ETA_string;
ETA_string << std::put_time(std::localtime(&ETA_time), "%T %Z"); std::stringstream ETA_string;
ETA_string << std::put_time(std::localtime(&ETA_time), "%T %Z");
CORSIKA_LOG_INFO(
"StackInspector: " CORSIKA_LOG_DEBUG(
" time={}" "StackInspector: "
", running={:.1f} seconds" " time={}"
" ( {:.1f}%)" ", running={:.1f} seconds"
", nStep={}" " ( {:.1f}%)"
", stackSize={}" ", nStep={}"
", Estack={:.1f} GeV" ", stackSize={}"
", ETA={}{}", ", Estack={:.1f} GeV"
std::put_time(std::localtime(&now_time), "%T %Z"), elapsed_seconds.count(), ", ETA={}{}",
(progress * 100), getStep(), vS.getSize(), Etot / 1_GeV, std::put_time(std::localtime(&now_time), "%T %Z"), elapsed_seconds.count(),
(dyday == 0 ? "" : fmt::format("+{}d ", dyday)), ETA_string.str()); (progress * 100), getStep(), vS.getSize(), Etot / 1_GeV,
(dyday == 0 ? "" : fmt::format("+{}d ", dyday)), ETA_string.str());
// Change reference time once the shower has begin (avoid counting overhead time)
if (progress > 0.02 && energyPostInit_ == HEPEnergyType::zero()) { PrintoutCounter_++;
energyPostInit_ = Etot;
timePostInit_ = std::chrono::system_clock::now(); if (PrintoutCounter_ == MaxNumberOfPrintouts_) {
CORSIKA_LOG_DEBUG("StackInspector reached allowed maximum of {} lines printout",
MaxNumberOfPrintouts_);
}
// Change reference time once the shower has begin (avoid counting overhead time)
if (progress > 0.02 && energyPostInit_ == HEPEnergyType::zero()) {
energyPostInit_ = Etot;
timePostInit_ = std::chrono::system_clock::now();
}
} }
} }
......
...@@ -46,6 +46,8 @@ namespace corsika { ...@@ -46,6 +46,8 @@ namespace corsika {
private: private:
bool ReportStack_; bool ReportStack_;
int PrintoutCounter_ = 0;
const int MaxNumberOfPrintouts_ = 10;
HEPEnergyType E0_; HEPEnergyType E0_;
const HEPEnergyType dE_threshold_ = 1_eV; const HEPEnergyType dE_threshold_ = 1_eV;
std::chrono::system_clock::time_point StartTime_; std::chrono::system_clock::time_point StartTime_;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment