Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-07-12 08:07:03

0001 // This file is part of the Acts project.
0002 //
0003 // Copyright (C) 2022 CERN for the benefit of the Acts project
0004 //
0005 // This Source Code Form is subject to the terms of the Mozilla Public
0006 // License, v. 2.0. If a copy of the MPL was not distributed with this
0007 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
0008 
0009 #pragma once
0010 
0011 #include "Acts/Utilities/BinningType.hpp"
0012 #include "Acts/Utilities/Delegate.hpp"
0013 
0014 #include <array>
0015 #include <map>
0016 #include <string>
0017 #include <vector>
0018 
0019 class G4VPhysicalVolume;
0020 
0021 namespace Acts {
0022 
0023 /// Interface class for selectors from physical volumes
0024 class IGeant4PhysicalVolumeSelector {
0025  public:
0026   virtual ~IGeant4PhysicalVolumeSelector() = default;
0027   /// @brief  The main interface method
0028   /// @param g4Phys the physical volume to be checked
0029   /// @return a boolean indicating if it should be selected or not
0030   virtual bool select(const G4VPhysicalVolume& g4Phys) const = 0;
0031 };
0032 
0033 namespace Geant4PhysicalVolumeSelectors {
0034 
0035 /// @brief  Struct that selects all G4VPhysicalVolume objects
0036 struct AllSelector : public IGeant4PhysicalVolumeSelector {
0037   bool select(const G4VPhysicalVolume& /*g4Phys*/) const final { return true; }
0038 };
0039 
0040 /// @brief Struct that selects G4VPhysicalVolume objects
0041 /// that match one of the provided names, exact or partially
0042 struct NameSelector : public IGeant4PhysicalVolumeSelector {
0043   std::vector<std::string> names = {};
0044   bool exact = false;
0045 
0046   /// Constructor with arguments
0047   /// @param ns the provided list of names
0048   /// @param e whether to select them exact or not
0049   NameSelector(const std::vector<std::string>& ns, bool e = false)
0050       : names(ns), exact(e) {}
0051 
0052   /// Secect function for the volume
0053   /// @param g4PhysVol the volume that is checked
0054   /// @return a boolean indicating the selection
0055   bool select(const G4VPhysicalVolume& g4PhysVol) const final;
0056 };
0057 
0058 /// @brief Struct that selects G4VPhysicalVolume objects
0059 /// based on the allowed range of their position
0060 ///
0061 /// @note Can be used for preselection of volumes
0062 /// before a KDTree search. This way the memory
0063 /// consumption can be reduced, compromising the
0064 /// execution speed
0065 ///
0066 /// @note Careful with axis conventions as
0067 /// Geant4 uses a different one than Acts
0068 struct PositionSelector : public IGeant4PhysicalVolumeSelector {
0069   std::map<unsigned int, std::tuple<double, double>> m_ranges;
0070 
0071   /// Constructor with arguments
0072   /// @param ranges the provided map of axes of ranges
0073   PositionSelector(
0074       const std::map<unsigned int, std::tuple<double, double>>& ranges)
0075       : m_ranges(ranges) {}
0076 
0077   /// Secect function for the volume
0078   /// @param g4PhysVol the volume that is checked
0079   /// @return a boolean indicating the selection
0080   bool select(const G4VPhysicalVolume& g4PhysVol) const final;
0081 };
0082 
0083 }  // namespace Geant4PhysicalVolumeSelectors
0084 }  // namespace Acts