Import Geant4 6.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 10:41:53 +02:00
parent 4aea781e80
commit 96686e0c8f
6560 changed files with 153347 additions and 238155 deletions
@@ -0,0 +1,73 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4NormalNavigation
//
// Class description:
//
// Utility for navigation in volumes containing only G4PVPlacement
// daughter volumes.
// History:
// - Created: Paul Kent, Aug 96
// --------------------------------------------------------------------
#ifndef G4AuxiliaryNavServices_hh
#define G4AuxiliaryNavServices_hh
#include "G4Types.hh"
#include "G4ThreeVector.hh"
#include "G4VSolid.hh"
#include "G4AffineTransform.hh"
class G4AuxiliaryNavServices
{
public: // with description
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,85 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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.icc,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4AuxiliaryNavServices Inline implementation
//
// --------------------------------------------------------------------
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;
EInside insideSolid = sampleSolid->Inside(localPoint);
if ( insideSolid!=kOutside )
{
G4bool checkDirection= locatedOnEdge && (globalDirection!=0);
if( (insideSolid==kSurface) && checkDirection)
{
// 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 )
{
if( sampleNormal.dot(localDirection) == 0 )
{
// We can't decide yet, let's make sure we're entering the solid.
// If by a confusion we entered the next solid we find out now
// whether to leave or to enter.
// This happens when we're on the surface or edge shared by two
// solids
//
G4double distanceToIn =
sampleSolid->DistanceToIn( localPoint, localDirection );
if( distanceToIn != kInfinity )
{
enter = true;
}
}
else
{
enter = true;
}
}
}
else
{
enter = true;
}
}
return enter;
}
@@ -0,0 +1,91 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4DrawVoxels.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4DrawVoxels
//
// Class description:
//
// Utility class for the visualization of voxels in the detector geometry.
// Define G4DrawVoxelsDebug in the environment at compilation for debugging
// information printed to G4cout.
// History:
// 03/08/1999 The G4VisAttributes have been made member data for lifetime
// reasons / visualisation - L.G (ask John Allison for further
// explanation).
// 29/07/1999 First comitted version - L.G.
// --------------------------------------------------------------------
#ifndef G4DrawVoxels_HH
#define G4DrawVoxels_HH
#include "G4VisAttributes.hh"
#include "G4VoxelLimits.hh"
#include "G4PlacedPolyhedron.hh"
class G4SmartVoxelHeader;
class G4LogicalVolume;
// ***********************************************************************
class G4DrawVoxels
{
public: // with description
G4DrawVoxels();
// Constructor. It initialises the members data to default colors
// Copy constructor and assignment operator not supported (array
// fvoxelcolours ...).
~G4DrawVoxels();
// Destructor NOT virtual. Not a base class.
void DrawVoxels(const G4LogicalVolume* lv) const;
G4PlacedPolyhedronList* CreatePlacedPolyhedra(const G4LogicalVolume*) const;
void SetVoxelsVisAttributes(G4VisAttributes&,
G4VisAttributes&,
G4VisAttributes&);
void SetBoundingBoxVisAttributes(G4VisAttributes&);
private:
// Member data
G4VisAttributes fVoxelsVisAttributes[3];
G4VisAttributes fBoundingBoxVisAttributes;
void ComputeVoxelPolyhedra(const G4LogicalVolume*,
const G4SmartVoxelHeader*,
G4VoxelLimits&,
G4PlacedPolyhedronList*) const;
// Copy constructor Assignment operator not supported
// (array fvoxelcolours ...)
G4DrawVoxels(const G4DrawVoxels&);
G4DrawVoxels operator=(const G4DrawVoxels&);
};
#endif
@@ -0,0 +1,109 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4GeomTestErrorList.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4GeomTestErrorList
//
// Class description:
//
// A list of line segments that are found inside two
// separate daughter volumes, indicating a geometry error.
//
// This class relies on the compiler generated copy constructor
// and assignment operator.
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4GeomTestErrorList_hh
#define G4GeomTestErrorList_hh
#include <vector>
#include "G4Types.hh"
#include "G4ThreeVector.hh"
#include "G4RotationMatrix.hh"
class G4VPhysicalVolume;
class G4GeomTestErrorList
{
public: // with description
G4GeomTestErrorList( const G4VPhysicalVolume *theMother );
virtual ~G4GeomTestErrorList();
// Constructor and virtual destructor
void AddError( const G4ThreeVector &s1, const G4ThreeVector &s2 );
// Declare a new instance of an error, by specifying
// two points in the coordinate system of the mother
const G4VPhysicalVolume *GetMother() const;
// Return pointers to mother volume
G4int NumError() const;
// Return number of errors
void GetMotherPoints( G4int i, G4ThreeVector &s1, G4ThreeVector &s2 ) const;
void GetGlobalPoints( G4int i, G4ThreeVector &s1, G4ThreeVector &s2 ) const;
// Return start and end points in various
// coordinate systems
void GetOneDaughtPoints( const G4VPhysicalVolume *daught,
G4int i, G4ThreeVector &s1, G4ThreeVector &s2 ) const;
// Return start and end points in the coordinate system of a
// daughter volume
private:
void FindGlobalCoordinateSystem();
// Calculate the global coordinate system
class Segment
{
public:
Segment( const G4ThreeVector &as1, const G4ThreeVector &as2 )
: s1(as1), s2(as2) {;}
const G4ThreeVector &GetS1() const { return s1; }
const G4ThreeVector &GetS2() const { return s2; }
private:
G4ThreeVector s1, s2;
};
std::vector<Segment> segments;
// List of error segments
const G4VPhysicalVolume *mother;
// Mother volume
G4ThreeVector globalTranslation;
G4RotationMatrix globalRotation;
// Global coordinate system with respect to mother
};
#endif
@@ -0,0 +1,75 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4GeomTestLogger.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4GeomTestLogger
//
// Class description:
//
// Abstract base class that defines the interface of a class that
// accepts error reports from the geometry test
//
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4GeomTestLogger_hh
#define G4GeomTestLogger_hh
#include "G4Types.hh"
#include "G4ThreeVector.hh"
class G4VSolid;
class G4GeomTestOverlapList;
class G4GeomTestOvershootList;
class G4GeomTestLogger
{
public: // with description
G4GeomTestLogger() {}
virtual ~G4GeomTestLogger() {}
// Constructor and virtual destructor
virtual void SolidProblem( const G4VSolid *solid,
const G4String &message,
const G4ThreeVector &point ) = 0;
// Accept an error from a local calculation of
// a solid, probably an inconsistency in geometry
virtual void NoProblem( const G4String &message ) = 0;
// Report a message of no error.
virtual void OverlappingDaughters( const G4GeomTestOverlapList *) = 0;
// Accept an error due to the overlap of two volumes
virtual void OvershootingDaughter( const G4GeomTestOvershootList *) = 0;
// Accept an error due to a daughter sticking outside
// a mother volume
};
#endif
@@ -0,0 +1,79 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4GeomTestOverlapList.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4GeomTestOverlapList
//
// Class description:
//
// A list of line segments that are found inside two
// separate daughter volumes, indicating a geometry
// overlap error.
//
// This class relies on the compiler generated copy constructor
// and assignment operator.
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4GeomTestOverlapList_hh
#define G4GeomTestOverlapList_hh
#include "G4GeomTestErrorList.hh"
class G4VPhysicalVolume;
class G4GeomTestOverlapList : public G4GeomTestErrorList
{
public: // with description
G4GeomTestOverlapList();
G4GeomTestOverlapList( const G4VPhysicalVolume *theMother,
G4int theDaughter1, G4int theDaughter2 );
virtual ~G4GeomTestOverlapList();
// Constructors and virtual destructor
G4bool operator==( const G4GeomTestOverlapList &other ) const;
G4bool operator< ( const G4GeomTestOverlapList &other ) const;
// Comparison operators, based on daughter index numbers
const G4VPhysicalVolume *GetDaughter1() const;
const G4VPhysicalVolume *GetDaughter2() const;
G4int GetDaughter1Index() const;
G4int GetDaughter2Index() const;
// Return pointers to volumes
void GetDaught1Points( G4int, G4ThreeVector &, G4ThreeVector & ) const;
void GetDaught2Points( G4int, G4ThreeVector &, G4ThreeVector & ) const;
// Return start and end points in various coordinate systems
private:
G4int daughter1, daughter2;
};
#endif
@@ -0,0 +1,71 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4GeomTestOvershootList.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4GeomTestOvershootList
//
// Class description:
//
// A list of line segments inside a specific volume daughter
// but outside its mother volume, indicating a geometry error
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4GeomTestOvershootList_hh
#define G4GeomTestOvershootList_hh
#include "G4GeomTestErrorList.hh"
class G4GeomTestOvershootList : public G4GeomTestErrorList
{
public: // with description
G4GeomTestOvershootList();
G4GeomTestOvershootList( const G4VPhysicalVolume *theMother,
G4int theDaughter );
virtual ~G4GeomTestOvershootList();
// Constructors and virtual destructor
G4bool operator==( const G4GeomTestOvershootList &other ) const;
G4bool operator< ( const G4GeomTestOvershootList &other ) const;
// Comparison operators, based on daughter index
const G4VPhysicalVolume *GetDaughter() const;
G4int GetDaughterIndex() const;
// Return pointers to volumes
void GetDaughtPoints( G4int i, G4ThreeVector &s1, G4ThreeVector &s2 ) const;
// Return start and end points in various
// coordinate systems
private:
G4int daughter;
};
#endif
@@ -0,0 +1,76 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4GeomTestPoint.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4GeomTestPoint
//
// Class description:
//
// A point on a line segment intersecting a solid, used
// for geometry tests
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4GeomTestPoint_hh
#define G4GeomTestPoint_hh
#include "G4Types.hh"
#include "G4ThreeVector.hh"
class G4VSolid;
class G4GeomTestPoint
{
public: // with description
G4GeomTestPoint();
G4GeomTestPoint( const G4GeomTestPoint &other );
G4GeomTestPoint( const G4ThreeVector &thePoint,
G4double theS,
G4bool isEntering );
virtual ~G4GeomTestPoint();
// Constructors and virtual destructor
G4bool operator==( const G4GeomTestPoint &other ) const;
G4bool operator< ( const G4GeomTestPoint &other ) const;
G4bool operator<=( const G4GeomTestPoint &other ) const;
// Operators
virtual const G4ThreeVector &GetPosition() const;
virtual G4double GetDistance() const;
virtual G4bool Entering() const;
// Accessors
protected:
G4ThreeVector p;
G4double s;
G4bool entering;
};
#endif
@@ -0,0 +1,80 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4GeomTestSegment.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4GeomTestSegment
//
// Class description:
//
// Locate all points on a line that intersect a solid,
// and return them in no particular order
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4GeomTestSegment_hh
#define G4GeomTestSegment_hh
#include "G4Types.hh"
#include "G4ThreeVector.hh"
#include "G4GeomTestPoint.hh"
#include <vector>
class G4VSolid;
class G4GeomTestLogger;
class G4GeomTestSegment
{
public: // with description
G4GeomTestSegment( const G4VSolid *theSolid,
const G4ThreeVector &theP,
const G4ThreeVector &theV,
G4GeomTestLogger *logger );
// Constructor
const G4VSolid *GetSolid() const;
const G4ThreeVector &GetP() const;
const G4ThreeVector &GetV() const;
const G4GeomTestPoint &GetPoint( G4int i ) const;
G4int GetNumberPoints() const;
// Accessors
private:
void FindPoints( G4GeomTestLogger *logger );
void FindSomePoints( G4GeomTestLogger *logger, G4bool forward );
void PatchInconsistencies( G4GeomTestLogger *logger );
const G4VSolid * solid;
const G4ThreeVector p0,v;
std::vector<G4GeomTestPoint> points;
};
#endif
@@ -0,0 +1,109 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4GeomTestStreamLogger.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4GeomTestStreamLogger
//
// Class description:
//
// A G4GeomTestLogger that outputs to a stream.
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4GeomTestStreamLogger_hh
#define G4GeomTestStreamLogger_hh
#include "G4Types.hh"
#include "G4GeomTestLogger.hh"
class G4VPhysicalVolume;
class G4GeomTestStreamLogger : public G4GeomTestLogger
{
public: // with description
G4GeomTestStreamLogger( std::ostream &o,
G4int theMaxPointsPerError=20 );
virtual ~G4GeomTestStreamLogger();
// Constructors and virtual destructor
virtual void SolidProblem( const G4VSolid *solid,
const G4String &message,
const G4ThreeVector &point );
virtual void OverlappingDaughters( const G4GeomTestOverlapList *list );
virtual void OvershootingDaughter( const G4GeomTestOvershootList *list );
virtual void NoProblem ( const G4String &message );
protected:
void PrintSegmentListHeader();
void PrintSegmentListElement( const G4ThreeVector &s1,
const G4ThreeVector &s2 );
// Format aides
const char *IsAre(G4int n);
public: // Solaris 7 insists on these guys being public
class PrintPos
{
public:
PrintPos(const G4ThreeVector pos, G4bool useUnit=true )
: p(pos), unit(useUnit) {;}
void Print( std::ostream & ) const;
private:
G4ThreeVector p;
G4bool unit;
};
class VolumeNameAndCopy
{
public:
VolumeNameAndCopy( const G4VPhysicalVolume *theVolume )
: volume(theVolume) {;}
void Print( std::ostream & ) const;
private:
const G4VPhysicalVolume *volume;
};
friend std::ostream &operator<<( std::ostream &,
const G4GeomTestStreamLogger::PrintPos & );
friend std::ostream &operator<<( std::ostream &,
const G4GeomTestStreamLogger::VolumeNameAndCopy & );
protected:
std::ostream &out;
G4int maxPointsPerError;
};
#endif
@@ -0,0 +1,73 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4GeomTestVolPoint.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4GeomTestVolPoint
//
// Class description:
//
// A point on a line segment intersecting a physical solid, used
// for geometry tests.
// A negative daughter index indicates the mother volume itself.
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4GeomTestVolPoint_hh
#define G4GeomTestVolPoint_hh
#include "G4GeomTestPoint.hh"
#include "G4RotationMatrix.hh"
class G4GeomTestVolPoint : public G4GeomTestPoint
{
public: // with description
G4GeomTestVolPoint();
G4GeomTestVolPoint( const G4ThreeVector &thePoint,
G4double theS,
G4bool isEntering,
G4int theDaughterIndex );
G4GeomTestVolPoint( const G4GeomTestPoint &base,
G4int theDaughterIndex );
G4GeomTestVolPoint( const G4GeomTestPoint &base,
G4int theDaughterIndex,
const G4ThreeVector &translation,
const G4RotationMatrix *rotation=0 );
G4GeomTestVolPoint( const G4GeomTestVolPoint &other );
virtual ~G4GeomTestVolPoint();
// Constructors and virtual destructor
G4int GetDaughterIndex() const;
// Accessors
protected:
G4int daughterIndex;
};
#endif
@@ -0,0 +1,175 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4GeomTestVolume.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4GeomTestVolume
//
// Class description:
//
// Checks for inconsistencies in the geometric boundaries of a physical
// volume and the boundaries of all its immediate daughters.
// Author: D.C.Williams, UCSC (davidw@scipp.ucsc.edu)
// --------------------------------------------------------------------
#ifndef G4GeomTestVolume_hh
#define G4GeomTestVolume_hh
#include "G4ThreeVector.hh"
#include "G4VisExtent.hh"
#include "G4GeomTestOverlapList.hh"
#include "G4GeomTestOvershootList.hh"
#include <map>
class G4VPhysicalVolume;
class G4GeomTestLogger;
class G4GeomTestVolume
{
public: // with description
G4GeomTestVolume( const G4VPhysicalVolume *theTarget,
G4GeomTestLogger *theLogger,
G4double theTolerance=1E-4*mm );
~G4GeomTestVolume();
// Constructor and destructor
G4double GetTolerance() const;
void SetTolerance(G4double tolerance);
// Get/Set error tolerance (default set to 1E-4*mm)
void TestCartGridXYZ( G4int nx=100, G4int ny=100, G4int nz=100 );
void TestCartGridX( G4int ny=100, G4int nz=100 );
void TestCartGridY( G4int nz=100, G4int nx=100 );
void TestCartGridZ( G4int nx=100, G4int ny=100 );
// Test using a grid of lines parallel to a cartesian axis
void TestCartGrid( const G4ThreeVector &g1,
const G4ThreeVector &g2,
const G4ThreeVector &v,
G4int n1,
G4int n2 );
// Test using a grid of parallel lines
// g1 = First grid axis
// g2 = Second grid axis
// v = Direction of lines
// n1 = Number of grid points along g1
// n2 = Number of grid points along g2
// The spread of the grid points are automatically calculated
// based on the extent of the solid
void TestRecursiveCartGrid( G4int nx=100, G4int ny=100, G4int nz=100,
G4int sLevel=0, G4int depth=-1 );
// Test using a grid, propagating recursively to the daughters, with
// possibility of specifying the initial level in the volume tree and
// the depth (default is the whole tree).
// Be careful: depending on the complexity of the geometry, this
// could require long computational time
void TestCylinder( G4int nPhi=90, G4int nZ=50, G4int nRho=50,
G4double fracZ=0.8, G4double fracRho=0.8,
G4bool usePhi=false );
// Test using a set of lines in a cylindrical
// pattern of gradually increasing mesh size
// nPhi = Number lines per phi
// nZ = Number of z points
// nRho = Number of rho points
// fracZ = Fraction scale for points along z
// fracRho = Fraction scale for points along rho
// usePhi = Include phi set of lines
// Define a set of rho values such that:
// rho0 = Size of volume
// rho1 = frac*rho0
// rho2 = frac*rho1
// ... etc
// And define a set of z values
// z0 = z size of volume
// z1 = fracZ*z0
// z2 = fracZ*z1
// .... etc
// And define a set of nPhi phi values, evenly
// distributed in phi
//
// Three sets of lines are tested:
// * Imagine the set of lines parallel to the z axis
// through each rho point, at a phi angle taken the
// set of phi angles
// * Imagine the set of lines running perpendicular
// to the z axis and through a point on the z axis
// at +/- each z point and at an angle taken from the
// set of phi values
// * If usePhi==true, now take each pair of lines from the
// above two sets and imagine the line through the
// intersection and perpendicular to both
void TestRecursiveCylinder( G4int nPhi=90, G4int nZ=50, G4int nRho=50,
G4double fracZ=0.8, G4double fracRho=0.8,
G4bool usePhi=false,
G4int sLevel=0, G4int depth=-1 );
// Test using a set of lines in a cylindrical pattern of gradually
// increasing mesh size, propagating recursively to the daughters, with
// possibility of specifying the initial level in the volume tree and
// the depth (default is the whole tree).
// Be careful: depending on the complexity of the geometry, this
// could require long computational time
void TestOneLine( const G4ThreeVector &p, const G4ThreeVector &v );
// Test using a single line, specified by a point and direction,
// in the coordinate system of the target volume
void TestRecursiveLine( const G4ThreeVector &p, const G4ThreeVector &v,
G4int sLevel=0, G4int depth=-1 );
// Test using a single line, specified by a point and direction,
// propagating recursively to the daughters, with possibility of
// specifying the initial level in the volume tree and
// the depth (default is the whole tree).
void ReportErrors();
// Tabulate and report all errors so far encountered
void ClearErrors();
// Clear list of errors
protected:
const G4VPhysicalVolume *target; // Target volume
G4GeomTestLogger *logger; // Error logger
G4double tolerance; // Error tolerance
G4VisExtent extent; // Geometric extent of volume
std::map<G4long,G4GeomTestOverlapList> overlaps;
// A list of overlap errors, keyed by the
// daughter1*numDaughter+daughter2, where daughter1
// is the smaller of the two daughter indices
std::map<G4long,G4GeomTestOvershootList> overshoots;
// A list of overshoot errors, keyed by the
// daughter number
};
#endif
@@ -0,0 +1,103 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4GeometryMessenger.hh,v 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
// G4GeometryMessenger
//
// Class description:
//
// A messenger defining commands for debugging, verifying
// and controlling the detector geometry and navigation.
// Author: G.Cosmo, CERN.
// --------------------------------------------------------------------
#ifndef G4GeometryMessenger_hh
#define G4GeometryMessenger_hh
#include "G4Types.hh"
#include "G4UImessenger.hh"
#include "G4ThreeVector.hh"
class G4UIdirectory;
class G4UIcommand;
class G4UIcmdWith3VectorAndUnit;
class G4UIcmdWith3Vector;
class G4UIcmdWithoutParameter;
class G4UIcmdWithABool;
class G4UIcmdWithAnInteger;
class G4UIcmdWithADouble;
class G4UIcmdWithADoubleAndUnit;
class G4TransportationManager;
class G4GeomTestStreamLogger;
class G4GeomTestVolume;
class G4GeometryMessenger : public G4UImessenger
{
public: // with description
G4GeometryMessenger(G4TransportationManager* tman);
~G4GeometryMessenger();
// Constructor and destructor
void SetNewValue( G4UIcommand* command, G4String newValues );
G4String GetCurrentValue( G4UIcommand* command );
private:
void Init();
void CheckGeometry();
void ResetNavigator();
void SetVerbosity(G4String newValue);
void LineTest();
void RecursiveLineTest();
void GridTest();
void RecursiveGridTest();
void CylinderTest();
void RecursiveCylinderTest();
G4UIdirectory *geodir, *navdir, *testdir;
G4UIcmdWith3VectorAndUnit *posCmd, *dirCmd;
G4UIcmdWith3Vector *grzCmd, *cyzCmd;
G4UIcmdWithABool *linCmd, *grdCmd, *cylCmd, *runCmd;
G4UIcmdWithoutParameter *recCmd, *resCmd;
G4UIcmdWithADoubleAndUnit *tolCmd;
G4UIcmdWithAnInteger *verbCmd, *rcsCmd, *rcdCmd;
G4UIcmdWithADouble *cfzCmd, *cfrCmd;
G4ThreeVector x, p, grdRes, cylRes;
G4double cylfZ, cylfR;
G4bool newtol;
G4double tol;
G4int recLevel, recDepth;
G4TransportationManager* tmanager;
G4GeomTestStreamLogger* tlogger;
G4GeomTestVolume* tvolume;
};
#endif
@@ -0,0 +1,407 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.4 2003/11/10 08:58:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4Navigator
//
// Class description:
//
// 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.
//
// NOTES:
//
// The following methods provide 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()
// G4bool IsExitNormalValid()
// G4ThreeVector GetLocalExitNormal()
//
// 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.
// History:
// - Created. Paul Kent, July 95/96
// ********************************************************************
#ifndef G4NAVIGATOR_HH
#define G4NAVIGATOR_HH
#include "geomdefs.hh"
#include "G4ThreeVector.hh"
#include "G4AffineTransform.hh"
#include "G4RotationMatrix.hh"
#include "G4LogicalVolume.hh" // Used in inline methods
#include "G4GRSVolume.hh" // " "
#include "G4GRSSolid.hh" // " "
#include "G4TouchableHandle.hh" // " "
#include "G4TouchableHistoryHandle.hh"
#include "G4NavigationHistory.hh"
#include "G4NormalNavigation.hh"
#include "G4VoxelNavigation.hh"
#include "G4ParameterisedNavigation.hh"
#include "G4ReplicaNavigation.hh"
#include <iostream>
class G4VPhysicalVolume;
class G4Navigator
{
public: // with description
friend std::ostream& operator << (std::ostream &os, const G4Navigator &n);
G4Navigator();
// Constructor - initialisers and setup.
virtual ~G4Navigator();
// Destructor. No actions.
virtual G4double ComputeStep(const G4ThreeVector &pGlobalPoint,
const G4ThreeVector &pDirection,
const G4double pCurrentProposedStepLength,
G4double &pNewSafety);
// Calculate the distance to the next boundary intersected
// along the specified NORMALISED vector direction and
// from the specified point in the global coordinate
// 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.
virtual
G4VPhysicalVolume* ResetHierarchyAndLocate(const G4ThreeVector &point,
const G4ThreeVector &direction,
const G4TouchableHistory &h);
// Resets the geometrical hierarchy and search for the volumes deepest
// in the hierarchy containing the point in the global coordinate space.
// The direction is used to check if a volume is entered.
// 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.
//
// Important Note: In order to call this the geometry MUST be closed.
G4VPhysicalVolume* LocateGlobalPointAndSetup(const G4ThreeVector& point,
const G4ThreeVector* direction=0,
const G4bool pRelativeSearch=true,
const G4bool ignoreDirection=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) if either
// - the argument ignoreDirection is false, or
// - the Navigator has determined that it is on an edge shared by two or
// more volumes. (This is state information.)
//
// Important Note: In order to call this the geometry MUST be closed.
virtual void LocateGlobalPointWithinVolume(const G4ThreeVector& position);
// Notify the Navigator that a track has moved to the new Global point
// 'position', that is known 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.
virtual void LocateGlobalPointAndUpdateTouchableHandle(
const G4ThreeVector& position,
const G4ThreeVector& direction,
G4TouchableHandle& oldTouchableToUpdate,
const G4bool RelativeSearch = true);
// First, search the geometrical hierarchy like the above method
// LocateGlobalPointAndSetup(). Then use the volume found and its
// navigation history to update the touchable.
inline void LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
const G4ThreeVector& direction,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch = true);
// First, search the geometrical hierarchy like the above method
// LocateGlobalPointAndSetup(). Then use the volume found and its
// navigation history to update the touchable.
inline void LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch = true);
// Old version (missing direction).
// Not recommended replace with newer version above.
inline void SetGeometricallyLimitedStep();
// Inform the navigator that the previous Step calculated
// by the geometry was taken in its entirety.
virtual 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.
inline G4VPhysicalVolume* GetWorldVolume() const;
// Return the current world (`topmost') volume.
inline void SetWorldVolume(G4VPhysicalVolume* pWorld);
// Set the world (`topmost') volume. This must be positioned at
// origin (0,0,0) and unrotated.
inline G4GRSVolume* CreateGRSVolume() const;
inline G4GRSSolid* CreateGRSSolid() const;
inline G4TouchableHistory* CreateTouchableHistory() const;
// `Touchable' creation methods: caller has deletion responsibility.
virtual G4TouchableHistoryHandle CreateTouchableHistoryHandle() const;
// Returns a reference counted handle to a touchable history.
virtual G4ThreeVector GetLocalExitNormal(G4bool* valid);
// Returns Exit Surface Normal and validity too.
// It can only be called if the Navigator's last Step has crossed a
// volume 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.
inline G4int GetVerboseLevel();
inline void SetVerboseLevel(G4int level);
// Get/Set Verbose(ness) level.
// [if level>0 && G4VERBOSE, printout can occur]
void PrintState();
// Print the internal state of the Navigator (for debugging).
// The level of detail is according to the verbosity.
inline const G4AffineTransform& GetGlobalToLocalTransform() const;
inline const G4AffineTransform GetLocalToGlobalTransform() const;
// Obtain the transformations Global/Local (and inverse).
// Clients of these methods must copy the data if they need to keep it.
inline void ResetStackAndState();
// Reset stack and minimum or navigator state machine necessary for reset
// as needed by LocalGlobalPointAndSetup.
// [Does not perform clears, resizes, or reset fLastLocatedPointLocal]
protected: // with description
inline G4ThreeVector GetCurrentLocalCoordinate() const;
// Return the local coordinate of the point in the reference system
// of its containing volume that was found by LocalGlobalPointAndSetup.
// The local coordinate of the last located track.
inline G4ThreeVector ComputeLocalPoint(const G4ThreeVector& rGlobPoint) const;
// Return position vector in local coordinate system, given a position
// vector in world coordinate system.
inline G4ThreeVector ComputeLocalAxis(const G4ThreeVector& pVec) const;
// Return the local direction of the specified vector in the reference
// system of the volume that was found by LocalGlobalPointAndSetup.
// The Local Coordinates of point in world coordinate system.
inline G4ThreeVector NetTranslation() const;
inline G4RotationMatrix NetRotation() const;
// Compute+return the local->global translation/rotation of current volume.
inline 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), i.e. in all other cases.
// This function is not guaranteed to work if SetGeometricallyLimitedStep()
// was not called when it should have been called.
virtual void ResetState();
// Utility method to reset the navigator state machine.
inline EVolume VolumeType(const G4VPhysicalVolume *pVol) const;
// Characterise `type' of volume - normal/replicated/parameterised.
inline EVolume CharacteriseDaughters(const G4LogicalVolume *pLog) const;
// Characterise daughter of logical volume.
virtual void SetupHierarchy();
// Renavigate & reset hierarchy described by current history
// o Reset volumes
// o Recompute transforms and/or solids of replicated/parameterised
// volumes.
private:
//
// BEGIN State information
//
G4ThreeVector fLastLocatedPointLocal;
// Position of the last located point relative to its containing volume.
G4bool fWasLimitedByGeometry;
// Set true if last Step was limited by geometry.
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;
G4VPhysicalVolume *fCandidatePhysicalVolume;
G4int fCandidateReplicaNo;
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
G4ThreeVector fGrandMotherExitNormal; // Leaving volume normal, in its
// own 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
//
G4VPhysicalVolume *fTopPhysical;
// A link to the topmost physical volume in the detector.
// Must be positioned at the origin and unrotated.
//
// 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,349 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.4 2003/11/10 08:58:42 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4Navigator Inline implementation
//
// ********************************************************************
// ********************************************************************
// GetCurrentLocalCoordinate
//
// Returns the local coordinate of the current track
// ********************************************************************
//
inline
G4ThreeVector G4Navigator::GetCurrentLocalCoordinate() const
{
return fLastLocatedPointLocal;
}
// ********************************************************************
// ComputeLocalAxis
//
// Returns 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 ;
}
// ********************************************************************
// ComputeLocalPoint
//
// Returns local coordinates of a point in the world coord system
// ********************************************************************
//
inline
G4ThreeVector
G4Navigator::ComputeLocalPoint(const G4ThreeVector& pGlobalPoint) const
{
return ( fHistory.GetTopTransform().TransformPoint(pGlobalPoint) ) ;
}
// ********************************************************************
// GetWorldVolume
//
// Returns the current world (`topmost') volume
// ********************************************************************
//
inline
G4VPhysicalVolume* G4Navigator::GetWorldVolume() const
{
return fTopPhysical;
}
// ********************************************************************
// SetWorldVolume
//
// Sets the world (`topmost') volume
// ********************************************************************
//
inline
void G4Navigator::SetWorldVolume(G4VPhysicalVolume* pWorld)
{
if ( !(pWorld->GetTranslation()==G4ThreeVector(0,0,0)) )
{
G4Exception ("G4Navigator::SetWorldVolume()", "InvalidSetup",
FatalException, "Volume must be centered on the origin.");
}
const G4RotationMatrix* rm = pWorld->GetRotation();
if ( rm && (!rm->isIdentity()) )
{
G4Exception ("G4Navigator::SetWorldVolume()", "InvalidSetup",
FatalException, "Volume must not be rotated.");
}
fTopPhysical = pWorld;
fHistory.SetFirstEntry(pWorld);
}
// ********************************************************************
// SetGeometrycallyLimitedStep
//
// Informs the navigator that the previous Step calculated
// by the geometry was taken in its entirety
// ********************************************************************
//
inline
void G4Navigator::SetGeometricallyLimitedStep()
{
fWasLimitedByGeometry=true;
}
// ********************************************************************
// ResetStackAndState
//
// Resets stack and minimum of navigator state `machine'
// ********************************************************************
//
inline
void G4Navigator::ResetStackAndState()
{
fHistory.Reset();
ResetState();
}
// ********************************************************************
// VolumeType
// ********************************************************************
//
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;
}
// ********************************************************************
// CharacteriseDahghters
// ********************************************************************
//
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;
}
// ********************************************************************
// GetGlobalToLocalTransform
//
// Returns local to global transformation.
// I.e. 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();
}
// ********************************************************************
// GetLocalToGlobalTransform
//
// Returns global to local transformation
// ********************************************************************
//
inline
const G4AffineTransform G4Navigator::GetLocalToGlobalTransform() const
{
G4AffineTransform tempTransform;
tempTransform = fHistory.GetTopTransform().Inverse();
return tempTransform;
}
// ********************************************************************
// NetTranslation
//
// Computes+returns the local->global translation of current volume
// ********************************************************************
//
inline
G4ThreeVector G4Navigator::NetTranslation() const
{
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
return tf.NetTranslation();
}
// ********************************************************************
// NetRotation
//
// Computes+returns the local->global rotation of current volume
// ********************************************************************
//
inline
G4RotationMatrix G4Navigator::NetRotation() const
{
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
return tf.NetRotation();
}
// ********************************************************************
// CreateGRSVolume
//
// `Touchable' creation method: caller has deletion responsibility
// ********************************************************************
//
inline
G4GRSVolume* G4Navigator::CreateGRSVolume() const
{
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
return new G4GRSVolume(fHistory.GetTopVolume(),
tf.NetRotation(),
tf.NetTranslation());
}
// ********************************************************************
// CreateGRSSolid
//
// `Touchable' creation method: caller has deletion responsibility
// ********************************************************************
//
inline
G4GRSSolid* G4Navigator::CreateGRSSolid() const
{
G4AffineTransform tf(fHistory.GetTopTransform().Inverse());
return new G4GRSSolid(fHistory.GetTopVolume()->GetLogicalVolume()->GetSolid(),
tf.NetRotation(),
tf.NetTranslation());
}
// ********************************************************************
// CreateTouchableHistory
//
// `Touchable' creation method: caller has deletion responsibility
// ********************************************************************
//
inline
G4TouchableHistory* G4Navigator::CreateTouchableHistory() const
{
return new G4TouchableHistory(fHistory);
}
// ********************************************************************
// EnteredDaughterVolume
//
// To inform the caller if the track is entering a daughter volume
// ********************************************************************
//
inline
G4bool G4Navigator::EnteredDaughterVolume()
{
return fEnteredDaughter;
}
// ********************************************************************
// LocateGlobalPointAndUpdateTouchable
//
// Use direction
// ********************************************************************
//
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 );
}
// ********************************************************************
// LocateGlobalPointAndUpdateTouchable
// ********************************************************************
//
inline
void G4Navigator::LocateGlobalPointAndUpdateTouchable(
const G4ThreeVector& position,
G4VTouchable* touchableToUpdate,
const G4bool RelativeSearch )
{
G4VPhysicalVolume* pPhysVol;
pPhysVol = LocateGlobalPointAndSetup( position, 0, RelativeSearch);
touchableToUpdate->UpdateYourself( pPhysVol, &fHistory );
}
// ********************************************************************
// GetVerboseLevel
// ********************************************************************
//
inline
G4int G4Navigator::GetVerboseLevel()
{
return fVerbose;
}
// ********************************************************************
// SetVerboseLevel
// ********************************************************************
//
inline
void G4Navigator::SetVerboseLevel(G4int level)
{
fVerbose = level;
}
@@ -0,0 +1,85 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4NormalNavigation
//
// Class description:
//
// Utility for navigation in volumes containing only G4PVPlacement
// daughter volumes.
// History:
// - Created. Paul Kent, Aug 96
// --------------------------------------------------------------------
#ifndef G4NORMALNAVIGATION_HH
#define G4NORMALNAVIGATION_HH
#include "G4NavigationHistory.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4ThreeVector.hh"
#include "G4AuxiliaryNavServices.hh" // Needed for inline methods
class G4NormalNavigation
{
public: // with description
G4bool LevelLocate( G4NavigationHistory &history,
const G4VPhysicalVolume *blockedVol,
const G4int blockedNum,
const G4ThreeVector &globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector &localPoint);
// 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.
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 "G4NormalNavigation.icc"
#endif
@@ -0,0 +1,88 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// G4NormalNavigation Inline Implementation
//
// --------------------------------------------------------------------
// ********************************************************************
// LevelLocate
// ********************************************************************
//
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;
targetPhysical = history.GetTopVolume();
targetLogical = targetPhysical->GetLogicalVolume();
targetNoDaughters = targetLogical->GetNoDaughters();
if (targetNoDaughters==0) return false;
//
// Search daughters in volume
//
for ( register int sampleNo=targetNoDaughters-1; sampleNo>=0; sampleNo-- )
{
samplePhysical = targetLogical->GetDaughter(sampleNo);
if ( samplePhysical!=blockedVol )
{
// Setup history
//
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
//
localPoint = samplePoint;
return true;
}
else
{
history.BackLevel();
}
}
}
return false;
}
@@ -0,0 +1,111 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4ParameterisedNavigation
//
// Class description:
//
// 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]
// History:
// - Created. Paul Kent, Aug 96
// --------------------------------------------------------------------
#ifndef G4PARAMETERISEDNAVIGATION_HH
#define G4PARAMETERISEDNAVIGATION_HH
#include "G4Types.hh"
#include <vector>
#include "G4VoxelNavigation.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"
class G4ParameterisedNavigation : public G4VoxelNavigation
{
public: // with description
G4ParameterisedNavigation();
~G4ParameterisedNavigation();
G4SmartVoxelNode* ParamVoxelLocate( 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 EAxis pAxis ) const;
G4bool LocateNextVoxel( const G4ThreeVector& localPoint,
const G4ThreeVector& localDirection,
const G4double currentStep,
const EAxis pAxis );
private:
// Voxel Stack information (for 1D optimisation only)
//
EAxis fVoxelAxis;
G4int fVoxelNoSlices;
G4double fVoxelSliceWidth;
G4int fVoxelNodeNo;
G4SmartVoxelHeader* fVoxelHeader;
};
#include "G4ParameterisedNavigation.icc"
#endif
@@ -0,0 +1,162 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:20 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4ParameterisedNavigation Inline implementation
//
// --------------------------------------------------------------------
// ********************************************************************
// ParamVoxelLocate
// ********************************************************************
//
inline
G4SmartVoxelNode*
G4ParameterisedNavigation::ParamVoxelLocate( G4SmartVoxelHeader* pHead,
const G4ThreeVector& localPoint )
{
// If no parameterisation axis is specified, adopt default
// location strategy as for placements
//
if ( pHead->GetParamAxis()==kUndefined )
{
fVoxelNode = G4VoxelNavigation::VoxelLocate(pHead,localPoint);
}
else
{
G4double targetHeaderMin, targetHeaderNodeWidth;
G4int targetHeaderNoSlices, targetNodeNo;
EAxis targetHeaderAxis;
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;
}
// ********************************************************************
// LevelLocate
// ********************************************************************
//
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, replicaNo;
motherPhysical = history.GetTopVolume();
motherLogical = motherPhysical->GetLogicalVolume();
motherVoxelHeader = motherLogical->GetVoxelHeader();
// Find the voxel containing the point
//
motherVoxelNode = ParamVoxelLocate(motherVoxelHeader,localPoint);
voxelNoDaughters = motherVoxelNode->GetNoContained();
if ( voxelNoDaughters==0 ) return false;
pPhysical = motherLogical->GetDaughter(0);
pParam = pPhysical->GetParameterisation();
// Search replicated daughter volume
//
for ( register int 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 history
//
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
//
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,276 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4PropagatorInField.hh,v 1.7 2003/11/26 14:45:04 japost Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// class G4PropagatorInField
//
// Class description:
//
// This class performs the navigation/propagation of a particle/track
// in a magnetic field. The field is in general non-uniform.
// For the calculation of the path, it relies on the class G4ChordFinder.
//
// Key Method:
// ComputeStep(..)
// History:
// -------
// 25.10.96 John Apostolakis, design and implementation
// 25.03.97 John Apostolakis, adaptation for G4Transportation and cleanup
// 8.11.02 John Apostolakis, changes to enable use of safety in intersecting
// ---------------------------------------------------------------------------
#ifndef G4PropagatorInField_hh
#define G4PropagatorInField_hh 1
#include "G4Types.hh"
#include <vector>
#include "G4FieldTrack.hh"
#include "G4FieldManager.hh"
class G4ChordFinder;
class G4Navigator;
class G4VPhysicalVolume;
class G4VCurvedTrajectoryFilter;
class G4PropagatorInField
{
public: // with description
G4PropagatorInField( G4Navigator *theNavigator,
G4FieldManager *detectorFieldMgr );
~G4PropagatorInField();
G4double ComputeStep( G4FieldTrack &pFieldTrack,
G4double pCurrentProposedStepLength,
G4double &pNewSafety,
G4VPhysicalVolume *pPhysVol=0 );
// Compute the next geometric Step
inline G4ThreeVector EndPosition() const;
inline G4ThreeVector EndMomentumDir() const;
inline G4bool IsParticleLooping() const;
// Return the state after the Step
inline G4double GetEpsilonStep() const;
// Relative accuracy for current Step (Calc.)
inline void SetEpsilonStep(G4double newEps);
// The ratio DeltaOneStep()/h_current_step
inline void SetChargeMomentumMass( G4double charge, // in e+ units
G4double momentum, // in Geant4 units
G4double pMass );
// Inform this and all associated classes of q, p, m
G4FieldManager* FindAndSetFieldManager(G4VPhysicalVolume* pCurrentPhysVol);
// Set (and return) the correct field manager (global or local),
// if it exists.
// Should be called before ComputeStep is called;
// - currently, ComputeStep will call it, if it has not been called.
inline G4ChordFinder* GetChordFinder();
inline G4int SetVerboseLevel( G4int verbose );
inline G4int GetVerboseLevel() const;
inline G4int Verbose() const;
inline G4int GetMaxLoopCount() const;
inline void SetMaxLoopCount( G4int new_max );
// A maximum for the number of steps that a (looping) particle can take.
void printStatus( const G4FieldTrack& startFT,
const G4FieldTrack& currentFT,
G4double requestStep,
G4double safety,
G4int step,
G4VPhysicalVolume* startVolume);
// Print Method - useful mostly for debugging.
inline G4FieldTrack GetEndState() const;
// The following methods are now obsolescent but *for now* will work
// They are being replaced by same-name methods in G4FieldManager,
// allowing the specialisation in different volumes.
// Their new behaviour is to change the values for the global field manager.
inline G4double GetMinimumEpsilonStep() const;
inline void SetMinimumEpsilonStep( G4double newEpsMin );
// Minimum for Relative accuracy of any Step
inline G4double GetMaximumEpsilonStep() const;
inline void SetMaximumEpsilonStep( G4double newEpsMax );
inline void SetLargestAcceptableStep( G4double newBigDist );
inline G4double GetLargestAcceptableStep();
public: // with description
// The following methods are obsolete and will not work --
// as they have been replaced by the same methods in G4FieldManager
// since Geant4 4.0
inline G4double GetDeltaIntersection() const;
inline G4double GetDeltaOneStep() const;
inline void SetAccuraciesWithDeltaOneStep( G4double deltaOneStep );
inline void SetDeltaIntersection( G4double deltaIntersection );
inline void SetDeltaOneStep( G4double deltaOneStep );
public: // without description
inline G4FieldManager* GetCurrentFieldManager();
public: // no description
inline void SetThresholdNoZeroStep( G4int noAct,
G4int noHarsh,
G4int noAbandon );
inline G4int GetThresholdNoZeroSteps( G4int i );
public: // with description
//
void SetTrajectoryFilter(G4VCurvedTrajectoryFilter* filter);
// Set the filter that examines & stores 'intermediate'
// curved trajectory points. Currently only position is stored.
std::vector<G4ThreeVector>* GimmeTrajectoryVectorAndForgetIt() const;
// Access the points which have passed by the filter.
// Responsibility for deleting the points lies with the client.
// This method MUST BE called exactly ONCE per step.
void ClearPropagatorState();
// Clear all the State of this class and its current associates
// --> the current field manager & chord finder will also be called
inline void SetDetectorFieldManager( G4FieldManager* newGlobalFieldManager );
// Update this (dangerous) state -- for the time being
inline void SetUseSafetyForOptimization( G4bool );
inline G4bool GetUseSafetyForOptimization();
// Toggle & view parameter for using safety to discard
// unneccesary calls to navigator (thus 'optimising' performance)
protected: // with description
G4bool LocateIntersectionPoint(
const G4FieldTrack& curveStartPointTangent, // A
const G4FieldTrack& curveEndPointTangent, // B
const G4ThreeVector& trialPoint, // E
G4FieldTrack& intersectPointTangent, // Output
G4bool& recalculatedEndPoint); // Out:
// If such an intersection exists, this function
// calculate the intersection point of the true path of the particle
// with the surface of the current volume (or of one of its daughters).
// (Should use lateral displacement as measure of convergence).
G4bool IntersectChord( G4ThreeVector StartPointA,
G4ThreeVector EndPointB,
G4double &NewSafety,
G4double &LinearStepLength,
G4ThreeVector &IntersectionPoint);
// Intersect the chord from StartPointA to EndPointB
// and return whether an intersection occurred
G4FieldTrack ReEstimateEndpoint( const G4FieldTrack &CurrentStateA,
const G4FieldTrack &EstimtdEndStateB,
G4double linearDistSq,
G4double curveDist);
// Return new estimate for state after curveDist
// starting from CurrentStateA, to replace EstimtdEndStateB,
// (and report displacement -- if field is compiled verbose.)
void PrintStepLengthDiagnostic( G4double currentProposedStepLength,
G4double decreaseFactor,
G4double stepTrial,
const G4FieldTrack& aFieldTrack);
private:
// ----------------------------------------------------------------------
// DATA Members
// ----------------------------------------------------------------------
G4FieldManager *fDetectorFieldMgr;
// The Field Manager of the whole Detector. (default)
G4FieldManager *fCurrentFieldMgr;
// The Field Manager of the current volume (may be the one above.)
G4Navigator *fNavigator;
// STATE information
// -----------------
G4double fEpsilonStep;
// Relative accuracy for current Step (Calc.)
G4FieldTrack End_PointAndTangent;
// End point storage
G4bool fParticleIsLooping;
G4int fVerboseLevel;
// For debuging purposes
// Limit for the number of sub-steps taken in one call to ComputeStep
G4int fMax_loop_count;
// Variables to keep track of "abnormal" case - which causes loop
//
G4int fNoZeroStep; // Counter of zeroStep
G4int fActionThreshold_NoZeroSteps; // Threshold: above this - act
G4int fSevereActionThreshold_NoZeroSteps; // Threshold to act harshly
G4int fAbandonThreshold_NoZeroSteps; // Threshold to abandon
G4double fFull_CurveLen_of_LastAttempt;
G4double fLast_ProposedStepLength;
G4double fLargestAcceptableStep;
G4double fCharge, fInitialMomentumModulus, fMass;
// Last safety origin & value: for optimisation
G4ThreeVector fPreviousSftOrigin;
G4double fPreviousSafety;
G4bool fUseSafetyForOptimisation;
// Flag whether field manager has been set for the current step
G4bool fSetFieldMgr;
private:
// The filter encapsulates the algorithm which selects which
// intermediate points should be stored in a trajectory.
// When it is NULL, no intermediate points will be stored.
// Else PIF::ComputeStep must submit (all) intermediate
// points it calculates, to this filter. (jacek 04/11/2002)
G4VCurvedTrajectoryFilter* fpTrajectoryFilter;
};
// ********************************************************************
// Inline methods.
// ********************************************************************
#include "G4PropagatorInField.icc"
#endif
@@ -0,0 +1,261 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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: G4PropagatorInField.icc,v 1.6 2003/11/26 14:45:48 japost Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// ------------------------------------------------------------------------
// GEANT 4 inline implementation
//
// ------------------------------------------------------------------------
//
// 25.10.96 John Apostolakis, design and implementation
// 25.03.97 John Apostolakis, adaptation for G4Transportation and cleanup
//
// To create an object of this type, must have:
// - an object that calculates the Curved paths
// - the navigator to find (linear) intersections
// - and ?? also must know the value of the maximum displacement allowed
// ------------------------------------------------------------------------
inline
G4ChordFinder* G4PropagatorInField::GetChordFinder()
{
// The "Chord Finder" of the current Field Mgr is used
// -- this could be of the global field manager
// or that of another, from the current volume
return fCurrentFieldMgr->GetChordFinder();
}
inline
void G4PropagatorInField::SetChargeMomentumMass(
G4double Charge, // in e+ units
G4double Momentum, // in GeV/c
G4double Mass) // in ? units
{
// GetChordFinder()->SetChargeMomentumMass(Charge, Momentum, Mass);
// --> Not needed anymore, as it is done in ComputeStep for the
// ChordFinder of the current step (which is known only then).
fCharge = Charge;
fInitialMomentumModulus = Momentum;
fMass = Mass;
}
// Obtain the final space-point and velocity (normal) at the end of the Step
//
inline
G4ThreeVector G4PropagatorInField::EndPosition() const
{
return End_PointAndTangent.GetPosition();
}
inline
G4ThreeVector G4PropagatorInField::EndMomentumDir() const
{
return End_PointAndTangent.GetMomentumDir();
}
inline
G4double G4PropagatorInField::GetEpsilonStep() const
{
return fEpsilonStep;
}
inline
void G4PropagatorInField::SetEpsilonStep( G4double newEps )
{
fEpsilonStep=newEps;
}
inline
G4bool G4PropagatorInField::IsParticleLooping() const
{
return fParticleIsLooping;
}
inline
G4int G4PropagatorInField::GetMaxLoopCount() const
{
return fMax_loop_count;
}
inline
void G4PropagatorInField::SetMaxLoopCount( G4int new_max )
{
fMax_loop_count = new_max;
}
inline
G4double G4PropagatorInField::GetDeltaIntersection() const
{
return fCurrentFieldMgr->GetDeltaIntersection();
}
inline
G4double G4PropagatorInField::GetDeltaOneStep() const
{
return fCurrentFieldMgr->GetDeltaOneStep();
}
inline
void
G4PropagatorInField::SetAccuraciesWithDeltaOneStep( G4double valDeltaOneStep )
{
fDetectorFieldMgr->SetAccuraciesWithDeltaOneStep(valDeltaOneStep);
}
inline
void G4PropagatorInField::SetDeltaOneStep( G4double valDeltaOneStep )
{
fDetectorFieldMgr->SetDeltaOneStep(valDeltaOneStep);
}
inline
void G4PropagatorInField::SetDeltaIntersection( G4double valDeltaIntersection )
{
fDetectorFieldMgr->SetDeltaIntersection(valDeltaIntersection);
}
inline
G4int G4PropagatorInField::SetVerboseLevel( G4int Verbose )
{
return fVerboseLevel = Verbose;
}
inline
G4int G4PropagatorInField::GetVerboseLevel() const
{
return fVerboseLevel;
}
inline
G4int G4PropagatorInField::Verbose() const // Obsolete
{
return GetVerboseLevel();
}
inline
G4FieldTrack G4PropagatorInField::GetEndState() const
{
return End_PointAndTangent;
}
// Minimum for Relative accuracy of a Step in volumes of global field
inline
G4double G4PropagatorInField::GetMinimumEpsilonStep() const
{
return fDetectorFieldMgr->GetMinimumEpsilonStep();
}
inline
void G4PropagatorInField::SetMinimumEpsilonStep( G4double newEpsMin )
{
fDetectorFieldMgr->SetMinimumEpsilonStep(newEpsMin);
}
// Maximum for Relative accuracy of any Step
inline
G4double G4PropagatorInField::GetMaximumEpsilonStep() const
{
return fDetectorFieldMgr->GetMaximumEpsilonStep();
}
inline
void G4PropagatorInField::SetMaximumEpsilonStep( G4double newEpsMax )
{
fDetectorFieldMgr->SetMaximumEpsilonStep( newEpsMax );
}
inline
void G4PropagatorInField::SetLargestAcceptableStep( G4double newBigDist )
{
if( fLargestAcceptableStep>0.0 )
{
fLargestAcceptableStep = newBigDist;
}
}
inline
G4double G4PropagatorInField::GetLargestAcceptableStep()
{
return fLargestAcceptableStep;
}
inline
G4FieldManager* G4PropagatorInField::GetCurrentFieldManager()
{
return fCurrentFieldMgr;
}
inline
void G4PropagatorInField::SetThresholdNoZeroStep( G4int noAct,
G4int noHarsh,
G4int noAbandon )
{
if( noAct>0 )
fActionThreshold_NoZeroSteps = noAct;
if( noHarsh > fActionThreshold_NoZeroSteps )
fSevereActionThreshold_NoZeroSteps = noHarsh;
else
fSevereActionThreshold_NoZeroSteps = 2*(fActionThreshold_NoZeroSteps+1);
if( noAbandon > fSevereActionThreshold_NoZeroSteps+5 )
fAbandonThreshold_NoZeroSteps = noAbandon;
else
fAbandonThreshold_NoZeroSteps = 2*(fSevereActionThreshold_NoZeroSteps+3);
}
inline
G4int G4PropagatorInField::GetThresholdNoZeroSteps( G4int i )
{
G4int t=0;
if( i==0 ) { t = 3; } // No of parameters
else if (i==1) { t = fActionThreshold_NoZeroSteps; }
else if (i==2) { t = fSevereActionThreshold_NoZeroSteps; }
else if (i==3) { t = fAbandonThreshold_NoZeroSteps; }
return t;
}
inline
void G4PropagatorInField::SetDetectorFieldManager(G4FieldManager* newDetectorFieldManager)
{
fDetectorFieldMgr = newDetectorFieldManager;
}
inline
void G4PropagatorInField:: SetUseSafetyForOptimization( G4bool value )
{
fUseSafetyForOptimisation= value;
}
inline
G4bool G4PropagatorInField::GetUseSafetyForOptimization()
{
return fUseSafetyForOptimisation;
}
@@ -0,0 +1,133 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4ReplicaNavigation
//
// Class description:
//
// 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]
// History:
// - Created. Paul Kent, Aug 96
// --------------------------------------------------------------------
#ifndef G4REPLICANAVIGATION_HH
#define G4REPLICANAVIGATION_HH
#include "G4Types.hh"
#include "G4NavigationHistory.hh"
#include "G4LogicalVolume.hh"
#include "G4VPhysicalVolume.hh"
#include "G4ThreeVector.hh"
#include "G4BlockingList.hh"
// Required for voxel handling
//
#include "G4SmartVoxelHeader.hh"
class G4VSolid;
class G4ReplicaNavigation
{
friend class G4ReplicaNavigationTester;
public: // with description
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,
const G4double pProposedMaxLength=DBL_MAX );
EInside BackLocate( G4NavigationHistory &history,
const G4ThreeVector &globalPoint,
G4ThreeVector &localPoint,
const G4bool &exiting,
G4bool &notKnownInside ) const;
void ComputeTransformation( const G4int replicaNo,
G4VPhysicalVolume *pVol,
G4ThreeVector &point ) const;
void ComputeTransformation( const G4int replicaNo,
G4VPhysicalVolume *pVol ) const;
EInside Inside( const G4VPhysicalVolume *pVol,
const G4int replicaNo,
const G4ThreeVector &localPoint ) const;
G4double DistanceToOut( const G4VPhysicalVolume *pVol,
const G4int replicaNo,
const G4ThreeVector &localPoint ) const;
G4double DistanceToOut( const G4VPhysicalVolume *pVol,
const G4int replicaNo,
const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection ) const;
private:
G4int VoxelLocate( const G4SmartVoxelHeader *pHead,
const G4ThreeVector &localPoint,
const G4int blocked=-1 ) const;
G4double DistanceToOutPhi( const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection,
const G4double width ) const;
G4double DistanceToOutRad( const G4ThreeVector &localPoint,
const G4ThreeVector &localDirection,
const G4double width,
const G4double offset,
const G4int replicaNo ) const;
void SetPhiTransformation( const G4double ang,
G4VPhysicalVolume *pVol=0 ) const;
};
#include "G4ReplicaNavigation.icc"
#endif
@@ -0,0 +1,196 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4ReplicaNavigation Inline implementation
//
// --------------------------------------------------------------------
// ********************************************************************
// VoxelLocate
// ********************************************************************
//
inline
G4int
G4ReplicaNavigation::VoxelLocate( const G4SmartVoxelHeader* pHead,
const G4ThreeVector& localPoint,
const G4int blocked ) const
{
EAxis targetHeaderAxis;
G4double coord=0.;
G4double targetHeaderMin, targetHeaderMax;
G4double targetHeaderNodeWidth, targetNodePos;
G4int targetHeaderNoSlices, targetNodeNo;
targetHeaderAxis = pHead->GetAxis();
targetHeaderNoSlices = pHead->GetNoSlices();
targetHeaderMin = pHead->GetMinExtent();
targetHeaderMax = pHead->GetMaxExtent();
targetHeaderNodeWidth = ( targetHeaderMax-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 G4DEBUG_NAVIGATION
G4cerr << " WARNING: assert in G4ReplicaNavigation::VoxelLocate "
<< " has failed : " << G4endl
<< " (targetNodeNo>=0&&targetNodeNo<targetHeaderNoSlices) "
<< " targetNodeNo= " << targetNodeNo
<< " Number of Slices = " << targetHeaderNoSlices << G4endl;
#endif
// In the case of rotational symmetry and an extent over the
// whole 360 degrees, the above is not true and you can go from
// the last voxel to the zeroth and vice versa
// H.Boie, April 30, 2001
if ( (targetHeaderAxis==kPhi)
&& (targetHeaderMin==0) && (targetHeaderMax==2*M_PI) )
{
if ( targetNodeNo<0 )
targetNodeNo = targetHeaderNoSlices-1;
else if ( targetNodeNo>=targetHeaderNoSlices )
targetNodeNo = 0;
}
else
{
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;
}
// ********************************************************************
// LevelLocate
// ********************************************************************
//
inline
G4bool
G4ReplicaNavigation::LevelLocate( G4NavigationHistory& history,
const G4VPhysicalVolume* blockedVol,
const G4int blockedNum,
const G4ThreeVector&, // globalPoint
const G4ThreeVector*, // globalDirection
const G4bool, // pLocatedOnEdge
G4ThreeVector& localPoint )
{
G4VPhysicalVolume *motherPhysical, *pPhysical;
G4LogicalVolume *motherLogical;
G4SmartVoxelHeader *motherVoxelHeader;
G4int nodeNo;
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);
history.NewLevel(pPhysical, kReplica, nodeNo);
pPhysical->SetCopyNo(nodeNo);
return true;
}
// ********************************************************************
// SetPhiTransformation
// ********************************************************************
//
inline
void
G4ReplicaNavigation::SetPhiTransformation( const G4double ang,
G4VPhysicalVolume* pVol ) const
{
G4RotationMatrix rm;
rm.rotateZ(ang);
if ( pVol )
*pVol->GetRotation() = rm;
}
@@ -0,0 +1,82 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
// class G4TransportationManager
//
// Class description:
//
// 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 G4GeometryMessenger;
class G4FieldManager;
class G4TransportationManager
{
public: // with description
static G4TransportationManager* GetTransportationManager();
inline G4Navigator* GetNavigatorForTracking() const;
inline G4PropagatorInField* GetPropagatorInField() const;
inline G4FieldManager* GetFieldManager() const;
inline void SetNavigatorForTracking( G4Navigator* newNavigator );
inline void SetPropagatorInField( G4PropagatorInField* newFieldPropagator );
void SetFieldManager( G4FieldManager* newFieldManager );
~G4TransportationManager();
protected:
G4TransportationManager();
private:
G4Navigator* fNavigatorForTracking ;
G4PropagatorInField* fPropagatorInField;
G4FieldManager* fFieldManager;
G4GeometryMessenger* fGeomMessenger;
static G4TransportationManager* fTransportationManager;
};
#include "G4TransportationManager.icc"
#endif
@@ -0,0 +1,64 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
// ------------------------------------------------------------
// GEANT 4 inlined function members implementation
// ------------------------------------------------------------
//
// Created: 10 March 1997, J. Apostolakis
//
// --------------------------------------------------------------------
inline
G4Navigator* G4TransportationManager::GetNavigatorForTracking() const
{
return fNavigatorForTracking;
}
inline
G4PropagatorInField* G4TransportationManager::GetPropagatorInField() const
{
return fPropagatorInField;
}
inline
G4FieldManager* G4TransportationManager::GetFieldManager() const
{
return fFieldManager;
}
inline
void G4TransportationManager::SetNavigatorForTracking(G4Navigator* newNavigator)
{
fNavigatorForTracking = newNavigator;
}
inline
void G4TransportationManager::SetPropagatorInField(
G4PropagatorInField* newFieldPropagator )
{
fPropagatorInField = newFieldPropagator;
}
@@ -0,0 +1,139 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4VoxelNavigation
//
// Class description:
//
// Utility for navigation in volumes containing only G4PVPlacement
// daughter volumes for which voxels have been constructed.
// History:
// - Created. Paul Kent, Aug 96
// --------------------------------------------------------------------
#ifndef G4VOXELNAVIGATION_HH
#define G4VOXELNAVIGATION_HH
#include "geomdefs.hh"
#include "G4NavigationHistory.hh"
#include "G4AffineTransform.hh"
#include "G4VPhysicalVolume.hh"
#include "G4LogicalVolume.hh"
#include "G4VSolid.hh"
#include "G4ThreeVector.hh"
#include "G4BlockingList.hh"
// Required for inline implementation
//
#include "G4AuxiliaryNavServices.hh"
// Required for voxel handling & voxel stack
//
#include <vector>
#include "G4SmartVoxelProxy.hh"
#include "G4SmartVoxelNode.hh"
#include "G4SmartVoxelHeader.hh"
class G4VoxelNavigation
{
public: // with description
G4VoxelNavigation();
virtual ~G4VoxelNavigation();
G4SmartVoxelNode* VoxelLocate( G4SmartVoxelHeader* pHead,
const G4ThreeVector& localPoint );
virtual G4bool LevelLocate( G4NavigationHistory& history,
const G4VPhysicalVolume* blockedVol,
const G4int blockedNum,
const G4ThreeVector& globalPoint,
const G4ThreeVector* globalDirection,
const G4bool pLocatedOnEdge,
G4ThreeVector& localPoint );
virtual 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 );
virtual G4double ComputeSafety( const G4ThreeVector& globalpoint,
const G4NavigationHistory& history,
const G4double pMaxLength=DBL_MAX );
protected:
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
//
G4int fVoxelDepth;
// Note: fVoxelDepth==0+ => fVoxelAxisStack(0+) contains axes of voxel
// fVoxelDepth==-1 -> not in voxel
std::vector<EAxis> fVoxelAxisStack;
// Voxel axes
std::vector<G4int> fVoxelNoSlicesStack;
// No slices per voxel at each level
std::vector<G4double> fVoxelSliceWidthStack;
// Width of voxels at each level
std::vector<G4int> fVoxelNodeNoStack;
// Node no point is inside at each level
std::vector<G4SmartVoxelHeader*> fVoxelHeaderStack;
// Voxel headers at each level
G4SmartVoxelNode* fVoxelNode;
// Node containing last located point
//
// END Voxel Stack information
//
};
#include "G4VoxelNavigation.icc"
#endif
@@ -0,0 +1,159 @@
//
// ********************************************************************
// * DISCLAIMER *
// * *
// * The following disclaimer summarizes all the specific disclaimers *
// * of contributors to this software. The specific disclaimers,which *
// * govern, are listed with their locations in: *
// * http://cern.ch/geant4/license *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. *
// * *
// * This code implementation is the intellectual property of the *
// * 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 1.2 2003/11/03 17:15:21 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-00 $
//
//
// class G4VoxelNavigation Inline implementation
//
// --------------------------------------------------------------------
// ********************************************************************
// VoxelLocate
// ********************************************************************
//
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;
while ( !targetVoxelNode )
{
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++;
}
}
fVoxelNode = targetVoxelNode;
return targetVoxelNode;
}
// ********************************************************************
// LevelLocate
// ********************************************************************
//
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;
targetPhysical = history.GetTopVolume();
targetLogical = targetPhysical->GetLogicalVolume();
targetVoxelHeader = targetLogical->GetVoxelHeader();
// Find the voxel containing the point
//
targetVoxelNode = VoxelLocate(targetVoxelHeader,localPoint);
targetNoDaughters=targetVoxelNode->GetNoContained();
if ( targetNoDaughters==0 ) return false;
//
// Search daughters in volume
//
for ( register int sampleNo=targetNoDaughters-1; sampleNo>=0; sampleNo-- )
{
samplePhysical = targetLogical->
GetDaughter(targetVoxelNode->GetVolume(sampleNo));
if ( samplePhysical!=blockedVol )
{
// Setup history
//
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
//
localPoint = samplePoint;
return true;
}
else
{
history.BackLevel();
}
}
}
return false;
}