Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4GeomTestStreamLogger.cc
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// $Id$
28//
29// --------------------------------------------------------------------
30// GEANT 4 class source file
31//
32// G4GeomTestStreamLogger
33//
34// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
35// --------------------------------------------------------------------
36
37#include <iomanip>
38
39#include "G4SystemOfUnits.hh"
41#include "G4VSolid.hh"
42#include "G4VPhysicalVolume.hh"
45
46//
47// Constructor and destructor
48//
50 G4int theMaxPointsPerError )
51 : out(o), maxPointsPerError(theMaxPointsPerError)
52{;}
53
55{;}
56
57//
58// ::PrintPos
59//
60// Utility class for printing a 3 vector position
61//
62void G4GeomTestStreamLogger::PrintPos::Print( std::ostream &o ) const
63{
64 o << std::setprecision(6) << std::setw(14) << p.x()/cm;
65 o << std::setprecision(6) << std::setw(14) << p.y()/cm;
66 o << std::setprecision(6) << std::setw(14) << p.z()/cm;
67 if (unit) o << " cm";
68}
69
70std::ostream &operator<<( std::ostream &o,
72{
73 p.Print(o);
74 return o;
75}
76
77//
78// ::VolumeNameAndCopy
79//
80// Utility class for printing a volume's name and copy number
81//
82void
84{
85 o << volume->GetName() << "[" << volume->GetCopyNo() << "]";
86}
87
88std::ostream &operator<<( std::ostream &o,
90{
91 p.Print(o);
92 return o;
93}
94
95
96//
97// SolidProblem
98//
100 const G4String &message,
101 const G4ThreeVector &point )
102{
103 out << "GeomTest Error: SolidProblem\n"
104 << " " << message << "\n"
105 << " Solid name = " << solid->GetName() << "\n"
106 << " Local position = " << PrintPos(point) << std::endl;
107}
108
109
110//
111// NoProblem
112//
114{
115 out << message << std::endl;
116}
117
118
119//
120// OverlappingDaughters
121//
122void
124{
125 G4int n = list->NumError();
126 if (n <= 0) return;
127
128 out << "GeomTest Error: Overlapping daughter volumes\n"
129 << " The volumes " << VolumeNameAndCopy(list->GetDaughter1())
130 << " and " << VolumeNameAndCopy(list->GetDaughter2()) << ",\n"
131 << " both daughters of volume " << VolumeNameAndCopy(list->GetMother())
132 << ",\n"
133 << " appear to overlap at the following " << (n>1 ? "points" : "point")
134 << " in global coordinates:";
135
136 G4int nInterval, nStop;
137
138 if (n <= maxPointsPerError) {
139 out << "\n";
140 nInterval = 1;
141 nStop = n;
142 }
143 else {
144 out << " (list truncated)\n";
145 nInterval = n/maxPointsPerError;
146 nStop = maxPointsPerError*nInterval;
147 }
148
149 G4int i;
150 G4ThreeVector s1, s2;
151
153 for(i=0;i<nStop;i+=nInterval) {
154 list->GetGlobalPoints( i, s1, s2 );
155 PrintSegmentListElement( s1, s2 );
156 }
157
158 out << " Which in the mother coordinate system " << IsAre(n) << ":\n";
159
161 for(i=0;i<nStop;i+=nInterval) {
162 list->GetMotherPoints( i, s1, s2 );
163 PrintSegmentListElement( s1, s2 );
164 }
165
166 out << " Which in the coordinate system of "
167 << VolumeNameAndCopy(list->GetDaughter1()) << " " << IsAre(n) << ":\n";
168
170 for(i=0;i<nStop;i+=nInterval) {
171 list->GetDaught1Points( i, s1, s2 );
172 PrintSegmentListElement( s1, s2 );
173 }
174
175 out << " Which in the coordinate system of "
176 << VolumeNameAndCopy(list->GetDaughter2()) << " " << IsAre(n) << ":\n";
177
179 for(i=0;i<nStop;i+=nInterval) {
180 list->GetDaught2Points( i, s1, s2 );
181 PrintSegmentListElement( s1, s2 );
182 }
183
184 out << std::endl;
185}
186
187
188//
189// OvershootingDaughter
190//
193{
194 G4int n = list->NumError();
195 if (n <= 0) return;
196
197 out << "GeomTest Error: Overshooting daughter volume\n"
198 << " The volume " << VolumeNameAndCopy(list->GetDaughter())
199 << " appears to extend outside the mother volume "
200 << VolumeNameAndCopy(list->GetMother()) << "\n"
201 << " at the following " << (n>1 ? "points" : "point")
202 << " in global coordinates:";
203
204
205 G4int nInterval, nStop;
206
207 if (n <= maxPointsPerError) {
208 out << "\n";
209 nInterval = 1;
210 nStop = n;
211 }
212 else {
213 out << " (list truncated)\n";
214 nInterval = n/maxPointsPerError;
215 nStop = maxPointsPerError*nInterval;
216 }
217
218 G4int i;
219 G4ThreeVector s1, s2;
220
222 for(i=0;i<nStop;i+=nInterval) {
223 list->GetGlobalPoints( i, s1, s2 );
224 PrintSegmentListElement( s1, s2 );
225 }
226
227 out << " Which in the mother coordinate system " << IsAre(n) << ":\n";
228
230 for(i=0;i<nStop;i+=nInterval) {
231 list->GetMotherPoints( i, s1, s2 );
232 PrintSegmentListElement( s1, s2 );
233 }
234
235 out << " Which in the coordinate system of "
236 << VolumeNameAndCopy(list->GetDaughter()) << " " << IsAre(n) << ":\n";
237
239 for(i=0;i<nStop;i+=nInterval) {
240 list->GetDaughtPoints( i, s1, s2 );
241 PrintSegmentListElement( s1, s2 );
242 }
243
244 out << std::endl;
245}
246
247
248
249//
250// PrintSegmentListHeader (protected)
251//
252// Print out a header for a segment list
253//
255{
256 static const char *header =
257 " length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------\n";
258 // .............| .............|.............|.............| .............|.............|.............|
259 // 1234 1234 123
260
261 out << header;
262}
263
264
265//
266// PrintSegmentListElement (protected)
267//
268// Print out one segment value
269//
271 const G4ThreeVector &s2 )
272{
273 out << " " << std::setprecision(6) << std::setw(14)
274 << (s1-s2).mag()/cm
275 << " " << PrintPos(s1,false) << " " << PrintPos(s2,false) << "\n";
276}
277
278
279//
280// IsAre (protected)
281//
282// Return a pointer to the string "is" if the argument
283// is equal to 1, otherwise return a pointer to "are"
284//
286{
287 const char *is = "is";
288 const char *are = "are";
289
290 return n > 1 ? are : is;
291}
int G4int
Definition: G4Types.hh:66
double z() const
double x() const
double y() const
const G4VPhysicalVolume * GetMother() const
void GetGlobalPoints(G4int i, G4ThreeVector &s1, G4ThreeVector &s2) const
void GetMotherPoints(G4int i, G4ThreeVector &s1, G4ThreeVector &s2) const
void GetDaught2Points(G4int, G4ThreeVector &, G4ThreeVector &) const
void GetDaught1Points(G4int, G4ThreeVector &, G4ThreeVector &) const
const G4VPhysicalVolume * GetDaughter1() const
const G4VPhysicalVolume * GetDaughter2() const
const G4VPhysicalVolume * GetDaughter() const
void GetDaughtPoints(G4int i, G4ThreeVector &s1, G4ThreeVector &s2) const
void PrintSegmentListElement(const G4ThreeVector &s1, const G4ThreeVector &s2)
virtual void OvershootingDaughter(const G4GeomTestOvershootList *list)
friend std::ostream & operator<<(std::ostream &, const G4GeomTestStreamLogger::PrintPos &)
G4GeomTestStreamLogger(std::ostream &o, G4int theMaxPointsPerError=20)
const char * IsAre(G4int n)
virtual void SolidProblem(const G4VSolid *solid, const G4String &message, const G4ThreeVector &point)
virtual void OverlappingDaughters(const G4GeomTestOverlapList *list)
virtual void NoProblem(const G4String &message)
G4String GetName() const