G4TouchableHistory.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 G4TouchableHistory inline implementation
00031 // ----------------------------------------------------------------------
00032 
00033 #if defined G4GEOM_ALLOC_EXPORT
00034   extern G4DLLEXPORT G4Allocator<G4TouchableHistory> aTouchableHistoryAllocator;
00035 #else
00036   extern G4DLLIMPORT G4Allocator<G4TouchableHistory> aTouchableHistoryAllocator;
00037 #endif
00038 
00039 inline
00040 void  G4TouchableHistory::UpdateYourself( G4VPhysicalVolume*   pPhysVol,
00041                                     const G4NavigationHistory* pHistory ) 
00042 {
00043   fhistory = *pHistory;  
00044   G4AffineTransform tf(fhistory.GetTopTransform().Inverse());
00045   if( pPhysVol == 0 )
00046   {
00047     // This means that the track has left the World Volume.
00048     // Since the Navigation History does not already reflect this,
00049     // we must correct this problem here.
00050     //
00051     fhistory.SetFirstEntry(pPhysVol);
00052   }
00053   ftlate = tf.NetTranslation();
00054   frot = tf.NetRotation();
00055 }
00056 
00057 inline
00058 G4int G4TouchableHistory::CalculateHistoryIndex( G4int stackDepth ) const
00059 {
00060   return (fhistory.GetDepth()-stackDepth); // was -1
00061 }
00062 
00063 inline
00064 G4VPhysicalVolume* G4TouchableHistory::GetVolume( G4int depth ) const
00065 {
00066   return fhistory.GetVolume(CalculateHistoryIndex(depth));
00067 }
00068 
00069 inline
00070 G4VSolid* G4TouchableHistory::GetSolid( G4int depth ) const
00071 {
00072   return fhistory.GetVolume(CalculateHistoryIndex(depth))
00073                             ->GetLogicalVolume()->GetSolid();
00074 }
00075 
00076 inline
00077 G4int G4TouchableHistory::GetReplicaNumber( G4int depth ) const
00078 {
00079   return fhistory.GetReplicaNo(CalculateHistoryIndex(depth));
00080 }
00081 
00082 inline
00083 G4int G4TouchableHistory::GetHistoryDepth()  const
00084 {
00085   return  fhistory.GetDepth();
00086 }
00087 
00088 inline
00089 G4int G4TouchableHistory::MoveUpHistory( G4int num_levels )
00090 {
00091   G4int maxLevelsMove = fhistory.GetDepth();
00092   G4int minLevelsMove = 0;              // Cannot redescend today!
00093                                         // Soon it will be possible
00094                                         // by adding a data member here
00095                                         //     fCurrentDepth;
00096   if( num_levels > maxLevelsMove )
00097   {
00098     num_levels = maxLevelsMove;
00099   }
00100   else if( num_levels < minLevelsMove )
00101   {
00102     num_levels = minLevelsMove;
00103   }
00104   fhistory.BackLevel( num_levels ); 
00105 
00106   return num_levels;
00107 }
00108 
00109 inline
00110 const G4NavigationHistory* G4TouchableHistory::GetHistory() const
00111 {
00112   return &fhistory;
00113 }
00114 
00115 // There is no provision in case this class is subclassed.
00116 // If it is subclassed, this will fail and may not give errors!
00117 //
00118 inline
00119 void* G4TouchableHistory::operator new(size_t)
00120 {
00121   return (void *) aTouchableHistoryAllocator.MallocSingle();
00122 }
00123 
00124 inline
00125 void G4TouchableHistory::operator delete(void *aTH)
00126 {
00127   aTouchableHistoryAllocator.FreeSingle((G4TouchableHistory *) aTH);
00128 }
00129 

Generated on Mon May 27 17:50:00 2013 for Geant4 by  doxygen 1.4.7