Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // >> 26 // >> 27 // $Id: G4NormalNavigation.cc,v 1.9 2007/05/11 13:43:59 gcosmo Exp $ >> 28 // GEANT4 tag $Name: geant4-09-02 $ >> 29 // >> 30 // 26 // class G4NormalNavigation Implementation 31 // class G4NormalNavigation Implementation 27 // 32 // 28 // Author: P.Kent, 1996 33 // Author: P.Kent, 1996 29 // 34 // 30 // ------------------------------------------- 35 // -------------------------------------------------------------------- 31 36 32 #include "G4NormalNavigation.hh" 37 #include "G4NormalNavigation.hh" 33 #include "G4NavigationLogger.hh" << 34 #include "G4AffineTransform.hh" 38 #include "G4AffineTransform.hh" 35 39 >> 40 #include <iomanip> >> 41 36 // ******************************************* 42 // ******************************************************************** 37 // Constructor 43 // Constructor 38 // ******************************************* 44 // ******************************************************************** 39 // 45 // 40 G4NormalNavigation::G4NormalNavigation() 46 G4NormalNavigation::G4NormalNavigation() >> 47 : fCheck(false), fVerbose(0) 41 { 48 { 42 fLogger = new G4NavigationLogger("G4NormalNa << 43 } 49 } 44 50 45 // ******************************************* 51 // ******************************************************************** 46 // Destructor 52 // Destructor 47 // ******************************************* 53 // ******************************************************************** 48 // 54 // 49 G4NormalNavigation::~G4NormalNavigation() 55 G4NormalNavigation::~G4NormalNavigation() 50 { << 56 {;} 51 delete fLogger; << 52 } << 53 57 54 // ******************************************* 58 // ******************************************************************** 55 // ComputeStep 59 // ComputeStep 56 // ******************************************* 60 // ******************************************************************** 57 // 61 // 58 // On entry << 59 // exitNormal, validExitNormal: for previo << 60 // << 61 // On exit << 62 // exitNormal, validExitNormal: for mother << 63 G4double 62 G4double 64 G4NormalNavigation::ComputeStep(const G4ThreeV << 63 G4NormalNavigation::ComputeStep(const G4ThreeVector &localPoint, 65 const G4ThreeV << 64 const G4ThreeVector &localDirection, 66 const G4double 65 const G4double currentProposedStepLength, 67 G4double << 66 G4double &newSafety, 68 G4Naviga << 67 G4NavigationHistory &history, 69 G4bool& << 68 G4bool &validExitNormal, 70 G4ThreeV << 69 G4ThreeVector &exitNormal, 71 G4bool& << 70 G4bool &exiting, 72 G4bool& << 71 G4bool &entering, 73 G4VPhysi << 72 G4VPhysicalVolume *(*pBlockedPhysical), 74 G4int& b << 73 G4int &blockedReplicaNo) 75 { 74 { 76 G4VPhysicalVolume *motherPhysical, *samplePh << 75 G4VPhysicalVolume *motherPhysical, *samplePhysical, *blockedExitedVol=0; 77 *blockedExitedVol = nullpt << 78 G4LogicalVolume *motherLogical; 76 G4LogicalVolume *motherLogical; 79 G4VSolid *motherSolid; 77 G4VSolid *motherSolid; 80 G4ThreeVector sampleDirection; 78 G4ThreeVector sampleDirection; 81 G4double ourStep = currentProposedStepLength << 79 G4double ourStep=currentProposedStepLength, motherSafety, ourSafety; 82 G4double motherSafety, motherStep = DBL_MAX; << 80 G4int localNoDaughters, sampleNo; 83 G4long localNoDaughters, sampleNo; << 84 G4bool motherValidExitNormal = false; << 85 G4ThreeVector motherExitNormal; << 86 81 87 motherPhysical = history.GetTopVolume(); 82 motherPhysical = history.GetTopVolume(); 88 motherLogical = motherPhysical->GetLogicalV 83 motherLogical = motherPhysical->GetLogicalVolume(); 89 motherSolid = motherLogical->GetSolid(); 84 motherSolid = motherLogical->GetSolid(); 90 85 91 // Compute mother safety 86 // Compute mother safety 92 // 87 // 93 motherSafety = motherSolid->DistanceToOut(lo 88 motherSafety = motherSolid->DistanceToOut(localPoint); 94 ourSafety = motherSafety; // Working isotrop 89 ourSafety = motherSafety; // Working isotropic safety 95 << 96 localNoDaughters = motherLogical->GetNoDaugh << 97 90 98 #ifdef G4VERBOSE 91 #ifdef G4VERBOSE 99 if ( fCheck && ( (localNoDaughters>0) || (ou << 92 static G4int precVerf= 20; // Precision >> 93 if ( fCheck ) 100 { 94 { 101 fLogger->PreComputeStepLog(motherPhysical, << 95 if( fVerbose == 1 ) >> 96 { >> 97 G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl >> 98 << " Invoked DistanceToOut(p) for mother solid: " >> 99 << motherSolid->GetName() >> 100 << ". Solid replied: " << motherSafety << G4endl >> 101 << " For local point p: " << localPoint << G4endl >> 102 << " To be considered as 'mother safety'." << G4endl; >> 103 } >> 104 if ( motherSafety < 0.0 ) >> 105 { >> 106 G4cerr << "ERROR - G4NormalNavigation::ComputeStep()" << G4endl >> 107 << " Current solid " << motherSolid->GetName() >> 108 << " gave negative safety: " << motherSafety << G4endl >> 109 << " for the current (local) point " << localPoint >> 110 << G4endl; >> 111 motherSolid->DumpInfo(); >> 112 G4Exception("G4NormalNavigation::ComputeStep()", >> 113 "NegativeSafetyMotherVol", FatalException, >> 114 "Negative Safety In Voxel Navigation !" ); >> 115 } >> 116 if( motherSolid->Inside(localPoint)==kOutside ) >> 117 { >> 118 G4cout << "WARNING - G4NormalNavigation::ComputeStep()" << G4endl >> 119 << " Point " << localPoint >> 120 << " is outside current volume " << motherPhysical->GetName() >> 121 << G4endl; >> 122 G4double estDistToSolid= motherSolid->DistanceToIn(localPoint); >> 123 G4cout << " Estimated isotropic distance to solid (distToIn)= " >> 124 << estDistToSolid << G4endl; >> 125 if( estDistToSolid > 100.0 * motherSolid->GetTolerance() ) >> 126 { >> 127 motherSolid->DumpInfo(); >> 128 G4Exception("G4NormalNavigation::ComputeStep()", >> 129 "FarOutsideCurrentVolume", FatalException, >> 130 "Point is far outside Current Volume !" ); >> 131 } >> 132 else >> 133 G4Exception("G4NormalNavigation::ComputeStep()", "OutsideCurrentVolume", >> 134 JustWarning, "Point is a little outside Current Volume."); >> 135 } >> 136 >> 137 // Verification / verbosity >> 138 // >> 139 if ( fVerbose > 1 ) >> 140 { >> 141 G4int oldprec = G4cout.precision(precVerf); >> 142 G4cout << " G4NormalNavigation::ComputeStep()" >> 143 << " - Information on mother / key daughters ..." << G4endl; >> 144 G4cout << " Type " << std::setw(12) << "Solid-Name" << " " >> 145 << std::setw(3*(6+precVerf)) << " local point" << " " >> 146 << std::setw(4+precVerf) << "solid-Safety" << " " >> 147 << std::setw(4+precVerf) << "solid-Step" << " " >> 148 << std::setw(17) << "distance Method " >> 149 << std::setw(3*(6+precVerf)) << " local direction" << " " >> 150 << G4endl; >> 151 G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " " >> 152 << std::setw(4+precVerf) << localPoint << " " >> 153 << std::setw(4+precVerf) << motherSafety << " " >> 154 << G4endl; >> 155 G4cout.precision(oldprec); >> 156 } >> 157 102 } 158 } 103 #endif 159 #endif >> 160 >> 161 // 104 // Compute daughter safeties & intersections 162 // Compute daughter safeties & intersections 105 // 163 // 106 164 107 // Exiting normal optimisation 165 // Exiting normal optimisation 108 // 166 // 109 if ( exiting && validExitNormal ) << 167 if ( exiting&&validExitNormal ) 110 { 168 { 111 if ( localDirection.dot(exitNormal)>=kMinE 169 if ( localDirection.dot(exitNormal)>=kMinExitingNormalCosine ) 112 { 170 { 113 // Block exited daughter volume 171 // Block exited daughter volume 114 // 172 // 115 blockedExitedVol = (*pBlockedPhysical); << 173 blockedExitedVol =* pBlockedPhysical; 116 ourSafety = 0; 174 ourSafety = 0; 117 } 175 } 118 } 176 } 119 exiting = false; 177 exiting = false; 120 entering = false; 178 entering = false; 121 179 122 #ifdef G4VERBOSE << 180 localNoDaughters = motherLogical->GetNoDaughters(); 123 if ( fCheck ) << 124 { << 125 // Compute early: << 126 // a) to check whether point is (wrongly) << 127 // (signaled if step < 0 or << 128 // b) to check value against answer of da << 129 << 130 motherStep = motherSolid->DistanceToOut(lo << 131 lo << 132 tr << 133 &mo << 134 &mo << 135 << 136 if( (motherStep >= kInfinity) || (motherSt << 137 { << 138 // Error - indication of being outside s << 139 fLogger->ReportOutsideMother(localPoint, << 140 << 141 ourStep = motherStep = 0.0; << 142 << 143 exiting = true; << 144 entering = false; << 145 << 146 // If we are outside the solid does the << 147 validExitNormal = motherValidExitNormal; << 148 exitNormal = motherExitNormal; << 149 << 150 *pBlockedPhysical = nullptr; // or mothe << 151 blockedReplicaNo = 0; // or motherRepli << 152 << 153 newSafety = 0.0; << 154 return ourStep; << 155 } << 156 } << 157 #endif << 158 << 159 for ( sampleNo=localNoDaughters-1; sampleNo> 181 for ( sampleNo=localNoDaughters-1; sampleNo>=0; sampleNo--) 160 { 182 { 161 samplePhysical = motherLogical->GetDaughte 183 samplePhysical = motherLogical->GetDaughter(sampleNo); 162 if ( samplePhysical!=blockedExitedVol ) 184 if ( samplePhysical!=blockedExitedVol ) 163 { 185 { 164 G4AffineTransform sampleTf(samplePhysica 186 G4AffineTransform sampleTf(samplePhysical->GetRotation(), 165 samplePhysica 187 samplePhysical->GetTranslation()); 166 sampleTf.Invert(); 188 sampleTf.Invert(); 167 const G4ThreeVector samplePoint = sample << 189 const G4ThreeVector samplePoint = >> 190 sampleTf.TransformPoint(localPoint); 168 const G4VSolid *sampleSolid = 191 const G4VSolid *sampleSolid = 169 samplePhysical->GetLogicalVolume 192 samplePhysical->GetLogicalVolume()->GetSolid(); 170 const G4double sampleSafety = 193 const G4double sampleSafety = 171 sampleSolid->DistanceToIn(sample 194 sampleSolid->DistanceToIn(samplePoint); 172 << 173 if ( sampleSafety<ourSafety ) 195 if ( sampleSafety<ourSafety ) 174 { 196 { 175 ourSafety=sampleSafety; 197 ourSafety=sampleSafety; 176 } 198 } 177 << 178 if ( sampleSafety<=ourStep ) 199 if ( sampleSafety<=ourStep ) 179 { 200 { 180 sampleDirection = sampleTf.TransformAx 201 sampleDirection = sampleTf.TransformAxis(localDirection); 181 const G4double sampleStep = 202 const G4double sampleStep = 182 sampleSolid->DistanceToIn(samp 203 sampleSolid->DistanceToIn(samplePoint,sampleDirection); 183 #ifdef G4VERBOSE << 204 #ifdef G4VERBOSE 184 if( fCheck ) << 205 if(( fCheck ) && ( fVerbose == 1 )) 185 { 206 { 186 fLogger->PrintDaughterLog(sampleSoli << 207 G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl 187 sampleSafe << 208 << " Invoked DistanceToIn(p,v) for daughter solid: " 188 sampleDire << 209 << sampleSolid->GetName() >> 210 << ". Solid replied: " << sampleStep << G4endl >> 211 << " For local point p: " << samplePoint << G4endl >> 212 << " Direction v: " << sampleDirection >> 213 << ", to be considered as 'daughter step'." << G4endl; 189 } 214 } 190 #endif 215 #endif 191 if ( sampleStep<=ourStep ) 216 if ( sampleStep<=ourStep ) 192 { 217 { 193 ourStep = sampleStep; 218 ourStep = sampleStep; 194 entering = true; 219 entering = true; 195 exiting = false; 220 exiting = false; 196 *pBlockedPhysical = samplePhysical; 221 *pBlockedPhysical = samplePhysical; 197 blockedReplicaNo = -1; 222 blockedReplicaNo = -1; >> 223 198 #ifdef G4VERBOSE 224 #ifdef G4VERBOSE 199 if( fCheck ) << 225 // Check to see that the resulting point is indeed in/on volume. >> 226 // This check could eventually be made only for successful candidate. >> 227 >> 228 if ( ( fCheck ) && ( sampleStep < kInfinity ) ) 200 { 229 { 201 fLogger->AlongComputeStepLog(sampl << 230 G4ThreeVector intersectionPoint; 202 sampl << 231 intersectionPoint= samplePoint + sampleStep * sampleDirection; 203 sampl << 232 EInside insideIntPt= sampleSolid->Inside(intersectionPoint); >> 233 G4String solidResponse = "-kInside-"; >> 234 if (insideIntPt == kOutside) >> 235 solidResponse = "-kOutside-"; >> 236 else if (insideIntPt == kSurface) >> 237 solidResponse = "-kSurface-"; >> 238 if( fVerbose == 1 ) >> 239 { >> 240 G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl >> 241 << " Invoked Inside() for solid: " >> 242 << sampleSolid->GetName() >> 243 << ". Solid replied: " << solidResponse << G4endl >> 244 << " For point p: " << intersectionPoint >> 245 << ", considered as 'intersection' point." << G4endl; >> 246 } >> 247 if ( insideIntPt != kSurface ) >> 248 { >> 249 G4int oldcoutPrec = G4cout.precision(16); >> 250 G4cout << "WARNING - G4NormalNavigation::ComputeStep()" << G4endl >> 251 << " Inaccurate DistanceToIn for solid " >> 252 << sampleSolid->GetName() << G4endl; >> 253 G4cout << " Solid gave DistanceToIn = " << sampleStep >> 254 << " yet returns " << solidResponse >> 255 << " for this point !" << G4endl; >> 256 G4cout << " Point = " << intersectionPoint << G4endl; >> 257 if ( insideIntPt != kInside ) >> 258 G4cout << " DistanceToIn(p) = " >> 259 << sampleSolid->DistanceToIn(intersectionPoint) >> 260 << G4endl; >> 261 if ( insideIntPt != kOutside ) >> 262 G4cout << " DistanceToOut(p) = " >> 263 << sampleSolid->DistanceToOut(intersectionPoint) >> 264 << G4endl; >> 265 G4Exception("G4NormalNavigation::ComputeStep()", >> 266 "InaccurateDistanceToIn", JustWarning, >> 267 "Navigator gets conflicting response from Solid."); >> 268 G4cout.precision(oldcoutPrec); >> 269 } 204 } 270 } 205 #endif << 206 } << 207 271 208 #ifdef G4VERBOSE << 272 // Verification / verbosity 209 if( fCheck && (sampleStep < kInfinity) << 273 // 210 { << 274 if ( fVerbose > 1 ) 211 // The intersection point with the << 275 { 212 // point from the mother volume. D << 276 G4int oldprec = G4cout.precision(precVerf); 213 fLogger->CheckDaughterEntryPoint(sa << 277 G4cout << " Daught " 214 sa << 278 << std::setw(12) << sampleSolid->GetName() << " " 215 mo << 279 << std::setw(4+precVerf) << samplePoint << " " 216 lo << 280 << std::setw(4+precVerf) << sampleSafety << " " 217 mo << 281 << std::setw(4+precVerf) << sampleStep << " " 218 } << 282 << std::setw(16) << "distanceToIn" << " " >> 283 << std::setw(4+precVerf) << localDirection << " " >> 284 << G4endl; >> 285 G4cout.precision(oldprec); >> 286 } 219 #endif 287 #endif 220 } // end of if ( sampleSafety <= ourStep << 288 } 221 #ifdef G4VERBOSE << 222 else if ( fCheck ) << 223 { << 224 fLogger->PrintDaughterLog(sampleSolid << 225 sampleSafet << 226 G4ThreeVect << 227 } 289 } 228 #endif << 229 } 290 } 230 } 291 } 231 if ( currentProposedStepLength<ourSafety ) 292 if ( currentProposedStepLength<ourSafety ) 232 { 293 { 233 // Guaranteed physics limited 294 // Guaranteed physics limited 234 // 295 // 235 entering = false; 296 entering = false; 236 exiting = false; 297 exiting = false; 237 *pBlockedPhysical = nullptr; << 298 *pBlockedPhysical = 0; 238 ourStep = kInfinity; 299 ourStep = kInfinity; 239 } 300 } 240 else 301 else 241 { 302 { 242 // Consider intersection with mother solid << 303 // Compute mother intersection if required 243 // 304 // 244 if ( motherSafety<=ourStep ) 305 if ( motherSafety<=ourStep ) 245 { 306 { 246 if ( !fCheck ) // The call is moved abo << 307 G4double motherStep = motherSolid->DistanceToOut(localPoint, 247 { << 308 localDirection, 248 motherStep = motherSolid->DistanceToOu << 309 true, 249 << 310 &validExitNormal, 250 << 311 &exitNormal); 251 << 252 << 253 } << 254 #ifdef G4VERBOSE 312 #ifdef G4VERBOSE 255 else // check_mode << 313 if ( fCheck ) 256 { 314 { 257 fLogger->PostComputeStepLog(motherSoli << 315 if( fVerbose == 1 ) 258 motherStep << 259 if( motherValidExitNormal ) << 260 { 316 { 261 fLogger->CheckAndReportBadNormal(mot << 317 G4cout << "*** G4NormalNavigation::ComputeStep(): ***" << G4endl 262 loc << 318 << " Invoked DistanceToOut(p,v,...) for mother solid: " 263 loc << 319 << motherSolid->GetName() 264 mot << 320 << ". Solid replied: " << motherStep << G4endl 265 mot << 321 << " For local point p: " << localPoint << G4endl 266 "Fr << 322 << " Direction v: " << localDirection >> 323 << ", to be considered as 'mother step'." << G4endl; 267 } 324 } 268 } << 325 if( ( motherStep < 0.0 ) || ( motherStep >= kInfinity) ) 269 #endif << 270 << 271 if( (motherStep >= kInfinity) || (mother << 272 { << 273 #ifdef G4VERBOSE << 274 if( fCheck ) // Clearly outside the m << 275 { 326 { 276 fLogger->ReportOutsideMother(localPo << 327 G4cerr << "ERROR - G4NormalNavigation::ComputeStep()" << G4endl 277 motherP << 328 << " Problem in Navigation" << G4endl >> 329 << " Point (local coordinates): " >> 330 << localPoint << G4endl >> 331 << " Local Direction: " << localDirection << G4endl >> 332 << " Solid: " << motherSolid->GetName() << G4endl; >> 333 motherSolid->DumpInfo(); >> 334 G4Exception("G4NormalNavigation::ComputeStep()", >> 335 "PointDistOutInvalid", FatalException, >> 336 "Current point is outside the current solid !"); 278 } 337 } 279 #endif << 280 ourStep = motherStep = 0.0; << 281 exiting = true; << 282 entering = false; << 283 // validExitNormal= motherValidExitNor << 284 // exitNormal= motherExitNormal; << 285 // The normal could be useful - but o << 286 // But it could be unreliable! << 287 validExitNormal = false; << 288 *pBlockedPhysical = nullptr; // or mot << 289 blockedReplicaNo = 0; // or motherRep << 290 newSafety= 0.0; << 291 return ourStep; << 292 } 338 } >> 339 if ( fVerbose > 1 ) >> 340 { >> 341 G4int oldprec = G4cout.precision(precVerf); >> 342 G4cout << " Mother " << std::setw(12) << motherSolid->GetName() << " " >> 343 << std::setw(4+precVerf) << localPoint << " " >> 344 << std::setw(4+precVerf) << motherSafety << " " >> 345 << std::setw(4+precVerf) << motherStep << " " >> 346 << std::setw(16) << "distanceToOut" << " " >> 347 << std::setw(4+precVerf) << localDirection << " " >> 348 << G4endl; >> 349 G4cout.precision(oldprec); >> 350 } >> 351 #endif 293 352 294 if ( motherStep<=ourStep ) 353 if ( motherStep<=ourStep ) 295 { 354 { 296 ourStep = motherStep; 355 ourStep = motherStep; 297 exiting = true; 356 exiting = true; 298 entering = false; 357 entering = false; 299 validExitNormal = motherValidExitNorma << 358 if ( validExitNormal ) 300 exitNormal = motherExitNormal; << 301 << 302 if ( motherValidExitNormal ) << 303 { 359 { 304 const G4RotationMatrix *rot = mother 360 const G4RotationMatrix *rot = motherPhysical->GetRotation(); 305 if (rot != nullptr) << 361 if (rot) 306 { 362 { 307 exitNormal *= rot->inverse(); 363 exitNormal *= rot->inverse(); 308 #ifdef G4VERBOSE << 309 if( fCheck ) << 310 { << 311 fLogger->CheckAndReportBadNorma << 312 << 313 << 314 << 315 } << 316 #endif << 317 } 364 } 318 } 365 } 319 } 366 } 320 else 367 else 321 { 368 { 322 validExitNormal = false; 369 validExitNormal = false; 323 } 370 } 324 } 371 } 325 } 372 } 326 newSafety = ourSafety; 373 newSafety = ourSafety; 327 return ourStep; 374 return ourStep; 328 } 375 } 329 376 330 // ******************************************* 377 // ******************************************************************** 331 // ComputeSafety 378 // ComputeSafety 332 // ******************************************* 379 // ******************************************************************** 333 // 380 // 334 G4double G4NormalNavigation::ComputeSafety(con << 381 G4double G4NormalNavigation::ComputeSafety(const G4ThreeVector &localPoint, 335 con << 382 const G4NavigationHistory &history, 336 con 383 const G4double) 337 { 384 { 338 G4VPhysicalVolume *motherPhysical, *samplePh 385 G4VPhysicalVolume *motherPhysical, *samplePhysical; 339 G4LogicalVolume *motherLogical; 386 G4LogicalVolume *motherLogical; 340 G4VSolid *motherSolid; 387 G4VSolid *motherSolid; 341 G4double motherSafety, ourSafety; 388 G4double motherSafety, ourSafety; 342 G4long localNoDaughters, sampleNo; << 389 G4int localNoDaughters, sampleNo; 343 390 344 motherPhysical = history.GetTopVolume(); 391 motherPhysical = history.GetTopVolume(); 345 motherLogical = motherPhysical->GetLogicalV 392 motherLogical = motherPhysical->GetLogicalVolume(); 346 motherSolid = motherLogical->GetSolid(); 393 motherSolid = motherLogical->GetSolid(); 347 394 348 // Compute mother safety 395 // Compute mother safety 349 // 396 // 350 motherSafety = motherSolid->DistanceToOut(lo 397 motherSafety = motherSolid->DistanceToOut(localPoint); 351 ourSafety = motherSafety; // Working isotrop 398 ourSafety = motherSafety; // Working isotropic safety 352 399 353 #ifdef G4VERBOSE 400 #ifdef G4VERBOSE 354 if( fCheck ) << 401 if(( fCheck ) && ( fVerbose == 1 )) 355 { 402 { 356 fLogger->ComputeSafetyLog(motherSolid,loca << 403 G4cout << "*** G4NormalNavigation::ComputeSafety(): ***" << G4endl >> 404 << " Invoked DistanceToOut(p) for mother solid: " >> 405 << motherSolid->GetName() >> 406 << ". Solid replied: " << motherSafety << G4endl >> 407 << " For local point p: " << localPoint >> 408 << ", to be considered as 'mother safety'." << G4endl; 357 } 409 } 358 #endif 410 #endif 359 411 360 // Compute daughter safeties 412 // Compute daughter safeties 361 // 413 // 362 localNoDaughters = motherLogical->GetNoDaugh 414 localNoDaughters = motherLogical->GetNoDaughters(); 363 for ( sampleNo=localNoDaughters-1; sampleNo> 415 for ( sampleNo=localNoDaughters-1; sampleNo>=0; sampleNo-- ) 364 { 416 { 365 samplePhysical = motherLogical->GetDaughte 417 samplePhysical = motherLogical->GetDaughter(sampleNo); 366 G4AffineTransform sampleTf(samplePhysical- 418 G4AffineTransform sampleTf(samplePhysical->GetRotation(), 367 samplePhysical- 419 samplePhysical->GetTranslation()); 368 sampleTf.Invert(); 420 sampleTf.Invert(); 369 const G4ThreeVector samplePoint = 421 const G4ThreeVector samplePoint = 370 sampleTf.TransformPoint(localPoint 422 sampleTf.TransformPoint(localPoint); 371 const G4VSolid *sampleSolid = 423 const G4VSolid *sampleSolid = 372 samplePhysical->GetLogicalVolume() 424 samplePhysical->GetLogicalVolume()->GetSolid(); 373 const G4double sampleSafety = 425 const G4double sampleSafety = 374 sampleSolid->DistanceToIn(samplePo 426 sampleSolid->DistanceToIn(samplePoint); 375 if ( sampleSafety<ourSafety ) 427 if ( sampleSafety<ourSafety ) 376 { 428 { 377 ourSafety = sampleSafety; 429 ourSafety = sampleSafety; 378 } 430 } 379 #ifdef G4VERBOSE 431 #ifdef G4VERBOSE 380 if(fCheck) << 432 if(( fCheck ) && ( fVerbose == 1 )) 381 { 433 { 382 fLogger->ComputeSafetyLog(sampleSolid, s << 434 G4cout << "*** G4NormalNavigation::ComputeSafety(): ***" << G4endl 383 sampleSafety, << 435 << " Invoked DistanceToIn(p) for daughter solid: " 384 // Not mother, no banner << 436 << sampleSolid->GetName() >> 437 << ". Solid replied: " << sampleSafety << G4endl >> 438 << " For local point p: " << samplePoint >> 439 << ", to be considered as 'daughter safety'." << G4endl; 385 } 440 } 386 #endif 441 #endif 387 } 442 } 388 return ourSafety; 443 return ourSafety; 389 } << 390 << 391 // The following methods have been imported to << 392 // in order to avoid dependency of the header << 393 // header implementation of G4NavigationLogger << 394 << 395 // ******************************************* << 396 // GetVerboseLevel << 397 // ******************************************* << 398 // << 399 G4int G4NormalNavigation::GetVerboseLevel() co << 400 { << 401 return fLogger->GetVerboseLevel(); << 402 } << 403 << 404 // ******************************************* << 405 // SetVerboseLevel << 406 // ******************************************* << 407 // << 408 void G4NormalNavigation::SetVerboseLevel(G4int << 409 { << 410 fLogger->SetVerboseLevel(level); << 411 } 444 } 412 445