Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-15 08:54:44

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/inp/Diagnostics.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <optional>
0010 #include <string>
0011 
0012 #include "corecel/Types.hh"
0013 #include "celeritas/user/RootStepWriterInput.hh"
0014 
0015 namespace celeritas
0016 {
0017 //---------------------------------------------------------------------------//
0018 class CoreParams;
0019 
0020 namespace inp
0021 {
0022 //---------------------------------------------------------------------------//
0023 /*!
0024  * Write out problem data to separate files for debugging.
0025  *
0026  * These options are meant for use in the context of a larger experiment
0027  * framework, for exporting physics settings, detector geometry, and offloaded
0028  * EM tracks for reproducing externally.
0029  *
0030  * \todo Some of these will be one per run; others will be one per thread.
0031  */
0032 struct ExportFiles
0033 {
0034     //! Filename for ROOT dump of physics data
0035     std::string physics;
0036     //! Filename to dump a ROOT/HepMC3 copy of primaries
0037     std::string offload;
0038     //! Filename to dump a GDML file of the active Geant4 geometry
0039     std::string geometry;
0040 };
0041 
0042 //---------------------------------------------------------------------------//
0043 /*!
0044  * Export (possibly large!) diagnostic output about track slot contents.
0045  *
0046  * \sa celeritas::SlotDiagnostic
0047  */
0048 struct SlotDiagnostic
0049 {
0050     //! Prefix of file names for outputting on each stream
0051     std::string basename;
0052 };
0053 
0054 //---------------------------------------------------------------------------//
0055 /*!
0056  * Set up Celeritas timers.
0057  */
0058 struct Timers
0059 {
0060     //! Accumulate elapsed time for each action
0061     bool action{false};
0062     //! Save elapsed time for each step
0063     bool step{false};
0064 };
0065 
0066 //---------------------------------------------------------------------------//
0067 /*!
0068  * Output track diagnostic counters.
0069  *
0070  * These include the number of tracks generated, active, aborted, and alive;
0071  * as well as the number of initializers (or the high water mark thereof).
0072  */
0073 struct Counters
0074 {
0075     //! Write diagnostics for each step
0076     bool step{false};
0077     //! Write diagnostics for each event (or run, if multiple events)
0078     bool event{false};
0079 };
0080 
0081 //---------------------------------------------------------------------------//
0082 /*!
0083  * Write out MC truth data.
0084  *
0085  * \sa celeritas::RootStepWriter
0086  */
0087 struct McTruth
0088 {
0089     //! Path to saved ROOT mc truth file
0090     std::string output_file;
0091 
0092     //! Filter saved data by track ID, particle type
0093     SimpleRootFilterInput filter;
0094 };
0095 
0096 //---------------------------------------------------------------------------//
0097 /*!
0098  * Accumulate distributions of the number of steps per particle type.
0099  */
0100 struct StepDiagnostic
0101 {
0102     //! Maximum number of steps per track to bin
0103     size_type bins{1000};
0104 };
0105 
0106 //---------------------------------------------------------------------------//
0107 /*!
0108  * Set up Celeritas built-in diagnostics.
0109  */
0110 struct Diagnostics
0111 {
0112     //! Write Celeritas diagnostics to this file ("-" is stdout)
0113     std::string output_file{"-"};
0114 
0115     //! Export problem setup
0116     ExportFiles export_files;
0117 
0118     //! Write elapsed times for each step
0119     Timers timers;
0120 
0121     //! Store step/track counts
0122     Counters counters;
0123 
0124     //! Write Perfetto tracing data to this filename
0125     std::string perfetto_file;
0126 
0127     //! Activate slot diagnostics
0128     std::optional<SlotDiagnostic> slot;
0129 
0130     /*!
0131      * Accumulate post-step actions for each particle type.
0132      *
0133      * \sa celeritas::ActionDiagnostic
0134      */
0135     bool action{false};
0136 
0137     //! Add a 'status checker' for debugging new actions
0138     bool status_checker{false};
0139 
0140     //! Write detailed MC truth output
0141     std::optional<McTruth> mctruth;
0142 
0143     //! Bin number of steps per track
0144     std::optional<StepDiagnostic> step;
0145 
0146     //! Log the execution progress every N events
0147     size_type log_frequency{1};
0148 
0149     //! Add additional diagnostic user actions
0150     std::function<void(CoreParams const&)> add_user_actions;
0151 };
0152 
0153 //---------------------------------------------------------------------------//
0154 }  // namespace inp
0155 }  // namespace celeritas