Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:12

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // class G4TouchableHistory inline implementation
0027 //
0028 // Created: Paul Kent, August 1996
0029 // ----------------------------------------------------------------------
0030 
0031 extern G4GEOM_DLL G4Allocator<G4TouchableHistory>*& aTouchableHistoryAllocator();
0032 
0033 inline
0034 void  G4TouchableHistory::UpdateYourself(       G4VPhysicalVolume*   pPhysVol,
0035                                           const G4NavigationHistory* pHistory )
0036 {
0037   fhistory = *pHistory;
0038   const G4AffineTransform& tf = fhistory.GetTopTransform();
0039   if( pPhysVol == nullptr )
0040   {
0041     // This means that the track has left the World Volume.
0042     // Since the Navigation History does not already reflect this,
0043     // we must correct this problem here.
0044     //
0045     fhistory.SetFirstEntry(pPhysVol);
0046   }
0047   ftlate = tf.InverseNetTranslation();
0048   frot = tf.InverseNetRotation();
0049 }
0050 
0051 inline
0052 G4int G4TouchableHistory::CalculateHistoryIndex( G4int stackDepth ) const
0053 { 
0054   return G4int(fhistory.GetDepth()-stackDepth); // was -1
0055 }
0056 
0057 inline
0058 G4VPhysicalVolume* G4TouchableHistory::GetVolume( G4int depth ) const
0059 { 
0060   return fhistory.GetVolume(CalculateHistoryIndex(depth));
0061 }
0062 
0063 inline
0064 G4VSolid* G4TouchableHistory::GetSolid( G4int depth ) const
0065 { 
0066   return fhistory.GetVolume(CalculateHistoryIndex(depth))
0067                             ->GetLogicalVolume()->GetSolid();
0068 }
0069 
0070 inline
0071 G4int G4TouchableHistory::GetReplicaNumber( G4int depth ) const
0072 { 
0073   return fhistory.GetReplicaNo(CalculateHistoryIndex(depth));
0074 }
0075 
0076 inline
0077 G4int G4TouchableHistory::GetCopyNumber(G4int depth) const
0078 {
0079   return GetReplicaNumber(depth);
0080 }
0081 
0082 inline
0083 G4int G4TouchableHistory::GetHistoryDepth()  const
0084 { 
0085   return  G4int(fhistory.GetDepth());
0086 }
0087 
0088 inline
0089 G4int G4TouchableHistory::MoveUpHistory( G4int num_levels )
0090 { 
0091   auto  maxLevelsMove = G4int(fhistory.GetDepth());
0092   G4int minLevelsMove = 0;              // Cannot redescend today!
0093                                         // Soon it will be possible
0094                                         // by adding a data member here
0095                                         //     fCurrentDepth;
0096   if( num_levels > maxLevelsMove )
0097   {
0098     num_levels = maxLevelsMove;
0099   }
0100   else if( num_levels < minLevelsMove )
0101   {
0102     num_levels = minLevelsMove;
0103   }
0104   fhistory.BackLevel( num_levels ); 
0105 
0106   return num_levels;
0107 }
0108 
0109 inline
0110 const G4NavigationHistory* G4TouchableHistory::GetHistory() const
0111 { 
0112   return &fhistory;
0113 }
0114 
0115 // There is no provision in case this class is subclassed.
0116 // If it is subclassed, this will fail and may not give errors!
0117 //
0118 inline
0119 void* G4TouchableHistory::operator new(std::size_t)
0120 { 
0121   // Once the Navigator calls InitializeAllocator,
0122   // the if block below can be removed.
0123   //
0124   if (aTouchableHistoryAllocator() == nullptr)
0125   {
0126      aTouchableHistoryAllocator() = new G4Allocator<G4TouchableHistory>;
0127   }
0128   return (void *) aTouchableHistoryAllocator()->MallocSingle();
0129 }
0130 
0131 inline
0132 void G4TouchableHistory::operator delete(void* aTH)
0133 {  
0134   aTouchableHistoryAllocator()->FreeSingle((G4TouchableHistory *) aTH);
0135 }
0136