Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-10-27 09:40:41

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 orange/inp/Import.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <iosfwd>
0010 #include <string>
0011 
0012 #include "corecel/Config.hh"
0013 
0014 #include "geocel/detail/LengthUnits.hh"
0015 #include "orange/OrangeTypes.hh"
0016 
0017 namespace celeritas
0018 {
0019 namespace inp
0020 {
0021 //---------------------------------------------------------------------------//
0022 //! How to inline volumes used only once
0023 enum class InlineSingletons
0024 {
0025     none,  //!< Never
0026     untransformed,  //!< Only if not translated nor rotated
0027     unrotated,  //!< Only if translated
0028     all,  //!< Always
0029     size_
0030 };
0031 
0032 //---------------------------------------------------------------------------//
0033 /*!
0034  * Construction options for CSG conversion.
0035  *
0036  * \warning Currently ORANGE tracking requires:
0037  * - inline unions to be true (see
0038  * https://github.com/celeritas-project/celeritas/issues/1260)
0039  * - implicit_parent_boundary to be true (see
0040  * https://github.com/celeritas-project/celeritas/issues/2012 )
0041  *
0042  * \todo Add IO for this separately; currently only FromGeant is supported.
0043  */
0044 struct OrangeGeoFromCsg
0045 {
0046     //!@{
0047     //! \name Problem scale and tolerance
0048 
0049     //! Scale factor (input unit length), customizable for unit testing
0050     double unit_length{celeritas::lengthunits::millimeter};
0051     //! Construction and tracking tolerance (native units)
0052     Tolerance<> tol;
0053 
0054     //!@}
0055 
0056     //!@{
0057     //! \name Structural conversion
0058 
0059     //! Remove bounding surfaces from lower-level universes
0060     bool implicit_parent_boundary{true};
0061 
0062     //! Logic expression notation for runtime: simplified if infix
0063     LogicNotation logic{LogicNotation::infix};
0064 
0065     //!@}
0066 
0067     //!@{
0068     //! \name Debug output
0069 
0070     //! Write converted Geant4 object structure to a JSON file
0071     std::string objects_output_file;
0072     //! Write constructed CSG surfaces and tree to a JSON file
0073     std::string csg_output_file;
0074     //! Write final org.json to a JSON file
0075     std::string org_output_file;
0076 
0077     //!@}
0078 };
0079 
0080 //---------------------------------------------------------------------------//
0081 /*!
0082  * Construction options for Geant4 conversion.
0083  *
0084  * Note that most of these should \em never be touched when running an actual
0085  * problem. If the length unit is changed, the resulting geometry is
0086  * inconsistent with Geant4's scale.
0087  */
0088 struct OrangeGeoFromGeant : public OrangeGeoFromCsg
0089 {
0090     //!@{
0091     //! \name Volume-to-universe conversion
0092 
0093     //! Volumes with up to this many children construct an explicit interior
0094     unsigned int explicit_interior_threshold{2};
0095 
0096     //! Forcibly inline volumes that have no children
0097     bool inline_childless{true};
0098 
0099     //! Forcibly inline volumes that are only used once
0100     InlineSingletons inline_singletons{InlineSingletons::untransformed};
0101 
0102     //! Forcibly copy child volumes that have union boundaries
0103     bool inline_unions{true};
0104 
0105     //!@}
0106     //!@{
0107     //! \name Debug output
0108 
0109     //! Write output about volumes being converted
0110     bool verbose_volumes{false};
0111     //! Write output about proto-universes being constructed
0112     bool verbose_structure{false};
0113 
0114     //!@}
0115 };
0116 
0117 //---------------------------------------------------------------------------//
0118 // NOTE: these are implemented in OptionsIO.json.cc
0119 
0120 char const* to_cstring(InlineSingletons value);
0121 
0122 // Helper to read from a file or stream
0123 std::istream& operator>>(std::istream& is, OrangeGeoFromGeant&);
0124 // Helper to write to a file or stream
0125 std::ostream& operator<<(std::ostream& os, OrangeGeoFromGeant const&);
0126 
0127 //---------------------------------------------------------------------------//
0128 }  // namespace inp
0129 }  // namespace celeritas