Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:29:26

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2022-2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file accel/GeantStepDiagnostic.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 #include <string>
0012 #include <unordered_map>
0013 #include <vector>
0014 #include <G4Track.hh>
0015 
0016 #include "corecel/Types.hh"
0017 #include "corecel/io/OutputInterface.hh"
0018 
0019 namespace celeritas
0020 {
0021 //---------------------------------------------------------------------------//
0022 /*!
0023  * Tally the steps per track transported with Geant4 for each particle type.
0024  *
0025  * For the diagnostic class that collects the same result for tracks
0026  * transported with Celeritas, see: \sa StepDiagnostic.
0027  */
0028 class GeantStepDiagnostic final : public OutputInterface
0029 {
0030   public:
0031     //!@{
0032     //! \name Type aliases
0033     using VecCount = std::vector<size_type>;
0034     using VecVecCount = std::vector<VecCount>;
0035     using MapIntVecCount = std::unordered_map<int, VecCount>;
0036     //!@}
0037 
0038   public:
0039     // Construct with number of bins and threads
0040     GeantStepDiagnostic(size_type num_bins, size_type num_threads);
0041 
0042     //!@{
0043     //! \name Output interface
0044     //! Category of data to write
0045     Category category() const final { return Category::result; }
0046     //! Key for the entry inside the category.
0047     std::string_view label() const final { return "g4-step-diagnostic"; }
0048     // Write output to the given JSON object
0049     void output(JsonPimpl*) const final;
0050     //!@}
0051 
0052     // Update the step count from the given track
0053     void Update(G4Track const* track);
0054 
0055     // Get the results accumulated over all threads
0056     VecVecCount CalcSteps() const;
0057 
0058     // Get a sorted vector of PDGs
0059     std::vector<int> GetPDGs() const;
0060 
0061   private:
0062     std::vector<MapIntVecCount> thread_store_;
0063     size_type num_bins_;
0064 };
0065 
0066 //---------------------------------------------------------------------------//
0067 }  // namespace celeritas