Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-09 10:20:17

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/g4org/ProtoConstructor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <unordered_map>
0011 
0012 #include "orange/orangeinp/ObjectInterface.hh"
0013 #include "orange/orangeinp/UnitProto.hh"
0014 
0015 #include "Volume.hh"
0016 
0017 namespace celeritas
0018 {
0019 class GeantGeoParams;
0020 namespace g4org
0021 {
0022 //---------------------------------------------------------------------------//
0023 /*!
0024  * Recursively build ORANGE proto-universes from a \c LogicalVolume .
0025  *
0026  * The input to this function is the output of \c LogicalVolumeConverter . This
0027  * class is responsible for "placing" the converted \c PhysicalVolume by
0028  * transforming its children. Depending on heuristics, the children are
0029  * directly inserted into a \c UnitProto as volumes (specifically, the logical
0030  * volume becomes a \c UnitProto::MaterialInput), or a \c LogicalVolume is
0031  * turned into a \em new \c UnitProto that can be used in multiple locations.
0032  */
0033 class ProtoConstructor
0034 {
0035   public:
0036     //!@{
0037     //! \name Type aliases
0038     using SPConstObject = std::shared_ptr<orangeinp::ObjectInterface const>;
0039     using ObjLv = std::pair<SPConstObject, LogicalVolume const*>;
0040     using SPUnitProto = std::shared_ptr<orangeinp::UnitProto>;
0041     using ProtoInput = orangeinp::UnitProto::Input;
0042     //!@}
0043 
0044   public:
0045     //! Construct with verbosity setting
0046     ProtoConstructor(GeantGeoParams const& geo, bool verbose)
0047         : geo_{geo}, verbose_{verbose}
0048     {
0049     }
0050 
0051     // Construct a proto from a logical volume
0052     SPUnitProto operator()(LogicalVolume const& lv);
0053 
0054   private:
0055     GeantGeoParams const& geo_;
0056     std::unordered_map<LogicalVolume const*, SPUnitProto> protos_;
0057     int depth_{0};
0058     bool verbose_{false};
0059 
0060     Label const& get_label(LogicalVolume const& lv);
0061     Label const& get_label(PhysicalVolume const& lv);
0062 
0063     // Place a physical volume into the given unconstructed proto
0064     void place_pv(VariantTransform const& parent_transform,
0065                   PhysicalVolume const& pv,
0066                   ProtoInput* proto);
0067 
0068     SPConstObject make_explicit_background(LogicalVolume const& lv,
0069                                            VariantTransform const& transform);
0070 
0071     // (TODO: make this configurable)
0072     //! Number of daughters above which we use a "fill" material
0073     static constexpr int fill_daughter_threshold() { return 2; }
0074 };
0075 
0076 //---------------------------------------------------------------------------//
0077 }  // namespace g4org
0078 }  // namespace celeritas