Import Geant4 6.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-09 10:56:29 +02:00
parent 1d812b78b1
commit e083ffb441
1415 changed files with 111223 additions and 21207 deletions
@@ -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: G4FlatSurface.hh,v 1.4 2004/05/24 12:09:46 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4FlatSurface
//
// Class description:
//
// Class describing a flat boundary surface for G4VSolid.
// Author:
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp)
//
// History:
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
#ifndef __G4FLATSURFACE__
#define __G4FLATSURFACE__
#include "G4VSurface.hh"
// class G4TwistedTubs;
class G4FlatSurface : public G4VSurface
{
public: // with description
G4FlatSurface(const G4String &name,
const G4RotationMatrix &rot,
const G4ThreeVector &tlate,
const G4ThreeVector &n,
const EAxis axis1 = kRho, // RHO axis !
const EAxis axis2 = kPhi, // PHI axis !
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity );
G4FlatSurface( const G4String &name,
G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
G4double DPhi,
G4double EndPhi[2],
G4double EndZ[2],
G4int handedness ) ;
virtual ~G4FlatSurface();
virtual G4ThreeVector GetNormal(const G4ThreeVector & /* xx */ ,
G4bool isGlobal = false);
virtual G4int DistanceToSurface(const G4ThreeVector &gp,
const G4ThreeVector &gv,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
EValidate validate = kValidateWithTol);
virtual G4int DistanceToSurface(const G4ThreeVector &gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]);
protected: // with description
virtual G4int GetAreaCode(const G4ThreeVector &xx,
G4bool withTol = true) ;
private:
virtual void SetCorners();
virtual void SetBoundaries();
};
#endif
@@ -0,0 +1,152 @@
//
// ********************************************************************
// * 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: G4HyperbolicSurface.hh,v 1.4 2004/05/24 12:09:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4HyperbolicSurface
//
// Class description:
//
// Class describing a hyperbolic boundary surface for G4VSolid.
// Author:
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp)
//
// History:
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
#ifndef __G4HYPERBOLICSURFACE__
#define __G4HYPERBOLICSURFACE__
#include "G4VSurface.hh"
class G4HyperbolicSurface : public G4VSurface
{
public: // with description
G4HyperbolicSurface(const G4String &name,
const G4RotationMatrix &rot, // 0.5*(phi-width segment)
const G4ThreeVector &tlate,
const G4int handedness,// R-hand = 1, L-hand = -1
const G4double kappa, // tan(TwistAngle/2)/fZHalfLen
const G4double tanstereo, // tan(stereo angle)
const G4double r0, // radius at z = 0
const EAxis axis0 = kPhi,
const EAxis axis1 = kZAxis,
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity);
G4HyperbolicSurface(const G4String &name,
G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
G4double DPhi,
G4double EndPhi[2],
G4double EndZ[2],
G4double InnerRadius,
G4double OuterRadius,
G4double Kappa,
G4double TanInnerStereo,
G4double TanOuterStereo,
G4int handedness) ;
virtual ~G4HyperbolicSurface();
virtual G4int DistanceToSurface(const G4ThreeVector &gp,
const G4ThreeVector &gv,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
EValidate validate = kValidateWithTol);
virtual G4int DistanceToSurface(const G4ThreeVector &gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]);
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx,
G4bool isGlobal = false) ;
virtual EInside Inside(const G4ThreeVector &gp) ;
inline virtual G4double GetRhoAtPZ(const G4ThreeVector &p,
G4bool isglobal = false) const ;
private:
virtual G4int GetAreaCode(const G4ThreeVector &xx,
G4bool withTol = true);
virtual G4int GetAreaCodeInPhi(const G4ThreeVector &xx,
G4bool withTol = true);
virtual void SetCorners();
virtual void SetCorners(G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
G4double DPhi,
G4double EndPhi[2],
G4double EndZ[2]);
virtual void SetBoundaries();
private:
G4double fKappa; // tan(TwistedAngle/2)/HalfLenZ;
G4double fTanStereo; // tan(StereoAngle)
G4double fTan2Stereo; // tan(StereoAngle)**2
G4double fR0; // radius at z = 0
G4double fR02; // radius**2 at z = 0
class Insidetype
{
public:
G4ThreeVector gp;
EInside inside;
};
Insidetype fInside;
};
//========================================================
// inline functions
//========================================================
inline
G4double G4HyperbolicSurface::GetRhoAtPZ(const G4ThreeVector &p,
G4bool isglobal) const
{
// Get Rho at p.z() on Hyperbolic Surface.
G4ThreeVector tmpp;
if (isglobal) {
tmpp = fRot.inverse()*p - fTrans;
} else {
tmpp = p;
}
return sqrt(fR02 + tmpp.z() * tmpp.z() * fTan2Stereo);
}
#endif
@@ -0,0 +1,150 @@
//
// ********************************************************************
// * 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: G4TwistedSurface.hh,v 1.4 2004/05/24 12:09:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4TwistedSurface
//
// Class description:
//
// Class describing a twisted boundary surface for G4VSolid.
// Author:
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp)
//
// History:
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
#ifndef __G4TWISTEDSURFACE__
#define __G4TWISTEDSURFACE__
#include "G4VSurface.hh"
class G4TwistedSurface : public G4VSurface
{
public: // with description
G4TwistedSurface(const G4String &name,
const G4RotationMatrix &rot, // 0.5*(phi-width segment)
const G4ThreeVector &tlate,
G4int handedness, // R-hand = 1, L-hand = -1
const G4double kappa, // tan(TwistAngle/2)/fZHalfLen
const EAxis axis0 = kXAxis,
const EAxis axis1 = kZAxis,
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity );
G4TwistedSurface(const G4String &name,
G4double EndInnerRadius[2],
G4double EndOuterRadius[2],
G4double DPhi,
G4double EndPhi[2],
G4double EndZ[2],
G4double InnerRadius,
G4double OuterRadius,
G4double Kappa,
G4int handedness);
virtual ~G4TwistedSurface();
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx,
G4bool isGlobal = false) ;
virtual G4int DistanceToSurface(const G4ThreeVector &gp,
const G4ThreeVector &gv,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
EValidate validate = kValidateWithTol);
virtual G4int DistanceToSurface(const G4ThreeVector &gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]);
inline G4ThreeVector ProjectAtPXPZ(const G4ThreeVector &p,
G4bool isglobal = false) const ;
private:
virtual G4double DistanceToPlane(const G4ThreeVector &p,
const G4ThreeVector &A,
const G4ThreeVector &B,
const G4ThreeVector &C,
const G4ThreeVector &D,
const G4int parity,
G4ThreeVector &xx,
G4ThreeVector &n);
virtual G4int GetAreaCode(const G4ThreeVector &xx,
G4bool withTol = true);
virtual void SetCorners();
virtual void SetCorners( G4double endInnerRad[2],
G4double endOuterRad[2],
G4double endPhi[2],
G4double endZ[2] ) ;
virtual void SetBoundaries();
private:
G4double fKappa; // tan(TwistedAngle/2)/HalfLenZ;
};
//========================================================
// inline functions
//========================================================
inline
G4ThreeVector G4TwistedSurface::ProjectAtPXPZ(const G4ThreeVector &p,
G4bool isglobal) const
{
// Get Rho at p.z() on Hyperbolic Surface.
G4ThreeVector tmpp;
if (isglobal) {
tmpp = fRot.inverse()*p - fTrans;
} else {
tmpp = p;
}
G4ThreeVector xx(p.x(), p.x() * fKappa * p.z(), p.z());
if (isglobal) {
return (fRot * xx + fTrans);
} else {
return xx;
}
}
#endif
@@ -0,0 +1,356 @@
//
// ********************************************************************
// * 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: G4TwistedTubs.hh,v 1.3 2004/05/24 12:09:47 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4TwistedTubs
//
// Class description:
//
// G4TwistedTubs is a sort of twisted cylinder.
// A twisted cylinder which is placed along with z-axis and is
// separated into phi-segments should become a hyperboloid, and
// its each segmented piece should be tilted with a stereo angle.
// G4TwistedTubs is a G4VSolid.
// It can have inner & outer surfaces as well as G4TwistedTubs,
// but cannot has different stereo angles between the inner surface
// and outer surface.
// Author:
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp)
//
// History:
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
#ifndef __G4TWISTEDTUBS__
#define __G4TWISTEDTUBS__
#include "G4VSolid.hh"
#include "G4FlatSurface.hh"
#include "G4TwistedSurface.hh"
#include "G4HyperbolicSurface.hh"
class G4SolidExtentList;
class G4ClippablePolygon;
class G4TwistedTubs : public G4VSolid
{
public: // with description
G4TwistedTubs(const G4String &pname, // Name of instance
G4double twistedangle, // Twisted angle
G4double endinnerrad, // Inner radius at endcap
G4double endouterrad, // Outer radius at endcap
G4double halfzlen, // half z length
G4double dphi); // Phi angle of a segment
G4TwistedTubs(const G4String &pname, // Name of instance
G4double twistedangle, // Stereo angle
G4double endinnerrad, // Inner radius at endcap
G4double endouterrad, // Outer radius at endcap
G4double halfzlen, // half z length
G4int nseg, // Number of segments in totalPhi
G4double totphi); // Total angle of all segments
G4TwistedTubs(const G4String &pname, // Name of instance
G4double twistedangle, // Twisted angle
G4double innerrad, // Inner radius at z=0
G4double outerrad, // Outer radius at z=0
G4double negativeEndz, // -ve z endplate
G4double positiveEndz, // +ve z endplate
G4double dphi); // Phi angle of a segment
G4TwistedTubs(const G4String &pname, // Name of instance
G4double twistedangle, // Stereo angle
G4double innerrad, // Inner radius at z=0
G4double outerrad, // Outer radius at z=0
G4double negativeEndz, // -ve z endplate
G4double positiveEndz, // +ve z endplate
G4int nseg, // Number of segments in totalPhi
G4double totphi); // Total angle of all segments
virtual ~G4TwistedTubs();
void ComputeDimensions(G4VPVParameterisation * /* p */ ,
const G4int /* n */ ,
const G4VPhysicalVolume * /* prep */ );
G4bool CalculateExtent(const EAxis paxis,
const G4VoxelLimits &pvoxellimit,
const G4AffineTransform &ptransform,
G4double &pmin,
G4double &pmax ) const;
G4double DistanceToIn (const G4ThreeVector &p,
const G4ThreeVector &v ) const;
G4double DistanceToIn (const G4ThreeVector &p ) const;
G4double DistanceToOut(const G4ThreeVector &p,
const G4ThreeVector &v,
const G4bool calcnorm=G4bool(false),
G4bool *validnorm=0,
G4ThreeVector *n=0 ) const;
G4double DistanceToOut(const G4ThreeVector &p) const;
EInside Inside (const G4ThreeVector &p) const;
G4ThreeVector SurfaceNormal(const G4ThreeVector &p) const;
void DescribeYourselfTo (G4VGraphicsScene &scene) const;
G4Polyhedron *CreatePolyhedron () const;
G4NURBS *CreateNURBS () const;
std::ostream &StreamInfo(std::ostream& os) const;
// accessors
inline G4double GetDPhi () const { return fDPhi ; }
inline G4double GetPhiTwist () const { return fPhiTwist ; }
inline G4double GetInnerRadius () const { return fInnerRadius; }
inline G4double GetOuterRadius () const { return fOuterRadius; }
inline G4double GetInnerStereo () const { return fInnerStereo; }
inline G4double GetOuterStereo () const { return fOuterStereo; }
inline G4double GetZHalfLength () const { return fZHalfLength; }
inline G4double GetKappa () const { return fKappa ; }
inline G4double GetTanInnerStereo () const { return fTanInnerStereo ; }
inline G4double GetTanInnerStereo2() const { return fTanInnerStereo2 ; }
inline G4double GetTanOuterStereo () const { return fTanOuterStereo ; }
inline G4double GetTanOuterStereo2() const { return fTanOuterStereo2 ; }
inline G4double GetEndZ (G4int i) const { return fEndZ[i] ; }
inline G4double GetEndPhi (G4int i) const { return fEndPhi[i]; }
inline G4double GetEndInnerRadius (G4int i) const
{ return fEndInnerRadius[i]; }
inline G4double GetEndOuterRadius (G4int i) const
{ return fEndOuterRadius[i]; }
inline G4double GetEndInnerRadius () const
{ return (fEndInnerRadius[0] > fEndInnerRadius[1] ?
fEndInnerRadius[0] : fEndInnerRadius[1]); }
inline G4double GetEndOuterRadius () const
{ return (fEndOuterRadius[0] > fEndOuterRadius[1] ?
fEndOuterRadius[0] : fEndOuterRadius[1]); }
G4VisExtent GetExtent () const;
G4GeometryType GetEntityType() const;
public: // without description
#ifdef G4SPECSDEBUG
G4VSurface * GetOuterHype() const { return fOuterHype; }
#endif
private:
inline void SetFields(G4double phitwist, G4double innerrad,
G4double outerrad,
G4double negativeEndz, G4double positiveEndz);
void CreateSurfaces();
static void AddPolyToExtent( const G4ThreeVector &v0,
const G4ThreeVector &v1,
const G4ThreeVector &w1,
const G4ThreeVector &w0,
const G4VoxelLimits &voxellimit,
const EAxis axis,
G4SolidExtentList &extentlist );
private:
G4double fPhiTwist; // Twist angle from -fZHalfLength to fZHalfLength
G4double fInnerRadius; // Inner-hype radius at z=0
G4double fOuterRadius; // Outer-hype radius at z=0
G4double fEndZ[2]; // z at endcaps, [0] = -ve z, [1] = +ve z
G4double fDPhi; // Phi-width of a segment fDPhi > 0
G4double fZHalfLength; // Half length along z-axis
G4double fInnerStereo; // Inner-hype stereo angle
G4double fOuterStereo; // Outer-hype stereo angle
G4double fTanInnerStereo; // tan(innerStereoAngle)
G4double fTanOuterStereo; // tan(outerStereoAngle)
G4double fKappa; // tan(fPhiTwist/2)/fZHalfLen;
G4double fEndInnerRadius[2]; // Inner-hype radii endcaps [0] -ve z, [1] +ve z
G4double fEndOuterRadius[2]; // Outer-hype radii endcaps [0] -ve z, [1] +ve z
G4double fEndPhi[2]; // Phi endcaps, [0] = -ve z, [1] = +ve z
G4double fInnerRadius2; // fInnerRadius * fInnerRadius
G4double fOuterRadius2; // fOuterRadius * fOuterRadius
G4double fTanInnerStereo2; // fInnerRadius * fInnerRadius
G4double fTanOuterStereo2; // fInnerRadius * fInnerRadius
G4double fEndZ2[2]; // fEndZ * fEndZ
G4VSurface *fLowerEndcap; // Surface of -ve z
G4VSurface *fUpperEndcap; // Surface of +ve z
G4VSurface *fLatterTwisted; // Surface of -ve phi
G4VSurface *fFormerTwisted; // Surface of +ve phi
G4VSurface *fInnerHype; // Surface of -ve r
G4VSurface *fOuterHype; // Surface of +ve r
class LastState // last Inside result
{
public:
LastState()
{
p.set(kInfinity,kInfinity,kInfinity);
inside = kOutside;
}
~LastState(){}
public:
G4ThreeVector p;
EInside inside;
};
class LastVector // last SurfaceNormal result
{
public:
LastVector()
{
p.set(kInfinity,kInfinity,kInfinity);
vec.set(kInfinity,kInfinity,kInfinity);
surface = new G4VSurface*[1];
}
~LastVector()
{
delete [] surface;
}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4VSurface **surface;
};
class LastValue // last G4double value
{
public:
LastValue()
{
p.set(kInfinity,kInfinity,kInfinity);
value = DBL_MAX;
}
~LastValue(){}
public:
G4ThreeVector p;
G4double value;
};
class LastValueWithDoubleVector // last G4double value
{
public:
LastValueWithDoubleVector()
{
p.set(kInfinity,kInfinity,kInfinity);
vec.set(kInfinity,kInfinity,kInfinity);
value = DBL_MAX;
}
~LastValueWithDoubleVector(){}
public:
G4ThreeVector p;
G4ThreeVector vec;
G4double value;
};
LastState fLastInside;
LastVector fLastNormal;
LastValue fLastDistanceToIn;
LastValue fLastDistanceToOut;
LastValueWithDoubleVector fLastDistanceToInWithV;
LastValueWithDoubleVector fLastDistanceToOutWithV;
};
//=====================================================================
//---------------------
// inline functions
//---------------------
inline
void G4TwistedTubs::SetFields(G4double phitwist, G4double innerrad,
G4double outerrad, G4double negativeEndz,
G4double positiveEndz)
{
fPhiTwist = phitwist;
fEndZ[0] = negativeEndz;
fEndZ[1] = positiveEndz;
fEndZ2[0] = fEndZ[0] * fEndZ[0];
fEndZ2[1] = fEndZ[1] * fEndZ[1];
fInnerRadius = innerrad;
fOuterRadius = outerrad;
fInnerRadius2 = fInnerRadius * fInnerRadius;
fOuterRadius2 = fOuterRadius * fOuterRadius;
G4int maxi;
if (fabs(fEndZ[0]) >= fabs(fEndZ[1])) {
fZHalfLength = fabs(fEndZ[0]);
maxi = 0;
} else {
fZHalfLength = fabs(fEndZ[1]);
maxi = 1;
}
G4double parity = (fPhiTwist > 0 ? 1 : -1);
G4double tanHalfTwist = tan(0.5 * fPhiTwist);
G4double innerNumerator = fabs(fInnerRadius * tanHalfTwist) * parity;
G4double outerNumerator = fabs(fOuterRadius * tanHalfTwist) * parity;
fTanInnerStereo = innerNumerator / fZHalfLength;
fTanOuterStereo = outerNumerator / fZHalfLength;
fTanInnerStereo2 = fTanInnerStereo * fTanInnerStereo;
fTanOuterStereo2 = fTanOuterStereo * fTanOuterStereo;
fInnerStereo = atan2(innerNumerator, fZHalfLength);
fOuterStereo = atan2(outerNumerator, fZHalfLength);
fEndInnerRadius[0] = sqrt(fInnerRadius2 + fEndZ2[0] * fTanInnerStereo2);
fEndInnerRadius[1] = sqrt(fInnerRadius2 + fEndZ2[1] * fTanInnerStereo2);
fEndOuterRadius[0] = sqrt(fOuterRadius2 + fEndZ2[0] * fTanOuterStereo2);
fEndOuterRadius[1] = sqrt(fOuterRadius2 + fEndZ2[1] * fTanOuterStereo2);
fKappa = tanHalfTwist / fZHalfLength;
fEndPhi[0] = atan2(fEndZ[0] * tanHalfTwist, fZHalfLength);
fEndPhi[1] = atan2(fEndZ[1] * tanHalfTwist, fZHalfLength);
#ifdef G4SPECSDEBUG
G4cout << "/********* G4TwistedTubs::SetFields() Field Parameters ***************** " << G4endl;
G4cout << "/* fPhiTwist : " << fPhiTwist << G4endl;
G4cout << "/* fEndZ(0, 1) : " << fEndZ[0] << " , " << fEndZ[1] << G4endl;
G4cout << "/* fEndPhi(0, 1) : " << fEndPhi[0] << " , " << fEndPhi[1] << G4endl;
G4cout << "/* fInnerRadius, fOuterRadius : " << fInnerRadius << " , " << fOuterRadius << G4endl;
G4cout << "/* fEndInnerRadius(0, 1) : " << fEndInnerRadius[0] << " , "
<< fEndInnerRadius[1] << G4endl;
G4cout << "/* fEndOuterRadius(0, 1) : " << fEndOuterRadius[0] << " , "
<< fEndOuterRadius[1] << G4endl;
G4cout << "/* fInnerStereo, fOuterStereo : " << fInnerStereo << " , " << fOuterStereo << G4endl;
G4cout << "/* tanHalfTwist, fKappa : " << tanHalfTwist << " , " << fKappa << G4endl;
G4cout << "/*********************************************************************** " << G4endl;
#endif
}
#endif
@@ -0,0 +1,337 @@
//
// ********************************************************************
// * 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: G4VSurface.hh,v 1.8 2004/05/28 18:19:05 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// --------------------------------------------------------------------
// GEANT 4 class header file
//
//
// G4VSurface
//
// Class description:
//
// Abstract base class for boundary surface of G4VSolid.
// Author:
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp)
//
// History:
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
#ifndef __G4VSURFACE__
#define __G4VSURFACE__
#include "G4VSolid.hh"
#include "geomdefs.hh"
#include "G4RotationMatrix.hh"
class G4VSurface
{
public: // without description
enum EValidate {kDontValidate = 0, kValidateWithTol = 1,
kValidateWithoutTol = 2, kUninitialized = 3};
public: // with description
G4VSurface (const G4String &name);
G4VSurface (const G4String &name,
const G4RotationMatrix &rot,
const G4ThreeVector &tlate,
G4int handedness,
const EAxis axis1,
const EAxis axis2,
G4double axis0min = -kInfinity,
G4double axis1min = -kInfinity,
G4double axis0max = kInfinity,
G4double axis1max = kInfinity);
virtual ~G4VSurface();
virtual G4int AmIOnLeftSide(const G4ThreeVector &me,
const G4ThreeVector &vec,
G4bool withTol = true);
virtual G4double DistanceToBoundary( G4int areacode,
G4ThreeVector &xx,
const G4ThreeVector &p) ;
virtual G4double DistanceToIn(const G4ThreeVector &gp,
const G4ThreeVector &gv,
G4ThreeVector &gxxbest);
virtual G4double DistanceToOut(const G4ThreeVector &gp,
const G4ThreeVector &gv,
G4ThreeVector &gxxbest);
virtual G4double DistanceTo(const G4ThreeVector &gp,
G4ThreeVector &gxx);
virtual G4int DistanceToSurface(const G4ThreeVector &gp,
const G4ThreeVector &gv,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[],
G4bool isvalid[],
EValidate validate=kValidateWithTol) = 0;
virtual G4int DistanceToSurface(const G4ThreeVector &gp,
G4ThreeVector gxx[],
G4double distance[],
G4int areacode[]) = 0;
void DebugPrint() const;
// get methods
virtual G4ThreeVector GetNormal(const G4ThreeVector &xx,G4bool isGlobal) = 0;
virtual G4String GetName() const { return fName; }
virtual void GetBoundaryParameters(const G4int &areacode,
G4ThreeVector &d,
G4ThreeVector &x0,
G4int &boundarytype) const;
virtual G4ThreeVector GetBoundaryAtPZ(G4int areacode,
const G4ThreeVector &p) const;
inline G4double DistanceToPlaneWithV(const G4ThreeVector &p,
const G4ThreeVector &v,
const G4ThreeVector &x0,
const G4ThreeVector &n0,
G4ThreeVector &xx);
inline G4double DistanceToPlane(const G4ThreeVector &p,
const G4ThreeVector &x0,
const G4ThreeVector &n0,
G4ThreeVector &xx);
inline G4double DistanceToPlane(const G4ThreeVector &p,
const G4ThreeVector &x0,
const G4ThreeVector &t1,
const G4ThreeVector &t2,
G4ThreeVector &xx,
G4ThreeVector &n);
inline G4double DistanceToLine (const G4ThreeVector &p,
const G4ThreeVector &x0,
const G4ThreeVector &d,
G4ThreeVector &xx);
inline G4bool IsAxis0 (G4int areacode) const;
inline G4bool IsAxis1 (G4int areacode) const;
inline G4bool IsOutside (G4int areacode) const;
inline G4bool IsInside (G4int areacode, G4bool testbitmode = false) const;
inline G4bool IsBoundary (G4int areacode, G4bool testbitmode = false) const;
inline G4bool IsCorner (G4int areacode, G4bool testbitmode = false) const;
inline G4bool IsValidNorm() const { return fIsValidNorm; }
G4bool IsSameBoundary (G4VSurface *surface1, G4int areacode1,
G4VSurface *surface2, G4int areacode2 ) const;
inline G4int GetAxisType(G4int areacode, G4int whichaxis) const;
inline G4ThreeVector ComputeGlobalPoint (const G4ThreeVector &lp) const;
inline G4ThreeVector ComputeLocalPoint (const G4ThreeVector &gp) const;
inline G4ThreeVector ComputeGlobalDirection (const G4ThreeVector &lp) const;
inline G4ThreeVector ComputeLocalDirection (const G4ThreeVector &gp) const;
// set methods
inline void SetAxis(G4int i, const EAxis axis) { fAxis[i] = axis; }
inline void SetNeighbours(G4VSurface* axis0min, G4VSurface* axis1min,
G4VSurface* axis0max, G4VSurface* axis1max);
protected: // with description
// get methods
inline G4VSurface** GetNeighbours() { return fNeighbours; }
inline G4int GetNeighbours(G4int areacode, G4VSurface* surfaces[]);
inline G4ThreeVector GetCorner(G4int areacode) const;
void GetBoundaryAxis(G4int areacode, EAxis axis[]) const;
void GetBoundaryLimit(G4int areacode, G4double limit[]) const;
virtual G4int GetAreaCode(const G4ThreeVector &xx, G4bool withtol=true) = 0;
// set methods
virtual void SetBoundary(const G4int &axiscode,
const G4ThreeVector &direction,
const G4ThreeVector &x0,
const G4int &boundarytype);
// areacode must be one of them:
// sAxis0 & sAxisMin, sAxis0 & sAxisMax,
// sAxis1 & sAxisMin, sAxis1 & sAxisMax.
// boundarytype represents the shape of locus
// from the start point to end point of boundary.
// ex.
// sAxisRho = linear line which start point is fixed at origin.
// sAxisPhi = part of circle which center placed at the origin.
void SetCorner(G4int areacode, G4double x, G4double y, G4double z);
private:
virtual void SetBoundaries() = 0;
virtual void SetCorners() = 0;
// data members ---------------------------------------------------------
public:
static const G4int sOutside ;
static const G4int sInside ;
static const G4int sBoundary;
static const G4int sCorner;
static const G4int sCMin1Min;
static const G4int sCMax1Min;
static const G4int sCMax1Max;
static const G4int sCMin1Max;
static const G4int sAxisMin;
static const G4int sAxisMax;
static const G4int sAxisX;
static const G4int sAxisY;
static const G4int sAxisZ;
static const G4int sAxisRho;
static const G4int sAxisPhi;
static const G4int sAxis0;
static const G4int sAxis1;
static const G4int sSizeMask;
static const G4int sAxisMask;
static const G4int sAreaMask;
protected:
class CurrentStatus
{
public:
CurrentStatus();
virtual ~CurrentStatus();
inline G4ThreeVector GetXX(G4int i) const { return fXX[i]; }
inline G4double GetDistance(G4int i) const { return fDistance[i]; }
inline G4int GetAreacode(G4int i) const { return fAreacode[i]; }
inline G4int GetNXX() const { return fNXX; }
inline G4bool IsDone() const { return fDone; }
inline G4bool IsValid(G4int i) const { return fIsValid[i]; }
void SetCurrentStatus(G4int i,
G4ThreeVector &xx,
G4double &dist,
G4int &areacode,
G4bool &isvalid,
G4int nxx,
EValidate validate,
const G4ThreeVector *p,
const G4ThreeVector *v = 0);
void ResetfDone(EValidate validate,
const G4ThreeVector *p,
const G4ThreeVector *v = 0);
void DebugPrint() const;
private:
G4double fDistance[2];
G4ThreeVector fXX[2];
G4int fAreacode[2];
G4bool fIsValid[2];
G4int fNXX;
G4ThreeVector fLastp;
G4ThreeVector fLastv;
EValidate fLastValidate;
G4bool fDone;
};
class Boundary
{
public:
Boundary();
virtual ~Boundary();
void SetFields(const G4int &areacode,
const G4ThreeVector &d,
const G4ThreeVector &x0,
const G4int &boundarytype);
G4bool IsEmpty() const;
G4bool GetBoundaryParameters(const G4int &areacode,
G4ThreeVector &d,
G4ThreeVector &x0,
G4int &boundarytype) const;
private:
G4int fBoundaryAcode;
G4ThreeVector fBoundaryDirection;
G4ThreeVector fBoundaryX0;
G4int fBoundaryType;
};
EAxis fAxis[2];
G4double fAxisMin[2];
G4double fAxisMax[2];
CurrentStatus fCurStatWithV;
CurrentStatus fCurStat;
G4RotationMatrix fRot;
G4ThreeVector fTrans;
G4int fHandedness;
class G4SurfCurNormal
{
public:
G4ThreeVector p;
G4ThreeVector normal;
};
G4SurfCurNormal fCurrentNormal;
G4bool fIsValidNorm;
private:
G4VSurface *fNeighbours[4]; // {0,1,2,3} = sAxis0min, sAxis1min,
// sAxis0max, sAxis1max
G4ThreeVector fCorners[4]; // corners of the surface in local coordinate
Boundary fBoundaries[4]; // boundaries of the surface.
G4String fName;
class G4SurfSideQuery
{
public:
G4ThreeVector me;
G4ThreeVector vec;
G4bool withTol;
G4int amIOnLeftSide;
};
G4SurfSideQuery fAmIOnLeftSide;
};
//========================================================
// inline functions
//========================================================
#include "G4VSurface.icc"
#endif
@@ -0,0 +1,369 @@
//
// ********************************************************************
// * 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: G4VSurface.icc,v 1.2 2004/05/28 13:13:35 gcosmo Exp $
// GEANT4 tag $Name: geant4-06-02 $
//
//
// --------------------------------------------------------------------
// G4VSurface class inline methods
//
// Author:
// 01-Aug-2002 - Kotoyo Hoshina (hoshina@hepburn.s.chiba-u.ac.jp)
//
// History:
// 13-Nov-2003 - O.Link (Oliver.Link@cern.ch), Integration in Geant4
// from original version in Jupiter-2.5.02 application.
// --------------------------------------------------------------------
//=====================================================================
//* DistanceToPlaneWithV ----------------------------------------------
inline
G4double G4VSurface::DistanceToPlaneWithV(const G4ThreeVector &p,
const G4ThreeVector &v,
const G4ThreeVector &x0,
const G4ThreeVector &n0,
G4ThreeVector &xx)
{
G4double t = (n0 * (x0 - p)) / (n0 * v);
xx = p + t * v;
return t;
}
//=====================================================================
//* DistanceToPlane ---------------------------------------------------
inline
G4double G4VSurface::DistanceToPlane(const G4ThreeVector &p,
const G4ThreeVector &x0,
const G4ThreeVector &n0,
G4ThreeVector &xx)
{
// DistanceToPlane :
// Calculate distance to plane in local coordinate,
// then return distance and global intersection points.
//
// p - location of flying particle
// x0 - reference point of surface
// xx - a foot of perpendicular line from p to the plane
// t - distance from xx to p
// n - a unit normal of this plane from plane to p.
//
// equation of plane:
// n*(x - x0) = 0;
//
// vector to xx:
// xx = p - t*n
//
// where
// t = n * (p - x0) / abs(n)
//
G4double t;
G4ThreeVector n = n0.unit();
t = n * (p - x0);
xx = p - t * n;
return t;
}
//=====================================================================
//* DistanceToPlane ---------------------------------------------------
inline
G4double G4VSurface::DistanceToPlane(const G4ThreeVector &p,
const G4ThreeVector &x0,
const G4ThreeVector &t1,
const G4ThreeVector &t2,
G4ThreeVector &xx,
G4ThreeVector &n)
{
// DistanceToPlane :
// Calculate distance to plane in local coordinate,
// then return distance and global intersection points.
// t1 - 1st. vector lying on the plane
// t2 - 2nd. vector lying on the plane
n = (t1.cross(t2)).unit();
return DistanceToPlane(p, x0, n, xx);
}
//=====================================================================
//* DistanceToLine ----------------------------------------------------
inline
G4double G4VSurface::DistanceToLine(const G4ThreeVector &p,
const G4ThreeVector &x0,
const G4ThreeVector &d,
G4ThreeVector &xx)
{
// DistanceToLine :
// Calculate distance to line,
// then return distance and global intersection points.
//
// p - location of flying particle
// x0 - reference point of line
// d - direction vector of line
// xx - a foot of perpendicular line from p to the plane
// t - distance from xx to p
//
// Equation
//
// distance^2 = |(xx - p)|^2
// with
// xx = x0 + t*d
//
// (d/dt)distance^2 = (d/dt)|((x0 + t*d) - p)|^2
// = 2*t*|d|^2 + 2*d*(x0 - p)
// = 0 // smallest distance
// then
// t = - d*(x0 - p) / |d|^2
//
G4double t;
G4ThreeVector dir = d.unit();
t = - dir * (x0 - p); // |dir|^2 = 1.
xx = x0 + t * dir;
G4ThreeVector dist = xx - p;
return dist.mag();
}
//=====================================================================
//* IsAxis0 -----------------------------------------------------------
inline
G4bool G4VSurface::IsAxis0(G4int areacode) const
{
if (areacode & sAxis0) return true;
return false;
}
//=====================================================================
//* IsAxis1 -----------------------------------------------------------
inline
G4bool G4VSurface::IsAxis1(G4int areacode) const
{
if (areacode & sAxis1) return true;
return false;
}
//=====================================================================
//* IsOutside ---------------------------------------------------------
inline
G4bool G4VSurface::IsOutside(G4int areacode) const
{
if (areacode & sInside) return false;
return true;
}
//=====================================================================
//* IsInside ----------------------------------------------------------
inline
G4bool G4VSurface::IsInside(G4int areacode, G4bool testbitmode) const
{
if (areacode & sInside) {
if (testbitmode) {
return true;
} else {
if (!((areacode & sBoundary) || (areacode & sCorner))) return true;
}
}
return false;
}
//=====================================================================
//* IsBoundary --------------------------------------------------------
inline
G4bool G4VSurface::IsBoundary(G4int areacode, G4bool testbitmode) const
{
if ((areacode & sBoundary) == sBoundary) {
if (testbitmode) {
return true;
} else {
if ((areacode & sInside) == sInside) return true;
}
}
return false;
}
//=====================================================================
//* IsCorner ----------------------------------------------------------
inline
G4bool G4VSurface::IsCorner(G4int areacode, G4bool testbitmode) const
{
if ((areacode & sCorner) == sCorner) {
if (testbitmode) {
return true;
} else {
if ((areacode & sInside) == sInside) return true;
}
}
return false;
}
//=====================================================================
//* GetAxisType -------------------------------------------------------
inline
G4int G4VSurface::GetAxisType(G4int areacode, G4int whichaxis) const
{
G4int axiscode = areacode & sAxisMask & whichaxis;
if (axiscode == (sAxisX & sAxis0) ||
axiscode == (sAxisX & sAxis1)) {
return sAxisX;
} else if (axiscode == (sAxisY & sAxis0) ||
axiscode == (sAxisY & sAxis1)) {
return sAxisY;
} else if (axiscode == (sAxisZ & sAxis0) ||
axiscode == (sAxisZ & sAxis1)) {
return sAxisZ;
} else if (axiscode == (sAxisRho & sAxis0) ||
axiscode == (sAxisRho & sAxis1)) {
return sAxisRho;
} else if (axiscode == (sAxisPhi & sAxis0) ||
axiscode == (sAxisPhi & sAxis1)) {
return sAxisPhi;
} else {
G4cerr << "ERROR - G4VSurface::GetAxisType()" << G4endl
<< " areacode = " << areacode << G4endl;
G4Exception("G4VSurface::GetAxisType()","NotSupported",
FatalException, "Configuration not supported.");
}
return 1;
}
//=====================================================================
//* ComputeGlobalPoint ------------------------------------------------
inline
G4ThreeVector G4VSurface::ComputeGlobalPoint(const G4ThreeVector &lp) const
{
return fRot * G4ThreeVector(lp) + fTrans;
}
//=====================================================================
//* ComputeGlobalPoint ------------------------------------------------
inline
G4ThreeVector G4VSurface::ComputeLocalPoint(const G4ThreeVector &gp) const
{
return fRot.inverse() * G4ThreeVector(gp) - fTrans;
}
//=====================================================================
//* ComputeGlobalDirection --------------------------------------------
inline
G4ThreeVector G4VSurface::ComputeGlobalDirection(const G4ThreeVector &lp) const
{
return fRot * G4ThreeVector(lp);
}
//=====================================================================
//* ComputeLocalDirection ---------------------------------------------
inline
G4ThreeVector G4VSurface::ComputeLocalDirection(const G4ThreeVector &gp) const
{
return fRot.inverse() * G4ThreeVector(gp);
}
//=====================================================================
//* SetNeighbours -----------------------------------------------------
inline
void G4VSurface::SetNeighbours(G4VSurface* axis0min, G4VSurface* axis1min,
G4VSurface* axis0max, G4VSurface* axis1max)
{
fNeighbours[0] = axis0min;
fNeighbours[1] = axis1min;
fNeighbours[2] = axis0max;
fNeighbours[4] = axis1max;
}
//=====================================================================
//* GetNeighbours -----------------------------------------------------
inline
G4int G4VSurface::GetNeighbours(G4int areacode, G4VSurface** surfaces)
{
G4int i = 0;
if (areacode & (sAxis0 | sAxisMin)) {
surfaces[i] = fNeighbours[0];
i++;
}
if (areacode & (sAxis1 | sAxisMin)) {
surfaces[i] = fNeighbours[1];
i++;
if (i == 2) return i;
}
if (areacode & (sAxis0 | sAxisMax)) {
surfaces[i] = fNeighbours[2];
i++;
if (i == 2) return i;
}
if (areacode & (sAxis1 | sAxisMax)) {
surfaces[i] = fNeighbours[3];
i++;
if (i == 2) return i;
}
return i;
}
//=====================================================================
//* GetCorner ---------------------------------------------------------
inline
G4ThreeVector G4VSurface::GetCorner(G4int areacode) const
{
if (!(areacode & sCorner)){
G4cerr << "ERROR - G4VSurface::GetCorner()" << G4endl
<< " areacode = " << areacode << G4endl;
G4Exception("G4VSurface::GetCorner()","InvalidSetup",
FatalException, "Area code must represent corner.");
}
if ((areacode & sCMin1Min) == sCMin1Min) {
return fCorners[0];
} else if ((areacode & sCMax1Min) == sCMax1Min) {
return fCorners[1];
} else if ((areacode & sCMax1Max) == sCMax1Max) {
return fCorners[2];
} else if ((areacode & sCMin1Max) == sCMin1Max) {
return fCorners[3];
} else {
G4cerr << "ERROR - G4VSurface::GetCorner()" << G4endl
<< " areacode = " << areacode << G4endl;
G4Exception("G4VSurface::GetCorner()", "NotSupported",
FatalException, "Configuration not supported.");
}
return fCorners[0];
}