![]() |
|
|||
File indexing completed on 2025-02-22 10:31:29
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2021-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 celeritas/phys/ParticleView.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include "ParticleData.hh" 0011 0012 namespace celeritas 0013 { 0014 //---------------------------------------------------------------------------// 0015 /*! 0016 * Access invariant particle data. 0017 * 0018 * A \c ParticleView can be used to access properties of a single particle 0019 * type, e.g. electron or photon. 0020 */ 0021 class ParticleView 0022 { 0023 public: 0024 //!@{ 0025 //! \name Type aliases 0026 using ParticleParamsRef = NativeCRef<ParticleParamsData>; 0027 //!@} 0028 0029 public: 0030 // Construct from "static" particle definitions 0031 inline CELER_FUNCTION ParticleView(ParticleParamsRef const&, ParticleId); 0032 0033 // Unique particle type identifier 0034 CELER_FORCEINLINE_FUNCTION ParticleId particle_id() const; 0035 0036 // Rest mass [MeV / c^2] 0037 CELER_FORCEINLINE_FUNCTION units::MevMass mass() const; 0038 0039 // Charge [elemental charge e+] 0040 CELER_FORCEINLINE_FUNCTION units::ElementaryCharge charge() const; 0041 0042 // Decay constant [1/s] 0043 CELER_FORCEINLINE_FUNCTION real_type decay_constant() const; 0044 0045 // Whether it is an antiparticle 0046 CELER_FORCEINLINE_FUNCTION bool is_antiparticle() const; 0047 0048 private: 0049 ParticleParamsRef const& params_; 0050 ParticleId const particle_; 0051 }; 0052 0053 //---------------------------------------------------------------------------// 0054 // INLINE DEFINITIONS 0055 //---------------------------------------------------------------------------// 0056 /*! 0057 * Construct from "static" particle definitions. 0058 */ 0059 CELER_FUNCTION 0060 ParticleView::ParticleView(ParticleParamsRef const& params, ParticleId id) 0061 : params_(params), particle_(id) 0062 { 0063 CELER_EXPECT(particle_ < params_.size()); 0064 } 0065 0066 //---------------------------------------------------------------------------// 0067 /*! 0068 * Unique particle type identifier. 0069 */ 0070 CELER_FUNCTION ParticleId ParticleView::particle_id() const 0071 { 0072 return particle_; 0073 } 0074 0075 //---------------------------------------------------------------------------// 0076 /*! 0077 * Rest mass [MeV / c^2]. 0078 */ 0079 CELER_FUNCTION units::MevMass ParticleView::mass() const 0080 { 0081 return params_.mass[particle_]; 0082 } 0083 0084 //---------------------------------------------------------------------------// 0085 /*! 0086 * Elementary charge. 0087 */ 0088 CELER_FUNCTION units::ElementaryCharge ParticleView::charge() const 0089 { 0090 return params_.charge[particle_]; 0091 } 0092 0093 //---------------------------------------------------------------------------// 0094 /*! 0095 * Decay constant. 0096 */ 0097 CELER_FUNCTION real_type ParticleView::decay_constant() const 0098 { 0099 return params_.decay_constant[particle_]; 0100 } 0101 0102 //---------------------------------------------------------------------------// 0103 /*! 0104 * Whether it is an antiparticle. 0105 */ 0106 CELER_FUNCTION bool ParticleView::is_antiparticle() const 0107 { 0108 return params_.matter[particle_] == MatterType::antiparticle; 0109 } 0110 0111 //---------------------------------------------------------------------------// 0112 } // 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 |
![]() ![]() |