|
|
|||
File indexing completed on 2026-05-07 08:34:55
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/phys/PrimaryGeneratorOptions.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <algorithm> 0010 #include <vector> 0011 0012 #include "corecel/io/StringEnumMapper.hh" 0013 #include "corecel/math/Algorithms.hh" 0014 #include "geocel/Types.hh" 0015 0016 #include "PDGNumber.hh" 0017 0018 namespace celeritas 0019 { 0020 namespace inp 0021 { 0022 struct CorePrimaryGenerator; 0023 } 0024 0025 //---------------------------------------------------------------------------// 0026 //! Distribution selection for sampling quantities in a \c PrimaryGenerator 0027 enum class DistributionSelection 0028 { 0029 delta, 0030 isotropic, 0031 box, 0032 size_ 0033 }; 0034 0035 //---------------------------------------------------------------------------// 0036 /*! 0037 * Distribution type and parameters. 0038 */ 0039 struct DistributionOptions 0040 { 0041 DistributionSelection distribution{DistributionSelection::size_}; 0042 std::vector<real_type> params; 0043 0044 //! Whether the options are valid 0045 explicit operator bool() const 0046 { 0047 return distribution != DistributionSelection::size_; 0048 } 0049 }; 0050 0051 //---------------------------------------------------------------------------// 0052 /*! 0053 * Primary generator options. 0054 * 0055 * - \c seed: RNG seed 0056 * - \c pdg: PDG numbers of the primaries. An equal number of primaries of each 0057 * type will be generated 0058 * - \c num_events: total number of events to generate 0059 * - \c primaries_per_event: number of primaries to generate in each event 0060 * - \c energy: energy distribution type and parameters 0061 * - \c position: spatial distribution type and parameters 0062 * - \c direction: angular distribution type and parameters 0063 * 0064 * \deprecated See inp::PrimaryGenerator 0065 */ 0066 struct PrimaryGeneratorOptions 0067 { 0068 unsigned int seed{}; 0069 std::vector<PDGNumber> pdg; 0070 size_type num_events{}; 0071 size_type primaries_per_event{}; 0072 DistributionOptions energy; 0073 DistributionOptions position; 0074 DistributionOptions direction; 0075 0076 //! Whether the options are valid 0077 explicit operator bool() const 0078 { 0079 return !pdg.empty() 0080 && std::all_of(pdg.begin(), pdg.end(), LogicalTrue{}) 0081 && num_events > 0 && primaries_per_event > 0 && energy 0082 && position && direction; 0083 } 0084 }; 0085 0086 //---------------------------------------------------------------------------// 0087 // Convert PrimaryGeneratorOptions to inp::CorePrimaryGenerator. 0088 inp::CorePrimaryGenerator to_input(PrimaryGeneratorOptions const&); 0089 0090 //---------------------------------------------------------------------------// 0091 // FREE FUNCTIONS 0092 //---------------------------------------------------------------------------// 0093 0094 // Get a distribution name 0095 char const* to_cstring(DistributionSelection value); 0096 0097 //---------------------------------------------------------------------------// 0098 } // 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 |
|