diff --git a/corsika/detail/modules/StackInspector.inl b/corsika/detail/modules/StackInspector.inl index 24a356fcb749f90796db5920bef351dee2d10ac9..06705ac8f6be0892750e8c3942e4710d273b6dc8 100644 --- a/corsika/detail/modules/StackInspector.inl +++ b/corsika/detail/modules/StackInspector.inl @@ -61,28 +61,44 @@ namespace corsika { if (dE < dE_threshold_) return; double const progress = dE / E0_; - double const eta_seconds = elapsed_seconds.count() / progress; std::time_t const start_time = std::chrono::system_clock::to_time_t(StartTime_); - std::time_t const eta_time = std::chrono::system_clock::to_time_t( - StartTime_ + std::chrono::seconds((int)eta_seconds)); - - int const yday0 = std::localtime(&start_time)->tm_yday; - int const yday1 = std::localtime(&eta_time)->tm_yday; - int const dyday = yday1 - yday0; - - CORSIKA_LOG_INFO( - "StackInspector: " - " time={}" - ", running={} seconds" - " ( {:.1f}%)" - ", nStep={}" - ", stackSize={}" - ", Estack={} GeV" - ", ETA={}{}", - std::put_time(std::localtime(&now_time), "%T"), elapsed_seconds.count(), - (progress * 100), getStep(), vS.getSize(), Etot / 1_GeV, - (dyday == 0 ? "" : fmt::format("+{}d ", dyday)), - std::put_time(std::localtime(&eta_time), "%T")); + + if (progress > 0) { + + double const eta_seconds = elapsed_seconds.count() / progress; + std::time_t const eta_time = std::chrono::system_clock::to_time_t( + StartTime_ + std::chrono::seconds((int)eta_seconds)); + + int const yday0 = std::localtime(&start_time)->tm_yday; + int const yday1 = std::localtime(&eta_time)->tm_yday; + int const dyday = yday1 - yday0; + + CORSIKA_LOG_INFO( + "StackInspector: " + " time={}" + ", running={} seconds" + " ( {:.1f}%)" + ", nStep={}" + ", stackSize={}" + ", Estack={} GeV" + ", ETA={}{}", + std::put_time(std::localtime(&now_time), "%T"), elapsed_seconds.count(), + (progress * 100), getStep(), vS.getSize(), Etot / 1_GeV, + (dyday == 0 ? "" : fmt::format("+{}d ", dyday)), + std::put_time(std::localtime(&eta_time), "%T")); + } else { + CORSIKA_LOG_INFO( + "StackInspector: " + " time={}" + ", running={} seconds" + " ( {:.1f}%)" + ", nStep={}" + ", stackSize={}" + ", Estack={} GeV" + ", ETA={}{}", + std::put_time(std::localtime(&now_time), "%T"), elapsed_seconds.count(), + (progress * 100), getStep(), vS.getSize(), Etot / 1_GeV, "---", "---"); + } } } // namespace corsika diff --git a/corsika/detail/modules/conex/CONEXhybrid.inl b/corsika/detail/modules/conex/CONEXhybrid.inl index 3a8109f631d41275567bda02e713e3d47b404a8f..1e84975f4c6904351f5be1af56c190e5a1eab156 100644 --- a/corsika/detail/modules/conex/CONEXhybrid.inl +++ b/corsika/detail/modules/conex/CONEXhybrid.inl @@ -28,6 +28,9 @@ namespace corsika { : center_{center} , showerAxis_{showerAxis} , groundDist_{groundDist} + , injectionHeight_{injectionHeight} + , primaryEnergy_{primaryEnergy} + , primaryPDG_{primaryPDG} , showerCore_{showerAxis_.getStart() + showerAxis_.getDirection() * groundDist_} , conexObservationCS_{std::invoke([&]() { auto const& c8cs = center.getCoordinateSystem(); @@ -92,8 +95,11 @@ namespace corsika { particleListMode, #endif configPath.c_str(), configPath.size()); + } + + inline void CONEXhybrid::init() { - double eprima = primaryEnergy / 1_GeV; + double eprima = primaryEnergy_ / 1_GeV; // set phi, theta Vector<length_d> ez{conexObservationCS_, {0._m, 0._m, -1_m}}; @@ -111,7 +117,7 @@ namespace corsika { "; phi (deg) = {}", theta, phi); - int ipart = static_cast<int>(primaryPDG); + int ipart = static_cast<int>(primaryPDG_); auto rng = RNGManager<>::getInstance().getRandomStream("conex"); double dimpact = 0.; // valid only if shower core is fixed on the observation plane; @@ -120,7 +126,7 @@ namespace corsika { std::array<int, 3> ioseed{static_cast<int>(rng()), static_cast<int>(rng()), static_cast<int>(rng())}; - double xminp = injectionHeight / 1_m; + double xminp = injectionHeight_ / 1_m; ::conex::conexrun_(ipart, eprima, theta, phi, xminp, dimpact, ioseed.data()); } diff --git a/corsika/modules/conex/CONEXhybrid.hpp b/corsika/modules/conex/CONEXhybrid.hpp index 2f0b80873dfa4109202f1a01cb11ff571c988cfd..aae3e0f99b528c92cd7638d8ede11e1e40680783 100644 --- a/corsika/modules/conex/CONEXhybrid.hpp +++ b/corsika/modules/conex/CONEXhybrid.hpp @@ -29,11 +29,29 @@ namespace corsika { CONEXhybrid(Point center, ShowerAxis const& showerAxis, LengthType groundDist, LengthType injectionHeight, HEPEnergyType primaryEnergy, PDGCode pdg); + /** + * Main entry point to pass new particle data towards CONEX. If a + * particles is selected for CONEX, it is removed from the CORSIKA + * 8 stack. + */ template <typename TStackView> void doSecondaries(TStackView&); + /** + * init currently needs to be called to initializa a new + * event. All tables are cleared, etc. + */ + void init(); + + /** + * Cascade equations are solved basoned on the data in the tables + */ void solveCE(); + /** + * Internal function to fill particle data inside CONEX + * tables. Only e.m. particles are selected right now. + */ bool addParticle(Code pid, HEPEnergyType energy, HEPEnergyType mass, Point const& position, Vector<dimensionless_d> const& direction, TimeType t); @@ -51,8 +69,11 @@ namespace corsika { Point const center_; //!< center of CONEX Earth ShowerAxis const& showerAxis_; - LengthType groundDist_; //!< length from injection point to shower core - Point const showerCore_; //!< shower core + LengthType groundDist_; //!< length from injection point to shower core + LengthType injectionHeight_; //!< starting height of primary particle + HEPEnergyType primaryEnergy_; //!< primary particle energy + PDGCode primaryPDG_; //!< primary particle PDG + Point const showerCore_; //!< shower core CoordinateSystemPtr const conexObservationCS_; //!< CONEX observation frame DirectionVector const x_sf_, y_sf_; //!< unit vectors of CONEX shower frame, z_sf is shower axis direction