Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 08:53:37

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 celeritas/ext/detail/NaviTouchableUpdater.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include <memory>
0010 #include <vector>
0011 
0012 #include "celeritas/Types.hh"
0013 #include "celeritas/Units.hh"
0014 
0015 #include "TouchableUpdaterInterface.hh"
0016 
0017 class G4Navigator;
0018 class G4LogicalVolume;
0019 class G4VPhysicalVolume;
0020 
0021 namespace celeritas
0022 {
0023 namespace detail
0024 {
0025 //---------------------------------------------------------------------------//
0026 /*!
0027  * Update a navigation state based on the position and direction.
0028  *
0029  * This is a helper class for \c HitProcessor.
0030  */
0031 class NaviTouchableUpdater final : public TouchableUpdaterInterface
0032 {
0033   public:
0034     //!@{
0035     //! \name Type aliases
0036     using SPConstVecLV
0037         = std::shared_ptr<std::vector<G4LogicalVolume const*> const>;
0038     //!@}
0039 
0040   public:
0041     //! Maximum step to try within the current volume [len]
0042     static constexpr double max_step() { return 1.0 * units::millimeter; }
0043 
0044     //! Print diagnostic when the step is greater than this amount [len]
0045     static constexpr double max_quiet_step()
0046     {
0047         return 1e-3 * units::millimeter;
0048     }
0049 
0050     // Construct from detector LVs
0051     explicit NaviTouchableUpdater(SPConstVecLV detector_volumes);
0052 
0053     // Construct from detector LVs and explicit world
0054     NaviTouchableUpdater(SPConstVecLV detector_volumes,
0055                          G4VPhysicalVolume const* world);
0056 
0057     // Default external deleter
0058     ~NaviTouchableUpdater() final;
0059 
0060     // Update from a particular detector step
0061     bool operator()(DetectorStepOutput const& out,
0062                     size_type step_index,
0063                     StepPoint step_point,
0064                     GeantTouchableBase* touchable) final;
0065 
0066     // Try to find the given point in the given logical volume
0067     bool operator()(Real3 const& pos,
0068                     Real3 const& dir,
0069                     G4LogicalVolume const* lv,
0070                     GeantTouchableBase* touchable);
0071 
0072   private:
0073     std::unique_ptr<G4Navigator> navi_;
0074     SPConstVecLV detector_volumes_;
0075 };
0076 
0077 //---------------------------------------------------------------------------//
0078 }  // namespace detail
0079 }  // namespace celeritas