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

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