Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:31:20

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 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/ext/Convert.root.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <TLeaf.h>
0011 
0012 #include "corecel/Macros.hh"
0013 
0014 namespace celeritas
0015 {
0016 //---------------------------------------------------------------------------//
0017 // FREE FUNCTIONS
0018 //---------------------------------------------------------------------------//
0019 /*!
0020  * Fetch single-dimension leaves.
0021  */
0022 template<class T>
0023 inline auto from_leaf(TLeaf const& leaf) -> T
0024 {
0025     CELER_EXPECT(!leaf.IsZombie());
0026     return static_cast<T>(leaf.GetValue());
0027 }
0028 
0029 //---------------------------------------------------------------------------//
0030 /*!
0031  * Fetch leaves containing `std::array<double, 3>`.
0032  */
0033 inline Real3 from_array_leaf(TLeaf const& leaf)
0034 {
0035     CELER_EXPECT(!leaf.IsZombie());
0036     CELER_ASSERT(leaf.GetLen() == 3);
0037     return {static_cast<real_type>(leaf.GetValue(0)),
0038             static_cast<real_type>(leaf.GetValue(1)),
0039             static_cast<real_type>(leaf.GetValue(2))};
0040 }
0041 
0042 //---------------------------------------------------------------------------//
0043 }  // namespace celeritas