Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
@@ -0,0 +1,51 @@
# $Id: GNUmakefile,v 2.4 1998/07/14 14:27:15 morita Exp $
name := G4pcsg
G4ODBMS := true
ifndef G4INSTALL
G4INSTALL = ../../../../..
endif
include $(G4INSTALL)/config/architecture.gmk
# $(G4TMPDIR) will be overriden in common.gmk later.
G4TMPDIR := $(G4TMP)/$(G4SYSTEM)/$(name)
CPPFLAGS += \
-Iinclude \
-I$(G4TMPDIR) \
-I$(G4TMP)/$(G4SYSTEM)/G4pgeomn \
-I../management/include \
-I$(G4INSTALL)/source/persistency/management/include \
-I$(G4INSTALL)/source/run/include \
-I$(G4INSTALL)/source/global/management/include \
-I$(G4INSTALL)/source/global/HEPRandom/include \
-I$(G4INSTALL)/source/global/HEPGeometry/include \
-I$(G4INSTALL)/source/geometry/management/include \
-I$(G4INSTALL)/source/geometry/magneticfield/include \
-I$(G4INSTALL)/source/geometry/volumes/include \
-I$(G4INSTALL)/source/geometry/solids/CSG/include \
-I$(G4INSTALL)/source/materials/include \
-I$(G4INSTALL)/source/graphics_reps/include
#--------------------------------------------------------------------
include $(G4INSTALL)/config/G4ODBMS_BUILD.gmk
include $(G4INSTALL)/config/common.gmk
#--------------------------------------------------------------------
# Explicit DDL dependencies:
$(G4TMPDIR)/G4PBox.hh: $(G4TMPDIR)/G4PCSGSolid.hh
$(G4TMPDIR)/G4PCSGSolid.hh:
$(G4TMPDIR)/G4PCons.hh: $(G4TMPDIR)/G4PCSGSolid.hh
$(G4TMPDIR)/G4PPara.hh: $(G4TMPDIR)/G4PCSGSolid.hh
$(G4TMPDIR)/G4PSphere.hh: $(G4TMPDIR)/G4PCSGSolid.hh
$(G4TMPDIR)/G4PTorus.hh: $(G4TMPDIR)/G4PCSGSolid.hh
$(G4TMPDIR)/G4PTrap.hh: $(G4TMPDIR)/G4PCSGSolid.hh
$(G4TMPDIR)/G4PTrd.hh: $(G4TMPDIR)/G4PCSGSolid.hh
$(G4TMPDIR)/G4PTubs.hh: $(G4TMPDIR)/G4PCSGSolid.hh
#--------------------------------------------------------------------
@@ -0,0 +1,39 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PBox.ddl,v 2.0 1998/07/02 16:12:56 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PBox
//
// History:
// 19.06.98 A.Kimura Converted from G4Box.hh
#ifndef G4PBOX_DDL
#define G4PBOX_DDL
#include "G4PCSGSolid.hh"
class G4VSolid;
class G4Box;
class G4PBox : public G4PCSGSolid {
public:
G4PBox(const G4Box* theBox);
virtual ~G4PBox();
G4VSolid* MakeTransientObject() const;
// Naming method (pseudo-RTTI : run-time type identification
virtual G4GeometryType GetEntityType() const { return G4String("G4Box"); }
private:
G4double fDx,fDy,fDz;
};
#endif
@@ -0,0 +1,29 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PCSGSolid.ddl,v 2.0 1998/07/02 16:13:00 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4CSGSolid
//
// History:
// 19.06.98 A.Kimura Converted G4CSGSolid.hh
#ifndef G4PCSGSOLID_DDL
#define G4PCSGSOLID_DDL
#include "G4PVSolid.hh"
class G4PCSGSolid : public G4PVSolid {
public:
G4PCSGSolid(const G4String& pName);
virtual ~G4PCSGSolid();
};
#endif
@@ -0,0 +1,42 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PCons.ddl,v 2.0 1998/07/02 16:12:58 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4Cons
//
// History:
// 19.06.98 A.Kimura Converted G4Cons.hh
#ifndef G4PCons_DDL
#define G4PCons_DDL
#include "G4PCSGSolid.hh"
class G4Cons;
class G4VSolid;
class G4PCons : public G4PCSGSolid {
public:
G4PCons(const G4Cons* theCons);
virtual ~G4PCons() ;
G4VSolid* MakeTransientObject() const;
// Naming method (pseudo-RTTI : run-time type identification
virtual G4GeometryType GetEntityType() const {return G4String("G4Cons");}
private:
G4double fRmin1, fRmin2,
fRmax1, fRmax2,
fDz,
fSPhi, fDPhi;
};
#endif
@@ -0,0 +1,95 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PHype.ddl,v 2.1 1998/07/12 03:01:24 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PHype
//
// History:
// 19.06.98 A.Kimura Converted G4Hype.hh
#ifndef G4PHYPE_DDL
#define G4PHYPE_DDL
#include "G4PCSGSolid.hh"
class G4VSolid;
class G4Hype;
class G4PHype : public G4PCSGSolid {
public:
G4PHype(const G4Hype* theHype);
virtual ~G4PHype();
G4VSolid* MakeTransientObject() const;
virtual G4GeometryType GetEntityType() const {return G4String("G4Hype");}
protected:
// values of hype radius at a given Z
G4double HypeInnerRadius2(double zVal) const {
return (tanInnerStereo2*zVal*zVal+innerRadius2);
}
G4double HypeOuterRadius2(double zVal) const {
return (tanOuterStereo2*zVal*zVal+outerRadius2);
}
G4double innerRadius; // variable names are quite self explanative
G4double outerRadius;
G4double halfLenZ;
G4double innerStereo;
G4double outerStereo;
// precalculated parameters, squared quantities
G4double tanInnerStereo2; // squared tan of Inner Stereo angle
G4double tanOuterStereo2; // squared tan of Outer Stereo angle
G4double innerRadius2; // squared Inner Radius
G4double outerRadius2; // squared Outer Radius
G4double endInnerRadius2; // squared endcap Inner Radius
G4double endOuterRadius2; // squared endcap Outer Radius
G4double endInnerRadius; // endcap Inner Radius
G4double endOuterRadius; // endcap Outer Radius
};
#endif
@@ -0,0 +1,56 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PPara.ddl,v 2.0 1998/07/02 16:13:04 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PPara
//
// History:
// 19.06.98 A.Kimura Converted G4Para.hh
#ifndef G4PPara_DDL
#define G4PPara_DDL
#include "G4PCSGSolid.hh"
class G4Para;
class G4VSolid;
#include "G4ThreeVector.hh"
#include <rw/tvordvec.h>
typedef RWTValOrderedVector<G4ThreeVector> G4ThreeVectorList;
class G4PPara : public G4PCSGSolid {
public:
G4PPara(const G4Para* thePara);
virtual ~G4PPara() ;
// Access functions
G4VSolid* MakeTransientObject() const ;
// Get functions
G4ThreeVector GetSymAxis() const {
G4double cosTheta
= 1.0/sqrt(1+fTthetaCphi*fTthetaCphi+fTthetaSphi*fTthetaSphi) ;
return G4ThreeVector(fTthetaCphi*cosTheta,fTthetaSphi*cosTheta,cosTheta) ;
}
// Naming method (pseudo-RTTI : run-time type identification
virtual G4GeometryType GetEntityType() const {return G4String("G4Para");}
private:
G4double fDx,fDy,fDz;
G4double fTalpha,fTthetaCphi,fTthetaSphi;
};
#endif
@@ -0,0 +1,47 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PSphere.ddl,v 2.0 1998/07/02 16:13:06 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PSphere
//
// History:
// 19.06.98 A.Kimura Converted G4Sphere.hh
#ifndef G4PSphere_DDL
#define G4PSphere_DDL
#include "G4PCSGSolid.hh"
class G4VSolid;
class G4Sphere;
#include "G4ThreeVector.hh"
#include <rw/tvordvec.h>
typedef RWTValOrderedVector<G4ThreeVector> G4ThreeVectorList;
class G4PSphere : public G4PCSGSolid {
public:
G4PSphere(const G4Sphere* theSphere);
virtual ~G4PSphere() ;
G4VSolid* MakeTransientObject() const;
// Naming method (pseudo-RTTI : run-time type identification
virtual G4GeometryType GetEntityType() const {return G4String("G4Sphere");}
private:
G4double fRmin,fRmax,
fSPhi,fDPhi,
fSTheta,fDTheta;
};
#endif
@@ -0,0 +1,45 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PTorus.ddl,v 2.0 1998/07/02 16:13:09 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4PTorus
//
// History:
// 19.06.98 A.Kimura Converted G4Torus.hh
#ifndef G4PTorus_DDL
#define G4PTorus_DDL
#include "G4PCSGSolid.hh"
class G4VSolid;
class G4Torus;
class G4PTorus : public G4PCSGSolid {
public:
G4PTorus(const G4Torus* theTorus);
virtual ~G4PTorus();
G4VSolid* MakeTransientObject() const;
void SetAllParameters(G4double pRmin, G4double pRmax, G4double pRtor,
G4double pSPhi, G4double pDPhi);
// Naming method (pseudo-RTTI : run-time type identification
virtual G4GeometryType GetEntityType() const {return G4String("G4Torus");}
protected:
G4double fRmin,fRmax,fRtor,fSPhi,fDPhi;
};
#endif
@@ -0,0 +1,81 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PTrap.ddl,v 2.0 1998/07/02 16:13:07 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PTrap
//
// History:
// 19.06.98 A.Kimura Converted G4Trap.hh
#ifndef G4PTrap_DDL
#define G4PTrap_DDL
#include "G4PCSGSolid.hh"
class G4VSolid;
class G4Trap;
#include "G4ThreeVector.hh"
#include <rw/tvordvec.h>
typedef RWTValOrderedVector<G4ThreeVector> G4ThreeVectorList;
struct PTrapSidePlane
{
G4double a,b,c,d; // Normal unit vector (a,b,c) and offset (d)
// => Ax+By+Cz+D=0
};
class G4PTrap : public G4PCSGSolid {
public:
// The most general constructor for G4Trap
G4PTrap(const G4Trap* theTrap);
virtual ~G4PTrap() ;
// Access functions
G4VSolid* MakeTransientObject() const;
void SetAllParameters ( G4double pDz,
G4double pTheta,
G4double pPhi,
G4double pDy1,
G4double pDx1,
G4double pDx2,
G4double pAlp1,
G4double pDy2,
G4double pDx3,
G4double pDx4,
G4double pAlp2);
// Naming method (pseudo-RTTI : run-time type identification
virtual G4GeometryType GetEntityType() const { return G4String("G4Trap"); }
protected:
G4bool MakePlanes();
G4bool MakePlane( const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
const G4ThreeVector& p4,
PTrapSidePlane& plane ) ;
private:
G4double fDz,fTthetaCphi,fTthetaSphi;
G4double fDy1,fDx1,fDx2,fTalpha1;
G4double fDy2,fDx3,fDx4,fTalpha2;
PTrapSidePlane fPlanes[4];
};
#endif
// **************************** End of G4Trap.hh *****************************************
@@ -0,0 +1,49 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PTrd.ddl,v 2.0 1998/07/02 16:13:10 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PTrd
//
// History:
// 19.06.98 A.Kimura Converted G4Trd.hh
#ifndef G4PTRD_DDL
#define G4PTRD_DDL
#include "G4PCSGSolid.hh"
class G4Trd;
class G4VSolid;
class G4PTrd : public G4PCSGSolid {
public:
G4PTrd(const G4Trd* theTrd);
virtual ~G4PTrd();
G4VSolid* MakeTransientObject() const;
// Naming method (pseudo-RTTI : run-time type identification
virtual G4GeometryType GetEntityType() const {return G4String("G4Trd");}
void CheckAndSetAllParameters (G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2,
G4double pdz);
protected:
G4double fDx1,fDx2,fDy1,fDy2,fDz;
};
#endif
@@ -0,0 +1,41 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PTubs.ddl,v 2.0 1998/07/02 16:13:11 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4PTubs
//
// History:
// 19.06.98 A.Kimura Converted G4Tubs.hh
#ifndef G4PTUBS_DDL
#define G4PTUBS_DDL
#include "G4PCSGSolid.hh"
class G4VSolid;
class G4Tubs;
class G4PTubs : public G4PCSGSolid {
public:
G4PTubs(const G4Tubs* theTubs);
virtual ~G4PTubs();
G4VSolid* MakeTransientObject() const;
// Naming method (pseudo-RTTI : run-time type identification)
virtual G4GeometryType GetEntityType() const { return G4String("G4Tubs"); }
protected:
G4double fRMin,fRMax,fDz,fSPhi,fDPhi;
};
#endif
@@ -0,0 +1,50 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PBox.cc,v 2.0 1998/07/02 16:13:16 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
//
// Implementation for G4PBox class
//
// History:
// 19.06.98 A.Kimura Converted G4Box.cc
#include "G4VSolid.hh"
#include "G4PBox.hh"
#include "G4Box.hh"
#include "G4AffineTransform.hh"
// Constructor - check & set half widths
G4PBox::G4PBox(const G4Box* theBox) : G4PCSGSolid(theBox->GetName()) {
G4double pX = theBox->GetXHalfLength();
G4double pY = theBox->GetYHalfLength();
G4double pZ = theBox->GetZHalfLength();
if (pX>0&&pY>0&&pZ>0) {
fDx=pX; fDy=pY; fDz=pZ;
} else {
G4Exception("Error in G4PBox::Box - negative parameters");
}
}
// Destructor
G4PBox::~G4PBox() {
;
}
// make a transient object
G4VSolid* G4PBox::MakeTransientObject() const {
G4VSolid* transientObject = new G4Box(GetName(),
fDx, fDy, fDz);
return transientObject;
}
@@ -0,0 +1,27 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PCSGSolid.cc,v 2.0 1998/07/02 16:13:15 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// History:
// 19.06.98 A.Kimura Converted G4CSGSolid.cc
#include "G4PCSGSolid.hh"
// Constructor
// - Base class constructor
G4PCSGSolid::G4PCSGSolid(const G4String& name) :
G4PVSolid(name)
{
}
G4PCSGSolid::~G4PCSGSolid()
{
}
@@ -0,0 +1,99 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PCons.cc,v 2.2 1998/07/12 03:01:26 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PCons
//
// Implementation for G4PCons class
//
// History:
// 19.06.98 A.Kimura Converted G4Cons.cc
#include "G4VSolid.hh"
#include "G4PCons.hh"
#include "G4Cons.hh"
#include "G4VoxelLimits.hh"
#include "G4AffineTransform.hh"
// #include "G4PVPVParameterisation.hh"
#include "meshdefs.hh"
#include "G4VGraphicsScene.hh"
#include "G4Polyhedron.hh"
#include "G4NURBS.hh"
#include "G4NURBSbox.hh"
#include "G4VisExtent.hh"
G4PCons::~G4PCons() {
;
}
// make a transient object
G4VSolid* G4PCons::MakeTransientObject() const {
G4VSolid* transientObject = new G4Cons(GetName(),
fRmin1, fRmax1,
fRmin2, fRmax2,
fDz,
fSPhi, fDPhi);
return transientObject;
}
// constructor - check parameters, convert angles so 0<sphi+dpshi<=2_PI
// - note if pDPhi>2PI then reset to 2PI
G4PCons::G4PCons(const G4Cons* theCons) : G4PCSGSolid(theCons->GetName()) {
G4double pRmin1 = theCons->GetInnerRadiusMinusZ();
G4double pRmax1 = theCons->GetOuterRadiusMinusZ();
G4double pRmin2 = theCons->GetInnerRadiusPlusZ();
G4double pRmax2 = theCons->GetOuterRadiusPlusZ();
G4double pDz = theCons->GetZHalfLength();
G4double pSPhi = theCons->GetStartPhiAngle();
G4double pDPhi = theCons->GetDeltaPhiAngle();
// Check z-len
if (pDz>0) {
fDz=pDz;
} else {
G4Exception("Error in G4PCons::G4PCons - invalid z half-length");
}
// Check radii
if (pRmin1<pRmax1 && pRmin2<pRmax2 && pRmin1>=0 && pRmin2>=0) {
fRmin1=pRmin1; fRmax1=pRmax1;
fRmin2=pRmin2; fRmax2=pRmax2;
} else {
G4Exception("Error in G4PCons::G4PCons - invalid radii");
}
// Check angles
if (pDPhi>=2.0*M_PI) {
fDPhi=2*M_PI;
fSPhi=0;
} else {
if (pDPhi>0) {
fDPhi=pDPhi;
} else {
G4Exception("Error in G4PCons::G4PCons - invalid pDPhi");
}
// Ensure pSPhi in 0-2PI or -2PI-0 range if shape crosses 0
if (pSPhi<0) {
fSPhi=2.0*M_PI-fmod(fabs(pSPhi),2.0*M_PI);
} else {
fSPhi=fmod(pSPhi,2.0*M_PI);
}
if (fSPhi+fDPhi>2.0*M_PI) fSPhi-=2.0*M_PI;
}
}
// ******************************* End of G4PCons.cc file **********************************
@@ -0,0 +1,81 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PHype.cc,v 2.1 1998/07/12 03:01:27 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PHype
//
// History:
// 19.06.98 A.Kimura Converted G4PHype.cc
#include "G4VSolid.hh"
#include "G4PHype.hh"
#include "G4Hype.hh"
#include "G4AffineTransform.hh"
#include "meshdefs.hh"
#define SURFACE_PRECISION (0.5*kCarTolerance)
// Constructor - check parameters, and fills protected data members
G4PHype::G4PHype(const G4Hype* theHype) : G4PCSGSolid(theHype->GetName()) {
const G4double newInnerRadius = theHype->GetInnerRadius();
const G4double newOuterRadius = theHype->GetOuterRadius();
const G4double newInnerStereo = theHype->GetOuterStereo();
const G4double newOuterStereo = theHype->GetInnerStereo();
const G4double newHalfLenZ = theHype->GetZHalfLength();
// Check z-len
if (newHalfLenZ>0) {
halfLenZ=newHalfLenZ;
} else {
G4Exception("Error in G4PHype::G4PHype - invalid z half-length");
}
// Check radii
if (newInnerRadius>=0 && newOuterRadius>=0) {
if (newInnerRadius < newOuterRadius) {
innerRadius=newInnerRadius;
outerRadius=newOuterRadius;
} else { // swapping radii (:-)
innerRadius=newOuterRadius;
outerRadius=newInnerRadius;
}
} else {
G4Exception("Error in G4PHype::G4PHype - invalid radii");
}
innerStereo=newInnerStereo;
outerStereo=newOuterStereo;
// init of precalculated quantities
tanInnerStereo2 = tan(innerStereo)*tan(innerStereo);
tanOuterStereo2 = tan(outerStereo)*tan(outerStereo);
innerRadius2 = innerRadius*innerRadius;
outerRadius2 = outerRadius*outerRadius;
endInnerRadius2 = HypeInnerRadius2(halfLenZ);
endOuterRadius2 = HypeOuterRadius2(halfLenZ);
endInnerRadius = sqrt(endInnerRadius2);
endOuterRadius = sqrt(endOuterRadius2);
}
// Destructor
G4PHype::~G4PHype()
{;}
// make a transient object
G4VSolid* G4PHype::MakeTransientObject() const {
G4VSolid* transientObject = new G4Hype(GetName(),
innerRadius,
outerRadius,
innerStereo,
outerStereo,
halfLenZ);
return transientObject;
}
@@ -0,0 +1,68 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PPara.cc,v 2.0 1998/07/02 16:13:21 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PPara
//
// Implementation for G4PPara class
//
// History:
// 19.06.98 A.Kimura Converted G4Para.cc
#include <math.h>
#include "G4VSolid.hh"
#include "G4PPara.hh"
#include "G4Para.hh"
#include "G4AffineTransform.hh"
// Constructor - check and set half-widths
G4PPara::G4PPara(const G4Para* thePara) : G4PCSGSolid(thePara->GetName())
{
G4double pDx = thePara->GetXHalfLength();
G4double pDy = thePara->GetYHalfLength();
G4double pDz = thePara->GetZHalfLength();
if(pDx>0&&pDy>0&&pDz>0) {
fDx = pDx;
fDy = pDy;
fDz = pDz;
fTalpha = thePara->GetTanAlpha();
G4ThreeVector symAxis = thePara->GetSymAxis();
fTthetaCphi = symAxis.x()/symAxis.z();
fTthetaSphi = symAxis.y()/symAxis.z();
} else {
G4Exception("Error in G4PPara::G4PPara - Invalid Length Parameters");
}
}
// ----------------------------------------------------------------------------
G4PPara::~G4PPara()
{
;
}
// ----------------------------------------------------------------------------
// make a transient object
G4VSolid* G4PPara::MakeTransientObject() const {
G4ThreeVector symaxis = GetSymAxis();
G4double alpha = atan(fTalpha);
G4double theta = acos(symaxis.z());
G4double phi = acos(fTthetaCphi/tan(theta));
G4VSolid* transientObject = new G4Para(GetName(),
fDx, fDy, fDz,
alpha, theta, phi);
return transientObject;
}
// ******************************** End of G4PPara.cc ********************************
@@ -0,0 +1,119 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PSphere.cc,v 2.0 1998/07/02 16:13:27 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4PSphere
//
// Implementation for G4PSphere class
//
// History:
// 19.06.98 A.Kimura Converted G4Sphere.cc
#include <assert.h>
#include "G4VSolid.hh"
#include "G4PSphere.hh"
#include "G4Sphere.hh"
#include "G4AffineTransform.hh"
#include "meshdefs.hh"
// Destructor
G4PSphere::~G4PSphere(){
;
}
// make a transient object
G4VSolid* G4PSphere::MakeTransientObject() const {
G4VSolid* transientObject = new G4Sphere(GetName(),
fRmin,
fRmax,
fSPhi,
fDPhi,
fSTheta,
fDTheta);
return transientObject;
}
// constructor - check parameters, convert angles so 0<sphi+dpshi<=2_PI
// - note if pDPhi>2PI then reset to 2PI
G4PSphere::G4PSphere(const G4Sphere* theSphere)
: G4PCSGSolid(theSphere->GetName())
{
G4double pRmin = fRmin;
G4double pRmax = fRmax;
G4double pSPhi = fSPhi;
G4double pDPhi = fDPhi;
G4double pSTheta = fSTheta;
G4double pDTheta = fDTheta;
// Check radii
if (pRmin<pRmax&&pRmin>=0)
{
fRmin=pRmin; fRmax=pRmax;
}
else
{
G4Exception("Error in G4PSphere::G4PSphere - invalid radii");
}
// Check angles
if (pDPhi>=2.0*M_PI)
{
fDPhi=2*M_PI;
}
else if (pDPhi>0)
{
fDPhi=pDPhi;
}
else
{
G4Exception("Error in G4PSphere::G4PSphere - invalid DPhi");
}
// Convert fSPhi to 0-2PI
if (pSPhi<0)
{
fSPhi=2.0*M_PI-fmod(fabs(pSPhi),2.0*M_PI);
}
else
{
fSPhi=fmod(pSPhi,2.0*M_PI);
}
// Sphere is placed such that fSPhi+fDPhi>2.0*M_PI ! fSPhi could be < 0 !!? P
if (fSPhi+fDPhi>2.0*M_PI) fSPhi-=2.0*M_PI;
// Check theta angles
if (pSTheta<0 || pSTheta>M_PI)
{
G4Exception("Error in G4PSphere::G4PSphere - stheta outside 0-PI range");
}
else
{
fSTheta=pSTheta;
}
if (pDTheta+pSTheta>=M_PI)
{
fDTheta=M_PI-pSTheta;
}
else if (pDTheta>0)
{
fDTheta=pDTheta;
}
else
{
G4Exception("Error in G4PSphere::G4PSphere - invalid pDTheta");
}
}
// ****************************** End of G4PSphere.cc ****************************************
@@ -0,0 +1,114 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PTorus.cc,v 2.0 1998/07/02 16:13:28 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4PTorus
//
// Implementation
//
// History:
// 19.06.98 A.Kimura Converted G4Torus.cc
#include "G4VSolid.hh"
#include "G4PTorus.hh"
#include "G4Torus.hh"
#include "G4AffineTransform.hh"
#include "meshdefs.hh"
// Constructor - check parameters, convert angles so 0<sphi+dpshi<=2_PI
// - note if pdphi>2PI then reset to 2PI
G4PTorus::G4PTorus(const G4Torus* theTorus)
: G4PCSGSolid(theTorus->GetName())
{
SetAllParameters(theTorus->GetRmin(),
theTorus->GetRmax(),
theTorus->GetRtor(),
theTorus->GetSPhi(),
theTorus->GetDPhi());
}
void
G4PTorus::SetAllParameters(
G4double pRmin,
G4double pRmax,
G4double pRtor,
G4double pSPhi,
G4double pDPhi)
{
// Check swept radius
if (pRtor>=pRmax)
{
fRtor=pRtor;
}
else
{
G4Exception("Error in G4PTorus::SetAllParameters - invalid swept radius");
}
// Check radii
if (pRmin<pRmax&&pRmin>=0)
{
fRmin=pRmin; fRmax=pRmax;
}
else
{
G4Exception("Error in G4PTorus::SetAllParameters - invalid radii");
}
// Check angles
if (pDPhi>=2.0*M_PI)
{
fDPhi=2*M_PI;
}
else
{
if (pDPhi>0)
{
fDPhi = pDPhi;
}
else
{
G4Exception("Error in G4PTorus::SetAllParameters - invalid dphi");
}
}
// Ensure psphi in 0-2PI or -2PI-0 range if shape crosses 0
fSPhi = pSPhi;
if (fSPhi<0)
{
fSPhi=2.0*M_PI-fmod(fabs(fSPhi),2.0*M_PI);
}
else
{
fSPhi=fmod(fSPhi,2.0*M_PI);
}
if (fSPhi+fDPhi>2.0*M_PI)
{
fSPhi-=2.0*M_PI;
}
}
// Destructor
G4PTorus::~G4PTorus()
{;}
// --------------------------------------------------------------------------
// make a transient object
G4VSolid* G4PTorus::MakeTransientObject() const {
G4VSolid* transientObject = new G4Torus(GetName(),
fRmin, fRmax,
fRtor,
fSPhi, fDPhi);
return transientObject;
}
@@ -0,0 +1,260 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PTrap.cc,v 2.1 1998/07/12 03:01:29 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// class G4PTrap
//
// Implementation for G4PTrap class
//
// History:
// 19.06.98 A.Kimura Converted G4Trap.cc
#include <math.h>
#include "G4VSolid.hh"
#include "G4PTrap.hh"
#include "G4Trap.hh"
#include "G4AffineTransform.hh"
const G4double kCoplanar_Tolerance=1E-4;
// Destructor
G4PTrap::~G4PTrap()
{
;
}
// make a transient object
G4VSolid* G4PTrap::MakeTransientObject() const {
G4VSolid* transientObject = new G4Trap(GetName(),
fDx1, fDx2,
fDy1, fDy2,
fDz);
return transientObject;
}
// Constructor for G4Trd
G4PTrap::G4PTrap(const G4Trap* theTrap)
: G4PCSGSolid(theTrap->GetName()) {
G4double pDx1 = theTrap->GetXHalfLength1();
G4double pDx2 = theTrap->GetXHalfLength2();
G4double pDy1 = theTrap->GetYHalfLength1();
G4double pDy2 = theTrap->GetYHalfLength2();
G4double pDz = theTrap->GetZHalfLength();
G4bool good;
if (pDz>0 && pDy1>0 && pDx1>0 && pDx2>0 && pDy2>0 )
{
fDz = pDz;
fTthetaCphi = 0 ;
fTthetaSphi = 0 ;
fDy1 = pDy1 ;
fDx1 = pDx1 ;
fDx2 = pDx1 ;
fTalpha1 = 0 ;
fDy2 = pDy2 ;
fDx3 = pDx2 ;
fDx4 = pDx2 ;
fTalpha2 = 0 ;
G4ThreeVector pt[8] ;
pt[0]=G4ThreeVector(-fDz*fTthetaCphi-fDy1*fTalpha1-fDx1,-fDz*fTthetaSphi-fDy1,-fDz);
pt[1]=G4ThreeVector(-fDz*fTthetaCphi-fDy1*fTalpha1+fDx1,-fDz*fTthetaSphi-fDy1,-fDz);
pt[2]=G4ThreeVector(-fDz*fTthetaCphi+fDy1*fTalpha1-fDx2,-fDz*fTthetaSphi+fDy1,-fDz);
pt[3]=G4ThreeVector(-fDz*fTthetaCphi+fDy1*fTalpha1+fDx2,-fDz*fTthetaSphi+fDy1,-fDz);
pt[4]=G4ThreeVector(+fDz*fTthetaCphi-fDy2*fTalpha2-fDx3,+fDz*fTthetaSphi-fDy2,+fDz);
pt[5]=G4ThreeVector(+fDz*fTthetaCphi-fDy2*fTalpha2+fDx3,+fDz*fTthetaSphi-fDy2,+fDz);
pt[6]=G4ThreeVector(+fDz*fTthetaCphi+fDy2*fTalpha2-fDx4,+fDz*fTthetaSphi+fDy2,+fDz);
pt[7]=G4ThreeVector(+fDz*fTthetaCphi+fDy2*fTalpha2+fDx4,+fDz*fTthetaSphi+fDy2,+fDz);
// Bottom side with normal approx. -Y
good=MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
if (!good)
{
G4Exception("G4PTrap::G4PTrap - face at ~-Y not planar");
}
// Top side with normal approx. +Y
good=MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
if (!good)
{
G4Exception("G4PTrap::G4PTrap - face at ~+Y not planar");
}
// Front side with normal approx. -X
good=MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
if (!good)
{
G4Exception("G4PTrap::G4PTrap - face at ~-X not planar");
}
// Back side iwth normal approx. +X
good=MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
if (!good)
{
G4Exception("G4PTrap::G4PTrap - face at ~+X not planar");
}
}
else
{
G4Exception("Error in G4PTrap::G4PTrap - Invalid Length G4PTrapmeters");
}
}
// Set all parameters, as for constructor - check and set half-widths
// as well as angles: final check of coplanarity
void G4PTrap::SetAllParameters ( G4double pDz,
G4double pTheta,
G4double pPhi,
G4double pDy1,
G4double pDx1,
G4double pDx2,
G4double pAlp1,
G4double pDy2,
G4double pDx3,
G4double pDx4,
G4double pAlp2)
{
if (pDz>0 && pDy1>0 && pDx1>0 && pDx2>0 && pDy2>0 && pDx3>0 && pDx4>0)
{
fDz=pDz;
fTthetaCphi=tan(pTheta)*cos(pPhi);
fTthetaSphi=tan(pTheta)*sin(pPhi);
fDy1=pDy1;
fDx1=pDx1;
fDx2=pDx2;
fTalpha1=tan(pAlp1);
fDy2=pDy2;
fDx3=pDx3;
fDx4=pDx4;
fTalpha2=tan(pAlp2);
MakePlanes();
}
else
{
G4Exception("Error in G4PTrap::SetAll - Invalid Length G4PTrapmeters");
}
}
G4bool G4PTrap::MakePlanes()
{
G4bool good = true;
G4ThreeVector pt[8] ;
pt[0]=G4ThreeVector(-fDz*fTthetaCphi-fDy1*fTalpha1-fDx1,-fDz*fTthetaSphi-fDy1,-fDz);
pt[1]=G4ThreeVector(-fDz*fTthetaCphi-fDy1*fTalpha1+fDx1,-fDz*fTthetaSphi-fDy1,-fDz);
pt[2]=G4ThreeVector(-fDz*fTthetaCphi+fDy1*fTalpha1-fDx2,-fDz*fTthetaSphi+fDy1,-fDz);
pt[3]=G4ThreeVector(-fDz*fTthetaCphi+fDy1*fTalpha1+fDx2,-fDz*fTthetaSphi+fDy1,-fDz);
pt[4]=G4ThreeVector(+fDz*fTthetaCphi-fDy2*fTalpha2-fDx3,+fDz*fTthetaSphi-fDy2,+fDz);
pt[5]=G4ThreeVector(+fDz*fTthetaCphi-fDy2*fTalpha2+fDx3,+fDz*fTthetaSphi-fDy2,+fDz);
pt[6]=G4ThreeVector(+fDz*fTthetaCphi+fDy2*fTalpha2-fDx4,+fDz*fTthetaSphi+fDy2,+fDz);
pt[7]=G4ThreeVector(+fDz*fTthetaCphi+fDy2*fTalpha2+fDx4,+fDz*fTthetaSphi+fDy2,+fDz);
// Bottom side with normal approx. -Y
good=MakePlane(pt[0],pt[4],pt[5],pt[1],fPlanes[0]);
if (!good)
{
G4Exception("G4PTrap::G4PTrap - face at ~-Y not planar");
}
// Top side with normal approx. +Y
good=MakePlane(pt[2],pt[3],pt[7],pt[6],fPlanes[1]);
if (!good)
{
G4Exception("G4PTrap::G4PTrap - face at ~+Y not planar");
}
// Front side with normal approx. -X
good=MakePlane(pt[0],pt[2],pt[6],pt[4],fPlanes[2]);
if (!good)
{
G4Exception("G4PTrap::G4PTrap - face at ~-X not planar");
}
// Back side iwth normal approx. +X
good=MakePlane(pt[1],pt[5],pt[7],pt[3],fPlanes[3]);
if (!good)
{
G4Exception("G4PTrap::G4PTrap - face at ~+X not planar");
}
return good;
}
// --------------------------------------------------------------------------
// Calculate the coef's of the plane p1->p2->p3->p4->p1
// where the ThreeVectors 1-4 are in anti-clockwise order when viewed from
// infront of the plane.
//
// Return true if the ThreeVectors are coplanar + set coef;s
// false if ThreeVectors are not coplanar
G4bool G4PTrap::MakePlane( const G4ThreeVector& p1,
const G4ThreeVector& p2,
const G4ThreeVector& p3,
const G4ThreeVector& p4,
PTrapSidePlane& plane )
{
G4double a,b,c,s;
G4ThreeVector v12,v13,v14,Vcross;
G4bool good;
v12 = p2-p1;
v13 = p3-p1;
v14 = p4-p1;
Vcross=v12.cross(v13);
if (fabs(Vcross.dot(v14)/(Vcross.mag()*v14.mag()))>kCoplanar_Tolerance)
{
good=false;
}
else
{
// a,b,c correspond to the x/y/z components of the normal vector to the plane
// a=(p2.y()-p1.y())*(p1.z()+p2.z())+(p3.y()-p2.y())*(p2.z()+p3.z());
// a+=(p4.y()-p3.y())*(p3.z()+p4.z())+(p1.y()-p4.y())*(p4.z()+p1.z()); // may be delete ?
// b=(p2.z()-p1.z())*(p1.x()+p2.x())+(p3.z()-p2.z())*(p2.x()+p3.x());
// b+=(p4.z()-p3.z())*(p3.x()+p4.x())+(p1.z()-p4.z())*(p4.x()+p1.x()); // ?
// c=(p2.x()-p1.x())*(p1.y()+p2.y())+(p3.x()-p2.x())*(p2.y()+p3.y());
// c+=(p4.x()-p3.x())*(p3.y()+p4.y())+(p1.x()-p4.x())*(p4.y()+p1.y()); // ?
// Let create diagonals 4-2 and 3-1 than (4-2)x(3-1) provides vector perpendicular to the
// plane directed to outside !!! and a,b,c, = f(1,2,3,4)
a = +(p4.y() - p2.y())*(p3.z() - p1.z()) - (p3.y() - p1.y())*(p4.z() - p2.z()) ;
b = -(p4.x() - p2.x())*(p3.z() - p1.z()) + (p3.x() - p1.x())*(p4.z() - p2.z()) ;
c = +(p4.x() - p2.x())*(p3.y() - p1.y()) - (p3.x() - p1.x())*(p4.y() - p2.y()) ;
s=sqrt(a*a+b*b+c*c); // so now vector plane.(a,b,c) is unit
plane.a=a/s;
plane.b=b/s;
plane.c=c/s;
// Calculate D: p1 in in plane so D=-n.p1.Vect()
plane.d=-(plane.a*p1.x()+plane.b*p1.y()+plane.c*p1.z());
good=true;
}
return good;
}
// ******************************** End of G4PTrap.cc ********************************
@@ -0,0 +1,85 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PTrd.cc,v 2.0 1998/07/02 16:13:29 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// Implementation for G4Trd class
//
//
// History:
// 19.06.98 A.Kimura Converted G4Trd.cc
#include "G4VSolid.hh"
#include "G4PTrd.hh"
#include "G4Trd.hh"
#include "G4AffineTransform.hh"
#include <math.h>
// Constructor - check & set half widths
G4PTrd::G4PTrd(const G4Trd* theTrd) : G4PCSGSolid(theTrd->GetName())
{
G4double pdx1 = theTrd->GetXHalfLength1();
G4double pdx2 = theTrd->GetXHalfLength2();
G4double pdy1 = theTrd->GetYHalfLength1();
G4double pdy2 = theTrd->GetYHalfLength2();
G4double pdz = theTrd->GetZHalfLength();
CheckAndSetAllParameters (pdx1, pdx2, pdy1, pdy2, pdz);
}
void
G4PTrd::CheckAndSetAllParameters (G4double pdx1, G4double pdx2,
G4double pdy1, G4double pdy2,
G4double pdz) {
if (pdx1>0&&pdx2>0&&pdy1>0&&pdy2>0&&pdz>0)
{
fDx1=pdx1; fDx2=pdx2;
fDy1=pdy1; fDy2=pdy2;
fDz=pdz;
}
else
{
if (pdx1>=0 && pdx2>=0 && pdy1>=0 && pdy2>=0 && pdz>=0)
{
// G4double Minimum_length= (1+per_thousand) * kCarTolerance/2.;
// FIX-ME : temporary solution for ZERO or very-small parameters.
G4double Minimum_length= kCarTolerance/2.;
fDx1=max(pdx1,Minimum_length);
fDx2=max(pdx2,Minimum_length);
fDy1=max(pdy1,Minimum_length);
fDy2=max(pdy2,Minimum_length);
fDz=max(pdz,Minimum_length);
}
else
G4Exception("Error in G4PTrd::G4PTrd - One or more parameters are < 0");
}
}
// -------------------------------------------------------------
// Destructor
G4PTrd::~G4PTrd()
{}
// -----------------------------------------------------------------------
// make a transient object
G4VSolid* G4PTrd::MakeTransientObject() const {
G4VSolid* transientObject = new G4Trd(GetName(),
fDx1, fDx2,
fDy1, fDy2,
fDz);
return transientObject;
}
@@ -0,0 +1,101 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4PTubs.cc,v 2.0 1998/07/02 16:13:31 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
//
// class G4PTubs
//
// History:
// 19.06.98 A.Kimura Converted G4Tubs.cc
#include "G4VSolid.hh"
#include "G4PTubs.hh"
#include "G4Tubs.hh"
#include "G4AffineTransform.hh"
#include "meshdefs.hh"
// Constructor - check parameters, convert angles so 0<sphi+dpshi<=2_PI
// - note if pdphi>2PI then reset to 2PI
G4PTubs::G4PTubs(const G4Tubs* theTubs) : G4PCSGSolid(theTubs->GetName()) {
G4double pRMin = theTubs->GetInnerRadius();
G4double pRMax = theTubs->GetOuterRadius();
G4double pDz = theTubs->GetZHalfLength();
G4double pSPhi = theTubs->GetStartPhiAngle();
G4double pDPhi = theTubs->GetDeltaPhiAngle();
// Check z-len
if (pDz>0)
{
fDz=pDz;
}
else
{
G4Exception("Error in G4PTubs::G4PTubs - invalid z half-length");
}
// Check radii
if (pRMin<pRMax&&pRMin>=0)
{
fRMin=pRMin; fRMax=pRMax;
}
else
{
G4Exception("Error in G4PTubs::G4PTubs - invalid radii");
}
// Check angles
if (pDPhi>=2.0*M_PI)
{
fDPhi=2*M_PI;
}
else
{
if (pDPhi>0)
{
fDPhi = pDPhi;
}
else
{
G4Exception("Error in G4PTubs::G4PTubs - invalid dphi");
}
}
// Ensure psphi in 0-2PI or -2PI-0 range if shape crosses 0
fSPhi = pSPhi;
if (fSPhi<0)
{
fSPhi=2.0*M_PI-fmod(fabs(fSPhi),2.0*M_PI);
}
else
{
fSPhi=fmod(fSPhi,2.0*M_PI);
}
if (fSPhi+fDPhi>2.0*M_PI)
{
fSPhi-=2.0*M_PI;
}
}
// Destructor
G4PTubs::~G4PTubs()
{;}
// make a transient object
G4VSolid* G4PTubs::MakeTransientObject() const {
G4VSolid* transientObject = new G4Tubs(GetName(),
fRMin, fRMax,
fDz,
fSPhi, fDPhi);
return transientObject;
}