Import Geant4 0.0.0 source tree
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
# $Id: GNUmakefile,v 2.1 1998/12/15 19:54:58 japost Exp $
|
||||
# --------------------------------------------------------------------
|
||||
# GNUmakefile for geometry/volumes library. Gabriele Cosmo, 16/11/96.
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
name := G4volumes
|
||||
|
||||
ifndef G4INSTALL
|
||||
G4INSTALL = ../../..
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/architecture.gmk
|
||||
|
||||
CPPFLAGS += -I$(G4BASE)/graphics_reps/include \
|
||||
-I$(G4BASE)/global/management/include \
|
||||
-I$(G4BASE)/global/HEPRandom/include \
|
||||
-I$(G4BASE)/global/HEPGeometry/include \
|
||||
-I$(G4BASE)/geometry/magneticfield/include \
|
||||
-I$(G4BASE)/geometry/management/include
|
||||
|
||||
CXXFLAGS_WITHOUT_O := $(filter-out -O% , $(CXXFLAGS))
|
||||
CXXFLAGS_WITHOUT_O := $(filter-out +O% , $(CXXFLAGS_WITHOUT_O))
|
||||
|
||||
ifeq ($(G4SYSTEM),SUN-CC)
|
||||
$(G4TMP)/$(G4SYSTEM)/$(name)/G4VoxelNavigation.o: src/G4VoxelNavigation.cc
|
||||
$(CXX) $(CXXFLAGS_WITHOUT_O) $(CPPFLAGS) -c $(OUT_OBJ)$@ src/G4VoxelNavigation.cc
|
||||
endif
|
||||
|
||||
include $(G4INSTALL)/config/common.gmk
|
||||
@@ -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 ¬KnownInside) 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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
#include "G4AuxiliaryNavServices.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
// This method currently exists only to allow compilers to find
|
||||
// the inline method (which are the core of this class)
|
||||
|
||||
G4bool G4AuxiliaryNavServices::testOne()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// 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.cc,v 2.1 1998/07/12 02:58:25 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// class G4BlockingList Implementation
|
||||
//
|
||||
|
||||
#include "G4BlockingList.hh"
|
||||
|
||||
// Clear List and reset tag
|
||||
// Fix: Out of line for HP-CC
|
||||
void G4BlockingList::FullyReset()
|
||||
{
|
||||
fBlockTagNo=1;
|
||||
for (G4int i=fBlockingList.length()-1;i>=0;i--)
|
||||
{
|
||||
fBlockingList(i)=0;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// 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.cc,v 2.0 1998/07/02 17:06:27 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// class G4GRSSolid Implementation
|
||||
|
||||
#include "G4GRSSolid.hh"
|
||||
|
||||
G4GRSSolid::~G4GRSSolid()
|
||||
{
|
||||
delete frot; // safe if null
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// 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.cc,v 2.0 1998/07/02 17:06:28 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// class G4GRSVolume Implementation
|
||||
|
||||
#include "G4GRSVolume.hh"
|
||||
|
||||
G4GRSVolume::~G4GRSVolume()
|
||||
{
|
||||
delete frot; // safe if null
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
// 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.cc,v 2.1 1998/07/13 16:55:04 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// G4LogicalBorderSurface Implementation
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// File: G4LogicalBorderSurface.cc
|
||||
// Description: A Logical Surface class for surfaces defined by the
|
||||
// boundary of two physical volumes.
|
||||
// Version: 1.0
|
||||
// Created: 1997-06-26
|
||||
// Author: John Apostolakis
|
||||
// mail: John.Apostolakis@cern.ch
|
||||
// Modified: 1997-06-26 John Apostolakis
|
||||
//
|
||||
// Id tag:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "G4LogicalBorderSurface.hh"
|
||||
|
||||
|
||||
G4LogicalBorderSurfaceTable G4LogicalBorderSurface::theBorderSurfaceTable;
|
||||
|
||||
/////////////////////////
|
||||
// Class Implementation
|
||||
/////////////////////////
|
||||
|
||||
/////////////////
|
||||
// Constructors
|
||||
/////////////////
|
||||
|
||||
G4LogicalBorderSurface::G4LogicalBorderSurface(const G4String& name,
|
||||
G4VPhysicalVolume* vol1,
|
||||
G4VPhysicalVolume* vol2,
|
||||
G4OpticalSurface* opticsSurface)
|
||||
: G4LogicalSurface(name, opticsSurface),
|
||||
Volume1(vol1),
|
||||
Volume2(vol2)
|
||||
{
|
||||
// Store in the table of Surfaces
|
||||
theBorderSurfaceTable.insert(this);
|
||||
theIndexInTable = theBorderSurfaceTable.index(this);
|
||||
}
|
||||
|
||||
G4LogicalBorderSurface::G4LogicalBorderSurface(const G4LogicalBorderSurface &right)
|
||||
: G4LogicalSurface(right.GetName(), right.GetOpticalSurface())
|
||||
{
|
||||
*this = right;
|
||||
}
|
||||
|
||||
G4LogicalBorderSurface::~G4LogicalBorderSurface(){}
|
||||
|
||||
//////////////
|
||||
// Operators
|
||||
//////////////
|
||||
|
||||
const G4LogicalBorderSurface& G4LogicalBorderSurface::operator=(const G4LogicalBorderSurface &right)
|
||||
{
|
||||
return right;
|
||||
}
|
||||
|
||||
G4int G4LogicalBorderSurface::operator==(const G4LogicalBorderSurface &right) const
|
||||
{
|
||||
return (this == (G4LogicalBorderSurface *) &right);
|
||||
}
|
||||
|
||||
G4int G4LogicalBorderSurface::operator!=(const G4LogicalBorderSurface &right) const
|
||||
{
|
||||
return (this != (G4LogicalBorderSurface *) &right);
|
||||
}
|
||||
////////////
|
||||
// Methods
|
||||
////////////
|
||||
|
||||
G4LogicalBorderSurface* G4LogicalBorderSurface::GetSurface(const G4VPhysicalVolume* vol1,
|
||||
const G4VPhysicalVolume* vol2)
|
||||
{
|
||||
for (int i=0; i<theBorderSurfaceTable.length(); i++) {
|
||||
if(theBorderSurfaceTable[i]->GetVolume1() == vol1 &&
|
||||
theBorderSurfaceTable[i]->GetVolume2() == vol2 )
|
||||
return theBorderSurfaceTable[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4LogicalBorderSurface::DumpInfo() // Class method (it is really const)
|
||||
{
|
||||
|
||||
// Dump info for known surfaces
|
||||
|
||||
G4cout << "***** Surface Table : Nb of Surfaces = " <<
|
||||
GetNumberOfBorderSurfaces() << " *****" << endl;
|
||||
|
||||
for (int i=0; i<theBorderSurfaceTable.length(); i++) {
|
||||
G4cout << theBorderSurfaceTable[i]->GetName() << " : " << endl <<
|
||||
" Surface type = " << theBorderSurfaceTable[i]->GetName() << endl;
|
||||
#ifdef PRINT_INFO
|
||||
" Surface type = " << theBorderSurfaceTable[i]->GetOpticalSurface()->GetType() << endl;
|
||||
" Surface finish = " << theBorderSurfaceTable[i]->GetFinish() << endl <<
|
||||
" Surface model = " << theBorderSurfaceTable[i]->GetModel() << endl;
|
||||
#endif
|
||||
}
|
||||
G4cout << endl;
|
||||
}
|
||||
@@ -0,0 +1,129 @@
|
||||
// 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.cc,v 2.1 1998/07/13 16:55:06 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// G4LogicalSkinSurface Implementation
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// File: G4LogicalSkinSurface.cc
|
||||
// Description: A Logical Surface class for the surface
|
||||
// surrounding a single logical volume.
|
||||
// Version: 1.0
|
||||
// Created: 1997-06-26
|
||||
// Author: John Apostolakis
|
||||
// mail: John.Apostolakis@cern.ch
|
||||
// Modified: 1997-06-26 John Apostolakis
|
||||
//
|
||||
// CVS Id tag:
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "G4LogicalSkinSurface.hh"
|
||||
#include "G4ios.hh"
|
||||
// #include "G4OpticalSurface.hh"
|
||||
|
||||
G4LogicalSkinSurfaceTable G4LogicalSkinSurface::theSurfaceTable;
|
||||
|
||||
/////////////////////////
|
||||
// Class Implementation
|
||||
/////////////////////////
|
||||
|
||||
/////////////////
|
||||
// Constructors
|
||||
/////////////////
|
||||
|
||||
G4LogicalSkinSurface::G4LogicalSkinSurface(const G4String& name,
|
||||
G4LogicalVolume* logicalVolume,
|
||||
G4OpticalSurface* opticalSurface)
|
||||
: G4LogicalSurface(name, opticalSurface),
|
||||
LogVolume(logicalVolume)
|
||||
{
|
||||
// Store in the table of Surfaces
|
||||
theSurfaceTable.insert(this);
|
||||
theIndexInTable = theSurfaceTable.index(this);
|
||||
}
|
||||
|
||||
G4LogicalSkinSurface::G4LogicalSkinSurface(const G4LogicalSkinSurface &right)
|
||||
: G4LogicalSurface(right.GetName(), right.GetOpticalSurface())
|
||||
{
|
||||
*this = right;
|
||||
}
|
||||
|
||||
G4LogicalSkinSurface::~G4LogicalSkinSurface(){}
|
||||
|
||||
//////////////
|
||||
// Operators
|
||||
//////////////
|
||||
|
||||
const G4LogicalSkinSurface& G4LogicalSkinSurface::operator=(const G4LogicalSkinSurface &right)
|
||||
{
|
||||
return right;
|
||||
}
|
||||
|
||||
G4int G4LogicalSkinSurface::operator==(const G4LogicalSkinSurface &right) const
|
||||
{
|
||||
return (this == (G4LogicalSkinSurface *) &right);
|
||||
}
|
||||
|
||||
G4int G4LogicalSkinSurface::operator!=(const G4LogicalSkinSurface &right) const
|
||||
{
|
||||
return (this != (G4LogicalSkinSurface *) &right);
|
||||
}
|
||||
////////////
|
||||
// Methods
|
||||
////////////
|
||||
|
||||
G4LogicalSkinSurface* G4LogicalSkinSurface::GetSurface(const G4LogicalVolume* vol)
|
||||
{
|
||||
for (int i=0; i<theSurfaceTable.length(); i++) {
|
||||
if(theSurfaceTable[i]->GetLogicalVolume() == vol)
|
||||
return theSurfaceTable[i];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void G4LogicalSkinSurface::DumpInfo()
|
||||
{
|
||||
|
||||
// Dump info for known surfaces
|
||||
|
||||
G4cout << "***** Surface Table : Nb of Surfaces = " <<
|
||||
// G4LogicalSkinSurface::
|
||||
GetNumberOfSkinSurfaces() << " *****" << endl;
|
||||
|
||||
for (int i=0; i<theSurfaceTable.length(); i++) {
|
||||
G4LogicalSkinSurface *pSkinSurface= theSurfaceTable[i];
|
||||
G4cout << theSurfaceTable[i]->GetName() << " : " << endl <<
|
||||
" Skin of logical volume " << pSkinSurface->GetLogicalVolume()->GetName ()
|
||||
<< endl <<
|
||||
" Optical Surface Ptr = " << (long) (pSkinSurface->GetOpticalSurface() )
|
||||
<< endl;
|
||||
|
||||
#ifdef PRINT_INFO
|
||||
// DOES NOT COMPILE without including "G4OpticalSurface.hh"
|
||||
|
||||
// G4cout << pSkinSurface->GetOpticalSurface() << endl ;
|
||||
G4pticalSurface opticalSurface= pSkinSurface->GetOpticalSurface();
|
||||
G4cout <<
|
||||
" Surface type = " << opticalSurface->GetType() << endl <<
|
||||
" Surface finish = " << opticalSurface->GetFinish() << endl <<
|
||||
" Surface model = " << opticalSurface->GetModel() << endl;
|
||||
|
||||
/*
|
||||
operator << ( G4OpticalSurface opticalSurface ) should exist
|
||||
and do something like:
|
||||
" Surface type = " << opticalSurface->GetType() << endl <<
|
||||
" Surface finish = " << opticalSurface->GetFinish() << endl <<
|
||||
" Surface model = " << opticalSurface->GetModel() << endl;
|
||||
*/
|
||||
#endif
|
||||
|
||||
}
|
||||
G4cout << endl;
|
||||
}
|
||||
@@ -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: G4NavigationHistory.cc,v 2.1 1998/07/13 16:55:07 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// G4NavigationHistory Implementation P.Kent August 96
|
||||
|
||||
#include "G4NavigationHistory.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
ostream& operator << (ostream& os, const G4NavigationHistory& nav)
|
||||
{
|
||||
G4cout << "History depth="<<nav.GetDepth()<< endl;
|
||||
for (G4int i=0;i<=nav.GetDepth();i++)
|
||||
{
|
||||
os << "Level=["<<i<<"]: " ;
|
||||
if( nav.GetVolume(i) != 0 ) {
|
||||
os << "Phys Name=["<< nav.GetVolume(i)->GetName()
|
||||
<< "] Type=[";
|
||||
switch(nav.GetVolumeType(i))
|
||||
{
|
||||
case kNormal:
|
||||
os <<"N";
|
||||
break;
|
||||
case kReplica:
|
||||
os <<"R" << nav.GetReplicaNo(i);
|
||||
break;
|
||||
case kParameterised:
|
||||
os <<"P" << nav.GetReplicaNo(i);
|
||||
break;
|
||||
}
|
||||
os << "]";
|
||||
}else{
|
||||
os << "Phys = <Null>";
|
||||
}
|
||||
os << endl;
|
||||
}
|
||||
return os;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
// 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.cc,v 2.0 1998/07/02 17:06:33 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
#include "G4NavigationLevel.hh"
|
||||
|
||||
G4Allocator<G4NavigationLevel> aNavigationLevelAllocator;
|
||||
G4Allocator<G4NavigationLevelRep> aNavigLevelRepAllocator;
|
||||
@@ -0,0 +1,942 @@
|
||||
// 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.cc,v 2.6 1998/11/25 17:57:23 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// class G4Navigator Implementation Paul Kent July 95/96
|
||||
|
||||
#include "G4Navigator.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <iomanip.h>
|
||||
|
||||
G4Navigator::G4Navigator() :
|
||||
fWasLimitedByGeometry(false),
|
||||
fTopPhysical(0),
|
||||
fVerbose(0)
|
||||
{
|
||||
ResetStackAndState();
|
||||
}
|
||||
|
||||
G4Navigator::~G4Navigator()
|
||||
{;}
|
||||
|
||||
// Set the world (`topmost') volume
|
||||
void G4Navigator::SetWorldVolume(G4VPhysicalVolume* pWorld)
|
||||
{
|
||||
// Setup the volume
|
||||
pWorld->Setup(0); // No mother since world volume
|
||||
if (!(pWorld->GetTranslation()==G4ThreeVector(0,0,0)))
|
||||
{
|
||||
G4Exception ("G4Navigator::SetWorldVolume - Must be centred on origin");
|
||||
}
|
||||
const G4RotationMatrix* rm=pWorld->GetRotation();
|
||||
if (rm&&(!rm->isIdentity()))
|
||||
{
|
||||
G4Exception ("G4Navigator::SetWorldVolume - Must not be rotated");
|
||||
}
|
||||
fTopPhysical=pWorld;
|
||||
fHistory.SetFirstEntry(pWorld);
|
||||
}
|
||||
|
||||
|
||||
// define DEBUG_HIST 1
|
||||
|
||||
// Locate the point in the hierarchy return 0 if outside
|
||||
//
|
||||
// ( The direction is required only if we are on an edge shared by
|
||||
// two or more surfaces. )
|
||||
//
|
||||
G4VPhysicalVolume*
|
||||
G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector& globalPoint,
|
||||
const G4ThreeVector* pGlobalDirection,
|
||||
const G4bool relativeSearch)
|
||||
{
|
||||
G4bool notKnownContained=true,noResult;
|
||||
G4VPhysicalVolume *targetPhysical;
|
||||
G4LogicalVolume *targetLogical;
|
||||
G4VSolid *targetSolid;
|
||||
G4ThreeVector localPoint;
|
||||
EInside insideCode;
|
||||
|
||||
#ifdef DEBUG_HIST
|
||||
G4cerr << "Upon entering LocateGlobalPointAndSetup " << endl;
|
||||
G4cerr << " History = " << endl << fHistory << endl << endl;
|
||||
#endif
|
||||
#ifdef G4VERBOSE
|
||||
if( fVerbose > 0 )
|
||||
{
|
||||
cout << "G4Navigator::LocateGlobalPointAndSetup: " << endl;
|
||||
cout.precision(8);
|
||||
cout << " I was called with the following arguments: " << endl
|
||||
<< " Globalpoint = " << globalPoint << endl
|
||||
<< " relativeSearch = " << relativeSearch << endl;
|
||||
// << " = " << << endl
|
||||
cout << " Upon entering my state is: " << endl;
|
||||
PrintState();
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!relativeSearch)
|
||||
{
|
||||
ResetStackAndState();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fWasLimitedByGeometry)
|
||||
{
|
||||
fWasLimitedByGeometry=false;
|
||||
fEnteredDaughter=fEntering; // Remember
|
||||
fExitedMother= fExiting; // Remember
|
||||
if (fExiting)
|
||||
{
|
||||
if (fHistory.GetDepth())
|
||||
{
|
||||
fBlockedPhysicalVolume=fHistory.GetTopVolume();
|
||||
fBlockedReplicaNo=fHistory.GetTopReplicaNo();
|
||||
fHistory.BackLevel();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Have exited world volume
|
||||
return 0;
|
||||
}
|
||||
|
||||
// A fix for the case where a volume is "entered" at an edge
|
||||
// and a coincident surface exists outside it.
|
||||
// This stops it from exiting further volumes and cycling
|
||||
if( fLastStepWasZero )
|
||||
{
|
||||
fExiting= false;
|
||||
}
|
||||
}
|
||||
else if (fEntering)
|
||||
{
|
||||
G4VPhysicalVolume *curPhysical=fHistory.GetTopVolume();
|
||||
switch (VolumeType(fBlockedPhysicalVolume))
|
||||
{
|
||||
case kNormal:
|
||||
fBlockedPhysicalVolume->Setup(curPhysical);
|
||||
fHistory.NewLevel(fBlockedPhysicalVolume);
|
||||
break;
|
||||
case kReplica:
|
||||
freplicaNav.ComputeTransformation(fBlockedReplicaNo,
|
||||
fBlockedPhysicalVolume);
|
||||
fBlockedPhysicalVolume->Setup(curPhysical);
|
||||
fHistory.NewLevel(fBlockedPhysicalVolume,
|
||||
kReplica,
|
||||
fBlockedReplicaNo);
|
||||
fBlockedPhysicalVolume->SetCopyNo(fBlockedReplicaNo);
|
||||
|
||||
break;
|
||||
case kParameterised:
|
||||
G4VSolid *pSolid;
|
||||
// G4VSolid *pSolid=fBlockedPhysicalVolume->
|
||||
// GetLogicalVolume()-> GetSolid();
|
||||
G4VPVParameterisation *pParam=fBlockedPhysicalVolume->
|
||||
GetParameterisation();
|
||||
pSolid= pParam->ComputeSolid(fBlockedReplicaNo,
|
||||
fBlockedPhysicalVolume);
|
||||
pSolid->ComputeDimensions(pParam,
|
||||
fBlockedReplicaNo,
|
||||
fBlockedPhysicalVolume);
|
||||
pParam->ComputeTransformation(fBlockedReplicaNo,
|
||||
fBlockedPhysicalVolume);
|
||||
fBlockedPhysicalVolume->Setup(curPhysical);
|
||||
fHistory.NewLevel(fBlockedPhysicalVolume,
|
||||
kParameterised,
|
||||
fBlockedReplicaNo);
|
||||
fBlockedPhysicalVolume->SetCopyNo(fBlockedReplicaNo);
|
||||
// Set the correct solid and material in Logical Volume
|
||||
G4LogicalVolume *pLogical;
|
||||
pLogical= fBlockedPhysicalVolume->GetLogicalVolume();
|
||||
pLogical->SetSolid( pSolid );
|
||||
pLogical->SetMaterial(
|
||||
pParam->ComputeMaterial(fBlockedReplicaNo,
|
||||
fBlockedPhysicalVolume));
|
||||
break;
|
||||
}
|
||||
fEntering=false;
|
||||
fBlockedPhysicalVolume=0;
|
||||
localPoint=fHistory.GetTopTransform().TransformPoint(globalPoint);
|
||||
notKnownContained=false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fBlockedPhysicalVolume=0;
|
||||
fEntering=false;
|
||||
fEnteredDaughter=false; // Full Step was not taken, did not enter
|
||||
fExiting=false;
|
||||
fExitedMother=false; // Full Step was not taken, did not exit
|
||||
}
|
||||
}
|
||||
//
|
||||
// Search from top of history up through geometry until
|
||||
// containing volume found:
|
||||
//
|
||||
// If on
|
||||
// o OUTSIDE - Back up level, not/no longer exiting volumes
|
||||
// o SURFACE and EXITING - Back up level, setting new blocking no.s
|
||||
// else
|
||||
// o containing volume found
|
||||
//
|
||||
while (notKnownContained)
|
||||
{
|
||||
if (fHistory.GetTopVolumeType()!=kReplica)
|
||||
{
|
||||
targetSolid=fHistory.GetTopVolume()->GetLogicalVolume()->GetSolid();
|
||||
localPoint=fHistory.GetTopTransform().TransformPoint(globalPoint);
|
||||
insideCode=targetSolid->Inside(localPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
insideCode=freplicaNav.BackLocate(fHistory,globalPoint,localPoint,fExiting,notKnownContained);
|
||||
// !CARE! if notKnownContained returns false then the point is within
|
||||
// the containing placement volume of the replica(s). If insidecode
|
||||
// will result in the history being backed up one level, then the
|
||||
// local point returned is the point in the system of this new level
|
||||
}
|
||||
|
||||
if (insideCode==kOutside)
|
||||
{
|
||||
if (fHistory.GetDepth())
|
||||
{
|
||||
fBlockedPhysicalVolume=fHistory.GetTopVolume();
|
||||
fBlockedReplicaNo=fHistory.GetTopReplicaNo();
|
||||
fHistory.BackLevel();
|
||||
fExiting=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Have exited world volume
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (insideCode==kSurface&&fExiting)
|
||||
{
|
||||
if (fHistory.GetDepth())
|
||||
{
|
||||
fBlockedPhysicalVolume=fHistory.GetTopVolume();
|
||||
fBlockedReplicaNo=fHistory.GetTopReplicaNo();
|
||||
fHistory.BackLevel();
|
||||
// Still on surface but exited volume not necessarily convex
|
||||
fValidExitNormal=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Have exited world volume
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
notKnownContained=false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Search downwards until deepest containing volume found,
|
||||
// blocking fBlockedPhysicalVolume/BlockedReplicaNum
|
||||
//
|
||||
// 3 Cases:
|
||||
//
|
||||
// o Parameterised daughters
|
||||
// =>Must be one G4PVParameterised daughter & voxels
|
||||
// o Positioned daughters & voxels
|
||||
// o Positioned daughters & no voxels
|
||||
|
||||
noResult=true; // noResult should be renamed to
|
||||
// something like enteredLevel, as that is its meaning.
|
||||
do
|
||||
{
|
||||
|
||||
// Determine `type' of current mother volume
|
||||
targetPhysical=fHistory.GetTopVolume();
|
||||
targetLogical=targetPhysical->GetLogicalVolume();
|
||||
switch(CharacteriseDaughters(targetLogical))
|
||||
{
|
||||
case kNormal:
|
||||
if (targetLogical->GetVoxelHeader())
|
||||
{
|
||||
noResult=fvoxelNav.LevelLocate(fHistory,
|
||||
fBlockedPhysicalVolume,
|
||||
fBlockedReplicaNo,
|
||||
globalPoint,
|
||||
pGlobalDirection,
|
||||
fLocatedOnEdge,
|
||||
localPoint);
|
||||
}
|
||||
else
|
||||
{
|
||||
noResult=fnormalNav.LevelLocate(fHistory,
|
||||
fBlockedPhysicalVolume,
|
||||
fBlockedReplicaNo,
|
||||
globalPoint,
|
||||
pGlobalDirection,
|
||||
fLocatedOnEdge,
|
||||
localPoint);
|
||||
}
|
||||
break;
|
||||
case kReplica:
|
||||
noResult=freplicaNav.LevelLocate(fHistory,
|
||||
fBlockedPhysicalVolume,
|
||||
fBlockedReplicaNo,
|
||||
globalPoint,
|
||||
pGlobalDirection,
|
||||
fLocatedOnEdge,
|
||||
localPoint);
|
||||
break;
|
||||
case kParameterised:
|
||||
noResult=fparamNav.LevelLocate(fHistory,
|
||||
fBlockedPhysicalVolume,
|
||||
fBlockedReplicaNo,
|
||||
globalPoint,
|
||||
pGlobalDirection,
|
||||
fLocatedOnEdge,
|
||||
localPoint);
|
||||
break;
|
||||
}
|
||||
|
||||
// LevelLocate returns true if it finds a daughter volume
|
||||
// in which globalPoint is inside (or on the surface).
|
||||
|
||||
if (noResult)
|
||||
{
|
||||
// The blocked volume is no longer valid - it was for another level
|
||||
fBlockedPhysicalVolume= 0;
|
||||
fBlockedReplicaNo= -1;
|
||||
}
|
||||
} while (noResult);
|
||||
|
||||
fLastLocatedPointLocal=localPoint;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if( fVerbose > 0 ) PrintState();
|
||||
|
||||
if( fVerbose > 1 )
|
||||
{
|
||||
cout.precision(6);
|
||||
|
||||
cout << " Return value = new volume = "
|
||||
<< (targetPhysical==0 ? G4String("None") :
|
||||
targetPhysical->GetName() ) << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_HIST
|
||||
G4cerr << "Upon exiting LocateGlobalPointAndSetup " << endl;
|
||||
G4cerr << " History = " << endl << fHistory << endl << endl;
|
||||
#endif
|
||||
return targetPhysical;
|
||||
}
|
||||
|
||||
// Compute the next geometric Step: Intersections with current
|
||||
// mother and `daughter' volumes.
|
||||
//
|
||||
// NOTE:
|
||||
//
|
||||
// Flags on entry:
|
||||
//
|
||||
// fValidExitNormal - Normal of exited volume is valid (convex, not a
|
||||
// coincident boundary)
|
||||
// fExitNormal - Surface normal of exited volume
|
||||
// fExiting - True if have exited solid
|
||||
//
|
||||
// fBlockedPhysicalVolume - Ptr to exited volume (or 0)
|
||||
// fBlockedReplicaNo - Replication no of exited volume
|
||||
// fLastStepWasZero - True if last Step size was zero.
|
||||
//
|
||||
// Flags on exit:
|
||||
// fValidExitNormal - True if surface normal of exited volume is valid
|
||||
// fExitNormal - Surface normal of exited volume rotated to mothers
|
||||
// reference system
|
||||
// fExiting - True if exiting mother
|
||||
// fEntering - True if entering `daughter' volume (or replica)
|
||||
// fBlockedPhysicalVolume - Ptr to candidate (entered) volume
|
||||
// fBlockedReplicaNo - Replication no of candidate (entered) volume
|
||||
// fLastStepWasZero - True if this Step size was zero.
|
||||
|
||||
G4double G4Navigator::ComputeStep(const G4ThreeVector &pGlobalpoint,
|
||||
const G4ThreeVector &pDirection,
|
||||
const G4double pCurrentProposedStepLength,
|
||||
G4double &pNewSafety)
|
||||
{
|
||||
G4double Step;
|
||||
G4ThreeVector localDirection=ComputeLocalAxis(pDirection);
|
||||
G4VPhysicalVolume *motherPhysical=fHistory.GetTopVolume();
|
||||
G4LogicalVolume *motherLogical=motherPhysical->GetLogicalVolume();
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
cout.precision(8);
|
||||
if( fVerbose > 1 )
|
||||
{
|
||||
cout << "*** G4Navigator::ComputeStep: ***" << endl;
|
||||
cout.precision(8);
|
||||
cout << " I was called with the following arguments: " << endl
|
||||
<< " Globalpoint = " << setw(25) << pGlobalpoint << endl
|
||||
<< " Direction = " << setw(25) << pDirection << endl
|
||||
<< " ProposedStepLength= " << pCurrentProposedStepLength << endl;
|
||||
// << " = " << << endl
|
||||
}
|
||||
|
||||
if( fVerbose > 2 )
|
||||
{
|
||||
// cout.precision(3);
|
||||
cout << " Upon entering my state is: " << endl;
|
||||
PrintState();
|
||||
}
|
||||
#endif
|
||||
|
||||
G4ThreeVector newLocalPoint =ComputeLocalPoint(pGlobalpoint);
|
||||
if( newLocalPoint != fLastLocatedPointLocal )
|
||||
{
|
||||
// Check whether the relocation is within safety
|
||||
//
|
||||
G4ThreeVector oldLocalPoint= fLastLocatedPointLocal;
|
||||
G4double moveLenSq= (newLocalPoint-oldLocalPoint).mag2();
|
||||
|
||||
if (moveLenSq >= kCarTolerance*kCarTolerance){
|
||||
//
|
||||
// The following checks only make sense if the move is larger
|
||||
// than the tolerance.
|
||||
//
|
||||
G4ThreeVector OriginalGlobalpoint;
|
||||
OriginalGlobalpoint = fHistory.GetTopTransform().Inverse()
|
||||
.TransformPoint(fLastLocatedPointLocal);
|
||||
|
||||
G4double shiftOriginSafSq= (fPreviousSftOrigin-pGlobalpoint).mag2();
|
||||
|
||||
#if 0
|
||||
// Reset point before computing safety
|
||||
LocateGlobalPointWithinVolume(OriginalGlobalpoint);
|
||||
G4double safety= ComputeSafety(OriginalGlobalpoint);
|
||||
if( moveLenSq >= sqr(safety) ){
|
||||
G4double moveLen=sqrt(moveLenSq);
|
||||
if( moveLen > safety + kCarTolerance ){
|
||||
G4cerr << " ERROR in G4Navigator::ComputeStep: " << endl
|
||||
<< "The Step's starting point has moved " << moveLen
|
||||
<< " since the last call to one of the Locate methods " << endl
|
||||
<< " which is more than the current safety=" << safety << endl;
|
||||
}else{
|
||||
G4cerr << " Warning in G4Navigator::ComputeStep: " << endl
|
||||
<< "The Step's starting point has moved " << moveLen
|
||||
<< " which is equal to the current safety. " << endl;
|
||||
}
|
||||
}
|
||||
G4double safetyPlus = safety + kCarTolerance;
|
||||
assert( moveLenSq <= sqr(safetyPlus) );
|
||||
#endif
|
||||
if( shiftOriginSafSq >= sqr(fPreviousSafety) ){
|
||||
G4double shiftOrigin=sqrt(shiftOriginSafSq);
|
||||
if( shiftOrigin > fPreviousSafety + kCarTolerance ){
|
||||
G4cerr << " ERROR in G4Navigator::ComputeStep: " << endl
|
||||
<< "The Step's starting point has moved " << sqrt(moveLenSq)
|
||||
<< " since the last call to one of the Locate methods " << endl
|
||||
<< " This has resulted in moving " << shiftOrigin
|
||||
<< " from the last point at which the safety was calculated "
|
||||
<< endl
|
||||
<< " which is more than the computed safety= "
|
||||
<< fPreviousSafety << "at that point." << endl;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
else
|
||||
{
|
||||
G4cerr << " Warning in G4Navigator::ComputeStep: " << endl
|
||||
<< "The Step's starting point has moved " << sqrt(moveLenSq)
|
||||
<< " which has taken it to the limit of the current safety. "
|
||||
<< endl;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
G4double safetyPlus = fPreviousSafety+ kCarTolerance;
|
||||
assert( shiftOriginSafSq <= sqr(safetyPlus) );
|
||||
|
||||
// Relocate the point within the same volume
|
||||
//
|
||||
LocateGlobalPointWithinVolume( pGlobalpoint );
|
||||
}
|
||||
}
|
||||
|
||||
if (fHistory.GetTopVolumeType()!=kReplica)
|
||||
{
|
||||
switch(CharacteriseDaughters(motherLogical))
|
||||
{
|
||||
case kNormal:
|
||||
if (motherLogical->GetVoxelHeader())
|
||||
{
|
||||
Step=fvoxelNav.ComputeStep(fLastLocatedPointLocal,
|
||||
localDirection,
|
||||
pCurrentProposedStepLength,
|
||||
pNewSafety,
|
||||
fHistory,
|
||||
fValidExitNormal,
|
||||
fExitNormal,
|
||||
fExiting,
|
||||
fEntering,
|
||||
&fBlockedPhysicalVolume,
|
||||
fBlockedReplicaNo);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Step=fnormalNav.ComputeStep(fLastLocatedPointLocal,
|
||||
localDirection,
|
||||
pCurrentProposedStepLength,
|
||||
pNewSafety,
|
||||
fHistory,
|
||||
fValidExitNormal,
|
||||
fExitNormal,
|
||||
fExiting,
|
||||
fEntering,
|
||||
&fBlockedPhysicalVolume,
|
||||
fBlockedReplicaNo);
|
||||
}
|
||||
break;
|
||||
case kParameterised:
|
||||
Step=fparamNav.ComputeStep(fLastLocatedPointLocal,
|
||||
localDirection,
|
||||
pCurrentProposedStepLength,
|
||||
pNewSafety,
|
||||
fHistory,
|
||||
fValidExitNormal,
|
||||
fExitNormal,
|
||||
fExiting,
|
||||
fEntering,
|
||||
&fBlockedPhysicalVolume,
|
||||
fBlockedReplicaNo);
|
||||
break;
|
||||
case kReplica:
|
||||
G4Exception("Logic Error in G4Navigator::ComputeStep()");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Step=freplicaNav.ComputeStep(pGlobalpoint,
|
||||
pDirection,
|
||||
fLastLocatedPointLocal,
|
||||
localDirection,
|
||||
pCurrentProposedStepLength,
|
||||
pNewSafety,
|
||||
fHistory,
|
||||
fValidExitNormal,
|
||||
fExitNormal,
|
||||
fExiting,
|
||||
fEntering,
|
||||
&fBlockedPhysicalVolume,
|
||||
fBlockedReplicaNo);
|
||||
}
|
||||
|
||||
if( (Step == pCurrentProposedStepLength) && (!fExiting) && (!fEntering) )
|
||||
{
|
||||
// This is Step is not really limited by the geometry.
|
||||
// The Navigator is obliged to return "infinity"
|
||||
Step = kInfinity;
|
||||
}
|
||||
|
||||
// Remember last safety origin & value.
|
||||
fPreviousSftOrigin= pGlobalpoint;
|
||||
fPreviousSafety= pNewSafety;
|
||||
|
||||
fLocatedOnEdge= fLastStepWasZero && (Step==0); // Edge if two consecutive
|
||||
// steps are zero, because
|
||||
// at least two candidate volumes must have been checked
|
||||
|
||||
fLastStepWasZero= (Step==0);
|
||||
fEnteredDaughter=fEntering; // I expect to enter a volume in this Step
|
||||
fExitedMother=fExiting;
|
||||
|
||||
if(fExiting && !fValidExitNormal)
|
||||
{
|
||||
// We must calculate the normal anyway (in order to have it if requested)
|
||||
G4ThreeVector FinalPoint= fLastLocatedPointLocal + localDirection*Step;
|
||||
fExitNormal= motherLogical->GetSolid()->SurfaceNormal(FinalPoint);
|
||||
}
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if( fVerbose > 1 )
|
||||
{
|
||||
cout << " Upon exiting my state is: " << endl;
|
||||
PrintState();
|
||||
}
|
||||
#endif
|
||||
|
||||
return Step;
|
||||
}
|
||||
|
||||
G4VPhysicalVolume* G4Navigator::LocateGlobalPointAndSetup(const G4ThreeVector &p,
|
||||
const G4TouchableHistory &h)
|
||||
{
|
||||
fHistory=*h.GetHistory();
|
||||
SetupHierarchy();
|
||||
return LocateGlobalPointAndSetup(p, 0);
|
||||
}
|
||||
|
||||
G4ThreeVector G4Navigator::NetTranslation() const
|
||||
{
|
||||
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
|
||||
return tf.NetTranslation();
|
||||
}
|
||||
|
||||
G4RotationMatrix G4Navigator::NetRotation() const
|
||||
{
|
||||
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
|
||||
return tf.NetRotation();
|
||||
}
|
||||
|
||||
G4GRSVolume* G4Navigator::CreateGRSVolume() const
|
||||
{
|
||||
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
|
||||
return new G4GRSVolume(fHistory.GetTopVolume(),
|
||||
tf.NetRotation(),
|
||||
tf.NetTranslation());
|
||||
}
|
||||
|
||||
G4GRSSolid* G4Navigator::CreateGRSSolid() const
|
||||
{
|
||||
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
|
||||
return new G4GRSSolid(fHistory.GetTopVolume()->GetLogicalVolume()->GetSolid(),
|
||||
tf.NetRotation(),
|
||||
tf.NetTranslation());
|
||||
|
||||
}
|
||||
|
||||
G4TouchableHistory* G4Navigator::CreateTouchableHistory() const
|
||||
{
|
||||
return new G4TouchableHistory(fHistory);
|
||||
}
|
||||
|
||||
// Renavigate & reset hierarchy described by current history
|
||||
// o Reset volumes
|
||||
// o Recompute transforms and/or solids of replicated/parameterised vols
|
||||
void G4Navigator::SetupHierarchy()
|
||||
{
|
||||
G4int i;
|
||||
const G4int cdepth=fHistory.GetDepth();
|
||||
G4VPhysicalVolume *mother,*current;
|
||||
G4VSolid *pSolid;
|
||||
G4VPVParameterisation *pParam;
|
||||
|
||||
mother=fHistory.GetVolume(0);
|
||||
for (i=1;i<=cdepth;i++)
|
||||
{
|
||||
current=fHistory.GetVolume(i);
|
||||
switch (fHistory.GetVolumeType(i))
|
||||
{
|
||||
case kNormal:
|
||||
break;
|
||||
case kReplica:
|
||||
freplicaNav.ComputeTransformation(fHistory.GetReplicaNo(i),
|
||||
current);
|
||||
break;
|
||||
case kParameterised:
|
||||
G4int replicaNo;
|
||||
// pSolid=current->GetLogicalVolume()->GetSolid();
|
||||
pParam=current->GetParameterisation();
|
||||
replicaNo= fHistory.GetReplicaNo(i);
|
||||
pSolid= pParam->ComputeSolid(replicaNo, current);
|
||||
// Set up dimensions & transform in solid/physical volume
|
||||
pSolid->ComputeDimensions(pParam, replicaNo, current);
|
||||
pParam->ComputeTransformation(replicaNo, current);
|
||||
|
||||
// Set up the correct solid and material in Logical Volume
|
||||
G4LogicalVolume *pLogical;
|
||||
pLogical= current->GetLogicalVolume();
|
||||
pLogical->SetSolid( pSolid );
|
||||
pLogical->SetMaterial( pParam->ComputeMaterial(replicaNo,
|
||||
current));
|
||||
break;
|
||||
}
|
||||
current->Setup(mother);
|
||||
mother=current;
|
||||
}
|
||||
}
|
||||
|
||||
ostream& operator << (ostream &os,const G4Navigator &n)
|
||||
{
|
||||
|
||||
os << "Current History: " << endl << n.fHistory;
|
||||
return os;
|
||||
}
|
||||
|
||||
// Return global to local transformation
|
||||
const G4AffineTransform G4Navigator::GetLocalToGlobalTransform() const
|
||||
{
|
||||
G4AffineTransform tempTransform;
|
||||
tempTransform= fHistory.GetTopTransform().Inverse();
|
||||
return tempTransform;
|
||||
}
|
||||
|
||||
// Obtain the Normal vector to a surface (in local coordinates)
|
||||
// pointing out of previous volume and into current volume
|
||||
//
|
||||
G4ThreeVector G4Navigator::GetLocalExitNormal(G4bool* valid)
|
||||
{
|
||||
G4ThreeVector ExitNormal(0.,0.,0.);
|
||||
|
||||
if( fExitedMother ){
|
||||
ExitNormal=fExitNormal;
|
||||
*valid = true;
|
||||
|
||||
}else if (EnteredDaughterVolume()) {
|
||||
ExitNormal= -(fHistory.GetTopVolume()->GetLogicalVolume()
|
||||
->GetSolid()->SurfaceNormal(fLastLocatedPointLocal));
|
||||
*valid = true;
|
||||
}else{
|
||||
// We are not at a boundary.
|
||||
// ExitNormal remains (0,0,0)
|
||||
*valid = false;
|
||||
}
|
||||
|
||||
return ExitNormal;
|
||||
}
|
||||
|
||||
// It assumes that it assumes that it will be
|
||||
// i) called with the Point equal to the EndPoint of the ComputeStep.
|
||||
// ii) after (or at the end of) ComputeStep OR after the relocation.
|
||||
|
||||
G4double G4Navigator::ComputeSafety(const G4ThreeVector &pGlobalpoint,
|
||||
const G4double pMaxLength)
|
||||
// A sort of MaximumLength ... ?
|
||||
{
|
||||
G4double newSafety=0.0;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if( fVerbose > 0 )
|
||||
{
|
||||
cout << "*** G4Navigator::ComputeSafety: ***" << endl;
|
||||
cout.precision(8);
|
||||
cout << " I was called with the following arguments: " << endl
|
||||
<< " Globalpoint = " << pGlobalpoint << endl;
|
||||
// cout << " pMaxLength = " << pMaxLength << endl;
|
||||
|
||||
cout << " Upon entering my state is: " << endl;
|
||||
PrintState();
|
||||
}
|
||||
#endif
|
||||
|
||||
if( ! (fEnteredDaughter || fExitedMother ) )
|
||||
{
|
||||
G4VPhysicalVolume *motherPhysical=fHistory.GetTopVolume();
|
||||
G4LogicalVolume *motherLogical=motherPhysical->GetLogicalVolume();
|
||||
|
||||
G4ThreeVector localPoint= ComputeLocalPoint(pGlobalpoint);
|
||||
if (fHistory.GetTopVolumeType()!=kReplica)
|
||||
{
|
||||
switch(CharacteriseDaughters(motherLogical))
|
||||
{
|
||||
case kNormal:
|
||||
if (motherLogical->GetVoxelHeader())
|
||||
{
|
||||
newSafety=fvoxelNav.ComputeSafety(localPoint,
|
||||
fHistory,
|
||||
pMaxLength);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
newSafety=fnormalNav.ComputeSafety(localPoint,
|
||||
fHistory,
|
||||
pMaxLength);
|
||||
|
||||
}
|
||||
break;
|
||||
case kParameterised:
|
||||
|
||||
newSafety=fparamNav.ComputeSafety(localPoint,
|
||||
fHistory,
|
||||
pMaxLength);
|
||||
break;
|
||||
case kReplica:
|
||||
G4Exception("Logic Error in G4Navigator::ComputeSafety()");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newSafety=freplicaNav.ComputeSafety(pGlobalpoint,
|
||||
localPoint,
|
||||
fHistory,
|
||||
pMaxLength);
|
||||
}
|
||||
}
|
||||
|
||||
// Remember last safety origin & value.
|
||||
fPreviousSftOrigin= pGlobalpoint;
|
||||
fPreviousSafety= newSafety;
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if( fVerbose > 1 )
|
||||
{
|
||||
cout.precision(8);
|
||||
cout << " Upon exiting my state is: " << endl;
|
||||
PrintState();
|
||||
cout << " and I return a value of Safety = " << newSafety << endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
return newSafety;
|
||||
}
|
||||
|
||||
G4bool G4Navigator::EnteredDaughterVolume()
|
||||
{
|
||||
return fEnteredDaughter;
|
||||
}
|
||||
|
||||
// G4bool G4Navigator::ExitedVolume()
|
||||
// {
|
||||
// return fExitedCurrent;
|
||||
// }
|
||||
|
||||
|
||||
void G4Navigator::PrintState()
|
||||
{
|
||||
if( fVerbose >= 4 )
|
||||
{
|
||||
cout.precision(3);
|
||||
cout << " Upon exiting my state is: " << endl;
|
||||
cout << " ValidExitNormal= " << fValidExitNormal << endl
|
||||
<< " ExitNormal = " << fExitNormal << endl
|
||||
<< " Exiting = " << fExiting << endl
|
||||
<< " Entering = " << fEntering << endl
|
||||
<< " BlockedPhysicalVolume= " << (fBlockedPhysicalVolume==0 ? G4String("None") :
|
||||
fBlockedPhysicalVolume->GetName() ) << endl
|
||||
<< " BlockedReplicaNo = " << fBlockedReplicaNo << endl
|
||||
<< " LastStepWasZero = " << fLastStepWasZero << endl
|
||||
<< endl;
|
||||
}
|
||||
if( ( 1 < fVerbose) && (fVerbose < 4) )
|
||||
{
|
||||
cout.precision(3);
|
||||
cout << setw(18) << " ExitNormal " << " "
|
||||
<< setw( 9) << " Valid " << " "
|
||||
<< setw( 9) << " Exiting " << " "
|
||||
<< setw( 9) << " Entering" << " "
|
||||
<< setw(15) << " Blocked:Volume " << " "
|
||||
<< setw( 9) << " ReplicaNo" << " "
|
||||
<< setw( 8) << " LastStepZero " << " "
|
||||
<< endl;
|
||||
cout << setw(24) << fExitNormal << " "
|
||||
<< setw( 3) << fValidExitNormal << " "
|
||||
<< setw( 9) << fExiting << " "
|
||||
<< setw( 9) << fEntering << " "
|
||||
<< setw(15) << (fBlockedPhysicalVolume==0 ? G4String("None") :
|
||||
fBlockedPhysicalVolume->GetName() ) << " "
|
||||
<< setw( 9) << fBlockedReplicaNo << " "
|
||||
<< setw( 8) << fLastStepWasZero << " "
|
||||
<< endl;
|
||||
}
|
||||
if( fVerbose > 2 )
|
||||
{
|
||||
cout.precision(8);
|
||||
cout << " Current Localpoint = " << fLastLocatedPointLocal << endl;
|
||||
cout << " PreviousSftOrigin = " << fPreviousSftOrigin << endl;
|
||||
cout << " PreviousSafety = " << fPreviousSafety << endl;
|
||||
}
|
||||
}
|
||||
|
||||
void G4Navigator::LocateGlobalPointWithinVolume(const G4ThreeVector& pGlobalpoint)
|
||||
{
|
||||
// The new implementation of LocateGlobalPointWithinVolume
|
||||
//
|
||||
// -> the state information of this Navigator and its subNavigators
|
||||
// is updated in order to start the next step at pGlobalpoint
|
||||
// -> no check is performed whether pGlobalpoint is inside the
|
||||
// original volume (this must be the case).
|
||||
//
|
||||
// Note: a direction could be added to the arguments, to aid in
|
||||
// future optional checking (via the Old code below).
|
||||
// [ This would be done only in verbose mode ]
|
||||
|
||||
fLastLocatedPointLocal =ComputeLocalPoint(pGlobalpoint);
|
||||
|
||||
// For the case of Voxel (or Parameterised) volume the respective
|
||||
// Navigator must be messaged to update its voxel information etc.o
|
||||
|
||||
// Update the state of the Sub Navigators
|
||||
// - in particular any voxel information they store/cache
|
||||
//.
|
||||
G4VPhysicalVolume* motherPhysical=fHistory.GetTopVolume();
|
||||
G4LogicalVolume* motherLogical= motherPhysical->GetLogicalVolume();
|
||||
G4SmartVoxelHeader* pVoxelHeader= motherLogical->GetVoxelHeader();
|
||||
|
||||
G4ThreeVector localPoint= ComputeLocalPoint(pGlobalpoint);
|
||||
if (fHistory.GetTopVolumeType()!=kReplica)
|
||||
{
|
||||
switch(CharacteriseDaughters(motherLogical))
|
||||
{
|
||||
case kNormal:
|
||||
if (pVoxelHeader)
|
||||
{
|
||||
fvoxelNav.VoxelLocate( pVoxelHeader, localPoint );
|
||||
}
|
||||
// else { fnormalNav. nothing !? }
|
||||
break;
|
||||
|
||||
case kParameterised:
|
||||
// Resets state & returns voxel node
|
||||
fparamNav.VoxelLocate( pVoxelHeader, localPoint );
|
||||
break;
|
||||
|
||||
case kReplica:
|
||||
G4Exception("Logic Error in G4Navigator::LocateGlobalPointWithinVolume()");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
else
|
||||
{
|
||||
// There is no state stored in G4ReplicaNavigation
|
||||
// freplicaNav.VoxelLocate( pVoxelHeader, localPoint );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef OLD_LOCATE
|
||||
// An alternative implementation using LocateGlobalPointAndSetup.
|
||||
// It can also be used to check the method's assumptions.
|
||||
//
|
||||
G4VPhysicalVolume *pOldVol, *pNewVol;
|
||||
|
||||
pOldVol= fHistory.GetTopVolume();
|
||||
pNewVol= LocateGlobalPointAndSetup(pGlobalpoint, 0);
|
||||
// , G4ThreeVector(1.,0.,0.));
|
||||
|
||||
if( pOldVol != pNewVol ){
|
||||
// This is abnormal behaviour.
|
||||
cerr << " ERROR in G4Navigator::LocateGlobalPointWithinVolume " << endl;
|
||||
cerr << " A volume change has occured - this is not expected & illegal" << endl;
|
||||
cerr << " Old volume name = " << pOldVol->GetName() << endl;
|
||||
cerr << " New volume name = " << pNewVol->GetName() << endl;
|
||||
|
||||
G4VPhysicalVolume *pNewVol2;
|
||||
pNewVol2= LocateGlobalPointAndSetup(pGlobalpoint, 0);
|
||||
//, G4ThreeVector(1.,0.,0.));
|
||||
cerr << " Tried again & found volume= " << pNewVol2->GetName() << endl;
|
||||
|
||||
}
|
||||
|
||||
// Check that the new volume located is same as the old one.
|
||||
assert( pOldVol == pNewVol );
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
G4int G4Navigator::GetVerboseLevel()
|
||||
{
|
||||
return fVerbose;
|
||||
}
|
||||
|
||||
void G4Navigator::SetVerboseLevel(G4int level)
|
||||
{
|
||||
fVerbose=level;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
// 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.cc,v 2.0 1998/07/02 17:06:37 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// class G4NormalNavigation Implementation
|
||||
//
|
||||
|
||||
#include "G4NormalNavigation.hh"
|
||||
|
||||
G4double G4NormalNavigation::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)
|
||||
{
|
||||
|
||||
G4VPhysicalVolume *motherPhysical,*samplePhysical,*blockedExitedVol=0;
|
||||
G4LogicalVolume *motherLogical;
|
||||
G4VSolid *motherSolid;
|
||||
G4ThreeVector sampleDirection;
|
||||
G4double ourStep=currentProposedStepLength,motherSafety,ourSafety;
|
||||
G4int localNoDaughters,sampleNo;
|
||||
|
||||
motherPhysical=history.GetTopVolume();
|
||||
motherLogical=motherPhysical->GetLogicalVolume();
|
||||
|
||||
motherSolid=motherLogical->GetSolid();
|
||||
|
||||
//
|
||||
// Compute mother safety
|
||||
//
|
||||
motherSafety=motherSolid->DistanceToOut(localPoint);
|
||||
ourSafety=motherSafety; // Working isotropic safety
|
||||
|
||||
//
|
||||
// Compute daughter safeties & intersections
|
||||
//
|
||||
|
||||
// Exiting normal optimisation
|
||||
if (exiting&&validExitNormal)
|
||||
{
|
||||
if (localDirection.dot(exitNormal)>=kMinExitingNormalCosine)
|
||||
{
|
||||
// Block exited daughter volume
|
||||
blockedExitedVol=*pBlockedPhysical;
|
||||
ourSafety=0;
|
||||
}
|
||||
}
|
||||
|
||||
exiting=false;
|
||||
entering=false;
|
||||
|
||||
localNoDaughters=motherLogical->GetNoDaughters();
|
||||
for (sampleNo=localNoDaughters-1;sampleNo>=0;sampleNo--)
|
||||
{
|
||||
samplePhysical=motherLogical->GetDaughter(sampleNo);
|
||||
if (samplePhysical!=blockedExitedVol)
|
||||
{
|
||||
samplePhysical->Setup(motherPhysical);
|
||||
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
|
||||
samplePhysical->GetTranslation());
|
||||
sampleTf.Invert();
|
||||
const G4ThreeVector samplePoint=sampleTf.TransformPoint(localPoint);
|
||||
const G4VSolid *sampleSolid=samplePhysical
|
||||
->GetLogicalVolume()
|
||||
->GetSolid();
|
||||
const G4double sampleSafety=sampleSolid
|
||||
->DistanceToIn(samplePoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
if (sampleSafety<=ourStep)
|
||||
{
|
||||
sampleDirection=sampleTf.TransformAxis(localDirection);
|
||||
const G4double sampleStep=sampleSolid
|
||||
->DistanceToIn(samplePoint,
|
||||
sampleDirection);
|
||||
if (sampleStep<=ourStep)
|
||||
{
|
||||
ourStep=sampleStep;
|
||||
entering=true;
|
||||
exiting=false;
|
||||
*pBlockedPhysical=samplePhysical;
|
||||
blockedReplicaNo=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (currentProposedStepLength<ourSafety)
|
||||
{
|
||||
//
|
||||
// Guaranteed physics limited
|
||||
//
|
||||
entering=false;
|
||||
exiting=false;
|
||||
*pBlockedPhysical=0;
|
||||
ourStep=kInfinity;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Compute mother intersection if required
|
||||
//
|
||||
if (motherSafety<=ourStep)
|
||||
{
|
||||
G4double motherStep=motherSolid
|
||||
->DistanceToOut(localPoint,
|
||||
localDirection,
|
||||
true,
|
||||
&validExitNormal,
|
||||
&exitNormal);
|
||||
if (motherStep<=ourStep)
|
||||
{
|
||||
ourStep=motherStep;
|
||||
exiting=true;
|
||||
entering=false;
|
||||
if (validExitNormal)
|
||||
{
|
||||
const G4RotationMatrix *rot=motherPhysical->GetRotation();
|
||||
if (rot)
|
||||
{
|
||||
exitNormal*=rot->inverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
validExitNormal=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
newSafety=ourSafety;
|
||||
return ourStep;
|
||||
}
|
||||
|
||||
G4double G4NormalNavigation::ComputeSafety(const G4ThreeVector &localPoint,
|
||||
const G4NavigationHistory &history,
|
||||
const G4double currentProposedStepLength)
|
||||
{
|
||||
G4VPhysicalVolume *motherPhysical,*samplePhysical;
|
||||
G4LogicalVolume *motherLogical;
|
||||
G4VSolid *motherSolid;
|
||||
G4double ourStep=currentProposedStepLength,motherSafety,ourSafety;
|
||||
G4int localNoDaughters,sampleNo;
|
||||
|
||||
motherPhysical=history.GetTopVolume();
|
||||
motherLogical=motherPhysical->GetLogicalVolume();
|
||||
motherSolid=motherLogical->GetSolid();
|
||||
|
||||
//
|
||||
// Compute mother safety
|
||||
//
|
||||
motherSafety=motherSolid->DistanceToOut(localPoint);
|
||||
ourSafety=motherSafety; // Working isotropic safety
|
||||
|
||||
//
|
||||
// Compute daughter safeties
|
||||
//
|
||||
localNoDaughters=motherLogical->GetNoDaughters();
|
||||
for (sampleNo=localNoDaughters-1;sampleNo>=0;sampleNo--)
|
||||
{
|
||||
samplePhysical=motherLogical->GetDaughter(sampleNo);
|
||||
|
||||
samplePhysical->Setup(motherPhysical);
|
||||
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
|
||||
samplePhysical->GetTranslation());
|
||||
sampleTf.Invert();
|
||||
const G4ThreeVector samplePoint=sampleTf.TransformPoint(localPoint);
|
||||
const G4VSolid *sampleSolid=samplePhysical
|
||||
->GetLogicalVolume()
|
||||
->GetSolid();
|
||||
const G4double sampleSafety=sampleSolid
|
||||
->DistanceToIn(samplePoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
}
|
||||
|
||||
return ourSafety;
|
||||
}
|
||||
@@ -0,0 +1,327 @@
|
||||
// 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.cc,v 2.4 1998/09/15 13:57:33 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// class G4ParameterisedNavigation Implementation
|
||||
//
|
||||
|
||||
#include "G4ParameterisedNavigation.hh"
|
||||
G4ParameterisedNavigation::~G4ParameterisedNavigation()
|
||||
{
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
cout << "G4ParameterisedNavigation::~G4ParameterisedNavigation() called."
|
||||
<< endl;
|
||||
#endif
|
||||
}
|
||||
|
||||
G4double G4ParameterisedNavigation::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)
|
||||
{
|
||||
|
||||
G4VPhysicalVolume *motherPhysical,*samplePhysical;
|
||||
G4VPVParameterisation *sampleParam;
|
||||
G4LogicalVolume *motherLogical;
|
||||
G4VSolid *motherSolid,*sampleSolid;
|
||||
G4ThreeVector sampleDirection;
|
||||
G4double ourStep=currentProposedStepLength,motherSafety,ourSafety;
|
||||
G4int sampleNo,blockedExitedReplicaNo=-1;
|
||||
|
||||
G4bool initialNode,noStep;
|
||||
G4SmartVoxelNode *curVoxelNode;
|
||||
G4int curNoVolumes,contentNo;
|
||||
G4double voxelSafety;
|
||||
|
||||
// Replication data
|
||||
EAxis axis;
|
||||
G4int nReplicas;
|
||||
G4double width,offset;
|
||||
G4bool consuming;
|
||||
|
||||
motherPhysical=history.GetTopVolume();
|
||||
motherLogical=motherPhysical->GetLogicalVolume();
|
||||
|
||||
motherSolid=motherLogical->GetSolid();
|
||||
|
||||
|
||||
//
|
||||
// Compute mother safety
|
||||
//
|
||||
motherSafety=motherSolid->DistanceToOut(localPoint);
|
||||
ourSafety=motherSafety; // Working isotropic safety
|
||||
|
||||
//
|
||||
// Compute daughter safeties & intersections
|
||||
//
|
||||
|
||||
initialNode=true;
|
||||
noStep=true;
|
||||
|
||||
// By definition, parameterised volumes exist as first
|
||||
// daughter of mother volume
|
||||
samplePhysical=motherLogical->GetDaughter(0);
|
||||
samplePhysical->GetReplicationData(axis,nReplicas,width,offset,consuming);
|
||||
fBList.Enlarge(nReplicas);
|
||||
fBList.Reset();
|
||||
|
||||
|
||||
// Exiting normal optimisation
|
||||
if (exiting && (*pBlockedPhysical==samplePhysical) && validExitNormal)
|
||||
{
|
||||
if (localDirection.dot(exitNormal)>=kMinExitingNormalCosine)
|
||||
{
|
||||
assert( (0 <= blockedReplicaNo)
|
||||
&&(blockedReplicaNo<nReplicas));
|
||||
// Block exited daughter replica; Must be on boundary => zero safety
|
||||
fBList.BlockVolume(blockedReplicaNo);
|
||||
ourSafety=0;
|
||||
}
|
||||
}
|
||||
|
||||
exiting=false;
|
||||
entering=false;
|
||||
|
||||
// sampleSolid=samplePhysical ->GetLogicalVolume() ->GetSolid();
|
||||
|
||||
sampleParam=samplePhysical->GetParameterisation();
|
||||
|
||||
do {
|
||||
|
||||
curVoxelNode=fVoxelNode;
|
||||
curNoVolumes=curVoxelNode->GetNoContained();
|
||||
|
||||
|
||||
for (contentNo=curNoVolumes-1;contentNo>=0;contentNo--)
|
||||
{
|
||||
sampleNo=curVoxelNode->GetVolume(contentNo);
|
||||
if (!fBList.IsBlocked(sampleNo))
|
||||
{
|
||||
fBList.BlockVolume(sampleNo);
|
||||
sampleSolid=sampleParam->ComputeSolid(sampleNo,
|
||||
samplePhysical);
|
||||
sampleSolid->ComputeDimensions(sampleParam,
|
||||
sampleNo,
|
||||
samplePhysical);
|
||||
sampleParam->ComputeTransformation(sampleNo,
|
||||
samplePhysical);
|
||||
samplePhysical->Setup(motherPhysical);
|
||||
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
|
||||
samplePhysical->GetTranslation());
|
||||
sampleTf.Invert();
|
||||
const G4ThreeVector samplePoint=sampleTf.TransformPoint(localPoint);
|
||||
const G4double sampleSafety=sampleSolid
|
||||
->DistanceToIn(samplePoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
if (sampleSafety<=ourStep)
|
||||
{
|
||||
sampleDirection=sampleTf.TransformAxis(localDirection);
|
||||
const G4double sampleStep=sampleSolid
|
||||
->DistanceToIn(samplePoint,
|
||||
sampleDirection);
|
||||
if (sampleStep<=ourStep)
|
||||
{
|
||||
ourStep=sampleStep;
|
||||
entering=true;
|
||||
exiting=false;
|
||||
*pBlockedPhysical=samplePhysical;
|
||||
blockedReplicaNo=sampleNo;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (initialNode)
|
||||
{
|
||||
initialNode=false;
|
||||
voxelSafety=ComputeVoxelSafety(localPoint);
|
||||
if (voxelSafety<ourSafety)
|
||||
{
|
||||
ourSafety=voxelSafety;
|
||||
}
|
||||
|
||||
if (currentProposedStepLength<ourSafety)
|
||||
{
|
||||
//
|
||||
// Guaranteed physics limited
|
||||
//
|
||||
noStep=false;
|
||||
entering=false;
|
||||
exiting=false;
|
||||
*pBlockedPhysical=0;
|
||||
ourStep=kInfinity;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Compute mother intersection if required
|
||||
//
|
||||
if (motherSafety<=ourStep)
|
||||
{
|
||||
G4double motherStep=motherSolid
|
||||
->DistanceToOut(localPoint,
|
||||
localDirection,
|
||||
true,
|
||||
&validExitNormal,
|
||||
&exitNormal);
|
||||
if (motherStep<=ourStep)
|
||||
{
|
||||
ourStep=motherStep;
|
||||
exiting=true;
|
||||
entering=false;
|
||||
if (validExitNormal)
|
||||
{
|
||||
const G4RotationMatrix *rot=motherPhysical->GetRotation();
|
||||
if (rot)
|
||||
{
|
||||
exitNormal*=rot->inverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
validExitNormal=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newSafety=ourSafety;
|
||||
}
|
||||
|
||||
if (noStep)
|
||||
{
|
||||
noStep=LocateNextVoxel(localPoint,
|
||||
localDirection,
|
||||
ourStep);
|
||||
}
|
||||
|
||||
} while (noStep);
|
||||
|
||||
return ourStep;
|
||||
}
|
||||
|
||||
G4double G4ParameterisedNavigation::ComputeSafety(const G4ThreeVector &localPoint,
|
||||
const G4NavigationHistory &history,
|
||||
const G4double pProposedMaxLength )
|
||||
{
|
||||
|
||||
G4VPhysicalVolume *motherPhysical,*samplePhysical;
|
||||
G4VPVParameterisation *sampleParam;
|
||||
G4LogicalVolume *motherLogical;
|
||||
G4VSolid *motherSolid,*sampleSolid;
|
||||
G4double motherSafety,ourSafety;
|
||||
G4int sampleNo, curVoxelNodeNo;
|
||||
|
||||
G4SmartVoxelNode *curVoxelNode;
|
||||
G4int curNoVolumes,contentNo;
|
||||
G4double voxelSafety;
|
||||
|
||||
// Replication data
|
||||
EAxis axis;
|
||||
G4int nReplicas;
|
||||
G4double width,offset;
|
||||
G4bool consuming;
|
||||
|
||||
motherPhysical=history.GetTopVolume();
|
||||
motherLogical=motherPhysical->GetLogicalVolume();
|
||||
|
||||
motherSolid=motherLogical->GetSolid();
|
||||
//
|
||||
// Compute mother safety
|
||||
//
|
||||
motherSafety=motherSolid->DistanceToOut(localPoint);
|
||||
ourSafety=motherSafety; // Working isotropic safety
|
||||
|
||||
//
|
||||
// Compute daughter safeties
|
||||
//
|
||||
|
||||
// By definition, parameterised volumes exist as first
|
||||
// daughter of mother volume
|
||||
samplePhysical=motherLogical->GetDaughter(0);
|
||||
samplePhysical->GetReplicationData(axis,nReplicas,width,offset,consuming);
|
||||
sampleParam=samplePhysical->GetParameterisation();
|
||||
|
||||
// Calculate new VoxelNode of current point
|
||||
curVoxelNodeNo= G4int (
|
||||
(localPoint(fVoxelAxis) -fVoxelHeader->GetMinExtent())
|
||||
/ fVoxelSliceWidth
|
||||
);
|
||||
curVoxelNode = fVoxelHeader->GetSlice(curVoxelNodeNo)->GetNode();
|
||||
|
||||
curNoVolumes=curVoxelNode->GetNoContained();
|
||||
|
||||
for (contentNo=curNoVolumes-1;contentNo>=0;contentNo--)
|
||||
{
|
||||
sampleNo=curVoxelNode->GetVolume(contentNo);
|
||||
|
||||
sampleSolid=sampleParam->ComputeSolid(sampleNo,
|
||||
samplePhysical);
|
||||
sampleSolid->ComputeDimensions(sampleParam,
|
||||
sampleNo,
|
||||
samplePhysical);
|
||||
sampleParam->ComputeTransformation(sampleNo,
|
||||
samplePhysical);
|
||||
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
|
||||
samplePhysical->GetTranslation());
|
||||
sampleTf.Invert();
|
||||
const G4ThreeVector samplePoint=sampleTf.TransformPoint(localPoint);
|
||||
const G4double sampleSafety=sampleSolid
|
||||
->DistanceToIn(samplePoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
}
|
||||
|
||||
// These must be current for ComputeVoxelSafety
|
||||
fVoxelNodeNo= curVoxelNodeNo;
|
||||
fVoxelNode = curVoxelNode;
|
||||
|
||||
voxelSafety=ComputeVoxelSafety(localPoint);
|
||||
if (voxelSafety<ourSafety)
|
||||
{
|
||||
ourSafety=voxelSafety;
|
||||
}
|
||||
|
||||
return ourSafety;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,880 @@
|
||||
// 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.cc,v 2.1 1998/07/12 02:58:28 urbi Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// class G4REplicaNavigation Implementation
|
||||
|
||||
#include "G4ReplicaNavigation.hh"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
G4ReplicaNavigation::G4ReplicaNavigation()
|
||||
{
|
||||
}
|
||||
|
||||
EInside G4ReplicaNavigation::Inside(const G4VPhysicalVolume *pVol,
|
||||
const G4int replicaNo,
|
||||
const G4ThreeVector &localPoint) const
|
||||
{
|
||||
EInside in=kOutside;
|
||||
// Replication data
|
||||
EAxis axis;
|
||||
G4int nReplicas;
|
||||
G4double width,offset;
|
||||
G4bool consuming;
|
||||
|
||||
G4double coord,rad2,rmin,tolRMax2,rmax,tolRMin2;
|
||||
|
||||
pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
|
||||
assert(consuming);
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case kXAxis:
|
||||
case kYAxis:
|
||||
case kZAxis:
|
||||
coord=fabs(localPoint(axis))-width*0.5;
|
||||
if (coord<=-kCarTolerance*0.5)
|
||||
{
|
||||
in=kInside;
|
||||
}
|
||||
else if (coord<=kCarTolerance*0.5)
|
||||
{
|
||||
in=kSurface;
|
||||
}
|
||||
break;
|
||||
case kPhi:
|
||||
if (localPoint.y()||localPoint.x())
|
||||
{
|
||||
coord=fabs(atan2(localPoint.y(),localPoint.x()))-width*0.5;
|
||||
if (coord<=-kAngTolerance*0.5)
|
||||
{
|
||||
in=kInside;
|
||||
}
|
||||
else if (coord<=kAngTolerance*0.5)
|
||||
{
|
||||
in=kSurface;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
in=kSurface;
|
||||
}
|
||||
break;
|
||||
case kRho:
|
||||
rad2=localPoint.perp2();
|
||||
rmax=(replicaNo+1)*width+offset;
|
||||
|
||||
tolRMax2=rmax-kRadTolerance*0.5;
|
||||
tolRMax2*=tolRMax2;
|
||||
if (rad2>tolRMax2)
|
||||
{
|
||||
tolRMax2=rmax+kRadTolerance*0.5;
|
||||
tolRMax2*=tolRMax2;
|
||||
if (rad2<=tolRMax2)
|
||||
{
|
||||
in=kSurface;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Known to be inside outer radius
|
||||
if (replicaNo||offset)
|
||||
{
|
||||
rmin=rmax-width;
|
||||
tolRMin2=rmin-kRadTolerance*0.5;
|
||||
tolRMin2*=tolRMin2;
|
||||
if (rad2>tolRMin2)
|
||||
{
|
||||
tolRMin2=rmin+kRadTolerance*0.5;
|
||||
tolRMin2*=tolRMin2;
|
||||
if (rad2>=tolRMin2)
|
||||
{
|
||||
in=kInside;
|
||||
}
|
||||
else
|
||||
{
|
||||
in=kSurface;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
in=kInside;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
G4Exception("Unknown axis in G4ReplicaNavigation::Inside");
|
||||
break;
|
||||
}
|
||||
return in;
|
||||
}
|
||||
|
||||
G4double G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume *pVol,
|
||||
const G4int replicaNo,
|
||||
const G4ThreeVector &localPoint) const
|
||||
{
|
||||
// Replication data
|
||||
EAxis axis;
|
||||
G4int nReplicas;
|
||||
G4double width,offset;
|
||||
G4bool consuming;
|
||||
|
||||
G4double safety,safe1,safe2;
|
||||
G4double coord,rho,rmin,rmax;
|
||||
|
||||
pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
|
||||
assert(consuming);
|
||||
switch(axis)
|
||||
{
|
||||
case kXAxis:
|
||||
case kYAxis:
|
||||
case kZAxis:
|
||||
coord=localPoint(axis);
|
||||
safe1=width*0.5-coord;
|
||||
safe2=width*0.5+coord;
|
||||
safety=(safe1<=safe2) ? safe1 : safe2;
|
||||
break;
|
||||
case kPhi:
|
||||
if (localPoint.y()<=0)
|
||||
{
|
||||
safety=localPoint.x()*sin(width*0.5)+localPoint.y()*cos(width*0.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
safety=localPoint.x()*sin(width*0.5)-localPoint.y()*cos(width*0.5);
|
||||
}
|
||||
break;
|
||||
case kRho:
|
||||
rho=localPoint.perp();
|
||||
rmax=width*(replicaNo+1)+offset;
|
||||
if (replicaNo||offset)
|
||||
{
|
||||
rmin=rmax-width;
|
||||
safe1=rho-rmin;
|
||||
safe2=rmax-rho;
|
||||
safety=(safe1<=safe2) ? safe1 : safe2;
|
||||
}
|
||||
else
|
||||
{
|
||||
safety=rmax-rho;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
G4Exception("Unknown axis in G4ReplicaNavigation::DistanceToOut");
|
||||
break;
|
||||
}
|
||||
if (safety<0) safety=0;
|
||||
return safety;
|
||||
}
|
||||
|
||||
G4double G4ReplicaNavigation::DistanceToOut(const G4VPhysicalVolume *pVol,
|
||||
const G4int replicaNo,
|
||||
const G4ThreeVector &localPoint,
|
||||
const G4ThreeVector &localDirection) const
|
||||
{
|
||||
// Replication data
|
||||
EAxis axis;
|
||||
G4int nReplicas;
|
||||
G4double width,offset;
|
||||
G4bool consuming;
|
||||
|
||||
G4double coord,Comp,Dist,lindist;
|
||||
|
||||
pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
|
||||
assert(consuming);
|
||||
switch(axis)
|
||||
{
|
||||
case kXAxis:
|
||||
case kYAxis:
|
||||
case kZAxis:
|
||||
coord=localPoint(axis);
|
||||
Comp=localDirection(axis);
|
||||
|
||||
if (Comp>0)
|
||||
{
|
||||
lindist=width*0.5-coord;
|
||||
Dist= (lindist>kCarTolerance*0.5) ? lindist/Comp : 0;
|
||||
}
|
||||
else if (Comp<0)
|
||||
{
|
||||
lindist=width*0.5+coord;
|
||||
Dist= (lindist>kCarTolerance*0.5) ? -lindist/Comp : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dist=kInfinity;
|
||||
}
|
||||
break;
|
||||
case kPhi:
|
||||
Dist=DistanceToOutPhi(localPoint,localDirection,width);
|
||||
break;
|
||||
case kRho:
|
||||
Dist=DistanceToOutRad(localPoint,localDirection,width,offset,replicaNo);
|
||||
break;
|
||||
default:
|
||||
G4Exception("Unknown axis in G4ReplicaNavigation::DistanceToOut");
|
||||
break;
|
||||
}
|
||||
return Dist;
|
||||
}
|
||||
|
||||
|
||||
G4double G4ReplicaNavigation::DistanceToOutPhi(const G4ThreeVector &localPoint,
|
||||
const G4ThreeVector &localDirection,
|
||||
const G4double width) const
|
||||
{
|
||||
// Phi Intersection
|
||||
// NOTE: width<=M_PI by definition
|
||||
|
||||
G4double sinSPhi,cosSPhi;
|
||||
G4double pDistS,pDistE,compS,compE,Dist,dist2,yi;
|
||||
if (localPoint.x()||localPoint.y())
|
||||
{
|
||||
sinSPhi=sin(-width*0.5); // SIN of starting phi plane
|
||||
cosSPhi=cos(width*0.5); // COS of starting phi plane
|
||||
// pDist -ve when inside
|
||||
pDistS=localPoint.x()*sinSPhi-localPoint.y()*cosSPhi;
|
||||
pDistE=localPoint.x()*sinSPhi+localPoint.y()*cosSPhi;
|
||||
// Comp -ve when in direction of outwards normal
|
||||
compS=-sinSPhi*localDirection.x()+cosSPhi*localDirection.y();
|
||||
compE=-sinSPhi*localDirection.x()-cosSPhi*localDirection.y();
|
||||
|
||||
if (pDistS<=0&&pDistE<=0)
|
||||
{
|
||||
// Inside both phi *full* planes
|
||||
if (compS<0)
|
||||
{
|
||||
dist2=pDistS/compS;
|
||||
yi=localPoint.y()+dist2*localDirection.y();
|
||||
// Check intersecting with correct half-plane (no -> no intersect)
|
||||
if (yi<=0)
|
||||
{
|
||||
Dist=(pDistS<=-kCarTolerance*0.5) ? dist2 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dist=kInfinity;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dist=kInfinity;
|
||||
}
|
||||
|
||||
if (compE<0)
|
||||
{
|
||||
dist2=pDistE/compE;
|
||||
// Only check further if < starting phi intersection
|
||||
if (dist2<Dist)
|
||||
{
|
||||
yi=localPoint.y()+dist2*localDirection.y();
|
||||
// Check intersecting with correct half-plane
|
||||
if (yi>=0)
|
||||
{
|
||||
// Leaving via ending phi
|
||||
Dist=(pDistE<=-kCarTolerance*0.5) ? dist2 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (pDistS>=0&&pDistE>=0)
|
||||
{
|
||||
// Outside both *full* phi planes
|
||||
// if towards both >=0 then once inside will remain inside
|
||||
Dist= (compS>=0&&compE>=0) ? kInfinity : 0;
|
||||
}
|
||||
else if (pDistS>0&&pDistE<0)
|
||||
{
|
||||
// Outside full starting plane, inside full ending plane
|
||||
if (compS>=0)
|
||||
{
|
||||
if (compE<0)
|
||||
{
|
||||
dist2=pDistE/compE;
|
||||
yi=localPoint.y()+dist2*localDirection.y();
|
||||
// Check intersection in correct half-plane (if not -> remain in extent)
|
||||
Dist=(yi>0) ? dist2 : kInfinity;
|
||||
}
|
||||
else Dist=kInfinity;
|
||||
}
|
||||
else
|
||||
{
|
||||
// leaving immediately by starting phi
|
||||
Dist=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Must be pDistS<0&&pDistE>0
|
||||
// Inside full starting plane, outside full ending plane
|
||||
if (compE>=0)
|
||||
{
|
||||
if (compS<0)
|
||||
{
|
||||
|
||||
dist2=pDistS/compS;
|
||||
yi=localPoint.y()+dist2*localDirection.y();
|
||||
// Check intersection in correct half-plane (if not -> remain in extent)
|
||||
Dist=(yi<0) ? dist2 : kInfinity;
|
||||
}
|
||||
else
|
||||
{
|
||||
Dist=kInfinity;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// leaving immediately by ending phi
|
||||
Dist=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// On z axis + travel not || to z axis -> use direction vector
|
||||
Dist = (fabs(localDirection.phi())<=width*0.5) ? kInfinity : 0;
|
||||
}
|
||||
|
||||
return Dist;
|
||||
}
|
||||
|
||||
G4double G4ReplicaNavigation::DistanceToOutRad(const G4ThreeVector &localPoint,
|
||||
const G4ThreeVector &localDirection,
|
||||
const G4double width,
|
||||
const G4double offset,
|
||||
const G4int replicaNo) const
|
||||
{
|
||||
|
||||
G4double rmin,rmax,t1,t2,t3,deltaR;
|
||||
G4double b,c,d2,sr;
|
||||
|
||||
//
|
||||
// Radial Intersections
|
||||
//
|
||||
|
||||
// Find intersction with cylinders at rmax/rmin
|
||||
// Intersection point (xi,yi,zi) on line
|
||||
// x=localPoint.x+t*localDirection.x etc.
|
||||
//
|
||||
// Intersects with x^2+y^2=R^2
|
||||
//
|
||||
// Hence (localDirection.x^2+localDirection.y^2)t^2+
|
||||
// 2t(localPoint.x*localDirection.x+localPoint.y*localDirection.y)+
|
||||
// localPoint.x^2+localPoint.y^2-R^2=0
|
||||
//
|
||||
// t1 t2 t3
|
||||
|
||||
rmin=replicaNo*width+offset;
|
||||
rmax=(replicaNo+1)*width+offset;
|
||||
|
||||
t1=1.0-localDirection.z()*localDirection.z(); // since v normalised
|
||||
t2=localPoint.x()*localDirection.x()+localPoint.y()*localDirection.y();
|
||||
t3=localPoint.x()*localPoint.x()+localPoint.y()*localPoint.y();
|
||||
|
||||
if (t1>0) // Check not parallel
|
||||
{
|
||||
// Calculate sr, r exit distance
|
||||
if (t2>=0)
|
||||
{
|
||||
// Delta r not negative => leaving via rmax
|
||||
deltaR=t3-rmax*rmax;
|
||||
// NOTE: Should use rho-rmax<-kRadTolerance*0.5 - [no sqrts for efficiency]
|
||||
if (deltaR<-kRadTolerance*0.5)
|
||||
{
|
||||
b=t2/t1;
|
||||
c=deltaR/t1;
|
||||
sr=-b+sqrt(b*b-c);
|
||||
}
|
||||
else
|
||||
{
|
||||
// On tolerant boundary & heading outwards (or locally perpendicular to)
|
||||
// outer radial surface -> leaving immediately
|
||||
sr=0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Possible rmin intersection
|
||||
if (rmin)
|
||||
{
|
||||
deltaR=t3-rmin*rmin;
|
||||
b=t2/t1;
|
||||
c=deltaR/t1;
|
||||
d2=b*b-c;
|
||||
if (d2>=0)
|
||||
{
|
||||
// Leaving via rmin
|
||||
// NOTE: Should use rho-rmin>kRadTolerance*0.5 - [no sqrts for efficiency]
|
||||
sr= (deltaR>kRadTolerance*0.5) ? -b-sqrt(d2) : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
// No rmin intersect -> must be rmax intersect
|
||||
deltaR=t3-rmax*rmax;
|
||||
c=deltaR/t1;
|
||||
sr=-b+sqrt(b*b-c);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// No rmin intersect -> must be rmax intersect
|
||||
deltaR=t3-rmax*rmax;
|
||||
b=t2/t1;
|
||||
c=deltaR/t1;
|
||||
sr=-b+sqrt(b*b-c);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sr=kInfinity;
|
||||
}
|
||||
return sr;
|
||||
}
|
||||
|
||||
// Setup transformation and transform point into local system
|
||||
void G4ReplicaNavigation::ComputeTransformation(const G4int replicaNo,
|
||||
G4VPhysicalVolume *pVol,
|
||||
G4ThreeVector& point) const
|
||||
{
|
||||
G4double val,cosv,sinv,tmp;
|
||||
// Replication data
|
||||
EAxis axis;
|
||||
G4int nReplicas;
|
||||
G4double width,offset;
|
||||
G4bool consuming;
|
||||
|
||||
pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
|
||||
assert(consuming);
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case kXAxis:
|
||||
val=-width*0.5*(nReplicas-1)+width*replicaNo;
|
||||
pVol->SetTranslation(G4ThreeVector(val,0,0));
|
||||
point.setX(point.x()-val);
|
||||
break;
|
||||
case kYAxis:
|
||||
val=-width*0.5*(nReplicas-1)+width*replicaNo;
|
||||
pVol->SetTranslation(G4ThreeVector(0,val,0));
|
||||
point.setY(point.y()-val);
|
||||
break;
|
||||
case kZAxis:
|
||||
val=-width*0.5*(nReplicas-1)+width*replicaNo;
|
||||
pVol->SetTranslation(G4ThreeVector(0,0,val));
|
||||
point.setZ(point.z()-val);
|
||||
break;
|
||||
case kPhi:
|
||||
val=-(offset+width*(replicaNo+0.5));
|
||||
SetPhiTransformation(val,pVol);
|
||||
cosv=cos(val);
|
||||
sinv=sin(val);
|
||||
tmp=point.x()*cosv-point.y()*sinv;
|
||||
point.setY(point.x()*sinv+point.y()*cosv);
|
||||
point.setX(tmp);
|
||||
break;
|
||||
case kRho:
|
||||
// No setup required for radial case
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Setup transformation
|
||||
void G4ReplicaNavigation::ComputeTransformation(const G4int replicaNo,
|
||||
G4VPhysicalVolume *pVol) const
|
||||
{
|
||||
G4double val;
|
||||
// Replication data
|
||||
EAxis axis;
|
||||
G4int nReplicas;
|
||||
G4double width,offset;
|
||||
G4bool consuming;
|
||||
|
||||
pVol->GetReplicationData(axis,nReplicas,width,offset,consuming);
|
||||
assert(consuming);
|
||||
|
||||
switch (axis)
|
||||
{
|
||||
case kXAxis:
|
||||
val=-width*0.5*(nReplicas-1)+width*replicaNo;
|
||||
pVol->SetTranslation(G4ThreeVector(val,0,0));
|
||||
break;
|
||||
case kYAxis:
|
||||
val=-width*0.5*(nReplicas-1)+width*replicaNo;
|
||||
pVol->SetTranslation(G4ThreeVector(0,val,0));
|
||||
break;
|
||||
case kZAxis:
|
||||
val=-width*0.5*(nReplicas-1)+width*replicaNo;
|
||||
pVol->SetTranslation(G4ThreeVector(0,0,val));
|
||||
break;
|
||||
case kPhi:
|
||||
val=-(offset+width*(replicaNo+0.5));
|
||||
SetPhiTransformation(val);
|
||||
break;
|
||||
case kRho:
|
||||
// No setup required for radial case
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
G4double G4ReplicaNavigation::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)
|
||||
{
|
||||
G4VPhysicalVolume *repPhysical,*motherPhysical;
|
||||
G4VPhysicalVolume *samplePhysical,*blockedExitedVol=0;
|
||||
G4LogicalVolume *repLogical;
|
||||
G4VSolid *motherSolid;
|
||||
G4ThreeVector repPoint,repDirection,sampleDirection;
|
||||
G4double ourStep=currentProposedStepLength;
|
||||
G4double ourSafety=kInfinity;
|
||||
G4double sampleStep,sampleSafety;
|
||||
G4int localNoDaughters,sampleNo;
|
||||
G4int depth;
|
||||
|
||||
// Exiting normal optimisation
|
||||
if (exiting&&validExitNormal)
|
||||
{
|
||||
if (localDirection.dot(exitNormal)>=kMinExitingNormalCosine)
|
||||
{
|
||||
// Block exited daughter volume
|
||||
blockedExitedVol=*pBlockedPhysical;
|
||||
ourSafety=0;
|
||||
}
|
||||
}
|
||||
|
||||
exiting=false;
|
||||
entering=false;
|
||||
|
||||
repPhysical=history.GetTopVolume();
|
||||
repLogical=repPhysical->GetLogicalVolume();
|
||||
|
||||
//
|
||||
// Compute intersection with replica boundaries & replica safety
|
||||
//
|
||||
|
||||
sampleSafety=DistanceToOut(history.GetTopVolume(),
|
||||
history.GetTopReplicaNo(),
|
||||
localPoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
if (sampleSafety<ourStep)
|
||||
{
|
||||
sampleStep=DistanceToOut(history.GetTopVolume(),
|
||||
history.GetTopReplicaNo(),
|
||||
localPoint,
|
||||
localDirection);
|
||||
if (sampleStep<ourStep)
|
||||
{
|
||||
ourStep=sampleStep;
|
||||
exiting=true;
|
||||
validExitNormal=false;
|
||||
}
|
||||
}
|
||||
|
||||
depth=history.GetDepth()-1;
|
||||
while (history.GetVolumeType(depth)==kReplica)
|
||||
{
|
||||
repPoint=history.GetTransform(depth).TransformPoint(globalPoint);
|
||||
sampleSafety=DistanceToOut(history.GetVolume(depth),
|
||||
history.GetReplicaNo(depth),
|
||||
repPoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
if (sampleSafety<ourStep)
|
||||
{
|
||||
sampleStep=DistanceToOut(history.GetVolume(depth),
|
||||
history.GetReplicaNo(depth),
|
||||
repPoint,
|
||||
history.GetTransform(depth).TransformAxis(globalDirection));
|
||||
if (sampleStep<ourStep)
|
||||
{
|
||||
ourStep=sampleStep;
|
||||
exiting=true;
|
||||
validExitNormal=false;
|
||||
}
|
||||
}
|
||||
depth--;
|
||||
}
|
||||
|
||||
// Compute mother safety & intersection
|
||||
repPoint=history.GetTransform(depth).TransformPoint(globalPoint);
|
||||
motherPhysical=history.GetVolume(depth);
|
||||
motherSolid=motherPhysical->GetLogicalVolume()->GetSolid();
|
||||
sampleSafety=motherSolid->DistanceToOut(repPoint);
|
||||
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
|
||||
// May need precision protection
|
||||
if (sampleSafety<=ourStep)
|
||||
{
|
||||
repDirection=history.GetTransform(depth).TransformAxis(globalDirection);
|
||||
sampleStep=motherSolid
|
||||
->DistanceToOut(repPoint,
|
||||
repDirection,
|
||||
true,
|
||||
&validExitNormal,
|
||||
&exitNormal);
|
||||
if (sampleStep<=ourStep)
|
||||
{
|
||||
ourStep=sampleStep;
|
||||
exiting=true;
|
||||
if (validExitNormal)
|
||||
{
|
||||
const G4RotationMatrix *rot=motherPhysical->GetRotation();
|
||||
if (rot)
|
||||
{
|
||||
exitNormal*=rot->inverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
validExitNormal=false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Compute daughter safeties & intersections
|
||||
//
|
||||
localNoDaughters=repLogical->GetNoDaughters();
|
||||
for (sampleNo=localNoDaughters-1;sampleNo>=0;sampleNo--)
|
||||
{
|
||||
samplePhysical=repLogical->GetDaughter(sampleNo);
|
||||
if (samplePhysical!=blockedExitedVol)
|
||||
{
|
||||
samplePhysical->Setup(repPhysical);
|
||||
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
|
||||
samplePhysical->GetTranslation());
|
||||
sampleTf.Invert();
|
||||
const G4ThreeVector samplePoint=sampleTf.TransformPoint(localPoint);
|
||||
const G4VSolid *sampleSolid=samplePhysical
|
||||
->GetLogicalVolume()
|
||||
->GetSolid();
|
||||
const G4double sampleSafety=sampleSolid
|
||||
->DistanceToIn(samplePoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
if (sampleSafety<=ourStep)
|
||||
{
|
||||
sampleDirection=sampleTf.TransformAxis(localDirection);
|
||||
const G4double sampleStep=sampleSolid
|
||||
->DistanceToIn(samplePoint,
|
||||
sampleDirection);
|
||||
if (sampleStep<=ourStep)
|
||||
{
|
||||
ourStep=sampleStep;
|
||||
entering=true;
|
||||
exiting=false;
|
||||
*pBlockedPhysical=samplePhysical;
|
||||
blockedReplicaNo=-1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newSafety=ourSafety;
|
||||
return ourStep;
|
||||
}
|
||||
|
||||
// Compute the isotropic distance to current volume's boundaries and
|
||||
// to daughter volumes.
|
||||
//
|
||||
|
||||
G4double G4ReplicaNavigation::ComputeSafety(const G4ThreeVector &globalPoint,
|
||||
const G4ThreeVector &localPoint,
|
||||
G4NavigationHistory &history,
|
||||
// const G4NavigationHistory &history, // -> NON-CONST
|
||||
const G4double pProposedMaxLength )
|
||||
{
|
||||
G4VPhysicalVolume *repPhysical,*motherPhysical;
|
||||
G4VPhysicalVolume *samplePhysical,*blockedExitedVol=0;
|
||||
G4LogicalVolume *repLogical;
|
||||
G4VSolid *motherSolid;
|
||||
G4ThreeVector repPoint;
|
||||
G4double ourSafety=kInfinity;
|
||||
G4double sampleSafety;
|
||||
G4int localNoDaughters,sampleNo;
|
||||
G4int depth;
|
||||
|
||||
repPhysical=history.GetTopVolume();
|
||||
repLogical=repPhysical->GetLogicalVolume();
|
||||
|
||||
//
|
||||
// Compute intersection with replica boundaries & replica safety
|
||||
//
|
||||
|
||||
sampleSafety=DistanceToOut(history.GetTopVolume(),
|
||||
history.GetTopReplicaNo(),
|
||||
localPoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
|
||||
depth=history.GetDepth()-1;
|
||||
while (history.GetVolumeType(depth)==kReplica)
|
||||
{
|
||||
repPoint=history.GetTransform(depth).TransformPoint(globalPoint);
|
||||
sampleSafety=DistanceToOut(history.GetVolume(depth),
|
||||
history.GetReplicaNo(depth),
|
||||
repPoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
depth--;
|
||||
}
|
||||
|
||||
// Compute mother safety & intersection
|
||||
repPoint=history.GetTransform(depth).TransformPoint(globalPoint);
|
||||
motherPhysical=history.GetVolume(depth);
|
||||
motherSolid=motherPhysical->GetLogicalVolume()->GetSolid();
|
||||
sampleSafety=motherSolid->DistanceToOut(repPoint);
|
||||
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
|
||||
//
|
||||
// Compute daughter safeties & intersections
|
||||
//
|
||||
localNoDaughters=repLogical->GetNoDaughters();
|
||||
for (sampleNo=localNoDaughters-1;sampleNo>=0;sampleNo--)
|
||||
{
|
||||
samplePhysical=repLogical->GetDaughter(sampleNo);
|
||||
if (samplePhysical!=blockedExitedVol)
|
||||
{
|
||||
samplePhysical->Setup(repPhysical);
|
||||
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
|
||||
samplePhysical->GetTranslation());
|
||||
sampleTf.Invert();
|
||||
const G4ThreeVector samplePoint=sampleTf.TransformPoint(localPoint);
|
||||
const G4VSolid *sampleSolid=samplePhysical
|
||||
->GetLogicalVolume()
|
||||
->GetSolid();
|
||||
const G4double sampleSafety=sampleSolid
|
||||
->DistanceToIn(samplePoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ourSafety;
|
||||
}
|
||||
|
||||
|
||||
|
||||
EInside G4ReplicaNavigation::BackLocate(G4NavigationHistory &history,
|
||||
const G4ThreeVector &globalPoint,
|
||||
G4ThreeVector &localPoint,
|
||||
const G4bool &exiting,
|
||||
G4bool ¬KnownInside) const
|
||||
{
|
||||
G4VPhysicalVolume *pNRMother=0;
|
||||
G4VSolid *motherSolid;
|
||||
G4ThreeVector repPoint,goodPoint;
|
||||
G4int mdepth,depth,cdepth;
|
||||
EInside insideCode;
|
||||
|
||||
cdepth=history.GetDepth();
|
||||
// Find non replicated mother
|
||||
for (mdepth=cdepth-1;mdepth>=0;mdepth--)
|
||||
{
|
||||
if (history.GetVolumeType(mdepth)!=kReplica)
|
||||
{
|
||||
pNRMother=history.GetVolume(mdepth);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if( pNRMother == 0 )
|
||||
{
|
||||
// All the tree of mother volumes were Replicas.
|
||||
// This is an error, as the World volume must be a Placement
|
||||
G4Exception( "G4ReplicaNavigation::BackLocate - World volume must be a Placement" );
|
||||
}
|
||||
|
||||
|
||||
motherSolid=pNRMother->GetLogicalVolume()->GetSolid();
|
||||
goodPoint=history.GetTransform(mdepth).TransformPoint(globalPoint);
|
||||
insideCode=motherSolid->Inside(goodPoint);
|
||||
if (insideCode==kOutside||insideCode==kSurface&&exiting)
|
||||
{
|
||||
// Outside mother -> back up to mother level
|
||||
// Locate.. in Navigator will back up one more level
|
||||
// localPoint not reqd
|
||||
history.BackLevel(cdepth-mdepth);
|
||||
// localPoint=goodPoint;
|
||||
}
|
||||
else
|
||||
{
|
||||
notKnownInside=false;
|
||||
// Still within replications
|
||||
// Check down: if on outside stop at this level
|
||||
for (depth=mdepth+1;depth<cdepth;depth++)
|
||||
{
|
||||
repPoint=history.GetTransform(depth).TransformPoint(globalPoint);
|
||||
insideCode=Inside(history.GetVolume(depth),
|
||||
history.GetReplicaNo(depth),
|
||||
repPoint);
|
||||
if (insideCode==kOutside||insideCode==kSurface&&exiting)
|
||||
{
|
||||
localPoint=goodPoint;
|
||||
history.BackLevel(cdepth-depth);
|
||||
return insideCode;
|
||||
}
|
||||
else
|
||||
{
|
||||
goodPoint=repPoint;
|
||||
}
|
||||
}
|
||||
localPoint=history.GetTransform(depth).TransformPoint(globalPoint);
|
||||
insideCode=Inside(history.GetVolume(depth),
|
||||
history.GetReplicaNo(depth),
|
||||
localPoint);
|
||||
// If outside level, set localPoint = coordinates in reference system
|
||||
// of *previous* level - location code in navigator will back up one
|
||||
// level [And also manage blocking]
|
||||
if (insideCode==kOutside||insideCode==kSurface&&exiting)
|
||||
{
|
||||
localPoint=goodPoint;
|
||||
}
|
||||
}
|
||||
|
||||
return insideCode;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
// 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.cc,v 2.1 1998/11/02 12:12:18 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// class G4TouchableHistory Implementation
|
||||
|
||||
#include "G4TouchableHistory.hh"
|
||||
|
||||
G4TouchableHistory::~G4TouchableHistory()
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
// 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.cc,v 2.0 1998/07/02 17:06:47 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// G4TransportationManager
|
||||
//
|
||||
//
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
// The following inclusions should be left here, as only
|
||||
// the constructor and destructor require them.
|
||||
#include "G4PropagatorInField.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
|
||||
G4TransportationManager G4TransportationManager::fTransportationManager;
|
||||
|
||||
G4TransportationManager::G4TransportationManager()
|
||||
{
|
||||
fNavigatorForTracking= new G4Navigator() ;
|
||||
fFieldManager= new G4FieldManager() ;
|
||||
fPropagatorInField= new G4PropagatorInField( fNavigatorForTracking,
|
||||
fFieldManager);
|
||||
}
|
||||
|
||||
|
||||
G4TransportationManager::~G4TransportationManager()
|
||||
{
|
||||
delete fNavigatorForTracking;
|
||||
delete fPropagatorInField;
|
||||
delete fFieldManager;
|
||||
}
|
||||
@@ -0,0 +1,528 @@
|
||||
// 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.cc,v 2.6 1998/11/02 12:12:19 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-00 $
|
||||
//
|
||||
//
|
||||
// class G4VoxelNavigation Implementation
|
||||
//
|
||||
// $ Id: $
|
||||
//
|
||||
// Modified by:
|
||||
// J. Apostolakis, 29 Apr 98 Fixed error in LocateNextVoxel that
|
||||
// ignored voxels at lower levels
|
||||
|
||||
#include "G4VoxelNavigation.hh"
|
||||
|
||||
G4double G4VoxelNavigation::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)
|
||||
{
|
||||
|
||||
G4VPhysicalVolume *motherPhysical,*samplePhysical,*blockedExitedVol=0;
|
||||
G4LogicalVolume *motherLogical;
|
||||
G4VSolid *motherSolid;
|
||||
G4ThreeVector sampleDirection;
|
||||
G4double ourStep=currentProposedStepLength,motherSafety,ourSafety;
|
||||
G4int localNoDaughters,sampleNo;
|
||||
|
||||
G4bool initialNode,noStep;
|
||||
G4SmartVoxelNode *curVoxelNode;
|
||||
G4int curNoVolumes,contentNo;
|
||||
G4double voxelSafety;
|
||||
|
||||
motherPhysical=history.GetTopVolume();
|
||||
motherLogical=motherPhysical->GetLogicalVolume();
|
||||
|
||||
motherSolid=motherLogical->GetSolid();
|
||||
|
||||
|
||||
//
|
||||
// Compute mother safety
|
||||
//
|
||||
motherSafety=motherSolid->DistanceToOut(localPoint);
|
||||
ourSafety=motherSafety; // Working isotropic safety
|
||||
|
||||
//
|
||||
// Compute daughter safeties & intersections
|
||||
//
|
||||
// Exiting normal optimisation
|
||||
if (exiting&&validExitNormal)
|
||||
{
|
||||
if (localDirection.dot(exitNormal)>=kMinExitingNormalCosine)
|
||||
{
|
||||
// Block exited daughter volume
|
||||
blockedExitedVol=*pBlockedPhysical;
|
||||
ourSafety=0;
|
||||
}
|
||||
}
|
||||
|
||||
exiting=false;
|
||||
entering=false;
|
||||
|
||||
localNoDaughters=motherLogical->GetNoDaughters();
|
||||
|
||||
fBList.Enlarge(localNoDaughters);
|
||||
fBList.Reset();
|
||||
|
||||
initialNode=true;
|
||||
noStep=true;
|
||||
|
||||
do {
|
||||
|
||||
curVoxelNode=fVoxelNode;
|
||||
curNoVolumes=curVoxelNode->GetNoContained();
|
||||
|
||||
|
||||
for (contentNo=curNoVolumes-1;contentNo>=0;contentNo--)
|
||||
{
|
||||
sampleNo=curVoxelNode->GetVolume(contentNo);
|
||||
if (!fBList.IsBlocked(sampleNo))
|
||||
{
|
||||
fBList.BlockVolume(sampleNo);
|
||||
samplePhysical=motherLogical->GetDaughter(sampleNo);
|
||||
if (samplePhysical!=blockedExitedVol)
|
||||
{
|
||||
samplePhysical->Setup(motherPhysical);
|
||||
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
|
||||
samplePhysical->GetTranslation());
|
||||
sampleTf.Invert();
|
||||
const G4ThreeVector samplePoint=sampleTf.TransformPoint(localPoint);
|
||||
const G4VSolid *sampleSolid=samplePhysical
|
||||
->GetLogicalVolume()
|
||||
->GetSolid();
|
||||
const G4double sampleSafety=sampleSolid
|
||||
->DistanceToIn(samplePoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
if (sampleSafety<=ourStep)
|
||||
{
|
||||
sampleDirection=sampleTf.TransformAxis(localDirection);
|
||||
const G4double sampleStep=sampleSolid
|
||||
->DistanceToIn(samplePoint,
|
||||
sampleDirection);
|
||||
if (sampleStep<=ourStep)
|
||||
{
|
||||
ourStep=sampleStep;
|
||||
entering=true;
|
||||
exiting=false;
|
||||
*pBlockedPhysical=samplePhysical;
|
||||
blockedReplicaNo=-1;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (initialNode)
|
||||
{
|
||||
initialNode=false;
|
||||
voxelSafety=ComputeVoxelSafety(localPoint);
|
||||
if (voxelSafety<ourSafety)
|
||||
{
|
||||
ourSafety=voxelSafety;
|
||||
}
|
||||
|
||||
if (currentProposedStepLength<ourSafety)
|
||||
{
|
||||
//
|
||||
// Guaranteed physics limited
|
||||
//
|
||||
noStep=false;
|
||||
entering=false;
|
||||
exiting=false;
|
||||
*pBlockedPhysical=0;
|
||||
ourStep=kInfinity;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Compute mother intersection if required
|
||||
//
|
||||
if (motherSafety<=ourStep)
|
||||
{
|
||||
G4double motherStep=motherSolid
|
||||
->DistanceToOut(localPoint,
|
||||
localDirection,
|
||||
true,
|
||||
&validExitNormal,
|
||||
&exitNormal);
|
||||
if (motherStep<=ourStep)
|
||||
{
|
||||
ourStep=motherStep;
|
||||
exiting=true;
|
||||
entering=false;
|
||||
if (validExitNormal)
|
||||
{
|
||||
const G4RotationMatrix *rot=motherPhysical->GetRotation();
|
||||
if (rot)
|
||||
{
|
||||
exitNormal*=rot->inverse();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
validExitNormal=false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newSafety=ourSafety;
|
||||
}
|
||||
|
||||
if (noStep)
|
||||
{
|
||||
noStep=LocateNextVoxel(localPoint,
|
||||
localDirection,
|
||||
ourStep);
|
||||
}
|
||||
|
||||
} while (noStep);
|
||||
|
||||
return ourStep;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// Compute safety from specified point to voxel boundaries
|
||||
// using already located point
|
||||
// o collected boundaries for most derived level
|
||||
// o adjacent boundaries for previous levels
|
||||
|
||||
G4double G4VoxelNavigation::ComputeVoxelSafety(const G4ThreeVector&localPoint) const
|
||||
{
|
||||
G4SmartVoxelHeader *curHeader;
|
||||
G4double voxelSafety,curNodeWidth;
|
||||
G4double curNodeOffset,minCurCommonDelta,maxCurCommonDelta;
|
||||
G4int minCurNodeNoDelta,maxCurNodeNoDelta;
|
||||
G4int localVoxelDepth,curNodeNo;
|
||||
EAxis curHeaderAxis;
|
||||
|
||||
localVoxelDepth=fVoxelDepth;
|
||||
|
||||
curHeader=fVoxelHeaderStack(localVoxelDepth);
|
||||
curHeaderAxis=fVoxelAxisStack(localVoxelDepth);
|
||||
curNodeNo=fVoxelNodeNoStack(localVoxelDepth);
|
||||
curNodeWidth=fVoxelSliceWidthStack(localVoxelDepth);
|
||||
|
||||
// Compute linear intersection distance to boundaries of max/min
|
||||
// to collected nodes at current level
|
||||
curNodeOffset=curNodeNo*curNodeWidth;
|
||||
maxCurNodeNoDelta=fVoxelNode->GetMaxEquivalentSliceNo()-curNodeNo;
|
||||
minCurNodeNoDelta=curNodeNo-fVoxelNode->GetMinEquivalentSliceNo();
|
||||
minCurCommonDelta=localPoint(curHeaderAxis)
|
||||
-curHeader->GetMinExtent()
|
||||
-curNodeOffset;
|
||||
maxCurCommonDelta=curNodeWidth-minCurCommonDelta;
|
||||
|
||||
if (minCurNodeNoDelta<maxCurNodeNoDelta)
|
||||
{
|
||||
voxelSafety=minCurNodeNoDelta*curNodeWidth;
|
||||
voxelSafety+=minCurCommonDelta;
|
||||
}
|
||||
else if (maxCurNodeNoDelta<minCurNodeNoDelta)
|
||||
{
|
||||
voxelSafety=maxCurNodeNoDelta*curNodeWidth;
|
||||
voxelSafety+=maxCurCommonDelta;
|
||||
}
|
||||
else // (maxCurNodeNoDelta == minCurNodeNoDelta)
|
||||
{
|
||||
voxelSafety=minCurNodeNoDelta*curNodeWidth;
|
||||
voxelSafety+=min(minCurCommonDelta,maxCurCommonDelta);
|
||||
}
|
||||
|
||||
// Compute isotropic safety to boundaries of previous levels
|
||||
// [NOT to collected boundaries]
|
||||
while (localVoxelDepth>0&&voxelSafety>0)
|
||||
{
|
||||
localVoxelDepth--;
|
||||
|
||||
curHeader=fVoxelHeaderStack(localVoxelDepth);
|
||||
curHeaderAxis=fVoxelAxisStack(localVoxelDepth);
|
||||
curNodeNo=fVoxelNodeNoStack(localVoxelDepth);
|
||||
curNodeWidth=fVoxelSliceWidthStack(localVoxelDepth);
|
||||
curNodeOffset=curNodeNo*curNodeWidth;
|
||||
minCurCommonDelta=localPoint(curHeaderAxis)
|
||||
-curHeader->GetMinExtent()
|
||||
-curNodeOffset;
|
||||
maxCurCommonDelta=curNodeWidth-minCurCommonDelta;
|
||||
|
||||
if (minCurCommonDelta<voxelSafety)
|
||||
{
|
||||
voxelSafety=minCurCommonDelta;
|
||||
}
|
||||
if (maxCurCommonDelta<voxelSafety)
|
||||
{
|
||||
voxelSafety=maxCurCommonDelta;
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
// [the information on the next voxel is put into the set of
|
||||
// fVoxel* variables & "stacks" ]
|
||||
//
|
||||
//
|
||||
G4bool G4VoxelNavigation::LocateNextVoxel(const G4ThreeVector& localPoint,
|
||||
const G4ThreeVector& localDirection,
|
||||
const G4double currentStep)
|
||||
{
|
||||
G4SmartVoxelHeader *workHeader,*newHeader;
|
||||
G4SmartVoxelProxy *newProxy;
|
||||
G4SmartVoxelNode *newVoxelNode;
|
||||
G4ThreeVector targetPoint,voxelPoint;
|
||||
G4double workNodeWidth,workMinExtent,workCoord;
|
||||
G4double minVal,maxVal,newDistance;
|
||||
G4double newHeaderMin,newHeaderNodeWidth;
|
||||
G4int depth, newDepth,workNodeNo,newNodeNo,newHeaderNoSlices;
|
||||
EAxis workHeaderAxis,newHeaderAxis;
|
||||
G4bool isNewVoxel=false;
|
||||
|
||||
G4double currentDistance= currentStep;
|
||||
|
||||
// Determine if end of Step within current voxel
|
||||
for (depth=0;depth<fVoxelDepth;depth++)
|
||||
{
|
||||
targetPoint=localPoint+localDirection*currentDistance;
|
||||
newDistance= currentDistance;
|
||||
workHeader=fVoxelHeaderStack(depth);
|
||||
workHeaderAxis=fVoxelAxisStack(depth);
|
||||
workNodeNo=fVoxelNodeNoStack(depth);
|
||||
workNodeWidth=fVoxelSliceWidthStack(depth);
|
||||
workMinExtent=workHeader->GetMinExtent();
|
||||
|
||||
workCoord=targetPoint(workHeaderAxis);
|
||||
minVal=workMinExtent+workNodeNo*workNodeWidth;
|
||||
if (minVal<=workCoord+kCarTolerance*0.5)
|
||||
{
|
||||
maxVal=minVal+workNodeWidth;
|
||||
if (maxVal<=workCoord-kCarTolerance*0.5)
|
||||
{
|
||||
// G4cout << "Must consider next voxel" << endl;
|
||||
newNodeNo=workNodeNo+1;
|
||||
newHeader=workHeader;
|
||||
newDistance=(maxVal-localPoint(workHeaderAxis))/localDirection(workHeaderAxis);
|
||||
isNewVoxel=true;
|
||||
newDepth= depth;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newNodeNo=workNodeNo-1;
|
||||
newHeader=workHeader;
|
||||
newDistance=(minVal-localPoint(workHeaderAxis))/localDirection(workHeaderAxis);
|
||||
isNewVoxel=true;
|
||||
newDepth= depth;
|
||||
}
|
||||
currentDistance= newDistance;
|
||||
}
|
||||
|
||||
targetPoint=localPoint+localDirection*currentDistance;
|
||||
// Check if end of Step within collected boundaries of current voxel
|
||||
depth=fVoxelDepth;
|
||||
{
|
||||
workHeader=fVoxelHeaderStack(depth);
|
||||
workHeaderAxis=fVoxelAxisStack(depth);
|
||||
workNodeNo=fVoxelNodeNoStack(depth);
|
||||
workNodeWidth=fVoxelSliceWidthStack(depth);
|
||||
workMinExtent=workHeader->GetMinExtent();
|
||||
|
||||
workCoord=targetPoint(workHeaderAxis);
|
||||
minVal=workMinExtent+fVoxelNode->GetMinEquivalentSliceNo()*workNodeWidth;
|
||||
if (minVal<=workCoord+kCarTolerance*0.5)
|
||||
{
|
||||
maxVal=workMinExtent+(fVoxelNode->GetMaxEquivalentSliceNo()+1)*workNodeWidth;
|
||||
if (maxVal<=workCoord-kCarTolerance*0.5)
|
||||
{
|
||||
newNodeNo=fVoxelNode->GetMaxEquivalentSliceNo()+1;
|
||||
newHeader=workHeader;
|
||||
newDistance=(maxVal-localPoint(workHeaderAxis))/localDirection(workHeaderAxis);
|
||||
isNewVoxel=true;
|
||||
newDepth= depth;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
newNodeNo=fVoxelNode->GetMinEquivalentSliceNo()-1;
|
||||
newHeader=workHeader;
|
||||
newDistance=(minVal-localPoint(workHeaderAxis))/localDirection(workHeaderAxis);
|
||||
isNewVoxel=true;
|
||||
newDepth= depth;
|
||||
}
|
||||
|
||||
currentDistance= newDistance;
|
||||
}
|
||||
|
||||
if (isNewVoxel)
|
||||
{
|
||||
// Compute new voxel & adjust voxel stack
|
||||
//
|
||||
// newNodeNo=Candidate node no at
|
||||
// newDepth =refinement depth of crossed voxel boundary
|
||||
// newHeader=Header for crossed voxel
|
||||
// newDistance=distance to crossed voxel boundary (along the track)
|
||||
//
|
||||
if (newNodeNo<0||newNodeNo>=newHeader->GetNoSlices())
|
||||
{
|
||||
// Leaving mother volume
|
||||
isNewVoxel=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Compute intersection point on the least refined voxel boundary that is Hit
|
||||
voxelPoint=localPoint+localDirection*newDistance;
|
||||
fVoxelNodeNoStack(newDepth)=newNodeNo;
|
||||
fVoxelDepth=newDepth;
|
||||
newVoxelNode=0;
|
||||
|
||||
while (!newVoxelNode)
|
||||
{
|
||||
newProxy=newHeader->GetSlice(newNodeNo);
|
||||
if (newProxy->IsNode())
|
||||
{
|
||||
newVoxelNode=newProxy->GetNode();
|
||||
}
|
||||
else
|
||||
{
|
||||
fVoxelDepth++;
|
||||
newHeader=newProxy->GetHeader();
|
||||
newHeaderAxis=newHeader->GetAxis();
|
||||
newHeaderNoSlices=newHeader->GetNoSlices();
|
||||
newHeaderMin=newHeader->GetMinExtent();
|
||||
newHeaderNodeWidth=(newHeader->GetMaxExtent()-newHeaderMin)/newHeaderNoSlices;
|
||||
newNodeNo=G4int ((voxelPoint(newHeaderAxis)-newHeaderMin)/newHeaderNodeWidth);
|
||||
// Rounding protection
|
||||
if (newNodeNo<0)
|
||||
{
|
||||
newNodeNo=0;
|
||||
}
|
||||
else if (newNodeNo>=newHeaderNoSlices)
|
||||
{
|
||||
newNodeNo=newHeaderNoSlices-1;
|
||||
}
|
||||
// Stack info for stepping
|
||||
fVoxelAxisStack(fVoxelDepth)=newHeaderAxis;
|
||||
fVoxelNoSlicesStack(fVoxelDepth)=newHeaderNoSlices;
|
||||
fVoxelSliceWidthStack(fVoxelDepth)=newHeaderNodeWidth;
|
||||
fVoxelNodeNoStack(fVoxelDepth)=newNodeNo;
|
||||
fVoxelHeaderStack(fVoxelDepth)=newHeader;
|
||||
}
|
||||
|
||||
}
|
||||
fVoxelNode=newVoxelNode;
|
||||
}
|
||||
}
|
||||
|
||||
return isNewVoxel;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
// Calculate the isotropic distance to the nearest boundary from the
|
||||
// specified point in the local coordinate system.
|
||||
// The localpoint utilised must be within the current volume.
|
||||
|
||||
G4double G4VoxelNavigation::ComputeSafety(const G4ThreeVector &localPoint,
|
||||
const G4NavigationHistory &history,
|
||||
const G4double pMaxLength )
|
||||
{
|
||||
|
||||
G4VPhysicalVolume *motherPhysical,*samplePhysical;
|
||||
G4LogicalVolume *motherLogical;
|
||||
G4VSolid *motherSolid;
|
||||
G4double motherSafety,ourSafety;
|
||||
G4int localNoDaughters,sampleNo;
|
||||
|
||||
G4SmartVoxelNode *curVoxelNode;
|
||||
G4int curNoVolumes,contentNo;
|
||||
G4double voxelSafety;
|
||||
|
||||
motherPhysical=history.GetTopVolume();
|
||||
motherLogical=motherPhysical->GetLogicalVolume();
|
||||
|
||||
motherSolid=motherLogical->GetSolid();
|
||||
//
|
||||
// Compute mother safety
|
||||
//
|
||||
motherSafety=motherSolid->DistanceToOut(localPoint);
|
||||
ourSafety=motherSafety; // Working isotropic safety
|
||||
|
||||
//
|
||||
// Compute daughter safeties
|
||||
//
|
||||
localNoDaughters=motherLogical->GetNoDaughters();
|
||||
|
||||
//
|
||||
// Look only inside the current Voxel only (in the first version).
|
||||
//
|
||||
|
||||
curVoxelNode=fVoxelNode;
|
||||
curNoVolumes=curVoxelNode->GetNoContained();
|
||||
|
||||
for (contentNo=curNoVolumes-1;contentNo>=0;contentNo--)
|
||||
{
|
||||
sampleNo=curVoxelNode->GetVolume(contentNo);
|
||||
samplePhysical=motherLogical->GetDaughter(sampleNo);
|
||||
|
||||
samplePhysical->Setup(motherPhysical);
|
||||
G4AffineTransform sampleTf(samplePhysical->GetRotation(),
|
||||
samplePhysical->GetTranslation());
|
||||
sampleTf.Invert();
|
||||
const G4ThreeVector samplePoint=sampleTf.TransformPoint(localPoint);
|
||||
const G4VSolid *sampleSolid=samplePhysical ->GetLogicalVolume()
|
||||
->GetSolid();
|
||||
const G4double sampleSafety=sampleSolid
|
||||
->DistanceToIn(samplePoint);
|
||||
if (sampleSafety<ourSafety)
|
||||
{
|
||||
ourSafety=sampleSafety;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
voxelSafety=ComputeVoxelSafety(localPoint);
|
||||
if (voxelSafety<ourSafety)
|
||||
{
|
||||
ourSafety=voxelSafety;
|
||||
}
|
||||
|
||||
return ourSafety;
|
||||
}
|
||||
|
||||
G4VoxelNavigation::~G4VoxelNavigation()
|
||||
{
|
||||
#ifdef G4DEBUG_NAVIGATION
|
||||
cout << "G4VoxelNavigation::~G4VoxelNavigation() called." << endl;
|
||||
#endif
|
||||
}
|
||||
Reference in New Issue
Block a user