00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #include <iomanip>
00038
00039 #include "G4SystemOfUnits.hh"
00040 #include "G4GeomTestStreamLogger.hh"
00041 #include "G4VSolid.hh"
00042 #include "G4VPhysicalVolume.hh"
00043 #include "G4GeomTestOverlapList.hh"
00044 #include "G4GeomTestOvershootList.hh"
00045
00046
00047
00048
00049 G4GeomTestStreamLogger::G4GeomTestStreamLogger( std::ostream &o,
00050 G4int theMaxPointsPerError )
00051 : out(o), maxPointsPerError(theMaxPointsPerError)
00052 {;}
00053
00054 G4GeomTestStreamLogger::~G4GeomTestStreamLogger()
00055 {;}
00056
00057
00058
00059
00060
00061
00062 void G4GeomTestStreamLogger::PrintPos::Print( std::ostream &o ) const
00063 {
00064 o << std::setprecision(6) << std::setw(14) << p.x()/cm;
00065 o << std::setprecision(6) << std::setw(14) << p.y()/cm;
00066 o << std::setprecision(6) << std::setw(14) << p.z()/cm;
00067 if (unit) o << " cm";
00068 }
00069
00070 std::ostream &operator<<( std::ostream &o,
00071 const G4GeomTestStreamLogger::PrintPos &p )
00072 {
00073 p.Print(o);
00074 return o;
00075 }
00076
00077
00078
00079
00080
00081
00082 void
00083 G4GeomTestStreamLogger::VolumeNameAndCopy::Print( std::ostream &o ) const
00084 {
00085 o << volume->GetName() << "[" << volume->GetCopyNo() << "]";
00086 }
00087
00088 std::ostream &operator<<( std::ostream &o,
00089 const G4GeomTestStreamLogger::VolumeNameAndCopy &p )
00090 {
00091 p.Print(o);
00092 return o;
00093 }
00094
00095
00096
00097
00098
00099 void G4GeomTestStreamLogger::SolidProblem( const G4VSolid *solid,
00100 const G4String &message,
00101 const G4ThreeVector &point )
00102 {
00103 out << "GeomTest Error: SolidProblem\n"
00104 << " " << message << "\n"
00105 << " Solid name = " << solid->GetName() << "\n"
00106 << " Local position = " << PrintPos(point) << std::endl;
00107 }
00108
00109
00110
00111
00112
00113 void G4GeomTestStreamLogger::NoProblem( const G4String &message )
00114 {
00115 out << message << std::endl;
00116 }
00117
00118
00119
00120
00121
00122 void
00123 G4GeomTestStreamLogger::OverlappingDaughters(const G4GeomTestOverlapList *list)
00124 {
00125 G4int n = list->NumError();
00126 if (n <= 0) return;
00127
00128 out << "GeomTest Error: Overlapping daughter volumes\n"
00129 << " The volumes " << VolumeNameAndCopy(list->GetDaughter1())
00130 << " and " << VolumeNameAndCopy(list->GetDaughter2()) << ",\n"
00131 << " both daughters of volume " << VolumeNameAndCopy(list->GetMother())
00132 << ",\n"
00133 << " appear to overlap at the following " << (n>1 ? "points" : "point")
00134 << " in global coordinates:";
00135
00136 G4int nInterval, nStop;
00137
00138 if (n <= maxPointsPerError) {
00139 out << "\n";
00140 nInterval = 1;
00141 nStop = n;
00142 }
00143 else {
00144 out << " (list truncated)\n";
00145 nInterval = n/maxPointsPerError;
00146 nStop = maxPointsPerError*nInterval;
00147 }
00148
00149 G4int i;
00150 G4ThreeVector s1, s2;
00151
00152 PrintSegmentListHeader();
00153 for(i=0;i<nStop;i+=nInterval) {
00154 list->GetGlobalPoints( i, s1, s2 );
00155 PrintSegmentListElement( s1, s2 );
00156 }
00157
00158 out << " Which in the mother coordinate system " << IsAre(n) << ":\n";
00159
00160 PrintSegmentListHeader();
00161 for(i=0;i<nStop;i+=nInterval) {
00162 list->GetMotherPoints( i, s1, s2 );
00163 PrintSegmentListElement( s1, s2 );
00164 }
00165
00166 out << " Which in the coordinate system of "
00167 << VolumeNameAndCopy(list->GetDaughter1()) << " " << IsAre(n) << ":\n";
00168
00169 PrintSegmentListHeader();
00170 for(i=0;i<nStop;i+=nInterval) {
00171 list->GetDaught1Points( i, s1, s2 );
00172 PrintSegmentListElement( s1, s2 );
00173 }
00174
00175 out << " Which in the coordinate system of "
00176 << VolumeNameAndCopy(list->GetDaughter2()) << " " << IsAre(n) << ":\n";
00177
00178 PrintSegmentListHeader();
00179 for(i=0;i<nStop;i+=nInterval) {
00180 list->GetDaught2Points( i, s1, s2 );
00181 PrintSegmentListElement( s1, s2 );
00182 }
00183
00184 out << std::endl;
00185 }
00186
00187
00188
00189
00190
00191 void G4GeomTestStreamLogger::
00192 OvershootingDaughter( const G4GeomTestOvershootList *list )
00193 {
00194 G4int n = list->NumError();
00195 if (n <= 0) return;
00196
00197 out << "GeomTest Error: Overshooting daughter volume\n"
00198 << " The volume " << VolumeNameAndCopy(list->GetDaughter())
00199 << " appears to extend outside the mother volume "
00200 << VolumeNameAndCopy(list->GetMother()) << "\n"
00201 << " at the following " << (n>1 ? "points" : "point")
00202 << " in global coordinates:";
00203
00204
00205 G4int nInterval, nStop;
00206
00207 if (n <= maxPointsPerError) {
00208 out << "\n";
00209 nInterval = 1;
00210 nStop = n;
00211 }
00212 else {
00213 out << " (list truncated)\n";
00214 nInterval = n/maxPointsPerError;
00215 nStop = maxPointsPerError*nInterval;
00216 }
00217
00218 G4int i;
00219 G4ThreeVector s1, s2;
00220
00221 PrintSegmentListHeader();
00222 for(i=0;i<nStop;i+=nInterval) {
00223 list->GetGlobalPoints( i, s1, s2 );
00224 PrintSegmentListElement( s1, s2 );
00225 }
00226
00227 out << " Which in the mother coordinate system " << IsAre(n) << ":\n";
00228
00229 PrintSegmentListHeader();
00230 for(i=0;i<nStop;i+=nInterval) {
00231 list->GetMotherPoints( i, s1, s2 );
00232 PrintSegmentListElement( s1, s2 );
00233 }
00234
00235 out << " Which in the coordinate system of "
00236 << VolumeNameAndCopy(list->GetDaughter()) << " " << IsAre(n) << ":\n";
00237
00238 PrintSegmentListHeader();
00239 for(i=0;i<nStop;i+=nInterval) {
00240 list->GetDaughtPoints( i, s1, s2 );
00241 PrintSegmentListElement( s1, s2 );
00242 }
00243
00244 out << std::endl;
00245 }
00246
00247
00248
00249
00250
00251
00252
00253
00254 void G4GeomTestStreamLogger::PrintSegmentListHeader()
00255 {
00256 static const char *header =
00257 " length (cm) ---------- start position (cm) ----------- ----------- end position (cm) ------------\n";
00258
00259
00260
00261 out << header;
00262 }
00263
00264
00265
00266
00267
00268
00269
00270 void G4GeomTestStreamLogger::PrintSegmentListElement( const G4ThreeVector &s1,
00271 const G4ThreeVector &s2 )
00272 {
00273 out << " " << std::setprecision(6) << std::setw(14)
00274 << (s1-s2).mag()/cm
00275 << " " << PrintPos(s1,false) << " " << PrintPos(s2,false) << "\n";
00276 }
00277
00278
00279
00280
00281
00282
00283
00284
00285 const char *G4GeomTestStreamLogger::IsAre( G4int n )
00286 {
00287 const char *is = "is";
00288 const char *are = "are";
00289
00290 return n > 1 ? are : is;
00291 }