|
|
|||
File indexing completed on 2026-11-07 10:20:32
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 larceler/Convert.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <larcoreobj/SimpleTypesAndConstants/geo_vectors.h> 0010 0011 #include "corecel/Types.hh" 0012 #include "corecel/cont/Array.hh" 0013 #include "corecel/math/ArrayQuantity.hh" 0014 #include "corecel/math/Quantity.hh" 0015 #include "celeritas/UnitTypes.hh" 0016 0017 namespace celeritas 0018 { 0019 //---------------------------------------------------------------------------// 0020 0021 using LarsoftTime = Quantity<celeritas::units::Nanosecond, double>; 0022 using LarsoftLen = Quantity<celeritas::units::Centimeter, double>; 0023 0024 //---------------------------------------------------------------------------// 0025 // FREE FUNCTIONS 0026 //---------------------------------------------------------------------------// 0027 //! Convert via a quantity to native LArSoft types/units 0028 template<class Q> 0029 inline double convert_to_larsoft(real_type v) 0030 { 0031 return value_as<Q>(native_value_to<Q>(v)); 0032 } 0033 0034 //---------------------------------------------------------------------------// 0035 //! Convert via a quantity from native LArSoft types/units 0036 template<class Q> 0037 inline real_type convert_from_larsoft(double v) 0038 { 0039 return native_value_from(Q(v)); 0040 } 0041 0042 //---------------------------------------------------------------------------// 0043 //! Convert from a Celeritas array to a ROOT point 0044 inline geo::Point_t to_larpoint(Array<double, 3> const& arr) 0045 { 0046 return {arr[0], arr[1], arr[2]}; 0047 } 0048 0049 //---------------------------------------------------------------------------// 0050 //! Convert a ROOT point to a Celeritas array 0051 inline Array<double, 3> to_array(geo::Point_t const& v) 0052 { 0053 return {v.X(), v.Y(), v.Z()}; 0054 } 0055 0056 //---------------------------------------------------------------------------// 0057 //! Convert via a quantity to native LArSoft types/units 0058 template<class Q> 0059 geo::Point_t convert_to_larsoft(Array<double, 3> const& v) 0060 { 0061 return to_larpoint(value_as<Q>(native_value_to<Q>(v))); 0062 } 0063 0064 //---------------------------------------------------------------------------// 0065 //! Convert via a quantity from native LArSoft types/units 0066 template<class Q> 0067 Array<typename Q::value_type, 3> convert_from_larsoft(geo::Point_t const& v) 0068 { 0069 return native_value_from(make_quantity_array<Q>(to_array(v))); 0070 } 0071 0072 //---------------------------------------------------------------------------// 0073 } // 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 |
|