Geant4-11
G4PhysicalVolumesSearchScene.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26//
27//
28//
29// John Allison 5th September 2018, based on G4PhysicalVolumeSearchScene
30// An artificial scene to find physical volumes. Instead of returning the
31// first occurrence (G4PhysicalVolumeSearchScene) this class (note the extra
32// 's' in the name of this class) returns a vector of all occurrences.
33// It can match a physical volume name with the required match. The latter can
34// be of the form "/regexp/", where regexp is a regular expression (see C++
35// regex), or a plain string, in which case there must be an exact match.
36
37#ifndef G4PHYSICALVOLUMESSEARCHSCENE_HH
38#define G4PHYSICALVOLUMESSEARCHSCENE_HH
39
40#include "G4PseudoScene.hh"
41
42#include "G4VPhysicalVolume.hh"
44
46{
47public:
48
50 (G4PhysicalVolumeModel* pSearchVolumeModel, // usually a world
51 const G4String& requiredPhysicalVolumeName,
52 G4int requiredCopyNo = -1, // -1 means any copy no
53 // Don't continue beyond requiredContinuation once found
54 G4int requiredContinuation = G4PhysicalVolumeModel::UNLIMITED);
55
57
58 struct Findings
59 {
61 (G4VPhysicalVolume* pSearchPV,
62 G4VPhysicalVolume* pFoundPV,
63 G4int foundPVCopyNo = 0,
64 G4int foundDepth = 0,
65 std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>
66 foundBasePVPath =
67 std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>(),
68 G4Transform3D foundObjectTransformation = G4Transform3D())
69 : fpSearchPV(pSearchPV)
70 , fpFoundPV(pFoundPV)
71 , fFoundPVCopyNo(foundPVCopyNo)
72 , fFoundDepth(foundDepth)
73 , fFoundBasePVPath(foundBasePVPath)
74 , fFoundObjectTransformation(foundObjectTransformation) {}
76 : fpSearchPV(nullptr)
77 , fpFoundPV(tp.fpTouchablePV)
78 , fFoundPVCopyNo(tp.fCopyNo)
79 , fFoundDepth(0)
80 , fFoundBasePVPath(tp.fTouchableBaseFullPVPath)
81 , fFoundObjectTransformation(tp.fTouchableGlobalTransform) {}
82 G4VPhysicalVolume* fpSearchPV; // Searched physical volume.
83 G4VPhysicalVolume* fpFoundPV; // Found physical volume.
84 G4int fFoundPVCopyNo; // Found Copy number.
85 G4int fFoundDepth; // Found depth.
86 std::vector<G4PhysicalVolumeModel::G4PhysicalVolumeNodeID>
87 fFoundBasePVPath; // Base path (e.g., empty for world volume)
88 G4Transform3D fFoundObjectTransformation; // Found transformation.
89 };
90
91 const std::vector<Findings>& GetFindings() const
92 {return fFindings;}
93
94private:
95
96 class Matcher {
97 public:
98 Matcher(const G4String& requiredMatch);
99 G4bool Match(const G4String&);
100 // Match the string with the required match. The latter can be of the form
101 // "/regexp/", where regexp is a regular expression (see C++ regex),
102 // or a plain string, in which case there must be an exact match.
103 private:
104 G4bool fRegexFlag; // True if fRequiredMatch is of the form "/.../".
106 };
107
108 void ProcessVolume(const G4VSolid&);
109
114 std::vector<Findings> fFindings;
115};
116
117#endif
HepGeom::Transform3D G4Transform3D
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
G4PhysicalVolumesSearchScene(G4PhysicalVolumeModel *pSearchVolumeModel, const G4String &requiredPhysicalVolumeName, G4int requiredCopyNo=-1, G4int requiredContinuation=G4PhysicalVolumeModel::UNLIMITED)
const G4PhysicalVolumeModel * fpSearchVolumesModel
const std::vector< Findings > & GetFindings() const
Findings(G4VPhysicalVolume *pSearchPV, G4VPhysicalVolume *pFoundPV, G4int foundPVCopyNo=0, G4int foundDepth=0, std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > foundBasePVPath=std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID >(), G4Transform3D foundObjectTransformation=G4Transform3D())
std::vector< G4PhysicalVolumeModel::G4PhysicalVolumeNodeID > fFoundBasePVPath
Findings(const G4PhysicalVolumeModel::TouchableProperties &tp)