Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:12:20

0001 // This file is part of the ACTS project.
0002 //
0003 // Copyright (C) 2016 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 https://mozilla.org/MPL/2.0/.
0008 
0009 #include "Acts/Plugins/Geant4/Geant4PhysicalVolumeSelectors.hpp"
0010 
0011 #include "G4VPhysicalVolume.hh"
0012 
0013 namespace Acts::Geant4PhysicalVolumeSelectors {
0014 
0015 bool NameSelector::select(const G4VPhysicalVolume& g4PhysVol) const {
0016   std::string volumeName = g4PhysVol.GetName();
0017   bool matched = false;
0018   for (const auto& name : names) {
0019     matched = exact ? (volumeName == name)
0020                     : volumeName.find(name) != std::string::npos;
0021     if (matched) {
0022       break;
0023     }
0024   }
0025   return matched;
0026 }
0027 
0028 bool PositionSelector::select(const G4VPhysicalVolume& g4PhysVol) const {
0029   bool matched = false;
0030   G4ThreeVector pos = g4PhysVol.GetTranslation();
0031   for (auto range : m_ranges) {
0032     auto& [min, max] = range.second;
0033     EAxis axis = static_cast<EAxis>(range.first);
0034     matched = (pos[axis] >= min) && (pos[axis] <= max);
0035     if (!matched) {
0036       break;
0037     }
0038   }
0039   return matched;
0040 }
0041 
0042 }  // namespace Acts::Geant4PhysicalVolumeSelectors