G4RegularNavigation Class Reference

#include <G4RegularNavigation.hh>


Public Member Functions

 G4RegularNavigation ()
 ~G4RegularNavigation ()
G4bool LevelLocate (G4NavigationHistory &history, const G4VPhysicalVolume *blockedVol, const G4int blockedNum, const G4ThreeVector &globalPoint, const G4ThreeVector *globalDirection, const G4bool pLocatedOnEdge, G4ThreeVector &localPoint)
G4double ComputeStep (const G4ThreeVector &globalPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo)
G4double ComputeStepSkippingEqualMaterials (G4ThreeVector &localPoint, const G4ThreeVector &globalDirection, const G4double currentProposedStepLength, G4double &newSafety, G4NavigationHistory &history, G4bool &validExitNormal, G4ThreeVector &exitNormal, G4bool &exiting, G4bool &entering, G4VPhysicalVolume *(*pBlockedPhysical), G4int &blockedReplicaNo, G4VPhysicalVolume *pCurrentPhysical)
G4double ComputeSafety (const G4ThreeVector &localPoint, const G4NavigationHistory &history, const G4double pProposedMaxLength=DBL_MAX)
void SetVerboseLevel (G4int level)
void CheckMode (G4bool mode)
void SetNormalNavigation (G4NormalNavigation *fnormnav)


Detailed Description

Definition at line 54 of file G4RegularNavigation.hh.


Constructor & Destructor Documentation

G4RegularNavigation::G4RegularNavigation (  ) 

Definition at line 46 of file G4RegularNavigation.cc.

References G4GeometryTolerance::GetInstance(), and G4GeometryTolerance::GetSurfaceTolerance().

00047   : fverbose(false), fcheck(false), fnormalNav(0)
00048 {
00049   kCarTolerance = G4GeometryTolerance::GetInstance()->GetSurfaceTolerance();
00050 }

G4RegularNavigation::~G4RegularNavigation (  ) 

Definition at line 54 of file G4RegularNavigation.cc.

00055 {
00056 }


Member Function Documentation

void G4RegularNavigation::CheckMode ( G4bool  mode  )  [inline]

Definition at line 118 of file G4RegularNavigation.hh.

Referenced by G4Navigator::CheckMode(), and G4ITNavigator::CheckMode().

00118 { fcheck = mode; }

G4double G4RegularNavigation::ComputeSafety ( const G4ThreeVector localPoint,
const G4NavigationHistory history,
const G4double  pProposedMaxLength = DBL_MAX 
)

Definition at line 266 of file G4RegularNavigation.cc.

References G4NormalNavigation::ComputeSafety().

Referenced by G4Navigator::ComputeSafety(), and G4ITNavigator::ComputeSafety().

00269 {
00270   // This method is never called because to be called the daughter has to be a
00271   // regular structure. This would only happen if the track is in the mother of
00272   // voxels volume. But the voxels fill completely their mother, so when a
00273   // track enters the mother it automatically enters a voxel. Only precision
00274   // problems would make this method to be called
00275 
00276   // Compute step in voxel
00277   //
00278   return fnormalNav->ComputeSafety(localPoint,
00279                                    history,
00280                                    pMaxLength );
00281 }

G4double G4RegularNavigation::ComputeStep ( const G4ThreeVector globalPoint,
const G4ThreeVector globalDirection,
const G4double  currentProposedStepLength,
G4double newSafety,
G4NavigationHistory history,
G4bool validExitNormal,
G4ThreeVector exitNormal,
G4bool exiting,
G4bool entering,
G4VPhysicalVolume **  pBlockedPhysical,
G4int blockedReplicaNo 
)

Definition at line 61 of file G4RegularNavigation.cc.

References G4NormalNavigation::ComputeStep(), G4LogicalVolume::GetDaughter(), G4VPhysicalVolume::GetLogicalVolume(), G4VPhysicalVolume::GetParameterisation(), G4PhantomParameterisation::GetReplicaNo(), G4NavigationHistory::GetTopTransform(), G4NavigationHistory::GetTopVolume(), G4PhantomParameterisation::GetTranslation(), G4AffineTransform::Inverse(), LevelLocate(), G4AffineTransform::TransformAxis(), and G4AffineTransform::TransformPoint().

Referenced by G4Navigator::ComputeStep(), and G4ITNavigator::ComputeStep().

00072 {
00073   // This method is never called because to be called the daughter has to be
00074   // a regular structure. This would only happen if the track is in the mother
00075   // of voxels volume. But the voxels fill completely their mother, so when a
00076   // track enters the mother it automatically enters a voxel. Only precision
00077   // problems would make this method to be called
00078 
00079   G4ThreeVector globalPoint =
00080          history.GetTopTransform().Inverse().TransformPoint(localPoint);
00081   G4ThreeVector globalDirection =
00082          history.GetTopTransform().Inverse().TransformAxis(localDirection);
00083 
00084   G4ThreeVector localPoint2 = localPoint; // take away constantness
00085 
00086   LevelLocate( history, *pBlockedPhysical, blockedReplicaNo, 
00087                globalPoint, &globalDirection, true, localPoint2 );
00088 
00089 
00090   // Get in which voxel it is
00091   //
00092   G4VPhysicalVolume *motherPhysical, *daughterPhysical;
00093   G4LogicalVolume *motherLogical;
00094   motherPhysical = history.GetTopVolume();
00095   motherLogical = motherPhysical->GetLogicalVolume();
00096   daughterPhysical = motherLogical->GetDaughter(0);
00097 
00098   G4PhantomParameterisation * daughterParam =
00099         (G4PhantomParameterisation*)(daughterPhysical->GetParameterisation());
00100   G4int copyNo = daughterParam ->GetReplicaNo(localPoint,localDirection);
00101 
00102   G4ThreeVector voxelTranslation = daughterParam->GetTranslation( copyNo );
00103   G4ThreeVector daughterPoint = localPoint - voxelTranslation;
00104 
00105 
00106   // Compute step in voxel
00107   //
00108   return fnormalNav->ComputeStep(daughterPoint,
00109                                  localDirection,
00110                                  currentProposedStepLength,
00111                                  newSafety,
00112                                  history,
00113                                  validExitNormal,
00114                                  exitNormal,
00115                                  exiting,
00116                                  entering,
00117                                  pBlockedPhysical,
00118                                  blockedReplicaNo);
00119 }

G4double G4RegularNavigation::ComputeStepSkippingEqualMaterials ( G4ThreeVector localPoint,
const G4ThreeVector globalDirection,
const G4double  currentProposedStepLength,
G4double newSafety,
G4NavigationHistory history,
G4bool validExitNormal,
G4ThreeVector exitNormal,
G4bool exiting,
G4bool entering,
G4VPhysicalVolume **  pBlockedPhysical,
G4int blockedReplicaNo,
G4VPhysicalVolume pCurrentPhysical 
)

Definition at line 123 of file G4RegularNavigation.cc.

References G4RegularNavigationHelper::AddStepLength(), G4RegularNavigationHelper::ClearStepLengths(), G4PhantomParameterisation::ComputeMaterial(), G4NormalNavigation::ComputeStep(), G4VSolid::DistanceToOut(), G4PhantomParameterisation::GetContainerSolid(), G4NavigationHistory::GetDepth(), G4VPhysicalVolume::GetLogicalVolume(), G4VPhysicalVolume::GetParameterisation(), G4PhantomParameterisation::GetReplicaNo(), G4LogicalVolume::GetSolid(), G4NavigationHistory::GetTransform(), G4PhantomParameterisation::GetTranslation(), G4VSolid::Inside(), G4RegularNavigationHelper::Instance(), G4AffineTransform::Inverse(), kInside, G4PhantomParameterisation::SkipEqualMaterials(), and G4AffineTransform::TransformPoint().

00136 {
00137   G4RegularNavigationHelper::Instance()->ClearStepLengths();
00138 
00139   G4PhantomParameterisation *param =
00140     (G4PhantomParameterisation*)(pCurrentPhysical->GetParameterisation());
00141 
00142   if( !param->SkipEqualMaterials() )
00143   {
00144     return fnormalNav->ComputeStep(localPoint,
00145                                    localDirection,
00146                                    currentProposedStepLength,
00147                                    newSafety,
00148                                    history,
00149                                    validExitNormal,
00150                                    exitNormal,
00151                                    exiting,
00152                                    entering,
00153                                    pBlockedPhysical,
00154                                    blockedReplicaNo);
00155   }
00156 
00157 
00158   G4double ourStep = 0.;
00159 
00160   // To get replica No: transform local point to the reference system of the
00161   // param container volume
00162   //
00163   G4int ide = history.GetDepth();
00164   G4ThreeVector containerPoint = history.GetTransform(ide).Inverse().TransformPoint(localPoint);
00165 
00166   // Point in global frame
00167   //
00168   containerPoint = history.GetTransform(ide).Inverse().TransformPoint(localPoint);
00169 
00170   // Point in voxel parent volume frame
00171   //
00172   containerPoint = history.GetTransform(ide-1).TransformPoint(containerPoint);
00173 
00174   // Store previous voxel translation to move localPoint by the difference
00175   // with the new one
00176   //
00177   G4ThreeVector prevVoxelTranslation = containerPoint - localPoint;
00178 
00179   // Do not use the expression below: There are cases where the
00180   // fLastLocatedPointLocal does not give the correct answer
00181   // (particle reaching a wall and bounced back, particle travelling through
00182   // the wall that is deviated in an step, ...; these are pathological cases
00183   // that give wrong answers in G4PhantomParameterisation::GetReplicaNo()
00184   //
00185   // G4ThreeVector prevVoxelTranslation = param->GetTranslation( copyNo );
00186 
00187   G4int copyNo = param->GetReplicaNo(containerPoint,localDirection);
00188 
00189   G4Material* currentMate = param->ComputeMaterial( copyNo, 0, 0 );
00190   G4VSolid* voxelBox = pCurrentPhysical->GetLogicalVolume()->GetSolid();
00191 
00192   G4VSolid* containerSolid = param->GetContainerSolid();
00193   G4Material* nextMate;
00194   G4bool bFirstStep = true;
00195   G4double newStep;
00196   G4double totalNewStep = 0.;
00197 
00198   // Loop while same material is found 
00199   //
00200   for( ;; )
00201   {
00202     newStep = voxelBox->DistanceToOut( localPoint, localDirection );
00203 
00204     if( (bFirstStep) && (newStep < currentProposedStepLength) )
00205     {
00206       exiting  = true;
00207     }
00208     bFirstStep = false;
00209  
00210     newStep += kCarTolerance;   // Avoid precision problems
00211     ourStep += newStep;
00212     totalNewStep += newStep;
00213 
00214     // Physical process is limiting the step, don't continue
00215     //
00216     if(std::fabs(totalNewStep-currentProposedStepLength) < kCarTolerance)
00217     { 
00218       return currentProposedStepLength;
00219     }
00220     if(totalNewStep > currentProposedStepLength) 
00221     { 
00222       G4RegularNavigationHelper::Instance()->
00223         AddStepLength(copyNo, newStep-totalNewStep+currentProposedStepLength);
00224       return currentProposedStepLength;
00225     }
00226     else
00227     {
00228       G4RegularNavigationHelper::Instance()->AddStepLength( copyNo, newStep );
00229     }
00230 
00231 
00232     // Move container point until wall of voxel
00233     //
00234     containerPoint += newStep*localDirection;
00235     if( containerSolid->Inside( containerPoint ) != kInside )
00236     {
00237       break;
00238     }
00239 
00240     // Get copyNo and translation of new voxel
00241     //
00242     copyNo = param->GetReplicaNo(containerPoint,localDirection);
00243     G4ThreeVector voxelTranslation = param->GetTranslation( copyNo );
00244 
00245     //    G4cout << " copyNo " << copyNo << " = " << pCurrentPhysical->GetCopyNo() << G4endl;
00246     // Move local point until wall of voxel and then put it in the new voxel
00247     // local coordinates
00248     //
00249     localPoint += newStep*localDirection;
00250     localPoint += prevVoxelTranslation - voxelTranslation;
00251 
00252     prevVoxelTranslation = voxelTranslation;
00253 
00254     // Check if material of next voxel is the same as that of the current voxel
00255     nextMate = param->ComputeMaterial( copyNo, 0, 0 );
00256 
00257     if( currentMate != nextMate ) { break; }
00258   }
00259 
00260   return ourStep;
00261 }

G4bool G4RegularNavigation::LevelLocate ( G4NavigationHistory history,
const G4VPhysicalVolume blockedVol,
const G4int  blockedNum,
const G4ThreeVector globalPoint,
const G4ThreeVector globalDirection,
const G4bool  pLocatedOnEdge,
G4ThreeVector localPoint 
)

Definition at line 286 of file G4RegularNavigation.cc.

References G4PhantomParameterisation::ComputeMaterial(), G4PhantomParameterisation::ComputeTransformation(), G4LogicalVolume::GetDaughter(), G4VPhysicalVolume::GetLogicalVolume(), G4PhantomParameterisation::GetNoVoxel(), G4VPhysicalVolume::GetParameterisation(), G4PhantomParameterisation::GetReplicaNo(), G4NavigationHistory::GetTopTransform(), G4NavigationHistory::GetTopVolume(), kParameterised, G4NavigationHistory::NewLevel(), G4VPhysicalVolume::SetCopyNo(), G4AffineTransform::TransformAxis(), G4AffineTransform::TransformPoint(), and G4LogicalVolume::UpdateMaterial().

Referenced by ComputeStep(), G4Navigator::LocateGlobalPointAndSetup(), and G4ITNavigator::LocateGlobalPointAndSetup().

00293 {
00294   G4VPhysicalVolume *motherPhysical, *pPhysical;
00295   G4PhantomParameterisation *pParam;
00296   G4LogicalVolume *motherLogical;
00297   G4ThreeVector localDir;
00298   G4int replicaNo;
00299   
00300   motherPhysical = history.GetTopVolume();
00301   motherLogical = motherPhysical->GetLogicalVolume();
00302   
00303   pPhysical = motherLogical->GetDaughter(0);
00304   pParam = (G4PhantomParameterisation*)(pPhysical->GetParameterisation());
00305   
00306   // Save parent history in touchable history
00307   // ... for use as parent t-h in ComputeMaterial method of param
00308   //
00309   G4TouchableHistory parentTouchable( history ); 
00310   
00311   // Get local direction
00312   //
00313   if( globalDirection )
00314   {
00315     localDir = history.GetTopTransform().TransformAxis(*globalDirection);
00316   }
00317   else
00318   {
00319     localDir = G4ThreeVector(0.,0.,0.);
00320   }
00321 
00322   // Enter this daughter
00323   //
00324   replicaNo = pParam->GetReplicaNo( localPoint, localDir );
00325 
00326   if( replicaNo < 0 || replicaNo >= G4int(pParam->GetNoVoxel()) )
00327   {
00328     return false;
00329   }
00330 
00331   // Set the correct copy number in physical
00332   //
00333   pPhysical->SetCopyNo(replicaNo);
00334   pParam->ComputeTransformation(replicaNo,pPhysical);
00335 
00336   history.NewLevel(pPhysical, kParameterised, replicaNo );
00337   localPoint = history.GetTopTransform().TransformPoint(globalPoint);
00338 
00339   // Set the correct solid and material in Logical Volume
00340   //
00341   G4LogicalVolume *pLogical = pPhysical->GetLogicalVolume();
00342       
00343   pLogical->UpdateMaterial(pParam->ComputeMaterial(replicaNo,
00344                            pPhysical, &parentTouchable) );
00345   return true;
00346 }

void G4RegularNavigation::SetNormalNavigation ( G4NormalNavigation fnormnav  )  [inline]

Definition at line 119 of file G4RegularNavigation.hh.

Referenced by G4ITNavigator::G4ITNavigator(), and G4Navigator::G4Navigator().

00120       { fnormalNav = fnormnav; }

void G4RegularNavigation::SetVerboseLevel ( G4int  level  )  [inline]

Definition at line 117 of file G4RegularNavigation.hh.

Referenced by G4Navigator::SetVerboseLevel(), and G4ITNavigator::SetVerboseLevel().

00117 { fverbose = level; }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:53:17 2013 for Geant4 by  doxygen 1.4.7