Geant4-11
Public Member Functions | Private Attributes
G4GeomTestVolume Class Reference

#include <G4GeomTestVolume.hh>

Public Member Functions

 G4GeomTestVolume (G4VPhysicalVolume *theTarget, G4double theTolerance=0.0, G4int numberOfPoints=10000, G4bool theVerbosity=true)
 
G4int GetErrorsThreshold () const
 
G4int GetResolution () const
 
G4double GetTolerance () const
 
G4bool GetVerbosity () const
 
void SetErrorsThreshold (G4int max)
 
void SetResolution (G4int points)
 
void SetTolerance (G4double tolerance)
 
void SetVerbosity (G4bool verbosity)
 
void TestOverlapInTree () const
 
void TestRecursiveOverlap (G4int sLevel=0, G4int depth=-1)
 
 ~G4GeomTestVolume ()
 

Private Attributes

G4int maxErr = 1
 
G4int resolution
 
G4VPhysicalVolumetarget
 
G4double tolerance
 
G4bool verbosity
 

Detailed Description

Definition at line 43 of file G4GeomTestVolume.hh.

Constructor & Destructor Documentation

◆ G4GeomTestVolume()

G4GeomTestVolume::G4GeomTestVolume ( G4VPhysicalVolume theTarget,
G4double  theTolerance = 0.0,
G4int  numberOfPoints = 10000,
G4bool  theVerbosity = true 
)

Definition at line 43 of file G4GeomTestVolume.cc.

47 : target(theTarget), tolerance(theTolerance),
48 resolution(numberOfPoints), verbosity(theVerbosity)
49{;}
G4VPhysicalVolume * target

◆ ~G4GeomTestVolume()

G4GeomTestVolume::~G4GeomTestVolume ( )

Definition at line 54 of file G4GeomTestVolume.cc.

54{;}

Member Function Documentation

◆ GetErrorsThreshold()

G4int G4GeomTestVolume::GetErrorsThreshold ( ) const

Definition at line 107 of file G4GeomTestVolume.cc.

108{
109 return maxErr;
110}

References maxErr.

◆ GetResolution()

G4int G4GeomTestVolume::GetResolution ( ) const

Definition at line 75 of file G4GeomTestVolume.cc.

76{
77 return resolution;
78}

References resolution.

◆ GetTolerance()

G4double G4GeomTestVolume::GetTolerance ( ) const

Definition at line 59 of file G4GeomTestVolume.cc.

60{
61 return tolerance;
62}

References tolerance.

◆ GetVerbosity()

G4bool G4GeomTestVolume::GetVerbosity ( ) const

Definition at line 91 of file G4GeomTestVolume.cc.

92{
93 return verbosity;
94}

References verbosity.

◆ SetErrorsThreshold()

void G4GeomTestVolume::SetErrorsThreshold ( G4int  max)

Definition at line 115 of file G4GeomTestVolume.cc.

116{
117 maxErr = max;
118}
T max(const T t1, const T t2)
brief Return the largest of the two arguments

References G4INCL::Math::max(), and maxErr.

Referenced by G4GeometryMessenger::SetNewValue(), and TestRecursiveOverlap().

◆ SetResolution()

void G4GeomTestVolume::SetResolution ( G4int  points)

Definition at line 83 of file G4GeomTestVolume.cc.

84{
85 resolution = np;
86}

References resolution.

Referenced by G4GeometryMessenger::SetNewValue().

◆ SetTolerance()

void G4GeomTestVolume::SetTolerance ( G4double  tolerance)

Definition at line 67 of file G4GeomTestVolume.cc.

68{
69 tolerance = tol;
70}

References tolerance.

Referenced by G4GeometryMessenger::SetNewValue().

◆ SetVerbosity()

void G4GeomTestVolume::SetVerbosity ( G4bool  verbosity)

Definition at line 99 of file G4GeomTestVolume.cc.

100{
101 verbosity = verb;
102}

References verbosity.

Referenced by G4GeometryMessenger::SetNewValue().

◆ TestOverlapInTree()

void G4GeomTestVolume::TestOverlapInTree ( ) const

Definition at line 123 of file G4GeomTestVolume.cc.

124{
125 std::queue<G4VPhysicalVolume*> volumes;
126 std::set<G4LogicalVolume*> checked;
127
128 volumes.push(target);
129 while (!volumes.empty())
130 {
131 G4VPhysicalVolume* current = volumes.front();
132 volumes.pop();
133
134 // check overlaps for daughters
135 G4LogicalVolume* logical = current->GetLogicalVolume();
136 G4int ndaughters = logical->GetNoDaughters();
137 for (G4int i=0; i<ndaughters; ++i)
138 {
139 G4VPhysicalVolume* daughter = logical->GetDaughter(i);
141 }
142
143 // append the queue of volumes
144 G4LogicalVolume* previousLogical = nullptr;
145 for (G4int i=0; i<ndaughters; ++i)
146 {
147 G4VPhysicalVolume* daughter = logical->GetDaughter(i);
148 G4LogicalVolume* daughterLogical = daughter->GetLogicalVolume();
149 if (daughterLogical->GetNoDaughters() == 0) continue;
150 G4bool found = (daughterLogical == previousLogical);
151 if (!found) found = (checked.find(daughterLogical) != checked.cend());
152 if (!found)
153 {
154 checked.emplace(daughterLogical);
155 previousLogical = daughterLogical;
156 volumes.push(daughter);
157 }
158 else
159 {
160 if (verbosity)
161 G4cout << "Checking overlaps in tree of volume " << daughter->GetName()
162 << " (" << daughterLogical->GetSolid()->GetEntityType() << ")"
163 << " is omitted, to avoid duplication" << G4endl;
164 }
165 }
166 }
167}
bool G4bool
Definition: G4Types.hh:86
int G4int
Definition: G4Types.hh:85
#define G4endl
Definition: G4ios.hh:57
G4GLOB_DLL std::ostream G4cout
G4VSolid * GetSolid() const
size_t GetNoDaughters() const
G4VPhysicalVolume * GetDaughter(const G4int i) const
virtual G4bool CheckOverlaps(G4int res=1000, G4double tol=0., G4bool verbose=true, G4int errMax=1)
G4LogicalVolume * GetLogicalVolume() const
const G4String & GetName() const
virtual G4GeometryType GetEntityType() const =0

References G4VPhysicalVolume::CheckOverlaps(), G4cout, G4endl, G4LogicalVolume::GetDaughter(), G4VSolid::GetEntityType(), G4VPhysicalVolume::GetLogicalVolume(), G4VPhysicalVolume::GetName(), G4LogicalVolume::GetNoDaughters(), G4LogicalVolume::GetSolid(), maxErr, resolution, target, tolerance, and verbosity.

◆ TestRecursiveOverlap()

void G4GeomTestVolume::TestRecursiveOverlap ( G4int  sLevel = 0,
G4int  depth = -1 
)

Definition at line 172 of file G4GeomTestVolume.cc.

173{
174 // If reached requested level of depth (i.e. set to 0), exit.
175 // If not depth specified (i.e. set to -1), visit the whole tree.
176 // If requested initial level of depth is not zero, visit from beginning
177 //
178 if (depth == 0) return;
179 if (depth != -1) depth--;
180 if (slevel != 0) slevel--;
181
182 //
183 // As long as we reached the requested
184 // initial level of depth, test ourselves
185 //
186 if ( slevel==0 )
187 {
189 }
190
191 //
192 // Loop over unique daughters
193 //
194 std::set<const G4LogicalVolume *> tested;
195
196 const G4LogicalVolume *logical = target->GetLogicalVolume();
197 G4int nDaughter = logical->GetNoDaughters();
198 for( auto iDaughter=0; iDaughter<nDaughter; ++iDaughter )
199 {
200 G4VPhysicalVolume *daughter = logical->GetDaughter(iDaughter);
201
202 // Tested already?
203 //
204 // const G4LogicalVolume *daughterLogical =
205 // daughter->GetLogicalVolume();
206 // std::pair<std::set<const G4LogicalVolume *>::iterator, G4bool>
207 // there = tested.insert(daughterLogical);
208 // if (!there.second) continue;
209
210 //
211 // Recurse
212 //
213 G4GeomTestVolume vTest( daughter, tolerance, resolution, verbosity );
214 vTest.SetErrorsThreshold(maxErr);
215 vTest.TestRecursiveOverlap( slevel,depth );
216 }
217}

References G4VPhysicalVolume::CheckOverlaps(), G4LogicalVolume::GetDaughter(), G4VPhysicalVolume::GetLogicalVolume(), G4LogicalVolume::GetNoDaughters(), maxErr, resolution, SetErrorsThreshold(), target, TestRecursiveOverlap(), tolerance, and verbosity.

Referenced by G4GeometryMessenger::RecursiveOverlapTest(), and TestRecursiveOverlap().

Field Documentation

◆ maxErr

G4int G4GeomTestVolume::maxErr = 1
private

◆ resolution

G4int G4GeomTestVolume::resolution
private

◆ target

G4VPhysicalVolume* G4GeomTestVolume::target
private

Definition at line 80 of file G4GeomTestVolume.hh.

Referenced by TestOverlapInTree(), and TestRecursiveOverlap().

◆ tolerance

G4double G4GeomTestVolume::tolerance
private

◆ verbosity

G4bool G4GeomTestVolume::verbosity
private

The documentation for this class was generated from the following files: