G4Navigator.icc

Go to the documentation of this file.
00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00015 // * use.  Please see the license in the file  LICENSE  and URL above *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // $Id$
00028 //
00029 // 
00030 // class G4Navigator Inline implementation
00031 //
00032 // ********************************************************************
00033 
00034 // ********************************************************************
00035 // GetCurrentLocalCoordinate
00036 //
00037 // Returns the local coordinate of the current track
00038 // ********************************************************************
00039 //
00040 inline
00041 G4ThreeVector G4Navigator::GetCurrentLocalCoordinate() const
00042 {
00043   return fLastLocatedPointLocal;
00044 }
00045 
00046 // ********************************************************************
00047 // ComputeLocalAxis
00048 //
00049 // Returns local direction of vector direction in world coord system
00050 // ********************************************************************
00051 //
00052 inline
00053 G4ThreeVector G4Navigator::ComputeLocalAxis(const G4ThreeVector& pVec) const
00054 {
00055   return (fHistory.GetTopTransform().IsRotated())
00056          ? fHistory.GetTopTransform().TransformAxis(pVec) : pVec ;
00057 }
00058 
00059 // ********************************************************************
00060 // ComputeLocalPoint
00061 //
00062 // Returns local coordinates of a point in the world coord system
00063 // ********************************************************************
00064 //
00065 inline
00066 G4ThreeVector
00067 G4Navigator::ComputeLocalPoint(const G4ThreeVector& pGlobalPoint) const
00068 {
00069   return ( fHistory.GetTopTransform().TransformPoint(pGlobalPoint) ) ;
00070 }
00071 
00072 // ********************************************************************
00073 // GetWorldVolume
00074 //
00075 // Returns the current  world (`topmost') volume
00076 // ********************************************************************
00077 //
00078 inline
00079 G4VPhysicalVolume* G4Navigator::GetWorldVolume() const
00080 {
00081   return fTopPhysical;
00082 }
00083 
00084 // ********************************************************************
00085 // SetWorldVolume
00086 //
00087 // Sets the world (`topmost') volume
00088 // ********************************************************************
00089 //
00090 inline
00091 void G4Navigator::SetWorldVolume(G4VPhysicalVolume* pWorld)
00092 {
00093   if ( !(pWorld->GetTranslation()==G4ThreeVector(0,0,0)) )
00094   {
00095     G4Exception ("G4Navigator::SetWorldVolume()", "GeomNav0002",
00096                  FatalException, "Volume must be centered on the origin.");
00097   }
00098   const G4RotationMatrix* rm = pWorld->GetRotation();
00099   if ( rm && (!rm->isIdentity()) )
00100   {
00101     G4Exception ("G4Navigator::SetWorldVolume()", "GeomNav0002",
00102                  FatalException, "Volume must not be rotated.");
00103   }
00104   fTopPhysical = pWorld;
00105   fHistory.SetFirstEntry(pWorld);
00106 }
00107 
00108 // ********************************************************************
00109 // SetGeometrycallyLimitedStep
00110 //
00111 // Informs the navigator that the previous Step calculated
00112 // by the geometry was taken in its entirety
00113 // ********************************************************************
00114 //
00115 inline
00116 void G4Navigator::SetGeometricallyLimitedStep()
00117 {
00118   fWasLimitedByGeometry=true;
00119 }
00120 
00121 // ********************************************************************
00122 // ResetStackAndState
00123 //
00124 // Resets stack and minimum of navigator state `machine'
00125 // ********************************************************************
00126 //
00127 inline
00128 void G4Navigator::ResetStackAndState()
00129 {
00130   fHistory.Reset();
00131   ResetState();
00132 }
00133 
00134 // ********************************************************************
00135 // VolumeType
00136 // ********************************************************************
00137 //
00138 inline
00139 EVolume G4Navigator::VolumeType(const G4VPhysicalVolume *pVol) const
00140 {
00141   EVolume type;
00142   EAxis axis;
00143   G4int nReplicas;
00144   G4double width,offset;
00145   G4bool consuming;
00146   if ( pVol->IsReplicated() )
00147   {
00148     pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
00149     type = (consuming) ? kReplica : kParameterised;
00150   }
00151   else
00152   {
00153     type = kNormal;
00154   }
00155   return type;
00156 }
00157 
00158 // ********************************************************************
00159 // CharacteriseDaughters
00160 // ********************************************************************
00161 //
00162 inline
00163 EVolume G4Navigator::CharacteriseDaughters(const G4LogicalVolume *pLog) const
00164 {
00165   EVolume type;
00166   EAxis axis;
00167   G4int nReplicas;
00168   G4double width,offset;
00169   G4bool consuming;
00170   G4VPhysicalVolume *pVol;
00171 
00172   if ( pLog->GetNoDaughters()==1 )
00173   {
00174     pVol = pLog->GetDaughter(0);
00175     if (pVol->IsReplicated())
00176     {
00177       pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
00178       type = (consuming) ? kReplica : kParameterised;
00179     }
00180     else
00181     {
00182       type = kNormal;
00183     }
00184   }
00185   else
00186   {
00187     type = kNormal;
00188   }
00189   return type;
00190 }
00191 
00192 // ********************************************************************
00193 // GetDaughtersRegularStructureId
00194 // ********************************************************************
00195 //
00196 inline
00197 G4int G4Navigator::
00198 GetDaughtersRegularStructureId(const G4LogicalVolume *pLog) const
00199 {
00200   G4int regId = 0;
00201   G4VPhysicalVolume *pVol;
00202 
00203   if ( pLog->GetNoDaughters()==1 )
00204   {
00205     pVol = pLog->GetDaughter(0);
00206     regId = pVol->GetRegularStructureId();
00207   }
00208   return regId;
00209 }
00210 
00211 // ********************************************************************
00212 // GetGlobalToLocalTransform
00213 //
00214 // Returns local to global transformation.
00215 // I.e. transformation that will take point or axis in world coord system
00216 // and return one in the local coord system
00217 // ********************************************************************
00218 //
00219 inline
00220 const G4AffineTransform& G4Navigator::GetGlobalToLocalTransform() const
00221 {
00222   return fHistory.GetTopTransform();
00223 }
00224 
00225 // ********************************************************************
00226 // GetLocalToGlobalTransform
00227 //
00228 // Returns global to local transformation 
00229 // ********************************************************************
00230 //
00231 inline
00232 const G4AffineTransform G4Navigator::GetLocalToGlobalTransform() const
00233 {
00234   G4AffineTransform  tempTransform;
00235   tempTransform = fHistory.GetTopTransform().Inverse(); 
00236   return tempTransform;
00237 }
00238 
00239 // ********************************************************************
00240 // NetTranslation
00241 //
00242 // Computes+returns the local->global translation of current volume
00243 // ********************************************************************
00244 //
00245 inline
00246 G4ThreeVector G4Navigator::NetTranslation() const
00247 {
00248   G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
00249   return tf.NetTranslation();
00250 }
00251 
00252 // ********************************************************************
00253 // NetRotation
00254 //
00255 // Computes+returns the local->global rotation of current volume
00256 // ********************************************************************
00257 //
00258 inline
00259 G4RotationMatrix G4Navigator::NetRotation() const
00260 {
00261   G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
00262   return tf.NetRotation();
00263 }
00264 
00265 // ********************************************************************
00266 // CreateGRSVolume
00267 //
00268 // `Touchable' creation method: caller has deletion responsibility
00269 // ********************************************************************
00270 //
00271 inline
00272 G4GRSVolume* G4Navigator::CreateGRSVolume() const
00273 {
00274   G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
00275   return new G4GRSVolume(fHistory.GetTopVolume(),
00276                          tf.NetRotation(),
00277                          tf.NetTranslation());
00278 }
00279 
00280 // ********************************************************************
00281 // CreateGRSSolid
00282 //
00283 // `Touchable' creation method: caller has deletion responsibility
00284 // ********************************************************************
00285 //
00286 inline
00287 G4GRSSolid* G4Navigator::CreateGRSSolid() const
00288 {
00289   G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
00290   return new G4GRSSolid(fHistory.GetTopVolume()->GetLogicalVolume()->GetSolid(),
00291                         tf.NetRotation(),
00292                         tf.NetTranslation());
00293 }
00294 
00295 // ********************************************************************
00296 // CreateTouchableHistory
00297 //
00298 // `Touchable' creation method: caller has deletion responsibility
00299 // ********************************************************************
00300 //
00301 inline
00302 G4TouchableHistory* G4Navigator::CreateTouchableHistory() const
00303 {
00304   return new G4TouchableHistory(fHistory);
00305 }
00306 
00307 // ********************************************************************
00308 // CreateTouchableHistory(history)
00309 //
00310 // `Touchable' creation method: caller has deletion responsibility
00311 // ********************************************************************
00312 //
00313 inline
00314 G4TouchableHistory*
00315 G4Navigator::CreateTouchableHistory(const G4NavigationHistory* history) const
00316 {
00317   return new G4TouchableHistory(*history);
00318 }
00319 
00320 // ********************************************************************
00321 // LocateGlobalPointAndUpdateTouchableHandle
00322 // ********************************************************************
00323 //
00324 inline
00325 void G4Navigator::LocateGlobalPointAndUpdateTouchableHandle(
00326                                const G4ThreeVector&       position,
00327                                const G4ThreeVector&       direction,
00328                                      G4TouchableHandle&   oldTouchableToUpdate,
00329                                const G4bool               RelativeSearch )
00330 {
00331   G4VPhysicalVolume* pPhysVol;
00332   pPhysVol = LocateGlobalPointAndSetup( position,&direction,RelativeSearch );
00333   if( fEnteredDaughter || fExitedMother )
00334   {
00335      oldTouchableToUpdate = CreateTouchableHistory();
00336      if( pPhysVol == 0 )
00337      {
00338        // We want to ensure that the touchable is correct in this case.
00339        //  The method below should do this and recalculate a lot more ....
00340        //
00341        oldTouchableToUpdate->UpdateYourself( pPhysVol, &fHistory );
00342      }
00343   }
00344   return;
00345 }
00346 
00347 // ********************************************************************
00348 // LocateGlobalPointAndUpdateTouchable
00349 //
00350 // Use direction
00351 // ********************************************************************
00352 //
00353 inline
00354 void G4Navigator::LocateGlobalPointAndUpdateTouchable(
00355                            const G4ThreeVector&       position,
00356                            const G4ThreeVector&       direction,
00357                                  G4VTouchable*        touchableToUpdate,
00358                            const G4bool               RelativeSearch  )
00359 {
00360   G4VPhysicalVolume* pPhysVol;
00361   pPhysVol = LocateGlobalPointAndSetup( position, &direction, RelativeSearch);  
00362   touchableToUpdate->UpdateYourself( pPhysVol, &fHistory );
00363 }
00364 
00365 // ********************************************************************
00366 // LocateGlobalPointAndUpdateTouchable
00367 // ********************************************************************
00368 //
00369 inline
00370 void G4Navigator::LocateGlobalPointAndUpdateTouchable(
00371                            const G4ThreeVector&       position,
00372                                  G4VTouchable*        touchableToUpdate,
00373                            const G4bool               RelativeSearch )
00374 {
00375   G4VPhysicalVolume* pPhysVol;
00376   pPhysVol = LocateGlobalPointAndSetup( position, 0, RelativeSearch);  
00377   touchableToUpdate->UpdateYourself( pPhysVol, &fHistory );
00378 }
00379 
00380 // ********************************************************************
00381 // GetVerboseLevel
00382 // ********************************************************************
00383 //
00384 inline
00385 G4int G4Navigator::GetVerboseLevel() const
00386 {
00387   return fVerbose;
00388 }
00389 
00390 // ********************************************************************
00391 // SetVerboseLevel
00392 // ********************************************************************
00393 //
00394 inline
00395 void G4Navigator::SetVerboseLevel(G4int level)
00396 {
00397   fVerbose = level;
00398   fnormalNav.SetVerboseLevel(level);
00399   fvoxelNav.SetVerboseLevel(level);
00400   fparamNav.SetVerboseLevel(level);
00401   freplicaNav.SetVerboseLevel(level);
00402   fregularNav.SetVerboseLevel(level);
00403 }
00404 
00405 // ********************************************************************
00406 // IsActive
00407 // ********************************************************************
00408 //
00409 inline
00410 G4bool G4Navigator::IsActive() const
00411 {
00412   return fActive;
00413 }
00414 
00415 // ********************************************************************
00416 // Activate
00417 // ********************************************************************
00418 //
00419 inline
00420 void G4Navigator::Activate(G4bool flag)
00421 {
00422   fActive = flag;
00423 }
00424 
00425 // ********************************************************************
00426 // EnteredDaughterVolume
00427 //
00428 // To inform the caller if the track is entering a daughter volume
00429 // ********************************************************************
00430 //
00431 inline
00432 G4bool G4Navigator::EnteredDaughterVolume() const
00433 {
00434   return fEnteredDaughter;
00435 }
00436 
00437 // ********************************************************************
00438 // ExitedMotherVolume
00439 // ********************************************************************
00440 //
00441 inline
00442 G4bool G4Navigator::ExitedMotherVolume() const
00443 {
00444   return fExitedMother;
00445 }
00446 
00447 // ********************************************************************
00448 // CheckMode
00449 // ********************************************************************
00450 //
00451 inline
00452 void  G4Navigator::CheckMode(G4bool mode)
00453 {
00454   fCheck = mode;
00455   fnormalNav.CheckMode(mode);
00456   fvoxelNav.CheckMode(mode);
00457   fparamNav.CheckMode(mode);
00458   freplicaNav.CheckMode(mode);
00459   fregularNav.CheckMode(mode);
00460 }
00461 
00462 // ********************************************************************
00463 // IsCheckModeActive
00464 // ********************************************************************
00465 //
00466 inline
00467 G4bool G4Navigator::IsCheckModeActive() const
00468 {
00469   return fCheck;
00470 }
00471 
00472 // ********************************************************************
00473 // SetPushVerbosity
00474 // ********************************************************************
00475 //
00476 inline
00477 void G4Navigator::SetPushVerbosity(G4bool mode)
00478 {
00479   fWarnPush = mode;
00480 }
00481 
00482 // ********************************************************************
00483 // SeverityOfZeroStepping
00484 //
00485 // Reports on severity of error in case Navigator is stuck
00486 // and is returning zero steps
00487 // ********************************************************************
00488 //
00489 inline 
00490 G4int G4Navigator::SeverityOfZeroStepping( G4int* noZeroSteps ) const 
00491 {
00492   G4int severity=0, noZeros= fNumberZeroSteps;
00493   if( noZeroSteps) *noZeroSteps = fNumberZeroSteps;
00494 
00495   if( noZeros >= fAbandonThreshold_NoZeroSteps )
00496   {
00497     severity = 10;
00498   }
00499   if( noZeros > 0 && noZeros < fActionThreshold_NoZeroSteps )
00500   {
00501     severity =  5 * noZeros / fActionThreshold_NoZeroSteps;
00502   }
00503   else if( noZeros == fActionThreshold_NoZeroSteps )
00504   {
00505     severity =  5; 
00506   }
00507   else if( noZeros >= fAbandonThreshold_NoZeroSteps - 2 )
00508   {
00509     severity =  9; 
00510   }
00511   else if( noZeros < fAbandonThreshold_NoZeroSteps - 2 )
00512   {
00513     severity =  5 + 4 * (noZeros-fAbandonThreshold_NoZeroSteps)
00514                       / fActionThreshold_NoZeroSteps;
00515   }
00516   return severity;
00517 }
00518 
00519 // ********************************************************************
00520 // EnableBestSafety
00521 // ********************************************************************
00522 //
00523 inline void G4Navigator::EnableBestSafety( G4bool value )
00524 {
00525   fvoxelNav.EnableBestSafety( value );
00526 }

Generated on Mon May 27 17:48:57 2013 for Geant4 by  doxygen 1.4.7