![]() |
|
|||
File indexing completed on 2025-09-16 08:27:18
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 accel/GeantStepDiagnostic.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <memory> 0010 #include <string> 0011 #include <unordered_map> 0012 #include <vector> 0013 #include <G4Track.hh> 0014 0015 #include "corecel/Types.hh" 0016 #include "corecel/io/OutputInterface.hh" 0017 0018 namespace celeritas 0019 { 0020 //---------------------------------------------------------------------------// 0021 /*! 0022 * Tally the steps per track transported with Geant4 for each particle type. 0023 * 0024 * For the diagnostic class that collects the same result for tracks 0025 * transported with Celeritas, see: \sa StepDiagnostic. 0026 */ 0027 class GeantStepDiagnostic final : public OutputInterface 0028 { 0029 public: 0030 //!@{ 0031 //! \name Type aliases 0032 using VecCount = std::vector<size_type>; 0033 using VecVecCount = std::vector<VecCount>; 0034 using MapIntVecCount = std::unordered_map<int, VecCount>; 0035 //!@} 0036 0037 public: 0038 // Construct with number of bins and threads 0039 GeantStepDiagnostic(size_type num_bins, size_type num_threads); 0040 0041 //!@{ 0042 //! \name Output interface 0043 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
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |