Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Geant4PhysicalVolumeSelectors.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file Geant4PhysicalVolumeSelectors.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2022 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
12 
13 #include <string>
14 #include <vector>
15 
16 #include "G4VPhysicalVolume.hh"
17 
18 namespace Acts {
19 
22  public:
23  virtual ~IGeant4PhysicalVolumeSelector() = default;
27  virtual bool select(const G4VPhysicalVolume& g4Phys) const = 0;
28 };
29 
30 namespace Geant4PhysicalVolumeSelectors {
31 
34  bool select(const G4VPhysicalVolume& /*g4Phys*/) const final { return true; }
35 };
36 
40  std::vector<std::string> names = {};
41  bool exact = false;
42 
46  NameSelector(const std::vector<std::string>& ns, bool e = false)
47  : names(ns), exact(e) {}
48 
52  bool select(const G4VPhysicalVolume& g4PhysVol) const final {
53  std::string volumeName = g4PhysVol.GetName();
54  bool matched = false;
55  for (const auto& name : names) {
56  matched = exact ? (volumeName == name)
57  : volumeName.find(name) != std::string::npos;
58  if (matched) {
59  break;
60  }
61  }
62  return matched;
63  }
64 };
65 
66 } // namespace Geant4PhysicalVolumeSelectors
67 } // namespace Acts