Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:11: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/user/StepDiagnosticBase.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <vector>
0010 
0011 #include "corecel/data/StreamStore.hh"
0012 #include "corecel/io/OutputInterface.hh"
0013 
0014 #include "ParticleTallyData.hh"
0015 
0016 namespace celeritas
0017 {
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Tally number of steps taken by each particle type.
0021  *
0022  * This adds an \c step-diagnostic entry to the \c result category of the
0023  * main Celeritas output that bins the total number of steps taken by a track,
0024  * grouped by particle type. The result is an integral over all events.
0025  */
0026 class StepDiagnosticBase : public OutputInterface
0027 {
0028   public:
0029     //!@{
0030     //! \name Type aliases
0031     using StoreT = StreamStore<ParticleTallyParamsData, ParticleTallyStateData>;
0032     using VecVecCount = std::vector<std::vector<size_type>>;
0033     //!@}
0034 
0035   public:
0036     //! Construct with counts
0037     StepDiagnosticBase(
0038         size_type num_particles, size_type max_bins, size_type num_streams);
0039 
0040     //! Default destructor
0041     ~StepDiagnosticBase();
0042 
0043     //!@{
0044     //! \name Output interface
0045 
0046     //! Category of data to write
0047     Category category() const final { return Category::result; }
0048     // Write output to the given JSON object
0049     void output(JsonPimpl*) const final;
0050     //!@}
0051 
0052     // Get the diagnostic results accumulated over all streams
0053     VecVecCount calc_steps() const;
0054 
0055     // Size of diagnostic state data (number of bins times number of particles)
0056     size_type state_size() const;
0057 
0058     // Access the storage
0059     StoreT& store() const { return store_; }
0060 
0061     // Reset diagnostic results
0062     void clear();
0063 
0064   private:
0065     size_type num_streams_;
0066     mutable StoreT store_;
0067 };
0068 
0069 //---------------------------------------------------------------------------//
0070 }  // namespace celeritas