Import Geant4 11.0.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2021-06-25 16:12:29 +02:00
parent c968e26a39
commit 6399a014b6
4200 changed files with 207479 additions and 237366 deletions
@@ -48,33 +48,37 @@
class G4ErrorFreeTrajParam
{
public: // with description
G4ErrorFreeTrajParam()
: fInvP(0.), fLambda(0.), fPhi(0.), fYPerp(0.), fZPerp(0.){}
G4ErrorFreeTrajParam( const G4Point3D& pos, const G4Vector3D& mom );
// build parameters from position and momentum
: fInvP(0.)
, fLambda(0.)
, fPhi(0.)
, fYPerp(0.)
, fZPerp(0.)
{}
G4ErrorFreeTrajParam(const G4Point3D& pos, const G4Vector3D& mom);
// build parameters from position and momentum
G4ErrorFreeTrajParam(const G4ErrorFreeTrajParam&) = default;
G4ErrorFreeTrajParam(G4ErrorFreeTrajParam&&) = default;
// The copy and move constructors
G4ErrorFreeTrajParam(G4ErrorFreeTrajParam&&) = default;
// The copy and move constructors
virtual ~G4ErrorFreeTrajParam(){}
virtual ~G4ErrorFreeTrajParam() {}
G4ErrorFreeTrajParam& operator = (const G4ErrorFreeTrajParam&) = default;
G4ErrorFreeTrajParam& operator = (G4ErrorFreeTrajParam&&) = default;
// The copy and move assignment operators
G4ErrorFreeTrajParam& operator=(const G4ErrorFreeTrajParam&) = default;
G4ErrorFreeTrajParam& operator=(G4ErrorFreeTrajParam&&) = default;
// The copy and move assignment operators
void Update( const G4Track* aTrack );
// update parameters from G4Track
void Update(const G4Track* aTrack);
// update parameters from G4Track
friend
std::ostream& operator<<(std::ostream&, const G4ErrorFreeTrajParam& ts);
// Set and Get methods
friend std::ostream& operator<<(std::ostream&,
const G4ErrorFreeTrajParam& ts);
void SetParameters( const G4Point3D& pos, const G4Vector3D& mom );
// Set and Get methods
G4Vector3D GetDirection() const { return fDir;}
void SetParameters(const G4Point3D& pos, const G4Vector3D& mom);
G4Vector3D GetDirection() const { return fDir; }
G4double GetInvP() const { return fInvP; }
G4double GetLambda() const { return fLambda; }
@@ -83,13 +87,12 @@ class G4ErrorFreeTrajParam
G4double GetZPerp() const { return fZPerp; }
private:
G4Vector3D fDir; //direction to which YPerp, ZPerp refer
G4double fInvP; // inverse of momentum
G4double fLambda; // 90 - theta angle of direction
G4double fPhi; // phi angle of direction
G4double fYPerp; // Y coordinate
G4double fZPerp; // Z coordinate
G4Vector3D fDir; // direction to which YPerp, ZPerp refer
G4double fInvP; // inverse of momentum
G4double fLambda; // 90 - theta angle of direction
G4double fPhi; // phi angle of direction
G4double fYPerp; // Y coordinate
G4double fZPerp; // Z coordinate
};
#endif
@@ -39,8 +39,8 @@
// local orthonormal reference frame with the x_perp axis along the
// particle direction, the y_perp being parallel to the x-y plane.
//
// This class also takes care of propagating the error associated to
// the trajectory
// This class also takes care of propagating the error associated to
// the trajectory
// History:
// - Created: P. Arce
@@ -64,74 +64,74 @@ class G4ErrorSurfaceTrajState;
class G4ErrorFreeTrajState : public G4ErrorTrajState
{
public: // with description
G4ErrorFreeTrajState()
: theFirstStep(true)
{}
G4ErrorFreeTrajState(const G4String& partName, const G4Point3D& pos,
const G4Vector3D& mom,
const G4ErrorTrajErr& errmat = G4ErrorTrajErr(5, 0));
// Constructor by providing particle, position and momentum
G4ErrorFreeTrajState() : theFirstStep(true) {}
G4ErrorFreeTrajState( const G4String& partName,
const G4Point3D& pos,
const G4Vector3D& mom,
const G4ErrorTrajErr& errmat = G4ErrorTrajErr(5,0) );
// Constructor by providing particle, position and momentum
G4ErrorFreeTrajState(const G4ErrorSurfaceTrajState& tpOS);
// Constructor by providing G4ErrorSurfaceTrajState
G4ErrorFreeTrajState( const G4ErrorSurfaceTrajState& tpOS );
// Constructor by providing G4ErrorSurfaceTrajState
~G4ErrorFreeTrajState() {}
~G4ErrorFreeTrajState(){}
virtual G4int Update(const G4Track* aTrack);
// update parameters from G4Track
virtual G4int Update( const G4Track* aTrack );
// update parameters from G4Track
virtual G4int PropagateError(const G4Track* aTrack);
// propagate the error along the step
virtual G4int PropagateError( const G4Track* aTrack );
// propagate the error along the step
virtual void Dump(std::ostream& out = G4cout) const;
// dump TrajState parameters
virtual void Dump( std::ostream& out = G4cout ) const;
// dump TrajState parameters
friend std::ostream& operator<<(std::ostream&,
const G4ErrorFreeTrajState& ts);
friend
std::ostream& operator<<(std::ostream&, const G4ErrorFreeTrajState& ts);
// Set and Get methods
// Set and Get methods
virtual void SetPosition(const G4Point3D pos)
{
SetParameters(pos, fMomentum);
}
virtual void SetPosition( const G4Point3D pos )
{ SetParameters( pos, fMomentum ); }
virtual void SetMomentum(const G4Vector3D& mom)
{
SetParameters(fPosition, mom);
}
virtual void SetMomentum( const G4Vector3D& mom )
{ SetParameters( fPosition, mom ); }
void SetParameters(const G4Point3D& pos, const G4Vector3D& mom)
{
fPosition = pos;
fMomentum = mom;
fTrajParam.SetParameters(pos, mom);
}
void SetParameters( const G4Point3D& pos, const G4Vector3D& mom )
{
fPosition = pos;
fMomentum = mom;
fTrajParam.SetParameters( pos, mom );
}
G4ErrorFreeTrajParam GetParameters() const
{ return fTrajParam; }
G4ErrorMatrix GetTransfMat() const
{ return theTransfMat; }
private:
void Init();
// define TrajState type and build charge
G4int PropagateErrorMSC( const G4Track* aTrack );
// add the error associated to multiple scattering
void CalculateEffectiveZandA( const G4Material* mate, double& effZ, double& effA );
// calculate effective Z and A (needed by PropagateErrorMSC)
G4int PropagateErrorIoni( const G4Track* aTrack );
// add the error associated to ionization energy loss
G4ErrorFreeTrajParam GetParameters() const { return fTrajParam; }
G4ErrorMatrix GetTransfMat() const { return theTransfMat; }
private:
void Init();
// define TrajState type and build charge
G4int PropagateErrorMSC(const G4Track* aTrack);
// add the error associated to multiple scattering
void CalculateEffectiveZandA(const G4Material* mate, double& effZ,
double& effA);
// calculate effective Z and A (needed by PropagateErrorMSC)
G4int PropagateErrorIoni(const G4Track* aTrack);
// add the error associated to ionization energy loss
private:
G4ErrorFreeTrajParam fTrajParam;
G4ErrorMatrix theTransfMat;
G4bool theFirstStep; // to count if transf mat is updated or initialized
G4bool theFirstStep; // to count if transf mat is updated or initialized
};
#endif
@@ -40,25 +40,23 @@
#include "G4ThreeVector.hh"
#include "G4ErrorTarget.hh"
#include "G4Plane3D.hh"
class G4Step;
class G4String;
class G4ErrorGeomVolumeTarget : public G4ErrorTarget
{
public: // with description
G4ErrorGeomVolumeTarget( const G4String& name );
virtual ~G4ErrorGeomVolumeTarget(){}
G4ErrorGeomVolumeTarget(const G4String& name);
virtual ~G4ErrorGeomVolumeTarget() {}
virtual G4bool TargetReached(const G4Step* aStep);
// return true when particle is entering the volume
// return true when particle is entering the volume
virtual void Dump( const G4String& msg ) const;
virtual void Dump(const G4String& msg) const;
private:
G4String theName;
G4String theName;
};
#endif
@@ -37,34 +37,30 @@
#ifndef G4ErrorMagFieldLimitProcess_h
#define G4ErrorMagFieldLimitProcess_h 1
#include "G4ios.hh"
#include "G4ios.hh"
#include "globals.hh"
#include "G4VDiscreteProcess.hh"
#include "G4PhysicsTable.hh"
#include "G4PhysicsLogVector.hh"
#include "G4ElementTable.hh"
#include "G4Gamma.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Step.hh"
#include "G4Step.hh"
#include "G4VErrorLimitProcess.hh"
//-----------------------------------------------------------------
class G4ErrorMagFieldLimitProcess : public G4VErrorLimitProcess
{
public: // with description
G4ErrorMagFieldLimitProcess(const G4String& processName
="G4ErrorMagFieldLimit");
G4ErrorMagFieldLimitProcess(
const G4String& processName = "G4ErrorMagFieldLimit");
~G4ErrorMagFieldLimitProcess();
virtual G4double
PostStepGetPhysicalInteractionLength(const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition);
// Returns the step length.
virtual G4double PostStepGetPhysicalInteractionLength(
const G4Track& track, G4double previousStepSize,
G4ForceCondition* condition);
// Returns the step length.
};
#endif
+167 -172
View File
@@ -40,259 +40,254 @@
class G4ErrorSymMatrix;
typedef std::vector<G4double >::iterator G4ErrorMatrixIter;
typedef std::vector<G4double >::const_iterator G4ErrorMatrixConstIter;
typedef std::vector<G4double>::iterator G4ErrorMatrixIter;
typedef std::vector<G4double>::const_iterator G4ErrorMatrixConstIter;
class G4ErrorMatrix
{
public: // with description
G4ErrorMatrix();
// Default constructor. Gives 0 x 0 matrix.
// Another G4ErrorMatrix can be assigned to it.
G4ErrorMatrix();
// Default constructor. Gives 0 x 0 matrix.
// Another G4ErrorMatrix can be assigned to it.
G4ErrorMatrix(G4int p, G4int q);
// Constructor. Gives an unitialized p x q matrix.
G4ErrorMatrix(G4int p, G4int q);
// Constructor. Gives an unitialized p x q matrix.
G4ErrorMatrix(G4int p, G4int q, G4int i);
// Constructor. Gives an initialized p x q matrix.
// If i=0, it is initialized to all 0. If i=1, the diagonal elements
// are set to 1.0.
G4ErrorMatrix(G4int p, G4int q, G4int i);
// Constructor. Gives an initialized p x q matrix.
// If i=0, it is initialized to all 0. If i=1, the diagonal elements
// are set to 1.0.
G4ErrorMatrix(const G4ErrorMatrix& m1);
G4ErrorMatrix(G4ErrorMatrix&&) = default;
// Copy and move constructor.
G4ErrorMatrix(const G4ErrorMatrix &m1);
G4ErrorMatrix(G4ErrorMatrix &&) = default;
// Copy and move constructor.
G4ErrorMatrix(const G4ErrorSymMatrix& m1);
// Constructors from G4ErrorSymG4ErrorMatrix, DiagG4ErrorMatrix and Vector.
G4ErrorMatrix(const G4ErrorSymMatrix &m1);
// Constructors from G4ErrorSymG4ErrorMatrix, DiagG4ErrorMatrix and Vector.
virtual ~G4ErrorMatrix();
// Destructor.
virtual ~G4ErrorMatrix();
// Destructor.
inline virtual G4int num_row() const;
// Returns the number of rows.
inline virtual G4int num_row() const;
// Returns the number of rows.
inline virtual G4int num_col() const;
// Returns the number of columns.
inline virtual G4int num_col() const;
// Returns the number of columns.
inline virtual const G4double& operator()(G4int row, G4int col) const;
inline virtual G4double& operator()(G4int row, G4int col);
// Read or write a matrix element.
// ** Note that the indexing starts from (1,1). **
inline virtual const G4double & operator()(G4int row, G4int col) const;
inline virtual G4double & operator()(G4int row, G4int col);
// Read or write a matrix element.
// ** Note that the indexing starts from (1,1). **
G4ErrorMatrix& operator*=(G4double t);
// Multiply a G4ErrorMatrix by a floating number.
G4ErrorMatrix & operator *= (G4double t);
// Multiply a G4ErrorMatrix by a floating number.
G4ErrorMatrix& operator/=(G4double t);
// Divide a G4ErrorMatrix by a floating number.
G4ErrorMatrix & operator /= (G4double t);
// Divide a G4ErrorMatrix by a floating number.
G4ErrorMatrix& operator+=(const G4ErrorMatrix& m2);
G4ErrorMatrix& operator+=(const G4ErrorSymMatrix& m2);
G4ErrorMatrix& operator-=(const G4ErrorMatrix& m2);
G4ErrorMatrix& operator-=(const G4ErrorSymMatrix& m2);
// Add or subtract a G4ErrorMatrix.
// When adding/subtracting Vector, G4ErrorMatrix must have num_col of one.
G4ErrorMatrix & operator += ( const G4ErrorMatrix &m2);
G4ErrorMatrix & operator += ( const G4ErrorSymMatrix &m2);
G4ErrorMatrix & operator -= ( const G4ErrorMatrix &m2);
G4ErrorMatrix & operator -= ( const G4ErrorSymMatrix &m2);
// Add or subtract a G4ErrorMatrix.
// When adding/subtracting Vector, G4ErrorMatrix must have num_col of one.
G4ErrorMatrix& operator=(const G4ErrorMatrix& m2);
G4ErrorMatrix& operator=(const G4ErrorSymMatrix& m2);
G4ErrorMatrix& operator=(G4ErrorMatrix&&) = default;
// Assignment and move operators.
G4ErrorMatrix & operator = ( const G4ErrorMatrix &m2);
G4ErrorMatrix & operator = ( const G4ErrorSymMatrix &m2);
G4ErrorMatrix & operator = (G4ErrorMatrix &&) = default;
// Assignment and move operators.
G4ErrorMatrix operator-() const;
// unary minus, ie. flip the sign of each element.
G4ErrorMatrix operator- () const;
// unary minus, ie. flip the sign of each element.
G4ErrorMatrix apply(G4double (*f)(G4double, G4int, G4int)) const;
// Apply a function to all elements of the matrix.
G4ErrorMatrix apply(G4double (*f)(G4double, G4int, G4int)) const;
// Apply a function to all elements of the matrix.
G4ErrorMatrix T() const;
// Returns the transpose of a G4ErrorMatrix.
G4ErrorMatrix T() const;
// Returns the transpose of a G4ErrorMatrix.
G4ErrorMatrix sub(G4int min_row, G4int max_row, G4int min_col,
G4int max_col) const;
// Returns a sub matrix of a G4ErrorMatrix.
// WARNING: rows and columns are numbered from 1
G4ErrorMatrix sub(G4int min_row, G4int max_row,
G4int min_col, G4int max_col) const;
// Returns a sub matrix of a G4ErrorMatrix.
// WARNING: rows and columns are numbered from 1
void sub(G4int row, G4int col, const G4ErrorMatrix& m1);
// Sub matrix of this G4ErrorMatrix is replaced with m1.
// WARNING: rows and columns are numbered from 1
void sub(G4int row, G4int col, const G4ErrorMatrix &m1);
// Sub matrix of this G4ErrorMatrix is replaced with m1.
// WARNING: rows and columns are numbered from 1
inline G4ErrorMatrix inverse(G4int& ierr) const;
// Invert a G4ErrorMatrix. G4ErrorMatrix must be square and is not changed.
// Returns ierr = 0 (zero) when successful, otherwise non-zero.
inline G4ErrorMatrix inverse(G4int& ierr) const;
// Invert a G4ErrorMatrix. G4ErrorMatrix must be square and is not changed.
// Returns ierr = 0 (zero) when successful, otherwise non-zero.
virtual void invert(G4int& ierr);
// Invert a G4ErrorMatrix. G4ErrorMatrix must be square.
// N.B. the contents of the matrix are replaced by the inverse.
// Returns ierr = 0 (zero) when successful, otherwise non-zero.
// This method has less overhead then inverse().
virtual void invert(G4int& ierr);
// Invert a G4ErrorMatrix. G4ErrorMatrix must be square.
// N.B. the contents of the matrix are replaced by the inverse.
// Returns ierr = 0 (zero) when successful, otherwise non-zero.
// This method has less overhead then inverse().
G4double determinant() const;
// calculate the determinant of the matrix.
G4double determinant() const;
// calculate the determinant of the matrix.
G4double trace() const;
// calculate the trace of the matrix (sum of diagonal elements).
G4double trace() const;
// calculate the trace of the matrix (sum of diagonal elements).
class G4ErrorMatrix_row
{
typedef std::vector<G4double>::const_iterator G4ErrorMatrixConstIter;
class G4ErrorMatrix_row
{
typedef std::vector<G4double >::const_iterator G4ErrorMatrixConstIter;
public:
inline G4ErrorMatrix_row(G4ErrorMatrix&,G4int);
G4double & operator[](G4int);
private:
G4ErrorMatrix& _a;
G4int _r;
};
class G4ErrorMatrix_row_const
{
public:
inline G4ErrorMatrix_row_const (const G4ErrorMatrix&,G4int);
const G4double & operator[](G4int) const;
private:
const G4ErrorMatrix& _a;
G4int _r;
};
// helper classes for implementing m[i][j]
public:
inline G4ErrorMatrix_row(G4ErrorMatrix&, G4int);
G4double& operator[](G4int);
inline G4ErrorMatrix_row operator[] (G4int);
inline const G4ErrorMatrix_row_const operator[] (G4int) const;
// Read or write a matrix element.
// While it may not look like it, you simply do m[i][j] to get an element.
// ** Note that the indexing starts from [0][0]. **
private:
G4ErrorMatrix& _a;
G4int _r;
};
class G4ErrorMatrix_row_const
{
public:
inline G4ErrorMatrix_row_const(const G4ErrorMatrix&, G4int);
const G4double& operator[](G4int) const;
private:
const G4ErrorMatrix& _a;
G4int _r;
};
// helper classes for implementing m[i][j]
inline G4ErrorMatrix_row operator[](G4int);
inline const G4ErrorMatrix_row_const operator[](G4int) const;
// Read or write a matrix element.
// While it may not look like it, you simply do m[i][j] to get an element.
// ** Note that the indexing starts from [0][0]. **
protected:
virtual inline G4int num_size() const;
virtual void invertHaywood4(G4int& ierr);
virtual void invertHaywood5(G4int& ierr);
virtual void invertHaywood6(G4int& ierr);
virtual inline G4int num_size() const;
virtual void invertHaywood4(G4int& ierr);
virtual void invertHaywood5(G4int& ierr);
virtual void invertHaywood6(G4int& ierr);
public:
static void error(const char *s);
static void error(const char* s);
private:
friend class G4ErrorMatrix_row;
friend class G4ErrorMatrix_row_const;
friend class G4ErrorSymMatrix;
// Friend classes.
friend class G4ErrorMatrix_row;
friend class G4ErrorMatrix_row_const;
friend class G4ErrorSymMatrix;
// Friend classes.
friend G4ErrorMatrix operator+(const G4ErrorMatrix& m1,
const G4ErrorMatrix& m2);
friend G4ErrorMatrix operator-(const G4ErrorMatrix& m1,
const G4ErrorMatrix& m2);
friend G4ErrorMatrix operator*(const G4ErrorMatrix& m1,
const G4ErrorMatrix& m2);
friend G4ErrorMatrix operator*(const G4ErrorMatrix& m1,
const G4ErrorSymMatrix& m2);
friend G4ErrorMatrix operator*(const G4ErrorSymMatrix& m1,
const G4ErrorMatrix& m2);
friend G4ErrorMatrix operator*(const G4ErrorSymMatrix& m1,
const G4ErrorSymMatrix& m2);
// Multiply a G4ErrorMatrix by a G4ErrorMatrix or Vector.
friend G4ErrorMatrix operator+(const G4ErrorMatrix &m1,
const G4ErrorMatrix &m2);
friend G4ErrorMatrix operator-(const G4ErrorMatrix &m1,
const G4ErrorMatrix &m2);
friend G4ErrorMatrix operator*(const G4ErrorMatrix &m1,
const G4ErrorMatrix &m2);
friend G4ErrorMatrix operator*(const G4ErrorMatrix &m1,
const G4ErrorSymMatrix &m2);
friend G4ErrorMatrix operator*(const G4ErrorSymMatrix &m1,
const G4ErrorMatrix &m2);
friend G4ErrorMatrix operator*(const G4ErrorSymMatrix &m1,
const G4ErrorSymMatrix &m2);
// Multiply a G4ErrorMatrix by a G4ErrorMatrix or Vector.
// solve the system of linear eq
// solve the system of linear eq
friend G4ErrorMatrix qr_solve(G4ErrorMatrix*, const G4ErrorMatrix& b);
friend void tridiagonal(G4ErrorSymMatrix* a, G4ErrorMatrix* hsm);
friend void row_house(G4ErrorMatrix*, const G4ErrorMatrix&, G4double, G4int,
G4int, G4int, G4int);
friend void back_solve(const G4ErrorMatrix& R, G4ErrorMatrix* b);
friend void col_givens(G4ErrorMatrix* A, G4double c, G4double s, G4int k1,
G4int k2, G4int rowmin, G4int rowmax);
// Does a column Givens update.
friend G4ErrorMatrix qr_solve(G4ErrorMatrix *, const G4ErrorMatrix &b);
friend void tridiagonal(G4ErrorSymMatrix *a,G4ErrorMatrix *hsm);
friend void row_house(G4ErrorMatrix *,const G4ErrorMatrix &, G4double,
G4int, G4int, G4int, G4int);
friend void back_solve(const G4ErrorMatrix &R, G4ErrorMatrix *b);
friend void col_givens(G4ErrorMatrix *A, G4double c,
G4double s, G4int k1, G4int k2,
G4int rowmin, G4int rowmax);
// Does a column Givens update.
friend void row_givens(G4ErrorMatrix *A, G4double c,
G4double s, G4int k1, G4int k2,
G4int colmin, G4int colmax);
friend void col_house(G4ErrorMatrix *,const G4ErrorMatrix &, G4double,
G4int, G4int, G4int, G4int);
friend void house_with_update(G4ErrorMatrix *a,G4int row,G4int col);
friend void house_with_update(G4ErrorMatrix *a,G4ErrorMatrix *v,
friend void row_givens(G4ErrorMatrix* A, G4double c, G4double s, G4int k1,
G4int k2, G4int colmin, G4int colmax);
friend void col_house(G4ErrorMatrix*, const G4ErrorMatrix&, G4double, G4int,
G4int, G4int, G4int);
friend void house_with_update(G4ErrorMatrix* a, G4int row, G4int col);
friend void house_with_update(G4ErrorMatrix* a, G4ErrorMatrix* v, G4int row,
G4int col);
friend void house_with_update2(G4ErrorSymMatrix* a, G4ErrorMatrix* v,
G4int row, G4int col);
friend void house_with_update2(G4ErrorSymMatrix *a,G4ErrorMatrix *v,
G4int row, G4int col);
G4int dfact_matrix(G4double &det, G4int *ir);
// factorize the matrix. If successful, the return code is 0. On
// return, det is the determinant and ir[] is row-interchange
// matrix. See CERNLIB's DFACT routine.
G4int dfact_matrix(G4double& det, G4int* ir);
// factorize the matrix. If successful, the return code is 0. On
// return, det is the determinant and ir[] is row-interchange
// matrix. See CERNLIB's DFACT routine.
G4int dfinv_matrix(G4int *ir);
// invert the matrix. See CERNLIB DFINV.
G4int dfinv_matrix(G4int* ir);
// invert the matrix. See CERNLIB DFINV.
std::vector<G4double > m;
std::vector<G4double> m;
G4int nrow, ncol;
G4int size;
G4int nrow, ncol;
G4int size;
};
// Operations other than member functions for G4ErrorMatrix
G4ErrorMatrix operator*(const G4ErrorMatrix &m1, const G4ErrorMatrix &m2);
G4ErrorMatrix operator*(G4double t, const G4ErrorMatrix &m1);
G4ErrorMatrix operator*(const G4ErrorMatrix &m1, G4double t);
G4ErrorMatrix operator*(const G4ErrorMatrix& m1, const G4ErrorMatrix& m2);
G4ErrorMatrix operator*(G4double t, const G4ErrorMatrix& m1);
G4ErrorMatrix operator*(const G4ErrorMatrix& m1, G4double t);
// Multiplication operators
// Note that m *= m1 is always faster than m = m * m1.
G4ErrorMatrix operator/(const G4ErrorMatrix &m1, G4double t);
G4ErrorMatrix operator/(const G4ErrorMatrix& m1, G4double t);
// m = m1 / t. (m /= t is faster if you can use it.)
G4ErrorMatrix operator+(const G4ErrorMatrix &m1, const G4ErrorMatrix &m2);
G4ErrorMatrix operator+(const G4ErrorMatrix& m1, const G4ErrorMatrix& m2);
// m = m1 + m2;
// Note that m += m1 is always faster than m = m + m1.
G4ErrorMatrix operator-(const G4ErrorMatrix &m1, const G4ErrorMatrix &m2);
G4ErrorMatrix operator-(const G4ErrorMatrix& m1, const G4ErrorMatrix& m2);
// m = m1 - m2;
// Note that m -= m1 is always faster than m = m - m1.
G4ErrorMatrix dsum(const G4ErrorMatrix&, const G4ErrorMatrix&);
// Direct sum of two matrices. The direct sum of A and B is the matrix
// Direct sum of two matrices. The direct sum of A and B is the matrix
// A 0
// 0 B
std::ostream& operator<<(std::ostream &s, const G4ErrorMatrix &q);
std::ostream& operator<<(std::ostream& s, const G4ErrorMatrix& q);
// Read in, write out G4ErrorMatrix into a stream.
//
// Specialized linear algebra functions
//
G4ErrorMatrix qr_solve(const G4ErrorMatrix &A, const G4ErrorMatrix &b);
G4ErrorMatrix qr_solve(G4ErrorMatrix *A, const G4ErrorMatrix &b);
G4ErrorMatrix qr_solve(const G4ErrorMatrix& A, const G4ErrorMatrix& b);
G4ErrorMatrix qr_solve(G4ErrorMatrix* A, const G4ErrorMatrix& b);
// Works like backsolve, except matrix does not need to be upper
// triangular. For nonsquare matrix, it solves in the least square sense.
G4ErrorMatrix qr_inverse(const G4ErrorMatrix &A);
G4ErrorMatrix qr_inverse(G4ErrorMatrix *A);
G4ErrorMatrix qr_inverse(const G4ErrorMatrix& A);
G4ErrorMatrix qr_inverse(G4ErrorMatrix* A);
// Finds the inverse of a matrix using QR decomposition. Note, often what
// you really want is solve or backsolve, they can be much quicker than
// inverse in many calculations.
void qr_decomp(G4ErrorMatrix *A, G4ErrorMatrix *hsm);
G4ErrorMatrix qr_decomp(G4ErrorMatrix *A);
void qr_decomp(G4ErrorMatrix* A, G4ErrorMatrix* hsm);
G4ErrorMatrix qr_decomp(G4ErrorMatrix* A);
// Does a QR decomposition of a matrix.
void back_solve(const G4ErrorMatrix &R, G4ErrorMatrix *b);
void back_solve(const G4ErrorMatrix& R, G4ErrorMatrix* b);
// Solves R*x = b where R is upper triangular. Also has a variation that
// solves a number of equations of this form in one step, where b is a matrix
// with each column a different vector. See also solve.
void col_house(G4ErrorMatrix *a, const G4ErrorMatrix &v, G4double vnormsq,
void col_house(G4ErrorMatrix* a, const G4ErrorMatrix& v, G4double vnormsq,
G4int row, G4int col, G4int row_start, G4int col_start);
void col_house(G4ErrorMatrix *a, const G4ErrorMatrix &v, G4int row, G4int col,
void col_house(G4ErrorMatrix* a, const G4ErrorMatrix& v, G4int row, G4int col,
G4int row_start, G4int col_start);
// Does a column Householder update.
void col_givens(G4ErrorMatrix *A, G4double c, G4double s,
G4int k1, G4int k2, G4int row_min=1, G4int row_max=0);
void col_givens(G4ErrorMatrix* A, G4double c, G4double s, G4int k1, G4int k2,
G4int row_min = 1, G4int row_max = 0);
// do a column Givens update
void row_givens(G4ErrorMatrix *A, G4double c, G4double s,
G4int k1, G4int k2, G4int col_min=1, G4int col_max=0);
void row_givens(G4ErrorMatrix* A, G4double c, G4double s, G4int k1, G4int k2,
G4int col_min = 1, G4int col_max = 0);
// do a row Givens update
// void givens(G4double a, G4double b, G4double *c, G4double *s);
@@ -300,14 +295,14 @@ void row_givens(G4ErrorMatrix *A, G4double c, G4double s,
// Returns a Householder vector to zero elements.
void house_with_update(G4ErrorMatrix *a, G4int row=1, G4int col=1);
void house_with_update(G4ErrorMatrix *a, G4ErrorMatrix *v,
G4int row=1, G4int col=1);
void house_with_update(G4ErrorMatrix* a, G4int row = 1, G4int col = 1);
void house_with_update(G4ErrorMatrix* a, G4ErrorMatrix* v, G4int row = 1,
G4int col = 1);
// Finds and does Householder reflection on matrix.
void row_house(G4ErrorMatrix *a, const G4ErrorMatrix &v, G4double vnormsq,
void row_house(G4ErrorMatrix* a, const G4ErrorMatrix& v, G4double vnormsq,
G4int row, G4int col, G4int row_start, G4int col_start);
void row_house(G4ErrorMatrix *a, const G4ErrorMatrix &v, G4int row, G4int col,
void row_house(G4ErrorMatrix* a, const G4ErrorMatrix& v, G4int row, G4int col,
G4int row_start, G4int col_start);
// Does a row Householder update.
@@ -29,74 +29,67 @@
// ------------------------------------------------------------
inline G4ErrorMatrix::G4ErrorMatrix()
: m(0), nrow(0), ncol(0), size(0)
: m(0)
, nrow(0)
, ncol(0)
, size(0)
{}
inline G4int G4ErrorMatrix::num_row() const { return nrow; }
inline G4int G4ErrorMatrix::num_col() const { return ncol; }
inline G4int G4ErrorMatrix::num_size() const { return size; }
inline G4double& G4ErrorMatrix::operator()(G4int row, G4int col)
{
return *(m.begin() + (row - 1) * ncol + col - 1);
}
inline G4int G4ErrorMatrix::num_row() const
inline const G4double& G4ErrorMatrix::operator()(G4int row, G4int col) const
{
return nrow;
return *(m.begin() + (row - 1) * ncol + col - 1);
}
inline G4int G4ErrorMatrix::num_col() const
inline G4ErrorMatrix::G4ErrorMatrix_row G4ErrorMatrix::operator[](G4int r)
{
return ncol;
}
inline G4int G4ErrorMatrix::num_size() const
{
return size;
}
inline G4double & G4ErrorMatrix::operator()(G4int row, G4int col)
{
return *(m.begin()+(row-1)*ncol+col-1);
}
inline const G4double & G4ErrorMatrix::operator()(G4int row, G4int col) const
{
return *(m.begin()+(row-1)*ncol+col-1);
}
inline G4ErrorMatrix::G4ErrorMatrix_row G4ErrorMatrix::operator[] (G4int r)
{
G4ErrorMatrix_row b(*this,r);
G4ErrorMatrix_row b(*this, r);
return b;
}
inline const G4ErrorMatrix::G4ErrorMatrix_row_const
G4ErrorMatrix::operator[] (G4int r) const
inline const G4ErrorMatrix::G4ErrorMatrix_row_const G4ErrorMatrix::operator[](
G4int r) const
{
G4ErrorMatrix_row_const b(*this,r);
G4ErrorMatrix_row_const b(*this, r);
return b;
}
inline G4double &G4ErrorMatrix::G4ErrorMatrix_row::operator[](G4int c)
inline G4double& G4ErrorMatrix::G4ErrorMatrix_row::operator[](G4int c)
{
return *(_a.m.begin()+_r*_a.ncol+c);
return *(_a.m.begin() + _r * _a.ncol + c);
}
inline const G4double &
G4ErrorMatrix::G4ErrorMatrix_row_const::operator[](G4int c) const
inline const G4double& G4ErrorMatrix::G4ErrorMatrix_row_const::operator[](
G4int c) const
{
return *(_a.m.begin()+_r*_a.ncol+c);
return *(_a.m.begin() + _r * _a.ncol + c);
}
inline G4ErrorMatrix::
G4ErrorMatrix_row::G4ErrorMatrix_row(G4ErrorMatrix&a, G4int r)
: _a(a)
inline G4ErrorMatrix::G4ErrorMatrix_row::G4ErrorMatrix_row(G4ErrorMatrix& a,
G4int r)
: _a(a)
{
_r = r;
}
inline G4ErrorMatrix::G4ErrorMatrix_row_const::G4ErrorMatrix_row_const
(const G4ErrorMatrix&a, G4int r)
: _a(a)
inline G4ErrorMatrix::G4ErrorMatrix_row_const::G4ErrorMatrix_row_const(
const G4ErrorMatrix& a, G4int r)
: _a(a)
{
_r = r;
}
inline G4ErrorMatrix G4ErrorMatrix::inverse(G4int &ierr) const
inline G4ErrorMatrix G4ErrorMatrix::inverse(G4int& ierr) const
{
G4ErrorMatrix mTmp(*this);
mTmp.invert(ierr);
@@ -52,20 +52,18 @@ class G4ErrorEnergyLoss;
class G4ErrorMessenger : public G4UImessenger
{
public: // with description
G4ErrorMessenger(G4ErrorStepLengthLimitProcess* lengthAct,
G4ErrorMagFieldLimitProcess* magAct,
G4ErrorEnergyLoss* elossAct);
~G4ErrorMessenger();
void SetNewValue(G4UIcommand*, G4String);
private:
G4ErrorStepLengthLimitProcess* StepLengthAction;
G4ErrorMagFieldLimitProcess* MagFieldAction;
G4ErrorEnergyLoss* EnergyLossAction;
G4UIdirectory* myDir;
G4UIdirectory* myDirLimits;
@@ -45,26 +45,24 @@
#include "globals.hh"
#include "G4VUserPhysicsList.hh"
class G4ErrorPhysicsList: public G4VUserPhysicsList
class G4ErrorPhysicsList : public G4VUserPhysicsList
{
public: // with description
G4ErrorPhysicsList();
virtual ~G4ErrorPhysicsList();
protected:
protected:
virtual void ConstructParticle();
// constructs gamma, e+/-, mu+/- and stable hadrons
// constructs gamma, e+/-, mu+/- and stable hadrons
virtual void ConstructProcess();
// construct physical processes
// construct physical processes
virtual void SetCuts();
// SetCutsWithDefault
virtual void SetCuts();
// SetCutsWithDefault
virtual void ConstructEM();
// constructs electromagnetic processes
// constructs electromagnetic processes
};
#endif
@@ -50,70 +50,67 @@ class G4ErrorFreeTrajState;
class G4ErrorTarget;
#include "globals.hh"
class G4ErrorPropagator
class G4ErrorPropagator
{
public: // with description
G4ErrorPropagator();
~G4ErrorPropagator(){}
~G4ErrorPropagator() {}
G4Track* InitG4Track( G4ErrorTrajState& initialTS );
// Creates a G4Track from a G4ErrorTrajState
G4Track* InitG4Track(G4ErrorTrajState& initialTS);
// Creates a G4Track from a G4ErrorTrajState
G4int Propagate( G4ErrorTrajState* currentTS,
const G4ErrorTarget* target,
G4ErrorMode mode = G4ErrorMode_PropForwards);
// Steers the GEANT4 propagation of a track:
// the particle will be extrapolated until the Target is reached.
// The final G4Track parameters will be passed to theFinalTrajState
G4int Propagate(G4ErrorTrajState* currentTS, const G4ErrorTarget* target,
G4ErrorMode mode = G4ErrorMode_PropForwards);
// Steers the GEANT4 propagation of a track:
// the particle will be extrapolated until the Target is reached.
// The final G4Track parameters will be passed to theFinalTrajState
G4int PropagateOneStep( G4ErrorTrajState* currentTS );
// Propagates a G4Track by one step, and then returns control to the user
G4int PropagateOneStep(G4ErrorTrajState* currentTS);
// Propagates a G4Track by one step, and then returns control to the user
G4int MakeOneStep( G4ErrorFreeTrajState* currentTS_FREE );
// Advance one step
G4int MakeOneStep(G4ErrorFreeTrajState* currentTS_FREE);
// Advance one step
G4ErrorFreeTrajState* InitFreeTrajState( G4ErrorTrajState* currentTS );
// Creates theCurrentTS_FREE (transforms the user G4ErrorSurfaceTrajState
// or copies the G4ErrorFreeTrajState)
G4ErrorFreeTrajState* InitFreeTrajState(G4ErrorTrajState* currentTS);
// Creates theCurrentTS_FREE (transforms the user G4ErrorSurfaceTrajState
// or copies the G4ErrorFreeTrajState)
void GetFinalTrajState( G4ErrorTrajState* currentTS, G4ErrorFreeTrajState* currentTS_FREE, const G4ErrorTarget* target );
// After steps are done, convert the G4ErrorFreeTrajState used for error
// propagation to the class of origin (G4ErrorFreeTrajState or
// G4eTrajStatOnSurface)
void GetFinalTrajState(G4ErrorTrajState* currentTS,
G4ErrorFreeTrajState* currentTS_FREE,
const G4ErrorTarget* target);
// After steps are done, convert the G4ErrorFreeTrajState used for error
// propagation to the class of origin (G4ErrorFreeTrajState or
// G4eTrajStatOnSurface)
void InvokePreUserTrackingAction( G4Track* fpTrack );
// Invoke the G4UserTrackingAction::PreUserTrackingAction
void InvokePostUserTrackingAction( G4Track* fpTrack );
// Invoke the G4UserTrackingAction::PostUserTrackingAction
void InvokePreUserTrackingAction(G4Track* fpTrack);
// Invoke the G4UserTrackingAction::PreUserTrackingAction
void InvokePostUserTrackingAction(G4Track* fpTrack);
// Invoke the G4UserTrackingAction::PostUserTrackingAction
G4bool CheckIfLastStep( G4Track* aTrack );
// Check if it is the last step for error propagation:
// - G4ErrorState is G4ErrorState_StoppedAtTarget
// - Track is OutOfWorld
// - G4TrackStatus is fStopAndKill
G4bool CheckIfLastStep(G4Track* aTrack);
// Check if it is the last step for error propagation:
// - G4ErrorState is G4ErrorState_StoppedAtTarget
// - Track is OutOfWorld
// - G4TrackStatus is fStopAndKill
// Get and Set methods
// Get and Set methods
const G4ErrorTrajState* GetInitialTrajState() const
{ return theInitialTrajState; }
{
return theInitialTrajState;
}
G4double GetStepLength() const
{ return theStepLength; }
G4double GetStepLength() const { return theStepLength; }
void SetStepLength( const G4double sl )
{ theStepLength = sl; }
void SetStepLength(const G4double sl) { theStepLength = sl; }
void SetStepN( const G4int sn )
{ theStepN = sn; }
void SetStepN(const G4int sn) { theStepN = sn; }
private:
G4int MakeSteps( G4ErrorFreeTrajState* currentTS_FREE );
// Advance steps until target is reached
G4int MakeSteps(G4ErrorFreeTrajState* currentTS_FREE);
// Advance steps until target is reached
private:
G4double theStepLength;
G4ErrorTrajState* theInitialTrajState;
@@ -127,7 +124,6 @@ class G4ErrorPropagator
G4int verbose;
G4bool thePropIsInitialized;
};
#endif
@@ -61,91 +61,91 @@ class G4Track;
class G4ErrorPropagatorManager
{
public: // with description
G4ErrorPropagatorManager();
// Initialise data to 0. Starts the G4ErrorRunManagerHelper and
// G4ErrorPropagationNavigator.
// Initialise data to 0. Starts the G4ErrorRunManagerHelper and
// G4ErrorPropagationNavigator.
~G4ErrorPropagatorManager();
static G4ErrorPropagatorManager* GetErrorPropagatorManager();
// Get only instance of G4ErrorPropagatorManager. If it does not exists,
// creates it
// Get only instance of G4ErrorPropagatorManager. If it does not exists,
// creates it
void EventTermination();
// Set state to G4ErrorState_Init
// Set state to G4ErrorState_Init
void RunTermination();
// Set state to G4ErrorState_Init and invoke
// G4ErrorRunManagerHelper::RunTermination()
// Set state to G4ErrorState_Init and invoke
// G4ErrorRunManagerHelper::RunTermination()
void InitGeant4e();
// Initializes Geant4 and Geant4e
// Initializes Geant4 and Geant4e
void InitTrackPropagation();
// Set the propagator step number to 0 and the G4ErrorState to Propagating
// Set the propagator step number to 0 and the G4ErrorState to Propagating
G4bool InitFieldForBackwards();
// Creates the G4ErrorMag_UsualEqRhs, that will control backwards tracking
// Creates the G4ErrorMag_UsualEqRhs, that will control backwards tracking
G4int Propagate( G4ErrorTrajState* currentTS, const G4ErrorTarget* target, G4ErrorMode mode = G4ErrorMode_PropForwards );
// Inits track propagation, invokes G4ErrorPropagator::Propagate and
// terminates "event"
G4int Propagate(G4ErrorTrajState* currentTS, const G4ErrorTarget* target,
G4ErrorMode mode = G4ErrorMode_PropForwards);
// Inits track propagation, invokes G4ErrorPropagator::Propagate and
// terminates "event"
G4int PropagateOneStep( G4ErrorTrajState* currentTS,
G4ErrorMode mode = G4ErrorMode_PropForwards );
// Invokes G4ErrorPropagator::PropagateOneStep
G4int PropagateOneStep(G4ErrorTrajState* currentTS,
G4ErrorMode mode = G4ErrorMode_PropForwards);
// Invokes G4ErrorPropagator::PropagateOneStep
G4bool CloseGeometry();
// Close Geant4 geometry
// Close Geant4 geometry
void SetUserInitialization(G4VUserDetectorConstruction* userInit);
// Invokes G4ErrorRunManagerHelper to construct detector and set
// world volume
// Invokes G4ErrorRunManagerHelper to construct detector and set
// world volume
void SetUserInitialization(G4VPhysicalVolume* userInit);
// Invokes G4ErrorRunManagerHelper to set world volume
// Invokes G4ErrorRunManagerHelper to set world volume
void SetUserInitialization(G4VUserPhysicsList* userInit);
// Invokes G4ErrorRunManagerHelper to initialize physics
// Invokes G4ErrorRunManagerHelper to initialize physics
void SetUserAction(G4UserTrackingAction* userAction);
// Invokes G4EventManager to set a G4UserTrackingAction
// Invokes G4EventManager to set a G4UserTrackingAction
void SetUserAction(G4UserSteppingAction* userAction);
// Invokes G4EventManager to set a G4UserSteppingAction
// Invokes G4EventManager to set a G4UserSteppingAction
G4String PrintG4ErrorState();
G4String PrintG4ErrorState( G4ErrorState state );
// Print Geant4e state
G4String PrintG4ErrorState(G4ErrorState state);
// Print Geant4e state
G4String PrintG4State();
G4String PrintG4State( G4ApplicationState state );
// Print Geant4 state
// Set and Get methods
G4String PrintG4State(G4ApplicationState state);
// Print Geant4 state
// Set and Get methods
G4ErrorRunManagerHelper* GetErrorRunManagerHelper() const
{ return theG4ErrorRunManagerHelper; }
{
return theG4ErrorRunManagerHelper;
}
void SetSteppingManagerVerboseLevel();
G4ErrorPropagationNavigator* GetErrorPropagationNavigator() const
{ return theG4ErrorPropagationNavigator; }
{
return theG4ErrorPropagationNavigator;
}
G4ErrorPropagator* GetPropagator() const
{ return thePropagator; }
G4ErrorPropagator* GetPropagator() const { return thePropagator; }
private:
void StartG4ErrorRunManagerHelper();
// Create a G4ErrorRunManagerHelper if it does not exist and set to it
// the G4ErrorPhysicsList
void StartNavigator();
// create a G4ErrorPropagationNavigator
private:
// Create a G4ErrorRunManagerHelper if it does not exist and set to it
// the G4ErrorPhysicsList
void StartNavigator();
// create a G4ErrorPropagationNavigator
private:
static G4ThreadLocal G4ErrorPropagatorManager* theG4ErrorPropagatorManager;
G4ErrorRunManagerHelper* theG4ErrorRunManagerHelper;
@@ -155,7 +155,6 @@ class G4ErrorPropagatorManager
G4Mag_UsualEqRhs* theEquationOfMotion;
G4ErrorPropagationNavigator* theG4ErrorPropagationNavigator;
};
#endif
@@ -28,7 +28,7 @@
//
// Class Description:
//
// This class helps G4ErrorPropagatorManager with the initialization of
// This class helps G4ErrorPropagatorManager with the initialization of
// geometry and physics, definition of actions and run termination
// (things done by G4RunManager in an standard GEANT4 run)
// It holds a pointer to G4RunManagerKernel
@@ -49,49 +49,45 @@ class G4VUserPhysicsList;
class G4UserTrackingAction;
class G4UserSteppingAction;
class G4ErrorRunManagerHelper
class G4ErrorRunManagerHelper
{
public: // with description
G4ErrorRunManagerHelper();
virtual ~G4ErrorRunManagerHelper();
static G4ErrorRunManagerHelper* GetRunManagerKernel();
// Static method which returns the singleton pointer of
// G4ErrorRunManagerHelper
// Static method which returns the singleton pointer of
// G4ErrorRunManagerHelper
void SetUserInitialization(G4VUserDetectorConstruction* userInit);
// Initialize geometry by passing a G4VUserDetectorConstruction
// Initialize geometry by passing a G4VUserDetectorConstruction
void SetUserInitialization(G4VPhysicalVolume* userInit);
// Initialize geometry by passing a G4VPhysicalVolume
// Initialize geometry by passing a G4VPhysicalVolume
void SetUserInitialization(G4VUserPhysicsList* userInit);
// Initializes physics
// Initializes physics
void SetUserAction(G4UserTrackingAction* userAction);
// Set the user tracking action
// Set the user tracking action
void SetUserAction(G4UserSteppingAction* userAction);
// Set the user stepping action
// Set the user stepping action
void RunInitialization();
// Invokes G4RunManagerKernel RunInitialization();
// Invokes G4RunManagerKernel RunInitialization();
void InitializeGeometry();
// Initializes GEANT4 geometry
// Initializes GEANT4 geometry
void InitializePhysics();
// Initializes GEANT4 physics
// Initializes GEANT4 physics
void RunTermination();
// Invokes G4RunManagerKernel RunTermination();
// Invokes G4RunManagerKernel RunTermination();
G4VUserPhysicsList* GetUserPhysicsList() const
{ return theUserPhysicsList; }
G4VUserPhysicsList* GetUserPhysicsList() const { return theUserPhysicsList; }
private:
static G4ThreadLocal G4ErrorRunManagerHelper* fRunManagerKernel;
G4VUserPhysicsList* theUserPhysicsList;
G4VPhysicalVolume* theUserWorld;
@@ -38,33 +38,30 @@
#ifndef G4ErrorStepLengthLimitProcess_hh
#define G4ErrorStepLengthLimitProcess_hh
#include "G4ios.hh"
#include "G4ios.hh"
#include "globals.hh"
#include "G4VDiscreteProcess.hh"
#include "G4PhysicsTable.hh"
#include "G4PhysicsLogVector.hh"
#include "G4ElementTable.hh"
#include "G4Gamma.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Step.hh"
#include "G4Step.hh"
#include "G4VErrorLimitProcess.hh"
//-----------------------------------------------------------------
class G4ErrorStepLengthLimitProcess : public G4VErrorLimitProcess
{
public: // with description
G4ErrorStepLengthLimitProcess(const G4String& processName =
"G4ErrorStepLengthLimit");
G4ErrorStepLengthLimitProcess(
const G4String& processName = "G4ErrorStepLengthLimit");
~G4ErrorStepLengthLimitProcess();
virtual G4double
PostStepGetPhysicalInteractionLength( const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition );
// returns the step length
virtual G4double PostStepGetPhysicalInteractionLength(
const G4Track& track, G4double previousStepSize,
G4ForceCondition* condition);
// returns the step length
};
#endif
@@ -31,7 +31,7 @@
// Holds the 5 independent variables of the trajectory for a
// G4ErrorSurfaceTrajState object. It is not used for anything but for
// printing, but anyhow it is updated everytime the position and momentum
// are updated
// are updated
// History:
// - Created: P. Arce
@@ -51,55 +51,57 @@
class G4ErrorSurfaceTrajParam
{
public: // with description
G4ErrorSurfaceTrajParam()
: fInvP(0.), fPV(0.), fPW(0.), fV(0.), fW(0.) {}
G4ErrorSurfaceTrajParam( const G4Point3D& pos, const G4Vector3D& mom,
const G4Vector3D& vecV, const G4Vector3D& vecW );
G4ErrorSurfaceTrajParam( const G4Point3D& pos, const G4Vector3D& mom,
const G4Plane3D& plane );
: fInvP(0.)
, fPV(0.)
, fPW(0.)
, fV(0.)
, fW(0.)
{}
G4ErrorSurfaceTrajParam(const G4Point3D& pos, const G4Vector3D& mom,
const G4Vector3D& vecV, const G4Vector3D& vecW);
G4ErrorSurfaceTrajParam(const G4Point3D& pos, const G4Vector3D& mom,
const G4Plane3D& plane);
G4ErrorSurfaceTrajParam(const G4ErrorSurfaceTrajParam&) = default;
G4ErrorSurfaceTrajParam(G4ErrorSurfaceTrajParam&&) = default;
// The copy and move constructors
G4ErrorSurfaceTrajParam(G4ErrorSurfaceTrajParam&&) = default;
// The copy and move constructors
virtual ~G4ErrorSurfaceTrajParam(){}
virtual ~G4ErrorSurfaceTrajParam() {}
G4ErrorSurfaceTrajParam& operator = (const G4ErrorSurfaceTrajParam&) = default;
G4ErrorSurfaceTrajParam& operator = (G4ErrorSurfaceTrajParam&&) = default;
// The copy and move assignment operators
G4ErrorSurfaceTrajParam& operator=(const G4ErrorSurfaceTrajParam&) = default;
G4ErrorSurfaceTrajParam& operator=(G4ErrorSurfaceTrajParam&&) = default;
// The copy and move assignment operators
friend
std::ostream& operator<<(std::ostream&, const G4ErrorSurfaceTrajParam& ts);
// Get and Set methods
friend std::ostream& operator<<(std::ostream&,
const G4ErrorSurfaceTrajParam& ts);
void SetParameters( const G4Point3D& pos, const G4Vector3D& mom,
const G4Vector3D& vecV, const G4Vector3D& vecW );
void SetParameters( const G4Point3D& pos, const G4Vector3D& mom,
const G4Plane3D& plane );
// Get and Set methods
void SetParameters(const G4Point3D& pos, const G4Vector3D& mom,
const G4Vector3D& vecV, const G4Vector3D& vecW);
void SetParameters(const G4Point3D& pos, const G4Vector3D& mom,
const G4Plane3D& plane);
G4Vector3D GetDirection() const { return fDir; }
G4Vector3D GetPlaneNormal() const { return fVectorV.cross(fVectorW); }
G4Vector3D GetVectorV() const { return fVectorV; }
G4Vector3D GetVectorW() const { return fVectorW; }
G4double GetPV() const{ return fPV; }
G4double GetPW() const{ return fPW; }
G4double GetV() const{ return fV; }
G4double GetW() const{ return fW; }
G4double GetInvP() const{ return fInvP; }
G4double GetPV() const { return fPV; }
G4double GetPW() const { return fPW; }
G4double GetV() const { return fV; }
G4double GetW() const { return fW; }
G4double GetInvP() const { return fInvP; }
private:
G4ThreeVector fDir;
G4Vector3D fVectorV; //one of the vectors defining the plane
G4Vector3D fVectorW; //one of the vectors defining the plane
G4double fInvP; // inverse of momentum
G4double fPV; // projection of momentum in one direction
G4double fPW; // projection of momentum in one direction
G4double fV; // projection of position in one direction
G4double fW; // projection of position in one direction
G4Vector3D fVectorV; // one of the vectors defining the plane
G4Vector3D fVectorW; // one of the vectors defining the plane
G4double fInvP; // inverse of momentum
G4double fPV; // projection of momentum in one direction
G4double fPW; // projection of momentum in one direction
G4double fV; // projection of position in one direction
G4double fW; // projection of position in one direction
};
#endif
@@ -36,7 +36,7 @@
// History:
//
// - Created: P. Arce
// - Created: P. Arce
// --------------------------------------------------------------------
#ifndef G4ErrorSurfaceTrajState_hh
@@ -54,80 +54,77 @@
class G4ErrorSurfaceTrajState : public G4ErrorTrajState
{
public: // with description
G4ErrorSurfaceTrajState(const G4String& partType, const G4Point3D& pos,
const G4Vector3D& mom, const G4Plane3D& plane,
const G4ErrorTrajErr& errmat = G4ErrorTrajErr(5, 0));
// Constructor by providing particle, position, momentum and
// G4Plane3D surface
G4ErrorSurfaceTrajState( const G4String& partType, const G4Point3D& pos,
const G4Vector3D& mom, const G4Plane3D& plane,
const G4ErrorTrajErr& errmat = G4ErrorTrajErr(5,0) );
// Constructor by providing particle, position, momentum and
// G4Plane3D surface
G4ErrorSurfaceTrajState(const G4String& partType, const G4Point3D& pos,
const G4Vector3D& mom, const G4Vector3D& vecV,
const G4Vector3D& vecW,
const G4ErrorTrajErr& errmat = G4ErrorTrajErr(5, 0));
// Constructor by providing particle, position, momentum and
// two vectors on surface
G4ErrorSurfaceTrajState( const G4String& partType, const G4Point3D& pos,
const G4Vector3D& mom, const G4Vector3D& vecV,
const G4Vector3D& vecW,
const G4ErrorTrajErr& errmat = G4ErrorTrajErr(5,0) );
// Constructor by providing particle, position, momentum and
// two vectors on surface
G4ErrorSurfaceTrajState(G4ErrorFreeTrajState& tpSC, const G4Plane3D& plane);
// Constructor by providing G4ErrorFreeTrajState and G4Plane3D surface
G4ErrorSurfaceTrajState( G4ErrorFreeTrajState& tpSC, const G4Plane3D& plane );
// Constructor by providing G4ErrorFreeTrajState and G4Plane3D surface
G4ErrorSurfaceTrajState(G4ErrorFreeTrajState& tpSC, const G4Vector3D& vecV,
const G4Vector3D& vecW, G4ErrorMatrix& transfM);
// Constructor by providing G4ErrorFreeTrajState and two vectors on surface
G4ErrorSurfaceTrajState( G4ErrorFreeTrajState& tpSC, const G4Vector3D& vecV,
const G4Vector3D& vecW , G4ErrorMatrix &transfM);
// Constructor by providing G4ErrorFreeTrajState and two vectors on surface
~G4ErrorSurfaceTrajState() {}
G4ErrorMatrix BuildErrorMatrix(G4ErrorFreeTrajState& tpSC,
const G4Vector3D& vecV,
const G4Vector3D& vecW);
// Build the error matrix from a free state plus the vectors of the surface
~G4ErrorSurfaceTrajState(){}
G4ErrorMatrix BuildErrorMatrix( G4ErrorFreeTrajState& tpSC, const G4Vector3D& vecV,
const G4Vector3D& vecW );
// Build the error matrix from a free state plus the vectors of the surface
virtual void Dump(std::ostream& out = G4cout) const;
virtual void Dump( std::ostream& out = G4cout ) const;
friend std::ostream& operator<<(std::ostream&,
const G4ErrorSurfaceTrajState& ts);
friend
std::ostream& operator<<(std::ostream&, const G4ErrorSurfaceTrajState& ts);
// Set and Get methods
// Set and Get methods
G4ErrorSurfaceTrajParam GetParameters() const { return fTrajParam; }
void SetParameters(const G4Point3D& pos, const G4Vector3D& mom,
const G4Vector3D& vecV, const G4Vector3D& vecW)
{
fPosition = pos;
fMomentum = mom;
fTrajParam.SetParameters(pos, mom, vecV, vecW);
}
G4ErrorSurfaceTrajParam GetParameters() const
{ return fTrajParam; }
void SetParameters( const G4Point3D& pos, const G4Vector3D& mom,
const G4Vector3D& vecV, const G4Vector3D& vecW )
{
fPosition = pos;
fMomentum = mom;
fTrajParam.SetParameters( pos, mom, vecV, vecW );
}
void SetParameters(const G4Point3D& pos, const G4Vector3D& mom,
const G4Plane3D& plane)
{
fPosition = pos;
fMomentum = mom;
fTrajParam.SetParameters(pos, mom, plane);
}
void SetParameters( const G4Point3D& pos, const G4Vector3D& mom,
const G4Plane3D& plane )
{
fPosition = pos;
fMomentum = mom;
fTrajParam.SetParameters( pos, mom, plane );
}
G4Vector3D GetVectorV() const { return fTrajParam.GetVectorV(); }
G4Vector3D GetVectorV() const
{ return fTrajParam.GetVectorV(); }
G4Vector3D GetVectorW() const { return fTrajParam.GetVectorW(); }
G4Vector3D GetVectorW() const
{ return fTrajParam.GetVectorW(); }
virtual void SetPosition(const G4Point3D pos)
{
SetParameters(pos, fMomentum, GetVectorV(), GetVectorW());
}
virtual void SetPosition( const G4Point3D pos )
{ SetParameters( pos, fMomentum, GetVectorV(), GetVectorW() ); }
virtual void SetMomentum(const G4Vector3D& mom)
{
SetParameters(fPosition, mom, GetVectorV(), GetVectorW());
}
virtual void SetMomentum( const G4Vector3D& mom )
{ SetParameters( fPosition, mom, GetVectorV(), GetVectorW() ); }
private:
void Init();
// Define Trajectory State type and build charge
// Define Trajectory State type and build charge
private:
G4ErrorSurfaceTrajParam fTrajParam;
};
#endif
@@ -42,199 +42,198 @@ class G4ErrorMatrix;
class G4ErrorSymMatrix
{
public: //with description
public: // with description
inline G4ErrorSymMatrix();
// Default constructor. Gives 0x0 symmetric matrix.
// Another G4ErrorSymMatrix can be assigned to it.
inline G4ErrorSymMatrix();
// Default constructor. Gives 0x0 symmetric matrix.
// Another G4ErrorSymMatrix can be assigned to it.
explicit G4ErrorSymMatrix(G4int p);
G4ErrorSymMatrix(G4int p, G4int);
// Constructor. Gives p x p symmetric matrix.
// With a second argument, the matrix is initialized. 0 means a zero
// matrix, 1 means the identity matrix.
explicit G4ErrorSymMatrix(G4int p);
G4ErrorSymMatrix(G4int p, G4int);
// Constructor. Gives p x p symmetric matrix.
// With a second argument, the matrix is initialized. 0 means a zero
// matrix, 1 means the identity matrix.
G4ErrorSymMatrix(const G4ErrorSymMatrix& m1);
G4ErrorSymMatrix(G4ErrorSymMatrix&&) = default;
// Copy and move constructor.
G4ErrorSymMatrix(const G4ErrorSymMatrix &m1);
G4ErrorSymMatrix(G4ErrorSymMatrix &&) = default;
// Copy and move constructor.
// Constructor from DiagMatrix
// Constructor from DiagMatrix
virtual ~G4ErrorSymMatrix();
// Destructor.
virtual ~G4ErrorSymMatrix();
// Destructor.
inline G4int num_row() const;
inline G4int num_col() const;
// Returns number of rows/columns.
inline G4int num_row() const;
inline G4int num_col() const;
// Returns number of rows/columns.
const G4double& operator()(G4int row, G4int col) const;
G4double& operator()(G4int row, G4int col);
// Read and write a G4ErrorSymMatrix element.
// ** Note that indexing starts from (1,1). **
const G4double & operator()(G4int row, G4int col) const;
G4double & operator()(G4int row, G4int col);
// Read and write a G4ErrorSymMatrix element.
// ** Note that indexing starts from (1,1). **
const G4double& fast(G4int row, G4int col) const;
G4double& fast(G4int row, G4int col);
// fast element access.
// Must be row>=col;
// ** Note that indexing starts from (1,1). **
const G4double & fast(G4int row, G4int col) const;
G4double & fast(G4int row, G4int col);
// fast element access.
// Must be row>=col;
// ** Note that indexing starts from (1,1). **
void assign(const G4ErrorMatrix& m2);
// Assigns m2 to s, assuming m2 is a symmetric matrix.
void assign(const G4ErrorMatrix &m2);
// Assigns m2 to s, assuming m2 is a symmetric matrix.
void assign(const G4ErrorSymMatrix& m2);
// Another form of assignment. For consistency.
void assign(const G4ErrorSymMatrix &m2);
// Another form of assignment. For consistency.
G4ErrorSymMatrix& operator*=(G4double t);
// Multiply a G4ErrorSymMatrix by a floating number.
G4ErrorSymMatrix & operator*=(G4double t);
// Multiply a G4ErrorSymMatrix by a floating number.
G4ErrorSymMatrix& operator/=(G4double t);
// Divide a G4ErrorSymMatrix by a floating number.
G4ErrorSymMatrix & operator/=(G4double t);
// Divide a G4ErrorSymMatrix by a floating number.
G4ErrorSymMatrix& operator+=(const G4ErrorSymMatrix& m2);
G4ErrorSymMatrix& operator-=(const G4ErrorSymMatrix& m2);
// Add or subtract a G4ErrorSymMatrix.
G4ErrorSymMatrix & operator+=( const G4ErrorSymMatrix &m2);
G4ErrorSymMatrix & operator-=( const G4ErrorSymMatrix &m2);
// Add or subtract a G4ErrorSymMatrix.
G4ErrorSymMatrix& operator=(const G4ErrorSymMatrix& m2);
G4ErrorSymMatrix& operator=(G4ErrorSymMatrix&&) = default;
// Assignment and move operators.
// Notice that there is no G4ErrorSymMatrix = Matrix.
G4ErrorSymMatrix & operator=( const G4ErrorSymMatrix &m2);
G4ErrorSymMatrix & operator=(G4ErrorSymMatrix &&) = default;
// Assignment and move operators.
// Notice that there is no G4ErrorSymMatrix = Matrix.
G4ErrorSymMatrix operator-() const;
// unary minus, ie. flip the sign of each element.
G4ErrorSymMatrix operator- () const;
// unary minus, ie. flip the sign of each element.
G4ErrorSymMatrix T() const;
// Returns the transpose of a G4ErrorSymMatrix (which is itself).
G4ErrorSymMatrix T() const;
// Returns the transpose of a G4ErrorSymMatrix (which is itself).
G4ErrorSymMatrix apply(G4double (*f)(G4double, G4int, G4int)) const;
// Apply a function to all elements of the matrix.
G4ErrorSymMatrix apply(G4double (*f)(G4double, G4int, G4int)) const;
// Apply a function to all elements of the matrix.
G4ErrorSymMatrix similarity(const G4ErrorMatrix& m1) const;
G4ErrorSymMatrix similarity(const G4ErrorSymMatrix& m1) const;
// Returns m1*s*m1.T().
G4ErrorSymMatrix similarity(const G4ErrorMatrix &m1) const;
G4ErrorSymMatrix similarity(const G4ErrorSymMatrix &m1) const;
// Returns m1*s*m1.T().
G4ErrorSymMatrix similarityT(const G4ErrorMatrix& m1) const;
// temporary. test of new similarity.
// Returns m1.T()*s*m1.
G4ErrorSymMatrix similarityT(const G4ErrorMatrix &m1) const;
// temporary. test of new similarity.
// Returns m1.T()*s*m1.
G4ErrorSymMatrix sub(G4int min_row, G4int max_row) const;
// Returns a sub matrix of a G4ErrorSymMatrix.
G4ErrorSymMatrix sub(G4int min_row, G4int max_row) const;
// Returns a sub matrix of a G4ErrorSymMatrix.
void sub(G4int row, const G4ErrorSymMatrix& m1);
// Sub matrix of this G4ErrorSymMatrix is replaced with m1.
void sub(G4int row, const G4ErrorSymMatrix &m1);
// Sub matrix of this G4ErrorSymMatrix is replaced with m1.
G4ErrorSymMatrix sub(G4int min_row, G4int max_row);
// SGI CC bug. I have to have both with/without const. I should not need
// one without const.
G4ErrorSymMatrix sub(G4int min_row, G4int max_row);
// SGI CC bug. I have to have both with/without const. I should not need
// one without const.
inline G4ErrorSymMatrix inverse(G4int& ifail) const;
// Invert a Matrix. The matrix is not changed
// Returns 0 when successful, otherwise non-zero.
inline G4ErrorSymMatrix inverse(G4int &ifail) const;
// Invert a Matrix. The matrix is not changed
// Returns 0 when successful, otherwise non-zero.
void invert(G4int& ifail);
// Invert a Matrix.
// N.B. the contents of the matrix are replaced by the inverse.
// Returns ierr = 0 when successful, otherwise non-zero.
// This method has less overhead then inverse().
void invert(G4int &ifail);
// Invert a Matrix.
// N.B. the contents of the matrix are replaced by the inverse.
// Returns ierr = 0 when successful, otherwise non-zero.
// This method has less overhead then inverse().
G4double determinant() const;
// calculate the determinant of the matrix.
G4double determinant() const;
// calculate the determinant of the matrix.
G4double trace() const;
// calculate the trace of the matrix (sum of diagonal elements).
G4double trace() const;
// calculate the trace of the matrix (sum of diagonal elements).
class G4ErrorSymMatrix_row
{
public:
inline G4ErrorSymMatrix_row(G4ErrorSymMatrix&, G4int);
inline G4double& operator[](G4int);
class G4ErrorSymMatrix_row
{
public:
inline G4ErrorSymMatrix_row(G4ErrorSymMatrix&,G4int);
inline G4double & operator[](G4int);
private:
G4ErrorSymMatrix& _a;
G4int _r;
};
class G4ErrorSymMatrix_row_const
{
public:
inline G4ErrorSymMatrix_row_const(const G4ErrorSymMatrix&,G4int);
inline const G4double & operator[](G4int) const;
private:
const G4ErrorSymMatrix& _a;
G4int _r;
};
// helper class to implement m[i][j]
private:
G4ErrorSymMatrix& _a;
G4int _r;
};
class G4ErrorSymMatrix_row_const
{
public:
inline G4ErrorSymMatrix_row_const(const G4ErrorSymMatrix&, G4int);
inline const G4double& operator[](G4int) const;
inline G4ErrorSymMatrix_row operator[] (G4int);
inline G4ErrorSymMatrix_row_const operator[] (G4int) const;
// Read or write a matrix element.
// While it may not look like it, you simply do m[i][j] to get an
// element.
// ** Note that the indexing starts from [0][0]. **
private:
const G4ErrorSymMatrix& _a;
G4int _r;
};
// helper class to implement m[i][j]
// Special-case inversions for 5x5 and 6x6 symmetric positive definite:
// These set ifail=0 and invert if the matrix was positive definite;
// otherwise ifail=1 and the matrix is left unaltered.
inline G4ErrorSymMatrix_row operator[](G4int);
inline G4ErrorSymMatrix_row_const operator[](G4int) const;
// Read or write a matrix element.
// While it may not look like it, you simply do m[i][j] to get an
// element.
// ** Note that the indexing starts from [0][0]. **
void invertCholesky5 (G4int &ifail);
void invertCholesky6 (G4int &ifail);
// Special-case inversions for 5x5 and 6x6 symmetric positive definite:
// These set ifail=0 and invert if the matrix was positive definite;
// otherwise ifail=1 and the matrix is left unaltered.
// Inversions for 5x5 and 6x6 forcing use of specific methods: The
// behavior (though not the speed) will be identical to invert(ifail).
void invertCholesky5(G4int& ifail);
void invertCholesky6(G4int& ifail);
void invertHaywood4 (G4int & ifail);
void invertHaywood5 (G4int &ifail);
void invertHaywood6 (G4int &ifail);
void invertBunchKaufman (G4int &ifail);
// Inversions for 5x5 and 6x6 forcing use of specific methods: The
// behavior (though not the speed) will be identical to invert(ifail).
void invertHaywood4(G4int& ifail);
void invertHaywood5(G4int& ifail);
void invertHaywood6(G4int& ifail);
void invertBunchKaufman(G4int& ifail);
protected:
inline G4int num_size() const;
inline G4int num_size() const;
private:
friend class G4ErrorSymMatrix_row;
friend class G4ErrorSymMatrix_row_const;
friend class G4ErrorMatrix;
friend class G4ErrorSymMatrix_row;
friend class G4ErrorSymMatrix_row_const;
friend class G4ErrorMatrix;
friend void tridiagonal(G4ErrorSymMatrix* a, G4ErrorMatrix* hsm);
friend G4double condition(const G4ErrorSymMatrix& m);
friend void diag_step(G4ErrorSymMatrix* t, G4int begin, G4int end);
friend void diag_step(G4ErrorSymMatrix* t, G4ErrorMatrix* u, G4int begin,
G4int end);
friend G4ErrorMatrix diagonalize(G4ErrorSymMatrix* s);
friend void house_with_update2(G4ErrorSymMatrix* a, G4ErrorMatrix* v,
G4int row, G4int col);
friend void tridiagonal(G4ErrorSymMatrix *a, G4ErrorMatrix *hsm);
friend G4double condition(const G4ErrorSymMatrix &m);
friend void diag_step(G4ErrorSymMatrix *t, G4int begin, G4int end);
friend void diag_step(G4ErrorSymMatrix *t, G4ErrorMatrix *u,
G4int begin, G4int end);
friend G4ErrorMatrix diagonalize(G4ErrorSymMatrix *s);
friend void house_with_update2(G4ErrorSymMatrix *a, G4ErrorMatrix *v,
G4int row, G4int col);
friend G4ErrorSymMatrix operator+(const G4ErrorSymMatrix& m1,
const G4ErrorSymMatrix& m2);
friend G4ErrorSymMatrix operator-(const G4ErrorSymMatrix& m1,
const G4ErrorSymMatrix& m2);
friend G4ErrorMatrix operator*(const G4ErrorSymMatrix& m1,
const G4ErrorSymMatrix& m2);
friend G4ErrorMatrix operator*(const G4ErrorSymMatrix& m1,
const G4ErrorMatrix& m2);
friend G4ErrorMatrix operator*(const G4ErrorMatrix& m1,
const G4ErrorSymMatrix& m2);
// Multiply a Matrix by a Matrix or Vector.
friend G4ErrorSymMatrix operator+(const G4ErrorSymMatrix &m1,
const G4ErrorSymMatrix &m2);
friend G4ErrorSymMatrix operator-(const G4ErrorSymMatrix &m1,
const G4ErrorSymMatrix &m2);
friend G4ErrorMatrix operator*(const G4ErrorSymMatrix &m1,
const G4ErrorSymMatrix &m2);
friend G4ErrorMatrix operator*(const G4ErrorSymMatrix &m1,
const G4ErrorMatrix &m2);
friend G4ErrorMatrix operator*(const G4ErrorMatrix &m1,
const G4ErrorSymMatrix &m2);
// Multiply a Matrix by a Matrix or Vector.
// Returns v * v.T();
// Returns v * v.T();
std::vector<G4double > m;
std::vector<G4double> m;
G4int nrow;
G4int size; // total number of elements
G4int nrow;
G4int size; // total number of elements
static G4ThreadLocal G4double posDefFraction5x5;
static G4ThreadLocal G4double adjustment5x5;
static const G4double CHOLESKY_THRESHOLD_5x5;
static const G4double CHOLESKY_CREEP_5x5;
static G4ThreadLocal G4double posDefFraction5x5;
static G4ThreadLocal G4double adjustment5x5;
static const G4double CHOLESKY_THRESHOLD_5x5;
static const G4double CHOLESKY_CREEP_5x5;
static G4ThreadLocal G4double posDefFraction6x6;
static G4ThreadLocal G4double adjustment6x6;
static const G4double CHOLESKY_THRESHOLD_6x6;
static const G4double CHOLESKY_CREEP_6x6;
static G4ThreadLocal G4double posDefFraction6x6;
static G4ThreadLocal G4double adjustment6x6;
static const G4double CHOLESKY_THRESHOLD_6x6;
static const G4double CHOLESKY_CREEP_6x6;
void invert4 (G4int & ifail);
void invert5 (G4int & ifail);
void invert6 (G4int & ifail);
void invert4(G4int& ifail);
void invert5(G4int& ifail);
void invert6(G4int& ifail);
};
//
@@ -242,60 +241,52 @@ class G4ErrorSymMatrix
// DiagMatrix and Vectors
//
std::ostream& operator<<(std::ostream &s, const G4ErrorSymMatrix &q);
std::ostream& operator<<(std::ostream& s, const G4ErrorSymMatrix& q);
// Write out Matrix, G4ErrorSymMatrix, DiagMatrix and Vector into ostream.
G4ErrorMatrix operator*(const G4ErrorMatrix &m1,
const G4ErrorSymMatrix &m2);
G4ErrorMatrix operator*(const G4ErrorSymMatrix &m1,
const G4ErrorMatrix &m2);
G4ErrorMatrix operator*(const G4ErrorSymMatrix &m1,
const G4ErrorSymMatrix &m2);
G4ErrorSymMatrix operator*(G4double t, const G4ErrorSymMatrix &s1);
G4ErrorSymMatrix operator*(const G4ErrorSymMatrix &s1, G4double t);
G4ErrorMatrix operator*(const G4ErrorMatrix& m1, const G4ErrorSymMatrix& m2);
G4ErrorMatrix operator*(const G4ErrorSymMatrix& m1, const G4ErrorMatrix& m2);
G4ErrorMatrix operator*(const G4ErrorSymMatrix& m1, const G4ErrorSymMatrix& m2);
G4ErrorSymMatrix operator*(G4double t, const G4ErrorSymMatrix& s1);
G4ErrorSymMatrix operator*(const G4ErrorSymMatrix& s1, G4double t);
// Multiplication operators.
// Note that m *= m1 is always faster than m = m * m1
G4ErrorSymMatrix operator/(const G4ErrorSymMatrix &m1, G4double t);
G4ErrorSymMatrix operator/(const G4ErrorSymMatrix& m1, G4double t);
// s = s1 / t. (s /= t is faster if you can use it.)
G4ErrorMatrix operator+(const G4ErrorMatrix &m1,
const G4ErrorSymMatrix &s2);
G4ErrorMatrix operator+(const G4ErrorSymMatrix &s1,
const G4ErrorMatrix &m2);
G4ErrorSymMatrix operator+(const G4ErrorSymMatrix &s1,
const G4ErrorSymMatrix &s2);
G4ErrorMatrix operator+(const G4ErrorMatrix& m1, const G4ErrorSymMatrix& s2);
G4ErrorMatrix operator+(const G4ErrorSymMatrix& s1, const G4ErrorMatrix& m2);
G4ErrorSymMatrix operator+(const G4ErrorSymMatrix& s1,
const G4ErrorSymMatrix& s2);
// Addition operators
G4ErrorMatrix operator-(const G4ErrorMatrix &m1,
const G4ErrorSymMatrix &s2);
G4ErrorMatrix operator-(const G4ErrorSymMatrix &m1,
const G4ErrorMatrix &m2);
G4ErrorSymMatrix operator-(const G4ErrorSymMatrix &s1,
const G4ErrorSymMatrix &s2);
G4ErrorMatrix operator-(const G4ErrorMatrix& m1, const G4ErrorSymMatrix& s2);
G4ErrorMatrix operator-(const G4ErrorSymMatrix& m1, const G4ErrorMatrix& m2);
G4ErrorSymMatrix operator-(const G4ErrorSymMatrix& s1,
const G4ErrorSymMatrix& s2);
// subtraction operators
G4ErrorSymMatrix dsum(const G4ErrorSymMatrix &s1,
const G4ErrorSymMatrix &s2);
G4ErrorSymMatrix dsum(const G4ErrorSymMatrix& s1, const G4ErrorSymMatrix& s2);
// Direct sum of two symmetric matrices;
G4double condition(const G4ErrorSymMatrix &m);
G4double condition(const G4ErrorSymMatrix& m);
// Find the conditon number of a symmetric matrix.
void diag_step(G4ErrorSymMatrix *t, G4int begin, G4int end);
void diag_step(G4ErrorSymMatrix *t, G4ErrorMatrix *u, G4int begin, G4int end);
void diag_step(G4ErrorSymMatrix* t, G4int begin, G4int end);
void diag_step(G4ErrorSymMatrix* t, G4ErrorMatrix* u, G4int begin, G4int end);
// Implicit symmetric QR step with Wilkinson Shift
G4ErrorMatrix diagonalize(G4ErrorSymMatrix *s);
G4ErrorMatrix diagonalize(G4ErrorSymMatrix* s);
// Diagonalize a symmetric matrix.
// It returns the matrix U so that s_old = U * s_diag * U.T()
void house_with_update2(G4ErrorSymMatrix *a, G4ErrorMatrix *v,
G4int row=1, G4int col=1);
void house_with_update2(G4ErrorSymMatrix* a, G4ErrorMatrix* v, G4int row = 1,
G4int col = 1);
// Finds and does Householder reflection on matrix.
void tridiagonal(G4ErrorSymMatrix *a, G4ErrorMatrix *hsm);
G4ErrorMatrix tridiagonal(G4ErrorSymMatrix *a);
void tridiagonal(G4ErrorSymMatrix* a, G4ErrorMatrix* hsm);
G4ErrorMatrix tridiagonal(G4ErrorSymMatrix* a);
// Does a Householder tridiagonalization of a symmetric matrix.
#include "G4ErrorSymMatrix.icc"
@@ -28,52 +28,41 @@
// GEANT 4 class inline implementation
// ------------------------------------------------------------
inline G4ErrorSymMatrix::G4ErrorSymMatrix()
: m(0)
, nrow(0)
, size(0)
{}
inline G4ErrorSymMatrix::G4ErrorSymMatrix()
: m(0), nrow(0), size(0)
inline G4int G4ErrorSymMatrix::num_row() const { return nrow; }
inline G4int G4ErrorSymMatrix::num_col() const { return nrow; }
inline G4int G4ErrorSymMatrix::num_size() const { return size; }
inline G4double& G4ErrorSymMatrix::fast(G4int row, G4int col)
{
return *(m.begin() + (row * (row - 1)) / 2 + (col - 1));
}
inline G4int G4ErrorSymMatrix::num_row() const
inline const G4double& G4ErrorSymMatrix::fast(G4int row, G4int col) const
{
return nrow;
return *(m.begin() + (row * (row - 1)) / 2 + (col - 1));
}
inline G4int G4ErrorSymMatrix::num_col() const
inline G4double& G4ErrorSymMatrix::operator()(G4int row, G4int col)
{
return nrow;
return (row >= col ? fast(row, col) : fast(col, row));
}
inline G4int G4ErrorSymMatrix::num_size() const
inline const G4double& G4ErrorSymMatrix::operator()(G4int row, G4int col) const
{
return size;
return (row >= col ? fast(row, col) : fast(col, row));
}
inline G4double & G4ErrorSymMatrix::fast(G4int row,G4int col)
inline void G4ErrorSymMatrix::assign(const G4ErrorSymMatrix& mat)
{
return *(m.begin()+(row*(row-1))/2+(col-1));
}
inline const G4double & G4ErrorSymMatrix::fast(G4int row,G4int col) const
{
return *(m.begin()+(row*(row-1))/2+(col-1));
}
inline G4double &
G4ErrorSymMatrix::operator()(G4int row, G4int col)
{
return (row>=col? fast(row,col) : fast(col,row));
}
inline const G4double &
G4ErrorSymMatrix::operator()(G4int row, G4int col) const
{
return (row>=col? fast(row,col) : fast(col,row));
}
inline void G4ErrorSymMatrix::assign(const G4ErrorSymMatrix &mat)
{
(*this)=mat;
(*this) = mat;
}
inline G4ErrorSymMatrix G4ErrorSymMatrix::T() const
@@ -81,57 +70,58 @@ inline G4ErrorSymMatrix G4ErrorSymMatrix::T() const
return G4ErrorSymMatrix(*this);
}
inline G4ErrorSymMatrix::G4ErrorSymMatrix_row
G4ErrorSymMatrix::operator[] (G4int r)
inline G4ErrorSymMatrix::G4ErrorSymMatrix_row G4ErrorSymMatrix::operator[](
G4int r)
{
G4ErrorSymMatrix_row b(*this,r);
G4ErrorSymMatrix_row b(*this, r);
return b;
}
inline G4ErrorSymMatrix::G4ErrorSymMatrix_row_const
G4ErrorSymMatrix::operator[] (G4int r) const
inline G4ErrorSymMatrix::G4ErrorSymMatrix_row_const G4ErrorSymMatrix::
operator[](G4int r) const
{
const G4ErrorSymMatrix_row_const b(*this,r);
const G4ErrorSymMatrix_row_const b(*this, r);
return b;
}
inline G4double &G4ErrorSymMatrix::G4ErrorSymMatrix_row::operator[](G4int c)
inline G4double& G4ErrorSymMatrix::G4ErrorSymMatrix_row::operator[](G4int c)
{
if (_r >= c )
{
return *(_a.m.begin() + (_r+1)*_r/2 + c);
}
else
{
return *(_a.m.begin() + (c+1)*c/2 + _r);
}
if(_r >= c)
{
return *(_a.m.begin() + (_r + 1) * _r / 2 + c);
}
else
{
return *(_a.m.begin() + (c + 1) * c / 2 + _r);
}
}
inline const G4double &
G4ErrorSymMatrix::G4ErrorSymMatrix_row_const::operator[](G4int c) const
inline const G4double& G4ErrorSymMatrix::G4ErrorSymMatrix_row_const::operator[](
G4int c) const
{
if (_r >= c )
{
return *(_a.m.begin() + (_r+1)*_r/2 + c);
}
else
{
return *(_a.m.begin() + (c+1)*c/2 + _r);
}
if(_r >= c)
{
return *(_a.m.begin() + (_r + 1) * _r / 2 + c);
}
else
{
return *(_a.m.begin() + (c + 1) * c / 2 + _r);
}
}
inline G4ErrorSymMatrix::
G4ErrorSymMatrix_row::G4ErrorSymMatrix_row(G4ErrorSymMatrix &a, G4int r)
: _a(a), _r(r)
inline G4ErrorSymMatrix::G4ErrorSymMatrix_row::G4ErrorSymMatrix_row(
G4ErrorSymMatrix& a, G4int r)
: _a(a)
, _r(r)
{}
inline G4ErrorSymMatrix::
G4ErrorSymMatrix_row_const::G4ErrorSymMatrix_row_const
(const G4ErrorSymMatrix&a,G4int r)
: _a(a), _r(r)
inline G4ErrorSymMatrix::G4ErrorSymMatrix_row_const::G4ErrorSymMatrix_row_const(
const G4ErrorSymMatrix& a, G4int r)
: _a(a)
, _r(r)
{}
inline G4ErrorSymMatrix G4ErrorSymMatrix::inverse(G4int &ifail) const
inline G4ErrorSymMatrix G4ErrorSymMatrix::inverse(G4int& ifail) const
{
G4ErrorSymMatrix mTmp(*this);
mTmp.invert(ifail);
@@ -39,53 +39,55 @@
#ifndef G4ErrorTrackLengthTarget_hh
#define G4ErrorTrackLengthTarget_hh
#include "G4ios.hh"
#include "G4ios.hh"
#include "globals.hh"
#include "G4VDiscreteProcess.hh"
#include "G4PhysicsTable.hh"
#include "G4PhysicsLogVector.hh"
#include "G4ElementTable.hh"
#include "G4Step.hh"
#include "G4Step.hh"
#include "G4ErrorTarget.hh"
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
class G4ErrorTrackLengthTarget : public G4VDiscreteProcess,
public G4ErrorTarget
class G4ErrorTrackLengthTarget
: public G4VDiscreteProcess
, public G4ErrorTarget
{
public: // with description
G4ErrorTrackLengthTarget(const G4double maxTrkLength);
// Constructs and add this process to G4ProcessManager of all particles
virtual ~G4ErrorTrackLengthTarget() {}
G4ErrorTrackLengthTarget(const G4double maxTrkLength );
// Constructs and add this process to G4ProcessManager of all particles
virtual ~G4ErrorTrackLengthTarget(){}
// These methods are dummy, as the step limitation is done in the
// PostStepGetPhysicalInteractionLength().
// These methods are dummy, as the step limitation is done in the
// PostStepGetPhysicalInteractionLength().
virtual G4double GetDistanceFromPoint( const G4ThreeVector&,
const G4ThreeVector& ) const
{ return DBL_MAX; }
virtual G4double GetDistanceFromPoint( const G4ThreeVector& ) const
{ return DBL_MAX; }
virtual G4double GetDistanceFromPoint(const G4ThreeVector&,
const G4ThreeVector&) const
{
return DBL_MAX;
}
virtual G4double GetDistanceFromPoint(const G4ThreeVector&) const
{
return DBL_MAX;
}
virtual G4double
PostStepGetPhysicalInteractionLength( const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition );
// Checks if the maximum track length has been reached
virtual G4double PostStepGetPhysicalInteractionLength(
const G4Track& track, G4double previousStepSize,
G4ForceCondition* condition);
// Checks if the maximum track length has been reached
virtual G4double GetMeanFreePath(const class G4Track & track,
G4double, G4ForceCondition *);
// Mean free path = theMaximumTrackLength - track.GetTrackLength()
virtual G4double GetMeanFreePath(const class G4Track& track, G4double,
G4ForceCondition*);
// Mean free path = theMaximumTrackLength - track.GetTrackLength()
virtual G4VParticleChange* PostStepDoIt( const G4Track&, const G4Step& );
virtual void Dump( const G4String& msg ) const;
virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&);
virtual void Dump(const G4String& msg) const;
private:
G4double theMaximumTrackLength;
G4VParticleChange theParticleChange;
};
#endif
@@ -43,91 +43,83 @@
#include "G4Vector3D.hh"
#include "G4ErrorTrajErr.hh"
enum G4eTSType{ G4eTS_FREE, G4eTS_OS };
enum G4eTSType
{
G4eTS_FREE,
G4eTS_OS
};
class G4ErrorTrajState
{
public: // with description
G4ErrorTrajState()
: fCharge(0.)
, theG4Track(0)
, iverbose(0)
{}
G4ErrorTrajState() : fCharge(0.), theG4Track(0), iverbose(0) {}
G4ErrorTrajState( const G4String& partType, const G4Point3D& pos,
const G4Vector3D& mom,
const G4ErrorTrajErr& errmat = G4ErrorTrajErr(5,0) );
// Constructor by providing particle, position and momentum
G4ErrorTrajState(const G4String& partType, const G4Point3D& pos,
const G4Vector3D& mom,
const G4ErrorTrajErr& errmat = G4ErrorTrajErr(5, 0));
// Constructor by providing particle, position and momentum
G4ErrorTrajState(const G4ErrorTrajState&);
G4ErrorTrajState(G4ErrorTrajState&&);
// The copy and move constructors
// The copy and move constructors
virtual ~G4ErrorTrajState(){}
virtual ~G4ErrorTrajState() {}
G4ErrorTrajState& operator = (const G4ErrorTrajState&);
G4ErrorTrajState& operator = (G4ErrorTrajState&&);
// The copy and move assignment operators
G4ErrorTrajState& operator=(const G4ErrorTrajState&);
G4ErrorTrajState& operator=(G4ErrorTrajState&&);
// The copy and move assignment operators
void SetData( const G4String& partType, const G4Point3D& pos,
const G4Vector3D& mom );
// Set particle, position and momentum
void SetData(const G4String& partType, const G4Point3D& pos,
const G4Vector3D& mom);
// Set particle, position and momentum
void BuildCharge();
// Build charge based on particle type
// Build charge based on particle type
friend
std::ostream& operator<<(std::ostream&, const G4ErrorTrajState& ts);
friend std::ostream& operator<<(std::ostream&, const G4ErrorTrajState& ts);
virtual G4int PropagateError( const G4Track* );
// Propagate the error along the step
virtual G4int PropagateError(const G4Track*);
// Propagate the error along the step
virtual G4int Update( const G4Track* ){ return -1; }
// Update parameters from G4Track
void UpdatePosMom( const G4Point3D& pos, const G4Vector3D& mom );
// Update position and momentum
virtual G4int Update(const G4Track*) { return -1; }
// Update parameters from G4Track
void DumpPosMomError( std::ostream& out = G4cout ) const;
// Dump position, momentum and error
void UpdatePosMom(const G4Point3D& pos, const G4Vector3D& mom);
// Update position and momentum
virtual void Dump( std::ostream& out = G4cout ) const = 0;
// Abstract method to dump all TrajState parameters
// Set and Get methods
void DumpPosMomError(std::ostream& out = G4cout) const;
// Dump position, momentum and error
const G4String& GetParticleType() const
{ return fParticleType;}
void SetParticleType( const G4String& partType )
{ fParticleType = partType;}
virtual void Dump(std::ostream& out = G4cout) const = 0;
// Abstract method to dump all TrajState parameters
G4Point3D GetPosition() const
{ return fPosition; }
virtual void SetPosition( const G4Point3D pos )
{ fPosition = pos; }
// Set and Get methods
G4Vector3D GetMomentum() const
{ return fMomentum; }
virtual void SetMomentum( const G4Vector3D& mom )
{ fMomentum = mom; }
const G4String& GetParticleType() const { return fParticleType; }
void SetParticleType(const G4String& partType) { fParticleType = partType; }
G4ErrorTrajErr GetError() const
{ return fError; }
virtual void SetError( G4ErrorTrajErr em )
{ fError = em; }
G4Point3D GetPosition() const { return fPosition; }
virtual void SetPosition(const G4Point3D pos) { fPosition = pos; }
G4Track* GetG4Track() const
{ return theG4Track; }
void SetG4Track( G4Track* trk )
{ theG4Track = trk; }
G4Vector3D GetMomentum() const { return fMomentum; }
virtual void SetMomentum(const G4Vector3D& mom) { fMomentum = mom; }
G4double GetCharge() const
{ return fCharge; }
void SetCharge( G4double ch )
{ fCharge = ch; }
G4ErrorTrajErr GetError() const { return fError; }
virtual void SetError(G4ErrorTrajErr em) { fError = em; }
virtual G4eTSType GetTSType() const
{ return theTSType; }
G4Track* GetG4Track() const { return theG4Track; }
void SetG4Track(G4Track* trk) { theG4Track = trk; }
G4double GetCharge() const { return fCharge; }
void SetCharge(G4double ch) { fCharge = ch; }
virtual G4eTSType GetTSType() const { return theTSType; }
protected:
G4String fParticleType;
G4Point3D fPosition;
G4Vector3D fMomentum;
@@ -38,55 +38,51 @@
#ifndef G4VErrorLimitProcess_hh
#define G4VErrorLimitProcess_hh
#include "G4ios.hh"
#include "G4ios.hh"
#include "globals.hh"
#include "G4VDiscreteProcess.hh"
#include "G4PhysicsTable.hh"
#include "G4PhysicsLogVector.hh"
#include "G4ElementTable.hh"
#include "G4Gamma.hh"
#include "G4Gamma.hh"
#include "G4Electron.hh"
#include "G4Step.hh"
#include "G4Step.hh"
class G4ErrorLimitsMessenger;
//-----------------------------------------------------------------
class G4VErrorLimitProcess : public G4VDiscreteProcess
{
public: // with description
G4VErrorLimitProcess(const G4String& processName);
~G4VErrorLimitProcess();
virtual G4double
PostStepGetPhysicalInteractionLength( const G4Track& track,
G4double previousStepSize,
G4ForceCondition* condition ) = 0;
// Returns the step limit
virtual G4double GetMeanFreePath(const class G4Track &, G4double,
enum G4ForceCondition *);
// Returns kInfinity
virtual G4double PostStepGetPhysicalInteractionLength(
const G4Track& track, G4double previousStepSize,
G4ForceCondition* condition) = 0;
// Returns the step limit
virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step& );
// No action but retrieving the G4VParticleChange
// extracted from the G4Track
virtual G4double GetMeanFreePath(const class G4Track&, G4double,
enum G4ForceCondition*);
// Returns kInfinity
virtual G4VParticleChange* PostStepDoIt(const G4Track&, const G4Step&);
// No action but retrieving the G4VParticleChange
// extracted from the G4Track
// Get and Set methods
G4double GetStepLimit() const { return theStepLimit; }
void SetStepLimit( G4double val ) { theStepLimit = val; }
void SetStepLimit(G4double val) { theStepLimit = val; }
protected:
G4double theStepLimit; // limit set by the user
G4double theStepLength; // step length extracted from the user step limit,
// with the algorithms of each concrete class
G4double theStepLimit; // limit set by the user
G4double theStepLength; // step length extracted from the user step limit,
// with the algorithms of each concrete class
G4VParticleChange theParticleChange;
};
#endif