From 5c0e767e4ad5623fb1332f2bb7e2e196f0f02035 Mon Sep 17 00:00:00 2001 From: F Zotter Date: Tue, 24 Sep 2024 16:51:58 +0200 Subject: [PATCH] remove startEventId --- .../rayx-core/src/Shader/DynamicElements.cpp | 2 +- Intern/rayx-core/src/Shader/Helper.cpp | 9 ++------ Intern/rayx-core/src/Shader/InvocationState.h | 2 +- Intern/rayx-core/src/Tracer/DeviceTracer.h | 4 ++-- Intern/rayx-core/src/Tracer/SimpleTracer.h | 11 ++++----- Intern/rayx-core/src/Tracer/Tracer.cpp | 5 ++-- Intern/rayx-core/src/Tracer/Tracer.h | 3 +-- Intern/rayx-core/src/Writer/CSVWriter.cpp | 4 ++-- Intern/rayx-core/src/Writer/CSVWriter.h | 2 +- Intern/rayx-core/src/Writer/H5Writer.cpp | 19 +++++---------- Intern/rayx-core/src/Writer/H5Writer.h | 6 ++--- Intern/rayx-ui/src/Application.cpp | 2 +- Intern/rayx-ui/src/RayProcessing.cpp | 6 ++--- Intern/rayx-ui/src/RayProcessing.h | 2 +- Intern/rayx-ui/src/Scene.cpp | 4 ++-- Intern/rayx-ui/src/Simulator.cpp | 20 ++++------------ Intern/rayx-ui/src/Simulator.h | 1 - Intern/rayx-ui/src/UserInterface/Settings.h | 8 ++----- .../rayx-ui/src/UserInterface/UIHandler.cpp | 4 +--- Intern/rayx/src/CommandParser.h | 2 -- Intern/rayx/src/TerminalApp.cpp | 23 ++++++------------- Intern/rayx/src/TerminalApp.h | 2 +- 22 files changed, 47 insertions(+), 94 deletions(-) diff --git a/Intern/rayx-core/src/Shader/DynamicElements.cpp b/Intern/rayx-core/src/Shader/DynamicElements.cpp index 92c86ce3d..fc4e82745 100644 --- a/Intern/rayx-core/src/Shader/DynamicElements.cpp +++ b/Intern/rayx-core/src/Shader/DynamicElements.cpp @@ -71,7 +71,7 @@ void dynamicElements(int gid, InvState& inv) { } // store recorded events count - auto eventsCount = static_cast(inv.nextEventIndex - inv.pushConstants.startEventID); + auto eventsCount = static_cast(inv.nextEventIndex); eventsCount = std::max(0, std::min(static_cast(inv.pushConstants.maxEvents), eventsCount)); inv.outputRayCounts[gid] = eventsCount; } diff --git a/Intern/rayx-core/src/Shader/Helper.cpp b/Intern/rayx-core/src/Shader/Helper.cpp index 85f11b610..2367419d1 100644 --- a/Intern/rayx-core/src/Shader/Helper.cpp +++ b/Intern/rayx-core/src/Shader/Helper.cpp @@ -11,7 +11,7 @@ void init(InvState& inv) { // TODO(Sven): dont waste time with initializing // sets all output rays controlled by this shader call to ETYPE_UNINIT. - for (uint32_t i = uint32_t(inv.pushConstants.startEventID); i < inv.pushConstants.maxEvents; i++) { + for (uint32_t i = uint32_t(0); i < inv.pushConstants.maxEvents; i++) { inv.outputRays[output_index(i, inv)].m_eventType = ETYPE_UNINIT; } inv.nextEventIndex = 0; @@ -32,18 +32,13 @@ uint64_t rayId(InvState& inv) { return uint64_t(inv.pushConstants.rayIdStart) + // Typically used as `outputRays[output_index(i)]`. RAYX_FN_ACC uint32_t output_index(uint32_t i, InvState& inv) { - return uint32_t(inv.globalInvocationId) * uint32_t(inv.pushConstants.maxEvents - inv.pushConstants.startEventID) + i - - uint32_t(inv.pushConstants.startEventID); + return uint32_t(inv.globalInvocationId) * uint32_t(inv.pushConstants.maxEvents) + i; } // record an event and store it in the next free spot in outputRays. // `r` will typically be ray, or some related ray. RAYX_FN_ACC void recordEvent(Ray r, double w, InvState& inv) { - if (inv.nextEventIndex < inv.pushConstants.startEventID) { - inv.nextEventIndex += 1; - return; - } if (inv.finalized) { return; } diff --git a/Intern/rayx-core/src/Shader/InvocationState.h b/Intern/rayx-core/src/Shader/InvocationState.h index 1d249277d..9dfc45353 100644 --- a/Intern/rayx-core/src/Shader/InvocationState.h +++ b/Intern/rayx-core/src/Shader/InvocationState.h @@ -16,7 +16,7 @@ struct PushConstants { // TODO(Jannis): PushConstants is not an expressive name double randomSeed; double maxEvents; double sequential; - double startEventID; + //double missing? }; struct _debug_struct { diff --git a/Intern/rayx-core/src/Tracer/DeviceTracer.h b/Intern/rayx-core/src/Tracer/DeviceTracer.h index 494da829a..82ab7fdf7 100644 --- a/Intern/rayx-core/src/Tracer/DeviceTracer.h +++ b/Intern/rayx-core/src/Tracer/DeviceTracer.h @@ -30,8 +30,8 @@ class RAYX_API DeviceTracer { public: virtual ~DeviceTracer() = default; - virtual BundleHistory trace(const Beamline&, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT = 1, uint32_t maxEvents = 1, - int startEventID = 0) = 0; + virtual BundleHistory trace(const Beamline&, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT = 1, + uint32_t maxEvents = 1) = 0; protected: PushConstants m_pushConstants; diff --git a/Intern/rayx-core/src/Tracer/SimpleTracer.h b/Intern/rayx-core/src/Tracer/SimpleTracer.h index dd1c34d57..fb6904d77 100644 --- a/Intern/rayx-core/src/Tracer/SimpleTracer.h +++ b/Intern/rayx-core/src/Tracer/SimpleTracer.h @@ -48,8 +48,7 @@ class SimpleTracer : public DeviceTracer { public: SimpleTracer(int deviceIndex); - BundleHistory trace(const Beamline&, Sequential sequential, uint64_t maxBatchSize, int getInputRaysThreadCount, uint32_t maxEvents, - int startEventID) override; + BundleHistory trace(const Beamline&, Sequential sequential, uint64_t maxBatchSize, int getInputRaysThreadCount, uint32_t maxEvents) override; private: struct TraceResult { @@ -124,8 +123,7 @@ template SimpleTracer::SimpleTracer(int deviceIndex) : m_deviceIndex(deviceIndex) {} template -BundleHistory SimpleTracer::trace(const Beamline& b, Sequential seq, uint64_t maxBatchSize, int getInputRaysThreadCount, uint32_t maxEvents, - int startEventID) { +BundleHistory SimpleTracer::trace(const Beamline& b, Sequential seq, uint64_t maxBatchSize, int getInputRaysThreadCount, uint32_t maxEvents) { RAYX_PROFILE_FUNCTION_STDOUT(); RAYX_VERB << "maxEvents: " << maxEvents; @@ -153,7 +151,7 @@ BundleHistory SimpleTracer::trace(const Beamline& b, Sequential seq, uint64 auto q = Queue(acc); const auto firstBatchSize = static_cast(glm::min(rays.size(), maxBatchSize)); - const auto maxOutputEventsCount = static_cast(maxBatchSize * (maxEvents - startEventID)); + const auto maxOutputEventsCount = static_cast(maxBatchSize * maxEvents); const auto initialCompactEventsSize = static_cast(maxBatchSize * glm::min(2u, maxEvents)); resizeBufferIfNeeded(q, m_batchOutput.compactEvents, initialCompactEventsSize); resizeBufferIfNeeded(q, m_batchOutput.compactEventCounts, firstBatchSize); @@ -184,8 +182,7 @@ BundleHistory SimpleTracer::trace(const Beamline& b, Sequential seq, uint64 .numRays = (double)rays.size(), .randomSeed = randomSeed, .maxEvents = (double)maxEvents, - .sequential = sequential, - .startEventID = (double)startEventID}; + .sequential = sequential}; const auto inputRays = rays.data() + rayIdStart; transferToBuffer(q, cpu, m_batchInput.rays, inputRays, static_cast(batchSize)); diff --git a/Intern/rayx-core/src/Tracer/Tracer.cpp b/Intern/rayx-core/src/Tracer/Tracer.cpp index 859efa8d3..36aeaa6da 100644 --- a/Intern/rayx-core/src/Tracer/Tracer.cpp +++ b/Intern/rayx-core/src/Tracer/Tracer.cpp @@ -53,9 +53,8 @@ Tracer::Tracer(const DeviceConfig& deviceConfig) { } } -BundleHistory Tracer::trace(const Beamline& beamline, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT, uint32_t maxEvents, - int startEventID) { - return m_deviceTracer->trace(beamline, sequential, max_batch_size, THREAD_COUNT, maxEvents, startEventID); +BundleHistory Tracer::trace(const Beamline& beamline, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT, uint32_t maxEvents) { + return m_deviceTracer->trace(beamline, sequential, max_batch_size, THREAD_COUNT, maxEvents); } /// Get the last event for each ray of the bundle. diff --git a/Intern/rayx-core/src/Tracer/Tracer.h b/Intern/rayx-core/src/Tracer/Tracer.h index 0cfbf1af9..6aadc907e 100644 --- a/Intern/rayx-core/src/Tracer/Tracer.h +++ b/Intern/rayx-core/src/Tracer/Tracer.h @@ -27,8 +27,7 @@ class RAYX_API Tracer { // This will call the trace implementation of a subclass // See `BundleHistory` for information about the return value. // `max_batch_size` corresponds to the maximal number of rays that will be put into `traceRaw` in one batch. - BundleHistory trace(const Beamline&, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT = 1, uint32_t maxEvents = 1, - int startEventID = 0); + BundleHistory trace(const Beamline&, Sequential sequential, uint64_t max_batch_size, int THREAD_COUNT = 1, uint32_t maxEvents = 1); static int defaultMaxEvents(const Beamline* beamline = nullptr); diff --git a/Intern/rayx-core/src/Writer/CSVWriter.cpp b/Intern/rayx-core/src/Writer/CSVWriter.cpp index eb819b64b..b4e2f0c61 100644 --- a/Intern/rayx-core/src/Writer/CSVWriter.cpp +++ b/Intern/rayx-core/src/Writer/CSVWriter.cpp @@ -56,7 +56,7 @@ Cell doubleToCell(double x) { return strToCell(s.c_str()); } -void writeCSV(const RAYX::BundleHistory& hist, const std::string& filename, const Format& format, int startEventID) { +void writeCSV(const RAYX::BundleHistory& hist, const std::string& filename, const Format& format) { std::ofstream file(filename); // write the header of the CSV file: @@ -79,7 +79,7 @@ void writeCSV(const RAYX::BundleHistory& hist, const std::string& filename, cons if (i > 0) { file << DELIMITER; } - double d = format[i].get_double(static_cast(ray_id), static_cast(event_id) + startEventID, event); + double d = format[i].get_double(static_cast(ray_id), static_cast(event_id), event); file << doubleToCell(d).buf; } file << '\n'; diff --git a/Intern/rayx-core/src/Writer/CSVWriter.h b/Intern/rayx-core/src/Writer/CSVWriter.h index ca068619d..70b4cd83a 100644 --- a/Intern/rayx-core/src/Writer/CSVWriter.h +++ b/Intern/rayx-core/src/Writer/CSVWriter.h @@ -8,7 +8,7 @@ #include "Tracer/Tracer.h" #include "Writer/Writer.h" -void RAYX_API writeCSV(const RAYX::BundleHistory&, const std::string& filename, const Format& format, int startEventID = 0); +void RAYX_API writeCSV(const RAYX::BundleHistory&, const std::string& filename, const Format& format); // loadCSV only works for csv files created using FULL_FORMAT. RAYX::BundleHistory RAYX_API loadCSV(const std::string& filename); diff --git a/Intern/rayx-core/src/Writer/H5Writer.cpp b/Intern/rayx-core/src/Writer/H5Writer.cpp index a1cc358a2..0b8977858 100644 --- a/Intern/rayx-core/src/Writer/H5Writer.cpp +++ b/Intern/rayx-core/src/Writer/H5Writer.cpp @@ -20,7 +20,7 @@ int count(const RAYX::BundleHistory& hist) { } // Re-formats `hist` into a bunch of doubles using the format. -std::vector toDoubles(const RAYX::BundleHistory& hist, const Format& format, int startEventID) { +std::vector toDoubles(const RAYX::BundleHistory& hist, const Format& format) { std::vector output; output.reserve(count(hist) * format.size()); @@ -29,7 +29,7 @@ std::vector toDoubles(const RAYX::BundleHistory& hist, const Format& for for (uint32_t event_id = 0; event_id < ray_hist.size(); event_id++) { const RAYX::Ray& event = ray_hist[event_id]; for (uint32_t i = 0; i < format.size(); i++) { - double next = format[i].get_double(ray_id, event_id + startEventID, event); + double next = format[i].get_double(ray_id, event_id, event); output.push_back(next); } } @@ -37,11 +37,10 @@ std::vector toDoubles(const RAYX::BundleHistory& hist, const Format& for return output; } -void writeH5(const RAYX::BundleHistory& hist, const std::string& filename, const Format& format, std::vector elementNames, - int startEventID) { +void writeH5(const RAYX::BundleHistory& hist, const std::string& filename, const Format& format, std::vector elementNames) { HighFive::File file(filename, HighFive::File::ReadWrite | HighFive::File::Create | HighFive::File::Truncate); - auto doubles = toDoubles(hist, format, startEventID); + auto doubles = toDoubles(hist, format); try { // write data @@ -78,15 +77,12 @@ RAYX::BundleHistory fromDoubles(const std::vector& doubles, const Format RAYX::RayHistory rayHist; rayHist.reserve(8); // Estimate: assume 8 events per ray on average - const double startEventID = doubles[1]; const double* data = doubles.data(); for (size_t i = 0; i < numRays; ++i) { const double* rayData = data + i * formatSize; - double eventId = rayData[1]; - - if (eventId == startEventID && !rayHist.empty()) { + if (!rayHist.empty()) { bundleHist.push_back(std::move(rayHist)); rayHist.clear(); rayHist.reserve(8); @@ -120,7 +116,7 @@ RAYX::BundleHistory fromDoubles(const std::vector& doubles, const Format return bundleHist; } -RAYX::BundleHistory raysFromH5(const std::string& filename, const Format& format, std::unique_ptr startEventID) { +RAYX::BundleHistory raysFromH5(const std::string& filename, const Format& format) { RAYX_PROFILE_FUNCTION_STDOUT(); RAYX::BundleHistory rays; @@ -138,9 +134,6 @@ RAYX::BundleHistory raysFromH5(const std::string& filename, const Format& format RAYX_WARN << "No rays found in " << filename; return rays; } - if (startEventID) { - *startEventID = static_cast(doubles[1]); - } rays = fromDoubles(doubles, format); RAYX_VERB << "Loaded " << rays.size() << " rays from " << filename; diff --git a/Intern/rayx-core/src/Writer/H5Writer.h b/Intern/rayx-core/src/Writer/H5Writer.h index a1f732f67..7a4744669 100644 --- a/Intern/rayx-core/src/Writer/H5Writer.h +++ b/Intern/rayx-core/src/Writer/H5Writer.h @@ -8,6 +8,6 @@ #include "Tracer/Tracer.h" #include "Writer/Writer.h" -RAYX_API void writeH5(const RAYX::BundleHistory&, const std::string& filename, const Format& format, std::vector elementNames, - int startEventID); -RAYX_API RAYX::BundleHistory raysFromH5(const std::string& filename, const Format& format, std::unique_ptr startEventID = nullptr); +RAYX_API void writeH5(const RAYX::BundleHistory&, const std::string& filename, const Format& format, std::vector elementNames); + +RAYX_API RAYX::BundleHistory raysFromH5(const std::string& filename, const Format& format); diff --git a/Intern/rayx-ui/src/Application.cpp b/Intern/rayx-ui/src/Application.cpp index f744226cf..302103a46 100644 --- a/Intern/rayx-ui/src/Application.cpp +++ b/Intern/rayx-ui/src/Application.cpp @@ -335,7 +335,7 @@ void Application::loadRays(const std::filesystem::path& rmlPath, const size_t nu RAYX_PROFILE_FUNCTION_STDOUT(); #ifndef NO_H5 std::string rayFilePath = rmlPath.string().substr(0, rmlPath.string().size() - 4) + ".h5"; - m_rays = raysFromH5(rayFilePath, FULL_FORMAT, std::make_unique(m_UIParams.rayInfo.startEventID)); + m_rays = raysFromH5(rayFilePath, FULL_FORMAT); #else std::string rayFilePath = rmlPath.string().substr(0, rmlPath.string().size() - 4) + ".csv"; diff --git a/Intern/rayx-ui/src/RayProcessing.cpp b/Intern/rayx-ui/src/RayProcessing.cpp index 305fcab0a..f1f760555 100644 --- a/Intern/rayx-ui/src/RayProcessing.cpp +++ b/Intern/rayx-ui/src/RayProcessing.cpp @@ -64,7 +64,7 @@ size_t getMaxEvents(const RAYX::BundleHistory& bundleHist) { // Define the type of the filter function std::vector getRays(const RAYX::BundleHistory& rayCache, const RAYX::Beamline& beamline, RayFilterFunction filterFunction, - uint32_t amountOfRays, int startEventID) { + uint32_t amountOfRays) { RAYX_PROFILE_FUNCTION_STDOUT(); std::vector rays; @@ -105,8 +105,8 @@ std::vector getRays(const RAYX::BundleHistory& rayCache, const RAYX::Beaml : (event.m_eventType == RAYX::ETYPE_ABSORBED) ? RED : WHITE; - if (!(isFirstEvent && startEventID > 0)) { - // Only execute if not the first event with startEventID > 0 + if (!(isFirstEvent > 0)) { //deleted starteventID from here, if errors + // Only execute if not the first event with > 0 ColorVertex origin = {rayLastPos, originColor}; ColorVertex point = {worldPos, pointColor}; diff --git a/Intern/rayx-ui/src/RayProcessing.h b/Intern/rayx-ui/src/RayProcessing.h index b6fc833d2..090e5e2a0 100644 --- a/Intern/rayx-ui/src/RayProcessing.h +++ b/Intern/rayx-ui/src/RayProcessing.h @@ -16,7 +16,7 @@ using RayFilterFunction = std::function(const RAYX::BundleHi */ std::vector getRays(const RAYX::BundleHistory& rayCache, const RAYX::Beamline& beamline, RayFilterFunction filterFunction, - uint32_t amountOfRays, int startEventID = 0); + uint32_t amountOfRays); void sortRaysByElement(const RAYX::BundleHistory& rays, std::vector>& sortedRays, size_t numElements); diff --git a/Intern/rayx-ui/src/Scene.cpp b/Intern/rayx-ui/src/Scene.cpp index 82558f389..2406db667 100644 --- a/Intern/rayx-ui/src/Scene.cpp +++ b/Intern/rayx-ui/src/Scene.cpp @@ -64,9 +64,9 @@ void Scene::buildRaysRObject(const RAYX::Beamline& beamline, UIRayInfo& rayInfo, rayInfo.amountOfRays = rayInfo.maxAmountOfRays; } if (!rayInfo.renderAllRays) { - rays = getRays(m_rayCache, beamline, kMeansFilter, (uint32_t)rayInfo.amountOfRays, rayInfo.startEventID); + rays = getRays(m_rayCache, beamline, kMeansFilter, (uint32_t)rayInfo.amountOfRays); } else { - rays = getRays(m_rayCache, beamline, noFilter, (uint32_t)rayInfo.maxAmountOfRays, rayInfo.startEventID); + rays = getRays(m_rayCache, beamline, noFilter, (uint32_t)rayInfo.maxAmountOfRays); } if (!rays.empty()) { // Temporarily aggregate all vertices, then create a single RenderObject diff --git a/Intern/rayx-ui/src/Simulator.cpp b/Intern/rayx-ui/src/Simulator.cpp index 56abfe2e7..bcc967750 100644 --- a/Intern/rayx-ui/src/Simulator.cpp +++ b/Intern/rayx-ui/src/Simulator.cpp @@ -18,17 +18,11 @@ void Simulator::runSimulation() { m_maxEvents = RAYX::Tracer::defaultMaxEvents(&m_Beamline); } - auto rays = m_Tracer->trace(m_Beamline, m_seq, m_max_batch_size, 1, m_maxEvents, m_startEventID); + auto rays = m_Tracer->trace(m_Beamline, m_seq, m_max_batch_size, 1, m_maxEvents); - // check max EventID - uint32_t maxEventID = 0; bool notEnoughEvents = false; for (auto& ray : rays) { - if (ray.size() > (maxEventID)) { - maxEventID = static_cast(ray.size()) + m_startEventID; - } - for (auto& event : ray) { if (event.m_eventType == RAYX::ETYPE_TOO_MANY_EVENTS) { notEnoughEvents = true; @@ -39,12 +33,7 @@ void Simulator::runSimulation() { if (notEnoughEvents) { RAYX_LOG << "Not enough events (" << m_maxEvents << ")! Consider increasing m_maxEvents."; } - if (maxEventID == 0) { - RAYX_LOG << "No events were recorded! If startEventID is set, it might need to be lowered."; - } else if (maxEventID < m_maxEvents) { - RAYX_LOG << "m_maxEvents is set to " << m_maxEvents << " but the maximum event ID is " << maxEventID << ". Consider setting m_maxEvents to " - << maxEventID << " to increase performance."; - } + // Export Rays to external data. std::string path = m_RMLPath.string(); @@ -65,9 +54,9 @@ void Simulator::runSimulation() { path += ".h5"; #ifndef NO_H5 - writeH5(rays, path, fmt, names, m_startEventID); + writeH5(rays, path, fmt, names); #else - writeCSV(rays, path, fmt, m_startEventID); + writeCSV(rays, path, fmt); #endif } @@ -83,7 +72,6 @@ void Simulator::setSimulationParameters(const std::filesystem::path& RMLPath, co m_Beamline = std::move(beamline); m_max_batch_size = simulationInfo.maxBatchSize; m_seq = simulationInfo.sequential ? RAYX::Sequential::Yes : RAYX::Sequential::No; - m_startEventID = simulationInfo.startEventID; m_maxEvents = simulationInfo.maxEvents; if (simulationInfo.fixedSeed) { if (simulationInfo.seed != -1) { diff --git a/Intern/rayx-ui/src/Simulator.h b/Intern/rayx-ui/src/Simulator.h index 4686091e0..e9de2936d 100644 --- a/Intern/rayx-ui/src/Simulator.h +++ b/Intern/rayx-ui/src/Simulator.h @@ -12,7 +12,6 @@ class Simulator { std::vector getAvailableDevices(); private: - uint32_t m_startEventID = 0; uint32_t m_maxEvents = 0; std::filesystem::path m_RMLPath; ///< Path to the RML file diff --git a/Intern/rayx-ui/src/UserInterface/Settings.h b/Intern/rayx-ui/src/UserInterface/Settings.h index d6184700f..534178eee 100644 --- a/Intern/rayx-ui/src/UserInterface/Settings.h +++ b/Intern/rayx-ui/src/UserInterface/Settings.h @@ -22,11 +22,9 @@ struct UIRayInfo { bool renderAllRays; size_t amountOfRays; size_t maxAmountOfRays; - uint32_t startEventID = 0; }; struct UISimulationInfo { - uint32_t startEventID = 0; uint32_t maxEvents = 0; uint32_t maxBatchSize = 100000; bool sequential = false; @@ -35,10 +33,9 @@ struct UISimulationInfo { bool fixedSeed = false; int seed; - UISimulationInfo(int startEventID, int maxEvents, int maxBatchSize, bool sequential, const std::vector& availableDevices, + UISimulationInfo(int maxEvents, int maxBatchSize, bool sequential, const std::vector& availableDevices, int deviceIndex, bool fixedSeed = false, int seed = 0) - : startEventID(startEventID), - maxEvents(maxEvents), + : maxEvents(maxEvents), maxBatchSize(maxBatchSize), sequential(sequential), availableDevices(availableDevices), @@ -83,7 +80,6 @@ struct UIParameters { runSimulation(false), simulationSettingsReady(false), simulationInfo({ - 0, 0, 100000, false, diff --git a/Intern/rayx-ui/src/UserInterface/UIHandler.cpp b/Intern/rayx-ui/src/UserInterface/UIHandler.cpp index ae45b2b9f..bd8d363ed 100644 --- a/Intern/rayx-ui/src/UserInterface/UIHandler.cpp +++ b/Intern/rayx-ui/src/UserInterface/UIHandler.cpp @@ -584,9 +584,7 @@ void UIHandler::showSimulationSettingsPopupWindow(UIParameters& uiParams) { ImGui::Combo("Device", reinterpret_cast(&uiParams.simulationInfo.deviceIndex), &deviceItems[0], static_cast(deviceItems.size())); - // startEventID selection - // ImGui::InputInt("Start Event ID", &uiParams.simulationInfo.startEventID); - + // maxEvents selection ImGui::InputScalar("Max Events", ImGuiDataType_U32, &uiParams.simulationInfo.maxEvents); diff --git a/Intern/rayx/src/CommandParser.h b/Intern/rayx/src/CommandParser.h index c177f5c94..1d1bab17e 100644 --- a/Intern/rayx/src/CommandParser.h +++ b/Intern/rayx/src/CommandParser.h @@ -42,7 +42,6 @@ class CommandParser { std::string m_format = defaultFormatString(); // --format int m_setThreads = 1; // -T (dipolesource) int m_maxEvents = -1; // -m (max events) - int m_startEventID = 0; // -e (start event id) } m_args; static inline void getVersion() { @@ -91,6 +90,5 @@ class CommandParser { {OptionType::INT, "setThreads", "Number of Threads for Lightsource-Parallelization'", &(m_args.m_setThreads)}}, // TODO: understandable description {'m', {OptionType::INT, "maxEvents", "Maximum number of events per ray", &(m_args.m_maxEvents)}}, - {'e', {OptionType::INT, "startEventID", "Start event ID", &(m_args.m_startEventID)}}, }; }; diff --git a/Intern/rayx/src/TerminalApp.cpp b/Intern/rayx/src/TerminalApp.cpp index ae73bbb27..0cfeb1e21 100644 --- a/Intern/rayx/src/TerminalApp.cpp +++ b/Intern/rayx/src/TerminalApp.cpp @@ -67,12 +67,7 @@ void TerminalApp::tracePath(const std::filesystem::path& path) { int maxEvents = (m_CommandParser->m_args.m_maxEvents < 1) ? RAYX::Tracer::defaultMaxEvents(m_Beamline.get()) : m_CommandParser->m_args.m_maxEvents; - if (m_CommandParser->m_args.m_startEventID >= maxEvents) { - RAYX_LOG << "startEventID must be < maxEvents. Setting to maxEvents-1."; - m_CommandParser->m_args.m_startEventID = maxEvents - 1; - } - auto rays = m_Tracer->trace(*m_Beamline, seq, max_batch_size, m_CommandParser->m_args.m_setThreads, maxEvents, - m_CommandParser->m_args.m_startEventID); + auto rays = m_Tracer->trace(*m_Beamline, seq, max_batch_size, m_CommandParser->m_args.m_setThreads, maxEvents); // check max EventID uint32_t maxEventID = 0; @@ -81,7 +76,7 @@ void TerminalApp::tracePath(const std::filesystem::path& path) { RAYX_PROFILE_SCOPE_STDOUT("maxEventID"); for (auto& ray : rays) { if (ray.size() > (maxEventID)) { - maxEventID = ray.size() + m_CommandParser->m_args.m_startEventID; + maxEventID = ray.size(); } for (auto& event : ray) { @@ -95,14 +90,14 @@ void TerminalApp::tracePath(const std::filesystem::path& path) { RAYX_LOG << "Not enough events (" << maxEvents << ")! Consider increasing maxEvents."; } if (maxEventID == 0) { - RAYX_LOG << "No events were recorded! If startEventID is set, it might need to be lowered."; + RAYX_LOG << "No events were recorded!"; } else if (maxEventID < maxEvents) { RAYX_LOG << "maxEvents is set to " << maxEvents << " but the maximum event ID is " << maxEventID << ". Consider setting maxEvents to " << maxEventID << " to increase performance."; } // Export Rays to external data. - auto file = exportRays(rays, path.string(), m_CommandParser->m_args.m_startEventID); + auto file = exportRays(rays, path.string()); // Plot if (m_CommandParser->m_args.m_plotFlag) { @@ -132,10 +127,6 @@ void TerminalApp::run() { if (m_CommandParser->m_args.m_verbose) { RAYX::setDebugVerbose(true); } - if (m_CommandParser->m_args.m_startEventID < 0) { - RAYX_LOG << "startEventID must be >= 0. Setting to 0."; - m_CommandParser->m_args.m_startEventID = 0; - } if (m_CommandParser->m_args.m_isFixSeed) { if (m_CommandParser->m_args.m_seed != -1) { @@ -184,7 +175,7 @@ void TerminalApp::run() { tracePath(m_CommandParser->m_args.m_providedFile); } -std::string TerminalApp::exportRays(const RAYX::BundleHistory& hist, std::string path, int startEventID) { +std::string TerminalApp::exportRays(const RAYX::BundleHistory& hist, std::string path) { RAYX_PROFILE_FUNCTION_STDOUT(); bool csv = m_CommandParser->m_args.m_csvFlag; @@ -199,13 +190,13 @@ std::string TerminalApp::exportRays(const RAYX::BundleHistory& hist, std::string if (csv) { path += ".csv"; - writeCSV(hist, path, fmt, startEventID); + writeCSV(hist, path, fmt); } else { #ifdef NO_H5 RAYX_EXIT << "writeH5 called during NO_H5 (HDF5 disabled during build))"; #else path += ".h5"; - writeH5(hist, path, fmt, getBeamlineOpticalElementsNames(), startEventID); + writeH5(hist, path, fmt, getBeamlineOpticalElementsNames()); #endif } return path; diff --git a/Intern/rayx/src/TerminalApp.h b/Intern/rayx/src/TerminalApp.h index 1645adcfb..a4d4523e3 100644 --- a/Intern/rayx/src/TerminalApp.h +++ b/Intern/rayx/src/TerminalApp.h @@ -30,7 +30,7 @@ class TerminalApp { /// children of that directory. void tracePath(const std::filesystem::path& path); // returns the output filename (either .csv or .h5) - std::string exportRays(const RAYX::BundleHistory&, std::string, int startEventID); + std::string exportRays(const RAYX::BundleHistory&, std::string); std::vector getBeamlineOpticalElementsNames(); std::vector getBeamlineLightSourcesNames();