ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4GeomTestVolume.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4GeomTestVolume.cc
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 // class G4GeomTestVolume implementation
27 //
28 // Author: G.Cosmo, CERN
29 // --------------------------------------------------------------------
30 
31 #include <set>
32 
33 #include "G4GeomTestVolume.hh"
34 #include "G4PhysicalConstants.hh"
35 #include "G4VPhysicalVolume.hh"
36 #include "G4LogicalVolume.hh"
37 #include "G4VSolid.hh"
38 
39 //
40 // Constructor
41 //
43  G4double theTolerance,
44  G4int numberOfPoints,
45  G4bool theVerbosity )
46  : target(theTarget), tolerance(theTolerance),
47  resolution(numberOfPoints), verbosity(theVerbosity)
48 {;}
49 
50 //
51 // Destructor
52 //
54 
55 //
56 // Get error tolerance
57 //
59 {
60  return tolerance;
61 }
62 
63 //
64 // Set error tolerance
65 //
67 {
68  tolerance = tol;
69 }
70 
71 //
72 // Get number of points to check (resolution)
73 //
75 {
76  return resolution;
77 }
78 
79 //
80 // Set number of points to check (resolution)
81 //
83 {
84  resolution = np;
85 }
86 
87 //
88 // Get verbosity
89 //
91 {
92  return verbosity;
93 }
94 
95 //
96 // Set verbosity
97 //
99 {
100  verbosity = verb;
101 }
102 
103 //
104 // Get errors reporting threshold
105 //
107 {
108  return maxErr;
109 }
110 
111 //
112 // Set maximum number of errors to report
113 //
115 {
116  maxErr = max;
117 }
118 
119 //
120 // TestRecursiveOverlap
121 //
123 {
124  // If reached requested level of depth (i.e. set to 0), exit.
125  // If not depth specified (i.e. set to -1), visit the whole tree.
126  // If requested initial level of depth is not zero, visit from beginning
127  //
128  if (depth == 0) return;
129  if (depth != -1) depth--;
130  if (slevel != 0) slevel--;
131 
132  //
133  // As long as we reached the requested
134  // initial level of depth, test ourselves
135  //
136  if ( slevel==0 )
137  {
138  target->CheckOverlaps(resolution, tolerance, verbosity, maxErr);
139  }
140 
141  //
142  // Loop over unique daughters
143  //
144  std::set<const G4LogicalVolume *> tested;
145 
146  const G4LogicalVolume *logical = target->GetLogicalVolume();
147  G4int nDaughter = logical->GetNoDaughters();
148  for( auto iDaughter=0; iDaughter<nDaughter; ++iDaughter )
149  {
150  G4VPhysicalVolume *daughter = logical->GetDaughter(iDaughter);
151 
152  // Tested already?
153  //
154  // const G4LogicalVolume *daughterLogical =
155  // daughter->GetLogicalVolume();
156  // std::pair<std::set<const G4LogicalVolume *>::iterator, G4bool>
157  // there = tested.insert(daughterLogical);
158  // if (!there.second) continue;
159 
160  //
161  // Recurse
162  //
163  G4GeomTestVolume vTest( daughter, tolerance, resolution, verbosity );
164  vTest.SetErrorsThreshold(maxErr);
165  vTest.TestRecursiveOverlap( slevel,depth );
166  }
167 }