|
||||
File indexing completed on 2025-01-18 09:59:34
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2023-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 geocel/g4vg/Scaler.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include <utility> 0011 #include <G4ThreeVector.hh> 0012 #include <G4TwoVector.hh> 0013 0014 #include "geocel/detail/LengthUnits.hh" 0015 0016 namespace celeritas 0017 { 0018 namespace g4vg 0019 { 0020 //---------------------------------------------------------------------------// 0021 /*! 0022 * Convert a unit from Geant4 scale to another. 0023 * 0024 * Currently the scale is hardcoded as mm (i.e., CLHEP units) but could easily 0025 * be a class attribute. 0026 */ 0027 class Scaler 0028 { 0029 public: 0030 //! Convert a positional scalar 0031 double operator()(double val) const { return val * scale_; } 0032 0033 //! Convert a two-vector 0034 std::pair<double, double> operator()(G4TwoVector const& vec) const 0035 { 0036 return {(*this)(vec.x()), (*this)(vec.y())}; 0037 } 0038 0039 //! Convert a three-vector 0040 vecgeom::Vector3D<double> operator()(G4ThreeVector const& vec) const 0041 { 0042 return {(*this)(vec.x()), (*this)(vec.y()), (*this)(vec.z())}; 0043 } 0044 0045 private: 0046 inline static constexpr double scale_ = celeritas::lengthunits::millimeter; 0047 }; 0048 0049 //---------------------------------------------------------------------------// 0050 } // namespace g4vg 0051 } // 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 |