Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
@@ -0,0 +1,46 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4AuxiliaryNavServices.hh,v 2.1 1998/11/02 12:11:50 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4NormalNavigation: Utility for navigation in volumes
// containing only G4PVPlacement daughter volumes. Paul Kent Aug 96
#ifndef G4AuxiliaryNavServices_hh
#define G4AuxiliaryNavServices_hh
#include "geomdefs.hh"
#include "G4ThreeVector.hh"
#include "G4VSolid.hh"
#include "G4AffineTransform.hh"
class G4AuxiliaryNavServices
{
public:
static G4bool CheckPointOnSurface( const G4VSolid* sampleSolid,
const G4ThreeVector& localPoint,
const G4ThreeVector* globalDirection,
const G4AffineTransform& sampleTransform,
const G4bool locatedOnEdge);
//
// Is the track (Point, direction) inside the solid sampleSolid ?
// Returns true if we are going to enter the volume,
// which is the case if:
// - The point is inside
// - The point is on the surface and the direction points inside or along it.
// Else returns false
private:
G4bool testOne();
};
#include "G4AuxiliaryNavServices.icc"
#endif
@@ -0,0 +1,33 @@
inline G4bool G4AuxiliaryNavServices::CheckPointOnSurface( const G4VSolid* sampleSolid,
const G4ThreeVector& localPoint,
const G4ThreeVector* globalDirection,
const G4AffineTransform& sampleTransform,
const G4bool locatedOnEdge)
{
G4ThreeVector localDirection, sampleNormal;
G4bool enter=false;
if (sampleSolid->Inside(localPoint)!=kOutside)
{
if(locatedOnEdge && (globalDirection!=0))
{
// We are probably located on an edge.
localDirection= sampleTransform.TransformAxis(*globalDirection);
// Check whether we enter the volume
//
sampleNormal= sampleSolid->SurfaceNormal(localPoint);
if ( sampleNormal.dot(localDirection) <= 0 )
{
enter= true;
}
}
else
{
enter= true;
}
}
return enter;
}
@@ -0,0 +1,100 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4BlockingList.hh,v 2.1 1998/07/12 02:58:14 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4BlockingList
//
// A utility class responsible for (efficiently) maintaining a List
// of blocked volume numbers, with rapid `reset' operations.
//
// Member functions:
//
// G4BlockingList(G4int maxDefault=511,G4int stride=512)
//
// Create empty blocking List of default size and `stride' resize
// count.
//
// ~G4BlockingList()
//
// Reset()
//
// Efficiently `Reset' the blocking List, so that no volumes
// are blocked
// [Advance tag no and only fully clear List if tag max reached]
//
// FullyReset()
//
// Clear the blocking List and reset tag value [slow]
//
// Enlarge(G4int nv)
//
// Enlarges blocking List is current size < nv, in units of stride
// Clears the new part of the List
//
// G4int Length()
//
// Returns the current length of the List. Note a length of 16
// means volumes of indices between 0 & 15 inclusive may be blocked
//
// void BlockVolume(G4int v)
//
// Block the volume number v. Requires: 0<=v<Length()
//
// G4bool IsBlocked(G4int v)
//
// Return true if the volume number v is blocked, else false
// Requires: 0<=v<Length()
//
// Notes:
//
// Implemented via a ValVector of ints: a tag value is used to set
// the indices of blocked volumes. On reset the current tag value is
// increases, so that the ValVector must only be zeroed when the
// numerical range of the tag is used.
//
// History:
//
// 24.7.96 P.Kent Separated from G4Navigator
#ifndef G4BLOCKINGLIST_HH
#define G4BLOCKINGLIST_HH
#include "globals.hh"
#include <rw/tvvector.h>
const G4int kBlockingListMaxDefault = 500; // Block up to 511 daughters
// initially
const G4int kBlockingListStride = 128;
const G4int kBlockTagNoMax = 2147483647; // 2^31-1 maximum tag no may reach
class G4BlockingList
{
public:
G4BlockingList(G4int maxDefault=kBlockingListMaxDefault,
G4int stride=kBlockingListStride);
~G4BlockingList();
void Reset();
void FullyReset();
void Enlarge(const G4int nv);
G4int Length() const;
void BlockVolume(const G4int v);
G4bool IsBlocked(const G4int v) const;
private:
// Current blocked volume tag no.
G4int fBlockTagNo,fStride;
// Blocked volumes: Elements with indices
// corresponding to blocked volume set to fBlockTagNo
RWTValVector<G4int> fBlockingList;
};
#include "G4BlockingList.icc"
#endif
@@ -0,0 +1,67 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4BlockingList.icc,v 2.0 1998/07/02 17:05:28 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4BlockingList Inlined Implementation
//
inline G4int G4BlockingList::Length() const
{
return fBlockingList.length();
}
inline void G4BlockingList::BlockVolume(const G4int v)
{
fBlockingList(v)=fBlockTagNo;
}
inline G4bool G4BlockingList::IsBlocked(const G4int v) const
{
return (fBlockingList(v)==fBlockTagNo) ? true:false;
}
inline void G4BlockingList::Reset()
{
if (fBlockTagNo!=kBlockTagNoMax)
{
fBlockTagNo+=1;
}
else
{
FullyReset();
}
}
inline void G4BlockingList::Enlarge(const G4int nv)
{
G4int len=fBlockingList.length();
if (len<nv)
{
G4int newlen=(nv/fStride+1)*fStride;
fBlockingList.reshape(newlen);
for (G4int i=len;i<newlen;i++)
{
fBlockingList(i)=0;
}
}
}
inline G4BlockingList::G4BlockingList(G4int maxDefault,G4int stride) :
fBlockingList(maxDefault),fStride(stride)
{
FullyReset();
}
// Do nothing destructor
inline G4BlockingList::~G4BlockingList()
{
}
@@ -0,0 +1,51 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4GRSSolid.hh,v 2.3 1998/11/09 17:15:26 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4GRSSolid Paul Kent August 1996
//
// Object representing a touchable solid - maintains
// association between a solid and its net resultant
// local->global transform
//
// NOTE: The (optional) rotation matrix is copied
#ifndef G4GRSSOLID_HH
#define G4GRSSOLID_HH
#include "G4VTouchable.hh"
#include "G4VPhysicalVolume.hh"
// #include "G4LogicalVolume.hh"
#include "G4RotationMatrix.hh"
class G4GRSSolid : public G4VTouchable
{
public:
G4GRSSolid(G4VSolid *pSolid,
const G4RotationMatrix *pRot,
const G4ThreeVector &tlate);
G4GRSSolid(G4VSolid *pSolid,
const G4RotationMatrix &rot,
const G4ThreeVector &tlate);
~G4GRSSolid();
G4VSolid* GetSolid(G4int depth=0) const;
const G4ThreeVector& GetTranslation(G4int depth=0) const;
const G4RotationMatrix* GetRotation(G4int depth=0) const;
private:
G4VSolid *fsolid;
G4RotationMatrix *frot;
G4ThreeVector ftlate;
};
#include "G4GRSSolid.icc"
#endif
@@ -0,0 +1,62 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4GRSSolid.icc,v 2.1 1998/07/18 10:11:35 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4GRSSolid inline implementation
inline G4GRSSolid::G4GRSSolid(G4VSolid *pSolid,
const G4RotationMatrix *pRot,
const G4ThreeVector &tlate)
: fsolid(pSolid),ftlate(tlate), G4VTouchable()
{
if (pRot)
{
frot=new G4RotationMatrix(*pRot);
if (!frot) G4Exception ("G4GRSSolid::G4GRSSolid cannot alloc G4RotationMatrix");
}
else
{
frot=0;
}
}
inline G4GRSSolid::G4GRSSolid(G4VSolid *pSolid,
const G4RotationMatrix &rot,
const G4ThreeVector &tlate)
: fsolid(pSolid),ftlate(tlate), G4VTouchable()
{
frot=new G4RotationMatrix(rot);
if (!frot) G4Exception ("G4GRSSolid::G4GRSSolid cannot alloc G4RotationMatrix");
}
inline G4VSolid* G4GRSSolid::GetSolid(G4int depth) const
{
if( depth != 0 ) {
G4Exception("G4GRSSolid::GetSolid: has no meaning for depth!=0");
}
return fsolid;
}
inline const G4ThreeVector& G4GRSSolid::GetTranslation(G4int depth) const
{
if( depth != 0 ) {
G4Exception("G4GRSSolid::GetTranslation: has no meaning for depth!=0");
}
return ftlate;
}
inline const G4RotationMatrix* G4GRSSolid::GetRotation(G4int depth) const
{
if( depth != 0 ) {
G4Exception("G4GRSSolid::GetRotation: has no meaning for depth!=0");
}
return frot;
}
@@ -0,0 +1,52 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4GRSVolume.hh,v 2.1 1998/07/18 10:11:36 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4GRSVolume Paul Kent August 1996
//
// Object representing a touchable detector element - maintains
// associations between a physical volume and its net resultant
// local->global transform
//
// NOTE: The (optional) rotation matrix is copied
#ifndef G4GRSVOLUME_HH
#define G4GRSVOLUME_HH
#include "G4VTouchable.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4RotationMatrix.hh"
class G4GRSVolume : public G4VTouchable
{
public:
G4GRSVolume(G4VPhysicalVolume *pVol,
const G4RotationMatrix *pRot,
const G4ThreeVector &tlate);
G4GRSVolume(G4VPhysicalVolume *pVol,
const G4RotationMatrix &rot,
const G4ThreeVector &tlate);
~G4GRSVolume();
G4VPhysicalVolume* GetVolume(G4int depth=0) const;
G4VSolid* GetSolid(G4int depth=0) const;
const G4ThreeVector& GetTranslation(G4int depth=0) const;
const G4RotationMatrix* GetRotation(G4int depth=0) const;
private:
G4VPhysicalVolume *fvol;
G4RotationMatrix *frot;
G4ThreeVector ftlate;
};
#include "G4GRSVolume.icc"
#endif
@@ -0,0 +1,69 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4GRSVolume.icc,v 2.1 1998/07/18 10:11:36 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4GRSVolume inline implementation
inline G4GRSVolume::G4GRSVolume(G4VPhysicalVolume *pVol,
const G4RotationMatrix *pRot,
const G4ThreeVector &tlate)
: fvol(pVol),ftlate(tlate), G4VTouchable()
{
if (pRot)
{
frot=new G4RotationMatrix(*pRot);
if (!frot) G4Exception ("G4GRSVolume::G4GRSVolume cannot alloc G4RotationMatrix");
}
else
{
frot=0;
}
}
inline G4GRSVolume::G4GRSVolume(G4VPhysicalVolume *pVol,
const G4RotationMatrix &rot,
const G4ThreeVector &tlate)
: fvol(pVol),ftlate(tlate), G4VTouchable()
{
frot=new G4RotationMatrix(rot);
if (!frot) G4Exception ("G4GRSVolume::G4GRSVolume cannot alloc G4RotationMatrix");
}
inline G4VPhysicalVolume* G4GRSVolume::GetVolume(G4int depth) const
{
if( depth != 0 ) {
G4Exception("G4GRSSolid::GetSolid: has no meaning for depth!=0");
}
return fvol;
}
inline G4VSolid* G4GRSVolume::GetSolid(G4int depth) const
{
if( depth != 0 ) {
G4Exception("G4GRSSolid::GetSolid: has no meaning for depth!=0");
}
return fvol->GetLogicalVolume()->GetSolid();
}
inline const G4ThreeVector& G4GRSVolume::GetTranslation(G4int depth) const
{
if( depth != 0 ) {
G4Exception("G4GRSSolid::GetSolid: has no meaning for depth!=0");
}
return ftlate;
}
inline const G4RotationMatrix* G4GRSVolume::GetRotation(G4int depth) const
{
if( depth != 0 ) {
G4Exception("G4GRSSolid::GetSolid: has no meaning for depth!=0");
}
return frot;
}
@@ -0,0 +1,127 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4LogicalBorderSurface.hh,v 2.0 1998/07/02 17:05:38 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
////////////////////////////////////////////////////////////////////////
// G4LogicalBorderSurface Definition
////////////////////////////////////////////////////////////////////////
//
// File: G4LogicalBorderSurface.hh
// Description: A Logical Surface class for surfaces defined by the
// boundary of two physical volumes.
// Version: 1.0
// Created: 1997-06-17
// Author: John Apostolakis
// mail: John.Apostolakis@cern.ch
// Modified: 1997-06-16 John Apostolakis
//
// Id tag:
////////////////////////////////////////////////////////////////////////
#ifndef G4LogicalBorderSurface_h
#define G4LogicalBorderSurface_h 1
/////////////
// Includes
/////////////
#include "G4LogicalSurface.hh"
#include "G4VPhysicalVolume.hh"
// RWTPtrOrderedVector
#include <rw/tpordvec.h>
class G4Event;
class G4VPhysicalVolume;
/////////////////////
// Class Definition
/////////////////////
class G4LogicalBorderSurface: public G4LogicalSurface
{
////////////////////////////////
// Constructors and Destructor
////////////////////////////////
public:
G4LogicalBorderSurface(const G4String& name,
G4VPhysicalVolume* vol1,
G4VPhysicalVolume* vol2,
G4OpticalSurface* opticsSurface);
~G4LogicalBorderSurface();
////////////
// Methods
////////////
public:
// public methods
static G4LogicalBorderSurface* GetSurface(const G4VPhysicalVolume* vol1,
const G4VPhysicalVolume* vol2);
void SetPhysicalVolumes(G4VPhysicalVolume* vol1,
G4VPhysicalVolume* vol2)
{ Volume1 = vol1; Volume2 = vol2; }
G4VPhysicalVolume* GetVolume1() const {return Volume1;}
G4VPhysicalVolume* GetVolume2() const {return Volume2;}
// These are potentially dangerous.
void SetVolume1(G4VPhysicalVolume* vol1)
{Volume1 = vol1;}
void SetVolume2(G4VPhysicalVolume* vol2)
{Volume2 = vol2;}
// Methods dealing with the table of surfaces.
//
static const RWTPtrOrderedVector<G4LogicalBorderSurface>* GetSurfaceTable()
{ return &theBorderSurfaceTable; }
static size_t GetNumberOfBorderSurfaces()
{ return theBorderSurfaceTable.length(); }
static void DumpInfo();
size_t GetIndex() const { return theIndexInTable; }
//////////////
// Operators
//////////////
public:
G4int operator==(const G4LogicalBorderSurface &right) const;
G4int operator!=(const G4LogicalBorderSurface &right) const;
private:
G4LogicalBorderSurface(const G4LogicalBorderSurface &right);
const G4LogicalBorderSurface & operator=(const G4LogicalBorderSurface &right);
// ------------------
// Basic data members ( To define a 'logical' surface)
// ------------------
private:
G4VPhysicalVolume* Volume1; // Physical Volume pointer on side 1
G4VPhysicalVolume* Volume2; // Physical Volume pointer on side 2
// The static Table of Surfaces
static RWTPtrOrderedVector<G4LogicalBorderSurface> theBorderSurfaceTable;
size_t theIndexInTable; // Index of surface in the surface table
};
typedef RWTPtrOrderedVector<G4LogicalBorderSurface> G4LogicalBorderSurfaceTable;
////////////////////
// Inline methods
////////////////////
#endif /* G4LogicalBorderSurface_h */
@@ -0,0 +1,121 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4LogicalSkinSurface.hh,v 2.0 1998/07/02 17:05:40 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
////////////////////////////////////////////////////////////////////////
// G4LogicalSkinSurface Definition
////////////////////////////////////////////////////////////////////////
//
// File: G4LogicalSkinSurface.hh
// Description: A Logical Surface class for the surface
// surrounding a single logical volume.
// Version: 1.0
// Created: 1997-06-16
// Author: John Apostolakis
// mail: John.Apostolakis@cern.ch
// Modified: 1997-06-16 John Apostolakis
//
// Id tag:
////////////////////////////////////////////////////////////////////////
#ifndef G4LogicalSkinSurface_h
#define G4LogicalSkinSurface_h 1
/////////////
// Includes
/////////////
#include "G4LogicalSurface.hh"
#include "G4LogicalVolume.hh"
// RWTPtrOrderedVector
#include <rw/tpordvec.h>
/////////////////////
// Class Definition
/////////////////////
class G4LogicalSkinSurface : public G4LogicalSurface
{
public:
////////////////////////////////
// Constructors and Destructor
////////////////////////////////
// Is the name meaningful for the logical skin surface ?
G4LogicalSkinSurface(const G4String& name, G4LogicalVolume* vol,
G4OpticalSurface* opticalSurface);
~G4LogicalSkinSurface();
////////////
// Methods
////////////
public:
// public methods
static G4LogicalSkinSurface* GetSurface(const G4LogicalVolume* vol);
G4LogicalVolume* GetLogicalVolume() const {return LogVolume;};
void SetLogicalVolume(G4LogicalVolume* vol)
{LogVolume = vol;};
// Methods dealing with the table of surfaces.
//
static size_t GetNumberOfSkinSurfaces()
{ return theSurfaceTable.length(); };
static void DumpInfo(); // const
#if THESE_ARE_NEEDED
// static const RWTPtrOrderedVector<G4LogicalSkinSurface>*
// GetSurfaceTable()
// { return &theSurfaceTable; };
size_t GetIndex() const { return theIndexInTable; };
#endif
//////////////
// Operators
//////////////
public:
G4int operator==(const G4LogicalSkinSurface &right) const;
G4int operator!=(const G4LogicalSkinSurface &right) const;
private:
// Assignment and copying must be denied.
G4LogicalSkinSurface(const G4LogicalSkinSurface &right);
const G4LogicalSkinSurface & operator=(const G4LogicalSkinSurface &right);
// ------------------
// Basic data members ( To define a 'logical' surface)
// ------------------
private:
G4LogicalVolume* LogVolume; // Logical Volume pointer on side 1
// The static Table of Surfaces
static RWTPtrOrderedVector<G4LogicalSkinSurface> theSurfaceTable;
// static G4LogicalSkinSurfaceTable theSurfaceTable;
size_t theIndexInTable; // Index of surface in the surface table
};
typedef RWTPtrOrderedVector<G4LogicalSkinSurface> G4LogicalSkinSurfaceTable;
////////////////////
// Inline methods
////////////////////
#endif /* G4LogicalSkinSurface_h */
@@ -0,0 +1,90 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4NavigationHistory.hh,v 2.0 1998/07/02 17:05:45 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4NavigationHistory
//
// Responsible for maintenance of the history of the path taken through
// the geometrical hierarchy. Principally a utility class for use by
// G4Navigator.
//
// History:
//
// 25.07.96 P.Kent Initial version. Services derived from
// requirements of G4Navigator.
#ifndef G4NAVIGATIONHISTORY_HH
#define G4NAVIGATIONHISTORY_HH
#include <assert.h>
#include "globals.hh"
#include "G4AffineTransform.hh"
#include "G4VPhysicalVolume.hh"
#include "G4NavigationLevel.hh"
#include <rw/tvvector.h>
#include <rw/tpvector.h>
const G4int kHistoryMax=15; // Default max size of history
const G4int kHistoryStride=16; // History increase stride
class ostream;
class G4NavigationHistory
{
public:
friend ostream& operator << (ostream &os,const G4NavigationHistory &h);
G4NavigationHistory();
G4NavigationHistory(const G4NavigationHistory &h);
~G4NavigationHistory();
void Reset();
void Clear();
void SetFirstEntry(G4VPhysicalVolume* pVol);
const G4AffineTransform& GetTopTransform() const;
const G4AffineTransform* GetPtrTopTransform() const;
G4int GetTopReplicaNo() const;
EVolume GetTopVolumeType() const;
G4VPhysicalVolume* GetTopVolume() const;
G4int GetDepth() const;
G4int GetMaxDepth() const;
const G4AffineTransform& GetTransform(const G4int n) const;
G4int GetReplicaNo(const G4int n) const;
EVolume GetVolumeType(const G4int n) const;
G4VPhysicalVolume* GetVolume(const G4int n) const;
void NewLevel(G4VPhysicalVolume *pNewMother,
EVolume vType=kNormal,
G4int nReplica=-1);
void BackLevel();
void BackLevel(G4int n);
G4NavigationHistory& operator=(const G4NavigationHistory &h);
private:
void EnlargeHistory();
// Depth of stack: effectively depth in geometrical tree
G4int fStackDepth;
RWTValVector<G4NavigationLevel> fNavHistory;
// RWTPtrVector<G4NavigationLevel> fNavHistory;
};
#include "G4NavigationHistory.icc"
#endif
@@ -0,0 +1,216 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4NavigationHistory.icc,v 2.0 1998/07/02 17:05:47 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4NavigationHistory Inline implementation
//
// `Reset' history. It now does clear most entries (It used to not do this).
// Level 0 is preserved
inline void G4NavigationHistory::Reset()
{
fStackDepth=0;
}
// 'Clear' entries, zeroing transforms, matrices & negating replica history
//
inline void G4NavigationHistory::Clear()
{
G4AffineTransform dummyTransform(G4ThreeVector(0.));
G4NavigationLevel tmpNavLevel;
tmpNavLevel=G4NavigationLevel(0, dummyTransform, kParameterised, -1) ;
Reset();
for (G4int ilev=fNavHistory.length()-1; ilev>=0; ilev--)
{
// fNavHistory(ilev)= 0;
fNavHistory(ilev)= tmpNavLevel;
}
}
// Constructor
// Size history lists & reset histories
inline G4NavigationHistory::G4NavigationHistory() :
fNavHistory(kHistoryMax),
fStackDepth(0)
{
Reset(); // Reset depth
Clear();
}
// Constructor
// Size history lists & reset histories
inline G4NavigationHistory::G4NavigationHistory(const G4NavigationHistory &h):
fNavHistory(h.fNavHistory),
fStackDepth(h.fStackDepth)
{
}
// Destructor
inline G4NavigationHistory::~G4NavigationHistory()
{
Reset(); // To delete all but one current entries!
// delete fNavHistory(0);
}
// Setup initial entry in stack: copies through volume transform & matrix
// The volume is assumed to be unrotated
//
inline void G4NavigationHistory::SetFirstEntry(G4VPhysicalVolume* pVol)
{
G4ThreeVector translation(0.,0.,0.);
// Protection needed in case pVol=null
// so that a touchable-history can signal OutOfWorld
//
if(pVol !=0) {
translation=pVol->GetTranslation();
}
fNavHistory(0)= G4NavigationLevel( pVol,
G4AffineTransform(translation),
kNormal );
}
// Return topmost transform
inline const G4AffineTransform* G4NavigationHistory::GetPtrTopTransform() const
{
return fNavHistory(fStackDepth).GetPtrTransform();
}
// Return topmost transform
inline const G4AffineTransform& G4NavigationHistory::GetTopTransform() const
{
return fNavHistory(fStackDepth).GetTransform();
}
// Return topmost replica no record
inline G4int G4NavigationHistory::GetTopReplicaNo() const
{
return fNavHistory(fStackDepth).GetReplicaNo();
}
// Return topmost volume type
inline EVolume G4NavigationHistory::GetTopVolumeType() const
{
return fNavHistory(fStackDepth).GetVolumeType();
}
// Return topmost physical volume ptr
inline G4VPhysicalVolume* G4NavigationHistory::GetTopVolume() const
{
return fNavHistory(fStackDepth).GetPhysicalVolume();
}
// Return current history depth
inline G4int G4NavigationHistory::GetDepth() const
{
return fStackDepth;
}
// Return specified transform
inline const G4AffineTransform& G4NavigationHistory::GetTransform(const G4int n) const
{
return fNavHistory(n).GetTransform();
}
// Return specified replica no record
inline G4int G4NavigationHistory::GetReplicaNo(const G4int n) const
{
return fNavHistory(n).GetReplicaNo();
}
// Return specified volume type
inline EVolume G4NavigationHistory::GetVolumeType(const G4int n) const
{
return fNavHistory(n).GetVolumeType();
}
// Return specified physical volume ptr
inline G4VPhysicalVolume* G4NavigationHistory::GetVolume(const G4int n) const
{
return fNavHistory(n).GetPhysicalVolume();
}
// Return current maximum size of history.
// Note: MaxDepth of 16 mean history entries 0 - 15 inclusive may be used
inline G4int G4NavigationHistory::GetMaxDepth() const
{
return fNavHistory.length();
}
// Back up one level in history: from mother to grandmother
// It does not erase history record of current mother
inline void G4NavigationHistory::BackLevel()
{
assert(fStackDepth>0);
// Tell the level that I am forgetting it
// delete fNavHistory(fStackDepth);
fStackDepth--;
}
// Back up specified no of levels in history
inline void G4NavigationHistory::BackLevel(G4int n)
{
assert(n<=fStackDepth);
fStackDepth-=n;
}
inline G4NavigationHistory& G4NavigationHistory::operator=(const G4NavigationHistory &h)
{
// fNavHistory=h.fNavHistory; // This works, but is very slow.
if( this->GetMaxDepth() < h.fStackDepth ){
fNavHistory.reshape( h.fStackDepth );
}
register G4int ilev= h.fStackDepth;
for ( ; ilev>=0; ilev--) {
fNavHistory(ilev) = h.fNavHistory(ilev);
}
fStackDepth=h.fStackDepth;
return *this;
}
// Enlarge history if required
// Increase size by kHistoryStride. Note that additional
// history entries are `dirty' (non zero) apart from volume history
inline void G4NavigationHistory::EnlargeHistory()
{
G4int len=fNavHistory.length();
if (len==fStackDepth)
{
G4int nlen=len+kHistoryStride;
fNavHistory.reshape(nlen);
// Note: Resize operation clears additional entries
}
}
inline void G4NavigationHistory::NewLevel(G4VPhysicalVolume *pNewMother,
EVolume vType,
G4int nReplica)
{
EnlargeHistory(); // Enlarge if required
fStackDepth++;
fNavHistory(fStackDepth) =
G4NavigationLevel(pNewMother,
fNavHistory(fStackDepth-1).GetTransform(),
G4AffineTransform(pNewMother->GetRotation(),
pNewMother->GetTranslation()),
vType,
nReplica);
// The constructor computes the new global->local transform
}
@@ -0,0 +1,86 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4NavigationLevel.hh,v 2.0 1998/07/02 17:05:48 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4NavigationLevel
//
// Maintains one level of the geometrical hierarchy. A utility class for use
// by G4NavigationHistory.
//
// History:
//
// 30.09.97 J.Apostolakis Initial version. Services derived from
// requirements of touchables & G4NavigatorHistory.
#ifndef G4NAVIGATIONLEVEL_HH
#define G4NAVIGATIONLEVEL_HH
// #include <assert.h>
#include "globals.hh"
#include "G4AffineTransform.hh"
#include "G4VPhysicalVolume.hh"
#include "G4NavigationLevelRep.hh"
#include "G4Allocator.hh"
class ostream;
class G4NavigationLevel
{
public:
G4NavigationLevel(G4VPhysicalVolume* newPtrPhysVol,
const G4AffineTransform& newT,
EVolume newVolTp,
G4int newRepNo= -1);
// As the previous constructor, but instead of giving Transform, give
// the AffineTransform to the level above and the current level's
// Transform relative to that.
//
G4NavigationLevel(G4VPhysicalVolume* newPtrPhysVol,
const G4AffineTransform& levelAbove,
const G4AffineTransform& relativeCurrent,
EVolume newVolTp,
G4int newRepNo= -1);
G4NavigationLevel();
G4NavigationLevel( G4NavigationLevel& );
~G4NavigationLevel();
G4NavigationLevel& operator=(const G4NavigationLevel &right);
G4VPhysicalVolume* GetPhysicalVolume() const;
const G4AffineTransform* GetTransformPtr() const ; // New
const G4AffineTransform& GetTransform() const ; // Old
// G4AffineTransform& GetTransform(); // Only temporarily
EVolume GetVolumeType() const ;
G4int GetReplicaNo() const ;
// To try to resolve the possible problem with returning a reference.
const G4AffineTransform* GetPtrTransform() const;
inline void *operator new(size_t);
// Override "new" to use "G4Allocator".
inline void operator delete(void *aTrack);
// Override "delete" to use "G4Allocator".
// Data members:
//
private:
G4NavigationLevelRep* fLevelRep;
};
// extern G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
#include "G4NavigationLevel.icc"
#endif
@@ -0,0 +1,115 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4NavigationLevel.icc,v 2.1 1998/07/12 02:58:16 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// 30.09.97 J.Apostolakis Initial version.
//
inline G4NavigationLevel::G4NavigationLevel(G4VPhysicalVolume* pPhysVol,
const G4AffineTransform& afTransform,
EVolume volTp,
G4int repNo)
{
fLevelRep=new G4NavigationLevelRep( pPhysVol,
afTransform,
volTp,
repNo );
}
inline G4NavigationLevel::
G4NavigationLevel(G4VPhysicalVolume* pPhysVol,
const G4AffineTransform& levelAbove,
const G4AffineTransform& relativeCurrent,
EVolume volTp,
G4int repNo)
{
fLevelRep=new G4NavigationLevelRep( pPhysVol,
levelAbove,
relativeCurrent,
volTp,
repNo );
}
inline G4NavigationLevel::G4NavigationLevel()
{
fLevelRep= new G4NavigationLevelRep();
}
inline G4NavigationLevel::G4NavigationLevel(G4NavigationLevel& right)
: fLevelRep( right.fLevelRep )
{
fLevelRep->AddAReference();
}
inline G4NavigationLevel::~G4NavigationLevel()
{
if( fLevelRep->RemoveAReference() ) delete fLevelRep;
}
inline G4NavigationLevel&
G4NavigationLevel::operator=(const G4NavigationLevel &right)
{
// The order of these two lines is needed to handle "a=a"
right.fLevelRep->AddAReference();
if( fLevelRep->RemoveAReference() ) delete fLevelRep;
fLevelRep= right.fLevelRep;
return *this;
}
inline G4VPhysicalVolume* G4NavigationLevel::GetPhysicalVolume() const
{
return fLevelRep->GetPhysicalVolume();
}
#if 0
inline G4AffineTransform& G4NavigationLevel::GetTransform()
{
return fLevelRep->GetTransform() ;
}
#endif
inline const G4AffineTransform& G4NavigationLevel::GetTransform() const
{
return fLevelRep->GetTransform() ;
}
inline const G4AffineTransform* G4NavigationLevel::GetPtrTransform() const
{
return fLevelRep->GetTransformPtr() ;
}
inline EVolume G4NavigationLevel::GetVolumeType() const
{
return fLevelRep->GetVolumeType() ;
}
inline G4int G4NavigationLevel::GetReplicaNo() const
{
return fLevelRep->GetReplicaNo() ;
}
extern G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
// I believe that there is no provision in case this class is subclassed.
// If it is subclassed, this will fail and may not give errors!
//
inline void* G4NavigationLevel::operator new(size_t)
{
// void *aNavigationLevel;
// aNavigationLevel= (void *) aNavigationLevelAllocator.MallocSingle();
// return aNavigationLevel;
return (void *) aNavigationLevelAllocator.MallocSingle();
}
inline void G4NavigationLevel::operator delete(void *aLevel)
{
aNavigationLevelAllocator.FreeSingle((G4NavigationLevel *) aLevel);
}
@@ -0,0 +1,100 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4NavigationLevelRep.hh,v 2.1 1998/07/12 02:58:17 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4NavigationLevelRep
//
// A data representation class, used to hold the data for
// a single level of the Navigation history tree.
//
// This is the body of a handle/body pair of classes,
// that implement reference counting for NavigationLevels.
// The corresponding handle class is G4NavigationLevel
//
// History:
//
// 1 October 1997, J.Apostolakis: Initial version.
#ifndef G4NAVIGATIONLEVELREP_HH
#define G4NAVIGATIONLEVELREP_HH
#include "globals.hh"
#include "G4AffineTransform.hh"
#include "G4VPhysicalVolume.hh"
#include "G4Allocator.hh"
class ostream;
class G4NavigationLevelRep
{
public:
G4NavigationLevelRep(G4VPhysicalVolume* newPtrPhysVol,
const G4AffineTransform& newT,
EVolume newVolTp,
G4int newRepNo= -1);
// As the previous constructor, but instead of giving Transform, give
// the AffineTransform to the level above and the current level's
// Transform relative to that.
//
G4NavigationLevelRep(G4VPhysicalVolume* newPtrPhysVol,
const G4AffineTransform& levelAbove,
const G4AffineTransform& relativeCurrent,
EVolume newVolTp,
G4int newRepNo= -1);
G4NavigationLevelRep();
G4NavigationLevelRep( G4NavigationLevelRep& );
~G4NavigationLevelRep();
G4NavigationLevelRep& operator=(const G4NavigationLevelRep &right);
G4VPhysicalVolume* GetPhysicalVolume() const;
const G4AffineTransform* GetTransformPtr() const ; // New
const G4AffineTransform& GetTransform() const ; // Old
// G4AffineTransform& GetTransform(); // Only temporarily
EVolume GetVolumeType() const ;
G4int GetReplicaNo() const ;
// const G4AffineTransform* GetPtrTransform() const;
// G4AffineTransform& accessTransform();
// Take care of the reference counts.
//
void AddAReference();
G4bool RemoveAReference();
inline void *operator new(size_t);
// Override "new" to use "G4Allocator".
inline void operator delete(void *aTrack);
// Override "delete" to use "G4Allocator".
private:
// Compounded global->local transformation (takes a point in the
// global reference system to the system of the volume at this level)
G4AffineTransform sTransform;
// Physical volume ptrs, for this level's volume
G4VPhysicalVolume* sPhysicalVolumePtr;
// Volume `type'
G4int sReplicaNo;
EVolume sVolumeType;
G4int fCountRef;
};
#include "G4NavigationLevelRep.icc"
// extern G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
#endif
@@ -0,0 +1,140 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4NavigationLevelRep.icc,v 2.1 1998/07/12 02:58:18 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// 1 October 1997 J.Apostolakis Initial version.
//
// Constructors
//--------------
inline G4NavigationLevelRep::G4NavigationLevelRep(G4VPhysicalVolume* pPhysVol,
const G4AffineTransform& afTransform,
EVolume volTp,
G4int repNo)
: sPhysicalVolumePtr(pPhysVol),
sTransform(afTransform),
sVolumeType(volTp),
sReplicaNo(repNo),
fCountRef(1)
{
}
inline G4NavigationLevelRep::G4NavigationLevelRep()
: sPhysicalVolumePtr(0),
sTransform(),
sVolumeType(kReplica),
sReplicaNo(-1),
fCountRef(1)
{
}
inline G4NavigationLevelRep::
G4NavigationLevelRep( G4VPhysicalVolume* pPhysVol,
const G4AffineTransform& levelAbove,
const G4AffineTransform& relativeCurrent,
EVolume volTp,
G4int repNo )
: sPhysicalVolumePtr(pPhysVol),
sReplicaNo(repNo),
sVolumeType(volTp),
fCountRef(1)
{
sTransform.InverseProduct( levelAbove, relativeCurrent );
}
inline G4NavigationLevelRep::G4NavigationLevelRep(G4NavigationLevelRep& right)
: sTransform(right.sTransform),
sPhysicalVolumePtr(right.sPhysicalVolumePtr),
sReplicaNo(right.sReplicaNo),
sVolumeType(right.sVolumeType),
fCountRef(1)
{
}
// Destructor
//--------------
inline G4NavigationLevelRep::~G4NavigationLevelRep()
{
#ifdef DEBUG_NAVIG_LEVEL
if(fCountRef>0){
G4Exception( " A G4NavigationLevelRep is being deleted that has a positive of reference counts (fCountRef > 0) " );
}
#endif
}
// Operators
// --------------
inline G4NavigationLevelRep&
G4NavigationLevelRep::operator=(const G4NavigationLevelRep &right)
{
sTransform= right.sTransform;
sPhysicalVolumePtr=right.sPhysicalVolumePtr;
sVolumeType= right.sVolumeType;
sReplicaNo= right.sReplicaNo;
return *this;
}
inline G4VPhysicalVolume* G4NavigationLevelRep::GetPhysicalVolume() const
{
return sPhysicalVolumePtr;
}
inline const G4AffineTransform& G4NavigationLevelRep::GetTransform() const
{
return sTransform;
}
#if 0
inline G4AffineTransform& G4NavigationLevelRep::GetTransform()
{
return sTransform;
}
#endif
inline const G4AffineTransform* G4NavigationLevelRep::GetTransformPtr() const
{
return &sTransform;
}
inline EVolume G4NavigationLevelRep::GetVolumeType() const
{
return sVolumeType;
}
inline G4int G4NavigationLevelRep::GetReplicaNo() const
{
return sReplicaNo;
}
inline void G4NavigationLevelRep::AddAReference()
{
fCountRef++;
}
inline G4bool G4NavigationLevelRep::RemoveAReference()
{
return( --fCountRef <= 0);
}
extern G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
// There is no provision that this class is subclassed.
// If it is subclassed & new data members are added then the
// following "new" & "delete" will fail and give errors.
//
inline void* G4NavigationLevelRep::operator new(size_t)
{
return (void *) aNavigLevelRepAllocator.MallocSingle();
}
inline void G4NavigationLevelRep::operator delete(void *aLevelRep)
{
aNavigLevelRepAllocator.FreeSingle((G4NavigationLevelRep *) aLevelRep);
}
@@ -0,0 +1,419 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Navigator.hh,v 2.4 1998/11/27 19:30:59 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4Navigator Paul Kent July 95/96
//
// A class for use by the tracking management, able to obtain/calculate
// dynamic tracking time information such as the distance to the next volume,
// or to find the physical volume containing a given point in the world
// reference system. The navigator maintains a transformation history and
// other information to optimise the tracking time performance.
//
// Member functions:
//
// G4Navigator()
// Constructor. No actions yet.
//
// ~G4Navigator()
// Destructor. No actions yet.
//
// G4double ComputeStep(const G4ThreeVector &globalpoint,
// const G4ThreeVector &direction,
// const G4double pCurrentProposedStepLength,
// G4double &newSafety)
// Calculate the distance to the next boundary intersected
// along the specified NORMALISED vector direction and
// from the specified point in the global coordiante
// system. LocateGlobalPointAndSetup or LocateGlobalPointWithinVolume
// must have been called with the same global point prior to this call.
// The isotropic distance to the nearest boundary is also
// calculated (usually an underestimate). The current
// proposed Step length is used to avoid intersection
// calculations: if it can be determined that the nearest
// boundary is >pCurrentProposedStepLength away, kInfinity
// is returned together with the computed isotropic safety
// distance. Geometry must be closed.
//
// G4double ComputeSafety(const G4ThreeVector &globalpoint,
// const G4double pProposedMaxLength=DBL_MAX )
//
// Calculate the isotropic distance to the nearest boundary from the
// specified point in the global coordinate system.
// The globalpoint utilised must be within the current volume.
// The value returned is usually an underestimate.
// The proposed maximum length is used to avoid volume safety
// calculations. The geometry must be closed.
//
// G4ThreeVector GetCurrentLocalCoordinate() const
// Return the local coordinate of the point in the reference system
// of its containing volume that was found by
// LocalGlobalPointAndSetup.
//
// G4ThreeVector ComputeLocalAxis(const G4ThreeVector& pGVector) const
// Return the local direction of the specified vector in the reference
// system of the volume that was found by LocalGlobalPointAndSetup.
//
// G4VPhysicalVolume* GetWorldVolume() const
// Return the current world (`topmost') volume
//
// G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point,
// const G4ThreeVector* direction=0,
// G4bool pRelativeSearch=true)
// Search the geometrical hierarchy for the volumes deepest in the hierarchy
// containing the point in the global coordinate space. Two main cases are:
// i) If pRelativeSearch=false it makes use of no previous/state
// information. Returns the physical volume containing the point,
// with all previous mothers correctly set up.
// ii) If pRelativeSearch is set to true, the search begin is the geometrical
// hierarchy at the location of the last located point, or the endpoint of
// the previous Step if SetGeometricallyLimitedStep() has been called
// immediately before.
// The direction is used (to check if a volume is entered) only if
// the Navigator has determined that it is on an edge shared by two or more
// volumes. (This is state information.)
// The geometry must be closed.
//
//
// void LocateGlobalPointWithinVolume( const G4ThreeVector& position)
// Notify the Navigator that a track has moved to the new Global point
// 'position', that is know to be within the current safety.
// No check is performed to ensure that it is within the volume.
// This method can be called instead of LocateGlobalPointAndSetup ONLY if
// the caller is certain that the new global point (position) is inside the
// same volume as the previous position. Usually this can be guaranteed
// only if the point is within safety.
//
// void
// LocateGlobalPointAndUpdateTouchable( const G4ThreeVector& position,
// const G4ThreeVector& globalDirection,
// G4Touchable* touchableToUpdate,
// const G4bool relativeSearch=true);
// First, search the geometrical hierarchy like the above method
// LocateGlobalPointAndSetup(const G4ThreeVector&, G4bool).
// Then use the volume found and its navigation history to
// update the touchable.
//
// void SetGeometricallyLimitedStep()
// Inform the navigator that the previous Step calculated
// by the geometry was taken in its entirety
//
// void SetWorldVolume(G4VPhysicalVolume* pWorld)
// Set the world (`topmost') volume. This must be
// positioned at (0,0,0) and unrotated.
//
// G4ThreeVector GetLocalExitNormal(G4bool* valid);
// Can be called only if the Navigator's last Step has arrived at
// a geometrical boundary.
// It returns the Normal to the surface pointing out of the volume that
// was left behind and/or into the volume that was entered.
// (The normal is in the coordinate system of the final volume.)
// This function takes full care about how to calculate this normal,
// but if the surfaces are not convex it will return valid=false.
//
// The following methods provide (more detailed) information when a Step has
// arrived at a geometrical boundary. They distinguish between the different
// causes that can result in the track leaving its current volume.
//
// Four cases are possible:
//
// 1) The particle has reached a boundary of a daughter of the current volume:
// (this could cause the relocation to enter the daughter itself
// or a potential granddaughter or further descendant)
//
// 2) The particle has reached a boundary of the current
// volume, exiting into a mother (regardless the level
// at which it is located in the tree):
//
// 3) The particle has reached a boundary of the current
// volume, exiting into a volume which is not in its
// parental hierarchy:
//
// 4) The particle is not on a boundary between volumes:
// the function returns an exception, and the caller is
// reccomended to compare the G4touchables associated
// to the preStepPoint and postStepPoint to handle this case.
//
// G4bool EnteredDaughterVolume();
// The purpose of this function is to inform the caller if the track is
// entering a daughter volume while exiting from the current volume.
// This method returns
// - True only in case 1) above, that is when
// the Step has caused the track to arrive at a boundary of a daughter.
// - False in cases 2), 3) and 4), ie in all other cases.
// This function is not guaranteed to work if SetGeometricallyLimitedStep()
// was not called when it should have been called.
//
// G4bool IsExitNormalValid();
// Return true if the Navigator
// i) found that it is exiting the previous volume and is not entering a
// daughter volume.
// ii) has obtained the normal for the previous volume.
//
// G4ThreeVector GetLocalExitNormal();
// Can be called (ie can return a valid result) only if Navigator replied
// true to IsExitNormalValid()
// It returns the ExitNormal of the previous volume
// (The normal is in the coordinate system of the final volume.)
//
// The expected usefulness of these methods is to allow the caller to
// determine how to compute the surface normal at the volume boundary. The two
// possibilities are to obtain the normal from:
//
// i) the solid associated with the volume of the initial point of the Step.
// This is valid for cases 2 and 3.
// (Note that the initial point is generally the PreStepPoint of a Step).
// or
// ii) the solid of the final point, ie of the volume after the relocation.
// This is valid for case 1.
// (Note that the final point is generally the PreStepPoint of a Step).
//
// This way the caller can always get a valid normal, pointing outside
// the solid for which it is computed, that can be used at his own
// discretion.
//
// 18th Dec 1997 John Allison Temporary change -> NON-CONST (8 functions)
#ifndef G4NAVIGATOR_HH
#define G4NAVIGATOR_HH
#include "geomdefs.hh"
#include "G4ThreeVector.hh"
#include "G4AffineTransform.hh"
#include "G4RotationMatrix.hh"
#include "G4VPhysicalVolume.hh"
#include "G4VPVParameterisation.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4GRSVolume.hh"
#include "G4GRSSolid.hh"
#include "G4TouchableHistory.hh"
#include "G4NavigationHistory.hh"
#include "G4NormalNavigation.hh"
#include "G4VoxelNavigation.hh"
#include "G4ParameterisedNavigation.hh"
#include "G4ReplicaNavigation.hh"
class ostream;
class G4Navigator
{
public:
friend ostream& operator << (ostream &os, const G4Navigator &n);
// Constructor - initialisers and setup
G4Navigator();
~G4Navigator();
// Compute the next geometric Step
G4double ComputeStep(const G4ThreeVector &pGlobalPoint,
const G4ThreeVector &pDirection,
const G4double pCurrentProposedStepLength,
G4double &pNewSafety);
// Locate the point in the hierarchy
G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point,
const G4ThreeVector* direction=0,
const G4bool pRelativeSearch=true);
G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector &p,
const G4TouchableHistory &h);
void LocateGlobalPointWithinVolume( const G4ThreeVector& position);
void LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
const G4ThreeVector& direction,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch =true);
// Old version (missing direction) : not recommended
// replace with new version above.
void LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch =true);
// Inform the navigator that the previous Step calculated
// by the geometry was taken in its entirety
void SetGeometricallyLimitedStep();
// Calculate the isotropic distance to the nearest boundary from the
// specified point in the global coordinate system.
G4double ComputeSafety(const G4ThreeVector &globalpoint,
const G4double pProposedMaxLength=DBL_MAX );
// Return the local coordinate of the last located track
G4ThreeVector GetCurrentLocalCoordinate() const;
// Return position vector in local coordinate system, given a position vector
// in world coord system
G4ThreeVector ComputeLocalPoint(const G4ThreeVector& rGlobPoint) const;
// Return Local Coordinates of point in world coordinate system
//
G4ThreeVector ComputeLocalAxis(const G4ThreeVector& pVec) const;
// Compute+return the local->global translation/rotation of current volume
G4ThreeVector NetTranslation() const;
G4RotationMatrix NetRotation() const;
// Return the current world (`topmost') volume
G4VPhysicalVolume* GetWorldVolume() const;
// Set the world (`topmost') volume. Check at origin and unrotated.
void SetWorldVolume(G4VPhysicalVolume* pWorld);
// `Touchable' creation methods: caller has deletion responsibility
G4GRSVolume* CreateGRSVolume() const;
G4GRSSolid* CreateGRSSolid() const;
G4TouchableHistory* CreateTouchableHistory() const;
// Obtain the Normal vector to a surface (in local coordinates)
G4bool IsExitNormalValid();
G4ThreeVector GetLocalExitNormal(); // Valid only if Navigator replied true
// It is in the coordinate system of the final volume
// More powerful calculation of Exit Surface Normal, returns validity too.
// But it can only be called if the Step has crossed a volume boundary.
G4ThreeVector GetLocalExitNormal(G4bool* valid);
//
G4bool EnteredDaughterVolume();
// G4bool ExitedMotherVolume();
// Get/Set Verbose(ness) level (if level>0 && G4VERBOSE, printout can occur)
G4int GetVerboseLevel();
void SetVerboseLevel(G4int level);
// Print the internal state of the Navigator (for debugging).
// The level of detail is according to the verbosity.
void PrintState();
// Obtain the transformations Global/Local (and inverse)
// Clients of these methods must copy the data if they need to keep it.
const G4AffineTransform& GetGlobalToLocalTransform() const;
const G4AffineTransform GetLocalToGlobalTransform() const;
protected:
// Reset stack and minimum or navigator state machine necessary for reset
// as needed by LocalGlobalPointAnsSetup
// [Does not perform clears, resizes, or reset fLastLocatedPointLocal]
void ResetStackAndState();
// Characterise `type' of volume - normal/replicated/parameterised
EVolume VolumeType(const G4VPhysicalVolume *pVol) const;
// Characterise daughter of logical volume
EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const;
// Renavigate & reset hierarchy described by current history
// o Reset volumes
// o Recompute transforms and/or solids of replicated/parameterised vols
void SetupHierarchy();
private:
//
// BEGIN State information
//
// Position of the last located point relative to its containing volume
G4ThreeVector fLastLocatedPointLocal;
// Set true if last Step was limited by geometry.
G4bool fWasLimitedByGeometry;
G4bool fEntering,fExiting;
// Entering/Exiting volumes blocking/setup
// o If exiting
// volume ptr & replica number (set & used by Locate..())
// used for blocking on redescent of geometry
// o If entering
// volume ptr & replica number (set by ComputeStep(),used by
// Locate..()) of volume for `automatic' entry
G4VPhysicalVolume *fBlockedPhysicalVolume;
G4int fBlockedReplicaNo;
G4bool fEnteredDaughter; // A memory of whether in this Step a daughter
// volume is entered (set in Compute & Locate)
// After Compute: it expects to enter a daughter
// After Locate: it has entered a daughter
G4bool fExitedMother; // A similar memory whether the Step exited
// current "mother" volume completely,
// not entering daughter.
G4bool fValidExitNormal; // Set true if have leaving volume normal
G4ThreeVector fExitNormal; // Leaving volume normal, in the
// volume containing the exited
// volume's coordinate system
G4NavigationHistory fHistory;
// Transformation & `path' history
// of current path through geomtrical
// hierarchy
G4bool fLastStepWasZero;
// Whether the last ComputeStep moved Zero
// Used to check for edges.
G4bool fLocatedOnEdge;
// Whether the Navigator has detected an edge
G4ThreeVector fPreviousSftOrigin;
G4double fPreviousSafety;
// Memory of last safety origin & value.
// Used in ComputeStep to ensure that
// origin of current Step is in the same
// volume as the point of the last relocation.
//
// END State information
//
//
// BEGIN Tracking Invariants
//
// A link to the topmost physical volume in the detector.
// Must be positioned at the origin and unrotated.
G4VPhysicalVolume *fTopPhysical;
//
// END Tracking Invariants
//
//
// BEGIN Utility information
//
G4int fVerbose; // Verbose(ness) level (if > 0, printout can occur)
//
// END Utility Invariants
//
//
// Helpers/Utility classes
//
G4NormalNavigation fnormalNav;
G4VoxelNavigation fvoxelNav;
G4ParameterisedNavigation fparamNav;
G4ReplicaNavigation freplicaNav;
};
#include "G4Navigator.icc"
#endif
@@ -0,0 +1,152 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Navigator.icc,v 2.3 1998/11/09 18:59:49 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4Navigator Inline implementation
// Return the local coordinate of the current track
inline G4ThreeVector G4Navigator::GetCurrentLocalCoordinate() const
{
return fLastLocatedPointLocal;
}
// Return local direction of vector direction in world coord system
inline G4ThreeVector G4Navigator::ComputeLocalAxis(const G4ThreeVector& pVec) const
{
return (fHistory.GetTopTransform().IsRotated()) ? fHistory.GetTopTransform().TransformAxis(pVec) : pVec ;
}
// Return local coordinates of a point in the world coord system
inline G4ThreeVector G4Navigator::ComputeLocalPoint(const G4ThreeVector& pGlobalPoint) const
{
return ( fHistory.GetTopTransform().TransformPoint(pGlobalPoint) ) ;
}
// Return the current world (`topmost') volume
inline G4VPhysicalVolume* G4Navigator::GetWorldVolume() const
{
return fTopPhysical;
}
// Inform the navigator that the previous Step calculated
// by the geometry was taken in its entirety
inline void G4Navigator::SetGeometricallyLimitedStep()
{
fWasLimitedByGeometry=true;
}
// Reset stack and minimum of navigator state `machine'
inline void G4Navigator::ResetStackAndState()
{
fHistory.Reset();
fWasLimitedByGeometry=false;
fEntering=false;
fExiting=false;
fLastStepWasZero= false;
fBlockedPhysicalVolume=0;
fBlockedReplicaNo=-1;
}
inline EVolume G4Navigator::VolumeType(const G4VPhysicalVolume *pVol) const
{
EVolume type;
EAxis axis;
G4int nReplicas;
G4double width,offset;
G4bool consuming;
if (pVol->IsReplicated())
{
pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
type=(consuming) ? kReplica : kParameterised;
}
else
{
type=kNormal;
}
return type;
}
inline EVolume G4Navigator::CharacteriseDaughters(const G4LogicalVolume *pLog) const
{
EVolume type;
EAxis axis;
G4int nReplicas;
G4double width,offset;
G4bool consuming;
G4VPhysicalVolume *pVol;
if (pLog->GetNoDaughters()==1)
{
pVol=pLog->GetDaughter(0);
if (pVol->IsReplicated())
{
pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
type=(consuming) ? kReplica : kParameterised;
}
else
{
type=kNormal;
}
}
else
{
type=kNormal;
}
return type;
}
// JA April 30th, 1997
//
// Is the Surface Normal valid?
inline G4bool G4Navigator::IsExitNormalValid()
{
return fExiting && fValidExitNormal;
}
// Obtain the Normal vector to a surface (in local coordinates)
// ( It is valid only if Navigator replied true to above function)
inline G4ThreeVector G4Navigator::GetLocalExitNormal()
{
return fExitNormal;
}
// Return local to global transformation
// ie transformation that will take point or axis in world coord system
// and return one in the local coord system
inline const G4AffineTransform& G4Navigator::GetGlobalToLocalTransform() const
{
return fHistory.GetTopTransform();
}
inline void G4Navigator::LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch )
{
G4VPhysicalVolume* pPhysVol;
pPhysVol= LocateGlobalPointAndSetup( position, 0, RelativeSearch);
touchableToUpdate->UpdateYourself( pPhysVol, &fHistory );
}
inline void G4Navigator::LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
const G4ThreeVector& direction,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch )
{
G4VPhysicalVolume* pPhysVol;
pPhysVol= LocateGlobalPointAndSetup( position, &direction, RelativeSearch);
touchableToUpdate->UpdateYourself( pPhysVol, &fHistory );
}
@@ -0,0 +1,65 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4NormalNavigation.hh,v 2.1 1998/11/02 12:11:54 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4NormalNavigation: Utility for navigation in volumes
// containing only G4PVPlacement daughter volumes. Paul Kent Aug 96
#ifndef G4NORMALNAVIGATION_HH
#define G4NORMALNAVIGATION_HH
#include "geomdefs.hh"
#include "G4NavigationHistory.hh"
#include "G4AffineTransform.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4ThreeVector.hh"
class G4NormalNavigation
{
public:
// Search positioned volumes in mother at current top level of history for
// volume containing globalPoint. Do not test the blocked volume. If a
// containing volume is found, `stack' the new volume and return true,
// else return false (the point lying in the mother but not any of the
// daughters). localPoint = global point in local system on entry,
// point in new system on exit.
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 &localPoint,
const G4ThreeVector &localDirection,
const G4double currentProposedStepLength,
G4double &newSafety,
G4NavigationHistory &history,
G4bool &validExitNormal,
G4ThreeVector &exitNormal,
G4bool &exiting,
G4bool &entering,
G4VPhysicalVolume *(*pBlockedPhysical),
G4int &blockedReplicaNo);
G4double ComputeSafety(const G4ThreeVector &globalpoint,
const G4NavigationHistory &history,
const G4double pMaxLength=DBL_MAX );
};
#include "G4AuxiliaryNavServices.hh" // Needed for inline methods
#include "G4NormalNavigation.icc"
#endif
@@ -0,0 +1,103 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4NormalNavigation.icc,v 2.4 1998/11/25 16:33:52 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// G4NormalNavigation Inline Implementation
inline G4bool G4NormalNavigation::LevelLocate(G4NavigationHistory &history,
const G4VPhysicalVolume *blockedVol,
const G4int,
const G4ThreeVector &globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector &localPoint)
{
G4VPhysicalVolume *targetPhysical,*samplePhysical;
G4LogicalVolume *targetLogical;
G4VSolid *sampleSolid;
G4ThreeVector samplePoint;
G4int targetNoDaughters,sampleNo;
targetPhysical=history.GetTopVolume();
targetLogical=targetPhysical->GetLogicalVolume();
targetNoDaughters=targetLogical->GetNoDaughters();
if (targetNoDaughters==0) return false;
//
// Search daughters in volume
//
for (sampleNo=targetNoDaughters-1;sampleNo>=0;sampleNo--)
{
samplePhysical=targetLogical->GetDaughter(sampleNo);
if (samplePhysical!=blockedVol)
{
EInside sampleInside;
// Setup volume with mother ptr
samplePhysical->Setup(targetPhysical);
history.NewLevel(samplePhysical, kNormal, samplePhysical->GetCopyNo());
sampleSolid=samplePhysical->GetLogicalVolume()->GetSolid();
samplePoint=history.GetTopTransform().TransformPoint(globalPoint);
#if 1
if( G4AuxiliaryNavServices::
CheckPointOnSurface(sampleSolid, samplePoint, globalDirection,
history.GetTopTransform(), pLocatedOnEdge)
)
{
// Enter this daughter
// blockedVol=0;
localPoint=samplePoint;
return true;
}
else
{
history.BackLevel();
}
#else
sampleInside= sampleSolid->Inside(samplePoint);
if( sampleInside == kOutside)
{
history.BackLevel();
}
else
{
if( !pLocatedOnEdge )
{
// Enter this daughter
// blockedVol=0;
localPoint=samplePoint;
return true;
}
else
{
// We are probably located on an edge.
sampleDirection= history.GetTopTransform()
.TransformAxis(globalDirection);
// Check whether we enter the volume
//
sampleNormal= sampleSolid->SurfaceNormal(samplePoint);
if ( sampleNormal.dot(sampleDirection) <= 0 )
{
// Enter this daughter
// blockedVol=0;
localPoint=samplePoint;
return true;
}
}
}
#endif
}
}
return false;
}
@@ -0,0 +1,92 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4ParameterisedNavigation.hh,v 2.2 1998/11/02 12:11:56 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4ParameterisedNavigation: Utility for navigation in volumes
// containing a single G4PVParameterised volume for which voxels for
// the replicated volumes have been constructed.
// [Voxels MUST be along one axis only: NOT refined] Paul Kent Aug 96
#ifndef G4PARAMETERISEDNAVIGATION_HH
#define G4PARAMETERISEDNAVIGATION_HH
#include "globals.hh"
#include "G4NavigationHistory.hh"
#include "G4AffineTransform.hh"
#include "G4VPhysicalVolume.hh"
#include "G4VPVParameterisation.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4ThreeVector.hh"
#include "G4BlockingList.hh"
// Required for voxel handling
#include "G4SmartVoxelProxy.hh"
#include "G4SmartVoxelNode.hh"
#include "G4SmartVoxelHeader.hh"
class G4ParameterisedNavigation
{
public:
G4ParameterisedNavigation();
~G4ParameterisedNavigation();
G4SmartVoxelNode* VoxelLocate(G4SmartVoxelHeader *pHead,
const G4ThreeVector &localPoint);
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 ComputeSafety(const G4ThreeVector &localPoint,
const G4NavigationHistory &history,
const G4double pProposedMaxLength=DBL_MAX );
private:
G4double ComputeVoxelSafety(const G4ThreeVector &localPoint) const;
G4bool LocateNextVoxel(const G4ThreeVector &localPoint,
const G4ThreeVector& localDirection,
const G4double currentStep);
G4BlockingList fBList; // Blocked volumes
//
// BEGIN Voxel Stack information
//
EAxis fVoxelAxis;
G4int fVoxelNoSlices;
G4double fVoxelSliceWidth;
G4int fVoxelNodeNo;
G4SmartVoxelHeader *fVoxelHeader;
G4SmartVoxelNode *fVoxelNode;
//
// END Voxel Stack information
//
};
#include "G4AuxiliaryNavServices.hh" // Needed for inline methods
#include "G4ParameterisedNavigation.icc"
#endif
@@ -0,0 +1,223 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4ParameterisedNavigation.icc,v 2.4 1998/11/02 12:11:56 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4ParameterisedNavigation Inline implementation
inline G4ParameterisedNavigation::G4ParameterisedNavigation() :
fVoxelNode(0),fVoxelHeader(0)
{
}
inline G4SmartVoxelNode* G4ParameterisedNavigation::VoxelLocate(G4SmartVoxelHeader *pHead,
const G4ThreeVector &localPoint)
{
EAxis targetHeaderAxis;
G4double targetHeaderMin,targetHeaderNodeWidth;
G4int targetHeaderNoSlices,targetNodeNo;
targetHeaderAxis=pHead->GetAxis();
targetHeaderNoSlices=pHead->GetNoSlices();
targetHeaderMin=pHead->GetMinExtent();
targetHeaderNodeWidth=(pHead->GetMaxExtent()-targetHeaderMin)/targetHeaderNoSlices;
targetNodeNo=G4int ((localPoint(targetHeaderAxis)-targetHeaderMin)/targetHeaderNodeWidth);
// Rounding protection
if (targetNodeNo<0)
{
targetNodeNo=0;
}
else if (targetNodeNo>=targetHeaderNoSlices)
{
targetNodeNo=targetHeaderNoSlices-1;
}
fVoxelAxis=targetHeaderAxis;
fVoxelNoSlices=targetHeaderNoSlices;
fVoxelSliceWidth=targetHeaderNodeWidth;
fVoxelNodeNo=targetNodeNo;
fVoxelHeader=pHead;
fVoxelNode=pHead->GetSlice(targetNodeNo)->GetNode();
return fVoxelNode;
}
// Compute safety from specified point to collected voxel boundaries
// using already located point
inline G4double G4ParameterisedNavigation::ComputeVoxelSafety(const G4ThreeVector&localPoint) const
{
G4double voxelSafety, plusVoxelSafety, minusVoxelSafety;
G4double curNodeOffset,minCurCommonDelta,maxCurCommonDelta;
G4int minCurNodeNoDelta,maxCurNodeNoDelta;
// Compute linear intersection distance to boundaries of max/min
// to collected nodes at current level
curNodeOffset=fVoxelNodeNo*fVoxelSliceWidth;
minCurCommonDelta=localPoint(fVoxelAxis)
-fVoxelHeader->GetMinExtent()
-curNodeOffset;
maxCurNodeNoDelta=fVoxelNode->GetMaxEquivalentSliceNo()-fVoxelNodeNo;
minCurNodeNoDelta=fVoxelNodeNo-fVoxelNode->GetMinEquivalentSliceNo();
maxCurCommonDelta=fVoxelSliceWidth-minCurCommonDelta;
plusVoxelSafety= minCurNodeNoDelta*fVoxelSliceWidth+minCurCommonDelta;
minusVoxelSafety=maxCurNodeNoDelta*fVoxelSliceWidth+maxCurCommonDelta;
voxelSafety= min(plusVoxelSafety,minusVoxelSafety);
if (voxelSafety<0)
{
voxelSafety=0;
}
return voxelSafety;
}
// Find the next voxel from the current voxel and point in the specified
// direction
//
// Return false if all voxels considered
// [current Step ends inside same voxel or leaves all voxels]
// true otherwise
inline G4bool G4ParameterisedNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double currentStep)
{
G4bool isNewVoxel;
G4int newNodeNo;
G4double minVal,maxVal,curMinExtent,curCoord;
curMinExtent=fVoxelHeader->GetMinExtent();
curCoord=localPoint(fVoxelAxis)+currentStep*localDirection(fVoxelAxis);
minVal=curMinExtent
+fVoxelNode->GetMinEquivalentSliceNo()*fVoxelSliceWidth;
isNewVoxel=false;
if (minVal<=curCoord)
{
maxVal=curMinExtent
+(fVoxelNode->GetMaxEquivalentSliceNo()+1)*fVoxelSliceWidth;
if (maxVal<curCoord)
{
newNodeNo=fVoxelNode->GetMaxEquivalentSliceNo()+1;
if (newNodeNo<fVoxelHeader->GetNoSlices())
{
fVoxelNodeNo=newNodeNo;
fVoxelNode=fVoxelHeader->GetSlice(newNodeNo)->GetNode();
isNewVoxel=true;
}
}
}
else
{
newNodeNo=fVoxelNode->GetMinEquivalentSliceNo()-1;
// Must locate from newNodeNo no and down to setup stack and fVoxelNode
// Repeat or earlier code...
if (newNodeNo>=0)
{
fVoxelNodeNo=newNodeNo;
fVoxelNode=fVoxelHeader->GetSlice(newNodeNo)->GetNode();
isNewVoxel=true;
}
}
return isNewVoxel;
}
inline G4bool G4ParameterisedNavigation::LevelLocate(G4NavigationHistory& history,
const G4VPhysicalVolume *blockedVol,
const G4int blockedNum,
const G4ThreeVector &globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector &localPoint)
{
G4SmartVoxelHeader *motherVoxelHeader;
G4SmartVoxelNode *motherVoxelNode;
G4VPhysicalVolume *motherPhysical,*pPhysical;
G4VPVParameterisation *pParam;
G4LogicalVolume *motherLogical;
G4VSolid *pSolid;
G4ThreeVector samplePoint;
G4int voxelNoDaughters,sampleNo,replicaNo;
motherPhysical=history.GetTopVolume();
motherLogical=motherPhysical->GetLogicalVolume();
motherVoxelHeader=motherLogical->GetVoxelHeader();
// localPoint=history.GetTopTransform().TransformPoint(globalPoint);
// Find the voxel containing the point
motherVoxelNode=VoxelLocate(motherVoxelHeader,localPoint);
voxelNoDaughters=motherVoxelNode->GetNoContained();
if (voxelNoDaughters==0) return false;
pPhysical=motherLogical->GetDaughter(0);
// pSolid=pPhysical->GetLogicalVolume()->GetSolid(); // Now it can vary
pParam=pPhysical->GetParameterisation();
//
// Search replicated daughter volume
//
for (sampleNo=voxelNoDaughters-1;sampleNo>=0;sampleNo--)
{
replicaNo=motherVoxelNode->GetVolume(sampleNo);
if (replicaNo!=blockedNum||pPhysical!=blockedVol)
{
// Obtain solid (as it can vary) and
// obtain its parameters
pSolid=pParam->ComputeSolid(replicaNo, pPhysical);
pSolid->ComputeDimensions(pParam,
replicaNo,
pPhysical);
pParam->ComputeTransformation(replicaNo,
pPhysical);
// Setup volume with mother ptr
pPhysical->Setup(motherPhysical);
history.NewLevel(pPhysical,
kParameterised,
replicaNo);
samplePoint=history.GetTopTransform().TransformPoint(globalPoint);
if (! G4AuxiliaryNavServices::
CheckPointOnSurface(pSolid, samplePoint, globalDirection,
history.GetTopTransform(), pLocatedOnEdge) )
{
history.BackLevel();
}
else
{
// Enter this daughter
// blockedVol=0;
localPoint=samplePoint;
// Set the correct copy number in physical
pPhysical->SetCopyNo(replicaNo);
// Set the correct solid and material in Logical Volume
G4LogicalVolume *pLogical=pPhysical->GetLogicalVolume();
pLogical->SetSolid( pSolid );
pLogical->SetMaterial( pParam->ComputeMaterial(replicaNo,
pPhysical));
return true;
}
}
}
return false;
}
@@ -0,0 +1,114 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4ReplicaNavigation.hh,v 2.1 1998/11/02 12:11:57 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4ReplicaNavigation: Utility for navigation in volumes
// containing a single G4PVParameterised volume for which voxels for
// the replicated volumes have been constructed.
// [Voxels MUST be along one axis only: NOT refined] Paul Kent Aug 96
#ifndef G4REPLICANAVIGATION_HH
#define G4REPLICANAVIGATION_HH
#include "globals.hh"
#include "G4NavigationHistory.hh"
#include "G4AffineTransform.hh"
#include "G4VPhysicalVolume.hh"
#include "G4VPVParameterisation.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4ThreeVector.hh"
#include "G4BlockingList.hh"
// Required for voxel handling
#include "G4SmartVoxelProxy.hh"
#include "G4SmartVoxelNode.hh"
#include "G4SmartVoxelHeader.hh"
class G4ReplicaNavigation
{
friend class G4ReplicaNavigationTester;
public:
G4ReplicaNavigation();
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 G4ThreeVector &localPoint,
const G4ThreeVector &localDirection,
const G4double currentProposedStepLength,
G4double &newSafety,
G4NavigationHistory &history,
G4bool &validExitNormal,
G4ThreeVector &exitNormal,
G4bool &exiting,
G4bool &entering,
G4VPhysicalVolume *(*pBlockedPhysical),
G4int &blockedReplicaNo);
G4double ComputeSafety(const G4ThreeVector &globalPoint,
const G4ThreeVector &localPoint,
G4NavigationHistory &history, // -> NON-CONST
// const G4NavigationHistory &history, // -> NON-CONST
const G4double pProposedMaxLength=DBL_MAX );
EInside BackLocate(G4NavigationHistory &history,
const G4ThreeVector &globalPoint,
G4ThreeVector &localPoint,
const G4bool &exiting,
G4bool &notKnownInside) const;
void ComputeTransformation(const G4int replicaNo,
G4VPhysicalVolume *pVol,
G4ThreeVector &point) const;
void ComputeTransformation(const G4int replicaNo,
G4VPhysicalVolume *pVol) const;
EInside Inside(const G4VPhysicalVolume *pVol,
const G4int replicaNo,
const G4ThreeVector &localPoint) const;
G4double DistanceToOut(const G4VPhysicalVolume *pVol,
const G4int replicaNo,
const G4ThreeVector &localPoint) const;
G4double DistanceToOut(const G4VPhysicalVolume *pVol,
const G4int replicaNo,
const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection) const;
private:
G4int VoxelLocate(const G4SmartVoxelHeader *pHead,
const G4ThreeVector &localPoint,
const G4int blocked=-1) const;
G4double DistanceToOutPhi(const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection,
const G4double width) const;
G4double DistanceToOutRad(const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection,
const G4double width,
const G4double offset,
const G4int replicaNo) const;
void SetPhiTransformation(const G4double ang,
G4VPhysicalVolume *pVol=0) const;
};
#include "G4ReplicaNavigation.icc"
#endif
@@ -0,0 +1,148 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4ReplicaNavigation.icc,v 2.2 1998/11/02 12:11:57 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4ReplicaNavigation Inline implementation
inline G4int G4ReplicaNavigation::VoxelLocate(const G4SmartVoxelHeader *pHead,
const G4ThreeVector &localPoint,
const G4int blocked) const
{
EAxis targetHeaderAxis;
G4double coord,targetHeaderMin;
G4double targetHeaderNodeWidth,targetNodePos;
G4int targetHeaderNoSlices,targetNodeNo;
targetHeaderAxis=pHead->GetAxis();
targetHeaderNoSlices=pHead->GetNoSlices();
targetHeaderMin=pHead->GetMinExtent();
targetHeaderNodeWidth=(pHead->GetMaxExtent()-targetHeaderMin)/targetHeaderNoSlices;
switch (targetHeaderAxis)
{
case kXAxis:
coord=localPoint.x();
break;
case kYAxis:
coord=localPoint.y();
break;
case kZAxis:
coord=localPoint.z();
break;
case kRho:
coord=localPoint.perp();
break;
case kPhi:
coord=localPoint.phi();
if (coord<0&&coord<targetHeaderMin) coord+=2.0*M_PI;
break;
case kRadial3D:
default:
break;
}
targetNodePos=(coord-targetHeaderMin)/targetHeaderNodeWidth;
targetNodeNo=(G4int) targetNodePos;
if (targetNodeNo==blocked)
{
targetNodeNo=(targetNodePos-targetNodeNo<0.5)
? targetNodeNo-1 : targetNodeNo+1;
// Do not need to check range: If on outer edge of zeroth
// voxel & it is blocked => should have exited mother
// (or similar) P.Kent
// assert(targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices);
// The assert above fails for simulation of high energy electrons
// It is not clear what is the cause for this failure.
// The code below attempts to rectify this problem until a
// complete resolution is possible.
// J.Apostolakis, June 12, 1998
if((targetNodeNo<0) || (targetNodeNo>=targetHeaderNoSlices))
{
#ifdef G4_REPORT_REPLICA_NAV
G4cerr << " ERROR: assert in G4ReplicaNavigation::VoxelLocate "
<< " has failed : " << endl <<
<< " (targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices) "
<< " targetNodeNo= " << targetNodeNo
<< " Number of Slices = " << targetHeaderNoSlices << endl;
#endif
if (targetNodeNo<0)
{
targetNodeNo=0;
}
else if (targetNodeNo>=targetHeaderNoSlices)
{
targetNodeNo=targetHeaderNoSlices-1;
}
}
}
else
{
// Rounding protection
if (targetNodeNo<0)
{
targetNodeNo=0;
}
else if (targetNodeNo>=targetHeaderNoSlices)
{
targetNodeNo=targetHeaderNoSlices-1;
}
}
return targetNodeNo;
}
inline G4bool G4ReplicaNavigation::LevelLocate(G4NavigationHistory& history,
const G4VPhysicalVolume *blockedVol,
const G4int blockedNum,
const G4ThreeVector &,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector &localPoint)
{
G4VPhysicalVolume *motherPhysical,*pPhysical;
G4LogicalVolume *motherLogical;
G4SmartVoxelHeader *motherVoxelHeader;
G4int nodeNo;
// localPoint=history.GetTopTransform().TransformPoint(globalPoint);
motherPhysical=history.GetTopVolume();
motherLogical=motherPhysical->GetLogicalVolume();
motherVoxelHeader=motherLogical->GetVoxelHeader();
pPhysical=motherLogical->GetDaughter(0);
if (blockedVol==pPhysical)
{
nodeNo=VoxelLocate(motherVoxelHeader,localPoint,blockedNum);
}
else
{
nodeNo=VoxelLocate(motherVoxelHeader,localPoint);
}
ComputeTransformation(nodeNo,
pPhysical,
localPoint);
pPhysical->Setup(motherPhysical);
history.NewLevel(pPhysical,
kReplica,
nodeNo);
pPhysical->SetCopyNo(nodeNo);
// localPoint=history.GetTopTransform().TransformPoint(globalPoint);
return true;
}
inline void G4ReplicaNavigation::SetPhiTransformation(const G4double ang,
G4VPhysicalVolume *pVol) const
{
G4RotationMatrix rm;
rm.rotateZ(ang);
if (pVol) *pVol->GetRotation()=rm;
}
@@ -0,0 +1,66 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4TouchableHistory.hh,v 2.2 1998/07/19 23:51:39 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4TouchableHistory Paul Kent August 1996
//
// Object representing a touchable detector element, and
// its history in the geomtrical hierarchy, including
// its net resultant local->global transform
#ifndef G4TOUCHABLEHISTORY_HH
#define G4TOUCHABLEHISTORY_HH
#include "G4VTouchable.hh"
#include "G4NavigationHistory.hh"
#include "G4LogicalVolume.hh"
#include "G4RotationMatrix.hh"
class G4TouchableHistory : public G4VTouchable
{
public:
G4TouchableHistory(const G4NavigationHistory &history);
// The default constructor produces a touchable-history of
// 'zero-depth', ie an "unphysical" and not very unusable one.
// It is for initialisation only .
G4TouchableHistory();
~G4TouchableHistory();
G4VPhysicalVolume* GetVolume(G4int depth=0) const;
G4VSolid* GetSolid(G4int depth=0) const;
const G4ThreeVector& GetTranslation(G4int depth=0) const;
const G4RotationMatrix* GetRotation(G4int depth=0) const;
// New access methods for touchables with history
G4int GetReplicaNumber(G4int depth=0) const;
G4int GetHistoryDepth() const;
G4int MoveUpHistory( G4int num_levels = 1 );
// void ResetLevel(); // Set the level to the top level.
// Update methods for touchables with history
virtual void UpdateYourself( G4VPhysicalVolume* pPhysVol,
const G4NavigationHistory* history=NULL);
// Should this method be "depricated" ?
// it is used now in G4Navigator::LocateGlobalPointAndSetup
//
const G4NavigationHistory* GetHistory() const;
private:
G4int CalculateHistoryIndex(G4int stackDepth) const;
private:
G4RotationMatrix frot;
G4ThreeVector ftlate;
G4NavigationHistory fhistory;
};
#include "G4TouchableHistory.icc"
#endif
@@ -0,0 +1,125 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4TouchableHistory.icc,v 2.2 1998/07/19 23:51:39 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4TouchableHistory inline implementation
inline G4TouchableHistory::G4TouchableHistory()
: fhistory()
{
ftlate= G4ThreeVector(0.,0.,0.);
frot= G4RotationMatrix();
}
inline G4TouchableHistory::G4TouchableHistory(const G4NavigationHistory &history)
: fhistory(history)
{
G4AffineTransform tf(fhistory.GetTopTransform().Inverse());
ftlate=tf.NetTranslation();
frot=tf.NetRotation();
}
inline
void G4TouchableHistory::UpdateYourself( G4VPhysicalVolume* pPhysVol,
const G4NavigationHistory* pHistory)
{
fhistory= *pHistory;
G4AffineTransform tf(fhistory.GetTopTransform().Inverse());
if( pPhysVol == 0 ){
// This means that the track has left the World Volume.
// Since the Navigation History does not already reflect this,
// we must correct this problem here. John A. (--> K. Amako)
fhistory.SetFirstEntry(pPhysVol);
}
ftlate=tf.NetTranslation();
frot=tf.NetRotation();
}
G4int
inline G4TouchableHistory::CalculateHistoryIndex(G4int stackDepth) const
{
return (fhistory.GetDepth()-stackDepth); // was -1
}
inline G4VPhysicalVolume* G4TouchableHistory::GetVolume(G4int depth) const
{
return fhistory.GetVolume(CalculateHistoryIndex(depth));
}
inline G4VSolid* G4TouchableHistory::GetSolid(G4int depth) const
{
return fhistory.GetVolume(CalculateHistoryIndex(depth))->GetLogicalVolume()->GetSolid();
}
inline const G4ThreeVector& G4TouchableHistory::GetTranslation(G4int depth) const
{
// The value returned will change at the next call
// Copy it if you want to use it!
//
static G4ThreeVector currTranslation;
if(depth==0.0) {
return ftlate;
}else{
currTranslation= fhistory.GetTransform(CalculateHistoryIndex(depth)).NetTranslation();
return currTranslation;
}
}
inline const G4RotationMatrix* G4TouchableHistory::GetRotation(G4int depth) const
{
// The value returned will change at the next call
// Copy it if you want to use it!
//
static G4RotationMatrix rotM;
if(depth==0.0) {
return &frot;
}else{
rotM= fhistory.GetTransform(CalculateHistoryIndex(depth)).NetRotation();
return &rotM;
}
}
inline G4int G4TouchableHistory::GetReplicaNumber(G4int depth) const
{
// return this->GetHistory()->GetTopReplicaNo();
return fhistory.GetReplicaNo(CalculateHistoryIndex(depth));
}
inline G4int G4TouchableHistory::GetHistoryDepth() const
{
return fhistory.GetDepth();
}
inline G4int G4TouchableHistory::MoveUpHistory( G4int num_levels )
{
G4NavigationHistory* nHistory= &fhistory;
G4int maxLevelsMove= nHistory->GetDepth();
G4int minLevelsMove= 0; // Cannot redescend today!
// Soon it will be possible
// by adding a data member here
// fCurrentDepth;
if( num_levels > maxLevelsMove ){
num_levels = maxLevelsMove;
}
else if( num_levels < minLevelsMove ){
num_levels = minLevelsMove;
}
nHistory->BackLevel( num_levels );
return num_levels;
}
inline const G4NavigationHistory* G4TouchableHistory::GetHistory() const
{
return &fhistory;
}
@@ -0,0 +1,266 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4Transform.hh,v 2.0 1998/07/02 17:05:31 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4Transform
//
// A coordinate transform, consisting of a translation and a rotation.
// When applying the forwards transformations, rotation is applied first, then
// the translation.
//
//
// Member functions:
//
// G4Transform(G4RotationMatrix* pRot=0)
// Create a translform consisting of a rotation by the specified matrix.
// If NULL (the default) and indentity transform is constructed
// G4Transform(G4RotationMatrix* pRot,const G4ThreeVector& pVec)
// Create a transform consisting of a rotation by the specified matrix, then
// a translation by specified vector. The transform does not copy the
// specified matrix: ownership (hence deletion responsibility) remains with
// the caller.
//
// If the rotation is 0 (NULL ptr), no rotation is performed.
//
// G4ThreeVector& Apply(G4ThreeVector& pVec)
// Apply to the transformation to the specified vector.
// G4ThreeVector& ApplyReverse(G4ThreeVector& pVec)
// Apply to the reverse transformation to the specified vector.
//
// G4ThreeVector Transform(const G4ThreeVector& pVec)
// Compute the transformation of the specified vector.
// G4ThreeVector ReverseTransform(const G4ThreeVector& pVec)
// Compute the reverse transformation to the specified vector.
//
// G4RotationMatrix* GetRotation()
// Return ptr to rotation for the transformation (possibly null if no
// rotation)
// const G4ThreeVector& GetTranslation() const
// Return the translation component of the transformation
// G4Transform& SetTranslation(const G4ThreeVector& pVec)
// Set the translation resulting from the transform.
// Returns a self reference.
//
// [Intended so that simple modifications can be made without creating
// new transforms]
//
// G4Transform& SetRotation(G4RotationMatrix* pRot)
// Set the translation resulting from the transform.
// Returns a self reference.
//
// G4Transform& ComputeCompoundTransform(const G4Transform& t1,
// const G4Transform& t2,G4RotationMatrix* pRot)
// Compute the compound transformation resulting from the transform t1
// followed by the transform t2. The Rotation matrix pRot is modified
// and set to the rotation resulting from the transformation. If no
// rotation results, the rotation ptr of the compounded transform is set
// to NULL. Returns self reference.
//
// If transforms are considered as 4*4 matrices computes t1 . t2
//
// G4Transform& ComputeCompoundReverseTransform(const G4Transform& t1,
// const G4Transform& t2,G4RotationMatrix* pRot)
// Compute the compound transformation resulting from the inverse of
// transform t1 followed by the transform t2. The Rotation matrix pRot
// is modified and set to the rotation resulting from the transformation.
// If no rotation results, the rotation ptr of the compounded transform
// is set to NULL. Returns self reference.
//
// If transforms are considered as 4*4 matrices computes [t1^-1].t2
//
// G4bool IsRotated() const
// Return true if transform involves rotation
//
// G4bool operator == (const G4Transform& t) const
// Define equality as
// 1) equal translations and equal rotation matrix *pointers*
// or
// 2) equal translation and rotation matrices (contents)
//
// Member data:
//
// G4RotationMatrix* frotation
// Pointer to the transmations rotation component
// G4ThreeVector ftranslation
// Translation component
//
// History:
// 16.07.95 P.Kent Added SetTranslation
// 13.07.95 P.Kent Initial version
#ifndef G4TRANSFORM_HH
#define G4TRANSFORM_HH
#include "globals.hh"
#include <assert.h>
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
class G4Transform
{
public:
inline G4Transform( G4RotationMatrix* pRot=0) :
frotation(pRot)
{;}
inline G4Transform( G4RotationMatrix* pRot,
const G4ThreeVector& pVec) :
frotation(pRot),
ftranslation(pVec)
{;}
// inline ~G4Transform() {;}
// Apply to specified vector
inline G4ThreeVector& Apply(G4ThreeVector& pVec) const
{
if (frotation)
{
return pVec=frotation->operator*(pVec)+ftranslation;
}
else
{
return pVec+=ftranslation;
}
}
// Apply reverse transformation to specified vector
inline G4ThreeVector& ApplyReverse(G4ThreeVector& pVec) const
{
if (frotation)
{
return pVec=frotation->inverse()*(pVec-ftranslation);
}
else
{
return pVec-=ftranslation;
}
}
// Compute the transform of the specified vector
inline G4ThreeVector Transform(const G4ThreeVector& pVec) const
{
if (frotation)
{
return frotation->operator*(pVec)+ftranslation;
}
else
{
return pVec+ftranslation;
}
}
// Compute the transform of the specified vector
inline G4ThreeVector ReverseTransform(const G4ThreeVector& pVec) const
{
if (frotation)
{
return frotation->inverse()*(pVec-ftranslation);
}
else
{
return pVec-ftranslation;
}
}
inline G4ThreeVector ComputeLocalAxis(const G4ThreeVector& pVec) const
{
if (!frotation)
{
return pVec;
}
else
{
return (*frotation)*pVec; // UNTESTED
}
}
inline G4RotationMatrix* GetRotation() const
{
return frotation;
}
inline const G4ThreeVector& GetTranslation() const
{
return ftranslation;
}
inline void SetTranslation(const G4ThreeVector& pVec)
{
ftranslation=pVec;
}
inline void SetRotation(G4RotationMatrix* pRot)
{
frotation=pRot;
}
inline G4Transform& ComputeCompoundTransform(const G4Transform& t1,
const G4Transform& t2,
G4RotationMatrix* pRot)
{
if (!(t1.GetRotation()&&t2.GetRotation()))
{
SetTranslation(t1.GetTranslation()+t2.GetTranslation());
SetRotation(0);
}
else
{
pRot=pRot; // Avoid unuse warning
assert(0==1); // Unimpl 13.7.95
}
return *this;
}
inline G4Transform& ComputeCompoundReverseTransform(const G4Transform& t1,
const G4Transform& t2,
G4RotationMatrix* pRot)
{
if (!(t1.GetRotation()&&t2.GetRotation()))
{
SetTranslation(t2.GetTranslation()-t1.GetTranslation());
SetRotation(0);
}
else
{
pRot=pRot; // Avoid unused warning
assert(0==1); // Unimpl 13.7.95
}
return *this;
}
// Return true if transform involves rotations
inline G4bool IsRotated() const
{
return (!frotation||frotation->isIdentity()) ? false : true;
}
// Define equality as
// 1) equal rotation matrix *pointers*, and equal translations
// or
// 2) equal rotation matrices and equal translations
inline G4bool operator == (const G4Transform& t) const
{
return ((GetTranslation()==t.GetTranslation())&&
( (GetRotation()==t.GetRotation())
|| (*GetRotation()==*t.GetRotation()) )) ? true : false;
}
private:
G4RotationMatrix* frotation;
G4ThreeVector ftranslation;
};
#endif
@@ -0,0 +1,66 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4TransportationManager.hh,v 2.1 1998/07/12 02:58:22 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------
// GEANT 4 inlude file implementation
//
// For information related to this code contact:
// CERN, IT Division (formely CN), ASD group
// ------------------------------------------------------------
//
// A singleton class which stores the (volume) navigator used by
// the transportation process to do the geometrical tracking.
// It also stores a pointer to the propagator used in a (magnetic)
// field and to the field manager.
// The class instance is created before main() is called, and
// in turn creates the navigator and the rest.
//
// =======================================================================
// Created: 10 March 1997, J. Apostolakis
// =======================================================================
#ifndef G4TransportationManager_hh
#define G4TransportationManager_hh
#include "G4Navigator.hh"
class G4PropagatorInField;
class G4FieldManager;
class G4TransportationManager
{
public:
static G4TransportationManager* GetTransportationManager();
G4Navigator* GetNavigatorForTracking();
G4PropagatorInField* GetPropagatorInField();
G4FieldManager* GetFieldManager();
void SetNavigatorForTracking( G4Navigator* newNavigator);
void SetPropagatorInField( G4PropagatorInField* newFieldPropagator);
void SetFieldManager( G4FieldManager* newFieldManager);
~G4TransportationManager();
private:
G4Navigator* fNavigatorForTracking ;
G4PropagatorInField* fPropagatorInField;
G4FieldManager* fFieldManager;
G4TransportationManager();
// Must we also declare a null copy constructor ??
static G4TransportationManager fTransportationManager;
};
#include "G4TransportationManager.icc"
#endif
// end of #ifndef G4TransportationManager_hh
@@ -0,0 +1,59 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4TransportationManager.icc,v 2.1 1998/07/12 02:58:23 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// ------------------------------------------------------------
// GEANT 4 inlined function members implementation
//
// For information related to this code contact:
// CERN, CN Division, ASD group
// ------------------------------------------------------------
//
// Created: 10 March 1997, J. Apostolakis
//
inline G4Navigator* G4TransportationManager::GetNavigatorForTracking()
{
return fNavigatorForTracking;
}
inline G4PropagatorInField* G4TransportationManager::GetPropagatorInField()
{
return fPropagatorInField;
}
inline G4FieldManager* G4TransportationManager::GetFieldManager()
{
return fFieldManager;
}
inline void G4TransportationManager::SetNavigatorForTracking(
G4Navigator* newNavigator)
{
fNavigatorForTracking= newNavigator;
// fPropagatorInField->setNavigator(newNavigator);
}
inline void G4TransportationManager::SetPropagatorInField(
G4PropagatorInField* newFieldPropagator )
{
fPropagatorInField= newFieldPropagator;
}
inline void G4TransportationManager::SetFieldManager(
G4FieldManager* newFieldManager)
{
fFieldManager= newFieldManager;
}
inline G4TransportationManager* G4TransportationManager::GetTransportationManager()
{
return &fTransportationManager;
}
@@ -0,0 +1,118 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VoxelNavigation.hh,v 2.2 1998/11/02 12:11:58 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4VoxelNavigation: Utility for navigation in volumes
// containing only G4PVPlacement daughter volumes for which voxels
// have been constructed. Paul Kent Aug 96
#ifndef G4VOXELNAVIGATION_HH
#define G4VOXELNAVIGATION_HH
#include "globals.hh"
#include "G4NavigationHistory.hh"
#include "G4AffineTransform.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4ThreeVector.hh"
#include "G4BlockingList.hh"
// Required for voxel handling & voxel stack
#include "G4SmartVoxelProxy.hh"
#include "G4SmartVoxelNode.hh"
#include "G4SmartVoxelHeader.hh"
#include <rw/tvvector.h>
#include <rw/tpvector.h>
// Voxel stack depth maximum [no resizing]
const G4int kNavigatorVoxelStackMax = 3;
class G4VoxelNavigation
{
public:
G4VoxelNavigation();
~G4VoxelNavigation();
G4SmartVoxelNode* VoxelLocate(G4SmartVoxelHeader *pHead,
const G4ThreeVector &localPoint);
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 ComputeSafety(const G4ThreeVector &globalpoint,
const G4NavigationHistory &history,
const G4double pMaxLength=DBL_MAX );
private:
G4double ComputeVoxelSafety(const G4ThreeVector &localPoint) const;
G4bool LocateNextVoxel(const G4ThreeVector &localPoint,
const G4ThreeVector& localDirection,
const G4double currentStep);
G4bool VoxelSubLevelSetup(const G4ThreeVector& pLoc,
G4SmartVoxelHeader *pHeader,
G4int pDepth);
G4BlockingList fBList; // Blocked volumes
//
// BEGIN Voxel Stack information
//
// Note: fVoxelDepth==0+ => fVoxelAxisStack(0+) contains axes of voxel
// fVoxelDepth==-1 -> not in voxel
G4int fVoxelDepth;
// Voxel axes
RWTValVector<EAxis> fVoxelAxisStack;
// No slices per voxel at each level
RWTValVector<G4int> fVoxelNoSlicesStack;
// Width of voxels at each level
RWTValVector<G4double> fVoxelSliceWidthStack;
// Node no point is inside at each level
RWTValVector<G4int> fVoxelNodeNoStack;
// Voxel headers at each level
RWTPtrVector<G4SmartVoxelHeader> fVoxelHeaderStack;
// Node containing last located point
G4SmartVoxelNode* fVoxelNode;
//
// END Voxel Stack information
//
};
#include "G4AuxiliaryNavServices.hh" // Needed for inline implementation
#include "G4VoxelNavigation.icc"
#endif
@@ -0,0 +1,132 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4VoxelNavigation.icc,v 2.1 1998/11/02 12:11:59 japost Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4VoxelNavigation Inline implementation
inline G4VoxelNavigation::G4VoxelNavigation() :
fVoxelAxisStack(kNavigatorVoxelStackMax),
fVoxelNoSlicesStack(kNavigatorVoxelStackMax),
fVoxelSliceWidthStack(kNavigatorVoxelStackMax),
fVoxelNodeNoStack(kNavigatorVoxelStackMax),
fVoxelHeaderStack(kNavigatorVoxelStackMax),
fVoxelDepth(-1),fVoxelNode(0)
{
}
inline G4SmartVoxelNode* G4VoxelNavigation::VoxelLocate(G4SmartVoxelHeader *pHead,
const G4ThreeVector &localPoint)
{
G4SmartVoxelHeader *targetVoxelHeader=pHead;
G4SmartVoxelNode *targetVoxelNode=0;
G4SmartVoxelProxy *sampleProxy;
EAxis targetHeaderAxis;
G4double targetHeaderMin,targetHeaderNodeWidth;
G4int targetHeaderNoSlices,targetNodeNo;
fVoxelDepth=0;
do {
targetHeaderAxis=targetVoxelHeader->GetAxis();
targetHeaderNoSlices=targetVoxelHeader->GetNoSlices();
targetHeaderMin=targetVoxelHeader->GetMinExtent();
targetHeaderNodeWidth=(targetVoxelHeader->GetMaxExtent()-targetHeaderMin)/targetHeaderNoSlices;
targetNodeNo=G4int ((localPoint(targetHeaderAxis)-targetHeaderMin)/targetHeaderNodeWidth);
// Rounding protection
if (targetNodeNo<0)
{
targetNodeNo=0;
}
else if (targetNodeNo>=targetHeaderNoSlices)
{
targetNodeNo=targetHeaderNoSlices-1;
}
// Stack info for stepping
fVoxelAxisStack(fVoxelDepth)=targetHeaderAxis;
fVoxelNoSlicesStack(fVoxelDepth)=targetHeaderNoSlices;
fVoxelSliceWidthStack(fVoxelDepth)=targetHeaderNodeWidth;
fVoxelNodeNoStack(fVoxelDepth)=targetNodeNo;
fVoxelHeaderStack(fVoxelDepth)=targetVoxelHeader;
sampleProxy=targetVoxelHeader->GetSlice(targetNodeNo);
if (sampleProxy->IsNode())
{
targetVoxelNode=sampleProxy->GetNode();
}
else
{
targetVoxelHeader=sampleProxy->GetHeader();
fVoxelDepth++;
}
} while (!targetVoxelNode);
fVoxelNode=targetVoxelNode;
return targetVoxelNode;
}
inline G4bool G4VoxelNavigation::LevelLocate(G4NavigationHistory& history,
const G4VPhysicalVolume *blockedVol,
const G4int,
const G4ThreeVector &globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector &localPoint)
{
G4SmartVoxelHeader *targetVoxelHeader;
G4SmartVoxelNode *targetVoxelNode;
G4VPhysicalVolume *targetPhysical,*samplePhysical;
G4LogicalVolume *targetLogical;
G4VSolid *sampleSolid;
G4ThreeVector samplePoint;
G4int targetNoDaughters,sampleNo;
targetPhysical=history.GetTopVolume();
targetLogical=targetPhysical->GetLogicalVolume();
targetVoxelHeader=targetLogical->GetVoxelHeader();
// localPoint=history.GetTopTransform().TransformPoint(globalPoint);
// Find the voxel containing the point
targetVoxelNode=VoxelLocate(targetVoxelHeader,localPoint);
targetNoDaughters=targetVoxelNode->GetNoContained();
if (targetNoDaughters==0) return false;
//
// Search daughters in volume
//
for (sampleNo=targetNoDaughters-1;sampleNo>=0;sampleNo--)
{
samplePhysical=targetLogical->
GetDaughter(targetVoxelNode->
GetVolume(sampleNo));
if (samplePhysical!=blockedVol)
{
// Setup volume with mother ptr
samplePhysical->Setup(targetPhysical);
history.NewLevel(samplePhysical, kNormal, samplePhysical->GetCopyNo());
sampleSolid=samplePhysical->GetLogicalVolume()->GetSolid();
samplePoint=history.GetTopTransform().TransformPoint(globalPoint);
if( G4AuxiliaryNavServices::
CheckPointOnSurface(sampleSolid, samplePoint, globalDirection,
history.GetTopTransform(), pLocatedOnEdge)
)
{
// Enter this daughter
// blockedVol=0;
localPoint=samplePoint;
return true;
}
else
{
history.BackLevel();
}
}
}
return false;
}