Celeritas 0.7+28f01d9
Loading...
Searching...
No Matches
Functions | Variables
Convert.hh File Reference
#include "corecel/math/ArrayOperators.hh"
#include "corecel/math/ArrayQuantity.hh"
#include "geocel/detail/LengthQuantities.hh"
#include "GeantTypes.hh"

Functions

template<class Q >
double celeritas::native_to_geant (real_type v)
 Convert a scalar via a quantity to native Geant4 types/units.
 
template<class Q , class T = typename Q::value_type>
T celeritas::native_from_geant (double v)
 Convert a scalar via a quantity from native Geant4 types/units.
 
template<class Q , class T >
G4ThreeVector celeritas::native_to_geant (Array< T, 3 > const &v)
 Convert an array via a quantity to native Geant4 types/units.
 
template<class Q , class T = typename Q::value_type>
Array< T, 3 > celeritas::native_from_geant (G4ThreeVector const &v)
 Convert via a quantity from native Geant4 types/units.
 
template<class Q , class T = typename Q::value_type>
Array< T, 3 > celeritas::native_from_geant (Array< double, 3 > const &v)
 Convert a C vector via a quantity from native Geant4 types/units.
 
Real3 celeritas::convert_from_geant (G4ThreeVector const &vec, double units)
 Convert a 3-vector from Geant4/CLHEP to Celeritas native units.
 
Real3 celeritas::convert_from_geant (double const vec[3], double units)
 Convert a C array from Geant4/CLHEP to Celeritas native units.
 
constexpr double celeritas::convert_to_geant (real_type val, double units)
 Convert a native Celeritas quantity to a Geant4 value with CLHEP units.
 
G4ThreeVector celeritas::convert_to_geant (Real3 const &arr, double units)
 Convert a native Celeritas 3-vector to a Geant4 equivalent.
 

Variables

constexpr double celeritas::clhep_length {1 / lengthunits::millimeter}
 Value of a unit Celeritas length in the CLHEP unit system.
 

Function Documentation

◆ native_from_geant() [1/2]

template<class Q , class T = typename Q::value_type>
T celeritas::native_from_geant ( double  v)

Convert a scalar via a quantity from native Geant4 types/units.

This performs a simultaneous unit conversion (from Geant4 to Celeritas) and optional type conversion (usually from double to real_type).

The first argument (required) is the quantity represented by the Geant4 value, and the second is to allow casting to real_type .

Examples

The track position is in native Celeritas units and value types:

track.position = native_from_geant<lengthunits::ClhepLength, real_type>(
g4track.GetPosition());

◆ native_from_geant() [2/2]

template<class Q , class T = typename Q::value_type>
Array< T, 3 > celeritas::native_from_geant ( G4ThreeVector const v)

Convert via a quantity from native Geant4 types/units.

The first argument (required) is the quantity represented by the Geant4 value, and the second is to allow casting to real_type .