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