Import Geant4 9.3.0 source tree
This commit is contained in:
@@ -0,0 +1,83 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $ Id: G4CachedMagneticField.hh,v 1.0 2009/07/20 18:53:00 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-09-03 $
|
||||
//
|
||||
//
|
||||
// class G4CachedMagneticField
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Caches Magnetic Field value, for field whose evaluation is expensive.
|
||||
|
||||
// History:
|
||||
// - Created. JA, July 20th, 2009.
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#ifndef G4CACHED_MAGNETIC_FIELD_DEF
|
||||
#define G4CACHED_MAGNETIC_FIELD_DEF
|
||||
|
||||
#include "G4Types.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4MagneticField.hh"
|
||||
|
||||
class G4CachedMagneticField : public G4MagneticField
|
||||
{
|
||||
public: // with description
|
||||
|
||||
G4CachedMagneticField(G4MagneticField *, G4double distanceConst);
|
||||
virtual ~G4CachedMagneticField();
|
||||
// Constructor and destructor. No actions.
|
||||
|
||||
G4CachedMagneticField(const G4CachedMagneticField &r);
|
||||
G4CachedMagneticField& operator = (const G4CachedMagneticField &p);
|
||||
// Copy constructor & assignment operator.
|
||||
|
||||
virtual void GetFieldValue( const G4double Point[4],
|
||||
G4double *Bfield ) const;
|
||||
|
||||
G4double GetConstDistance() const { return fDistanceConst; }
|
||||
void SetConstDistance( G4double dist ){ fDistanceConst= dist;}
|
||||
|
||||
G4int GetCountCalls() const { return fCountCalls; }
|
||||
G4int GetCountEvaluations() const { return fCountEvaluations; }
|
||||
void ClearCounts() { fCountCalls = 0; fCountEvaluations=0; }
|
||||
void ReportStatistics();
|
||||
|
||||
private:
|
||||
G4MagneticField *fpMagneticField;
|
||||
// When the field is evaluated within this distance it will not change
|
||||
G4double fDistanceConst;
|
||||
// Caching state
|
||||
mutable G4ThreeVector fLastLocation;
|
||||
mutable G4ThreeVector fLastValue;
|
||||
|
||||
protected:
|
||||
mutable G4int fCountCalls, fCountEvaluations;
|
||||
};
|
||||
|
||||
#endif /* G4CACHED_MAGNETIC_FIELD_DEF */
|
||||
@@ -0,0 +1,91 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4EqEMFieldWithEDM.hh,v 1.1 2009/11/04 23:51:42 gum Exp $
|
||||
// GEANT4 tag $Name: geant4-09-03 $
|
||||
//
|
||||
//
|
||||
// class G4EqEMFieldWithEDM
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// This is the right-hand side of equation of motion in a combined
|
||||
// electric and magnetic field, with spin tracking for both MDM and
|
||||
// EDM terms.
|
||||
|
||||
// History:
|
||||
// - Created. Kevin Lynch, 19.02.2009, based on G4EqEMFieldWithSpin
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#ifndef G4EQEMFIELDWITHEDM_hh
|
||||
#define G4EQEMFIELDWITHEDM_hh
|
||||
|
||||
#include "G4EquationOfMotion.hh"
|
||||
|
||||
class G4ElectroMagneticField;
|
||||
|
||||
class G4EqEMFieldWithEDM : public G4EquationOfMotion
|
||||
{
|
||||
public: // with description
|
||||
|
||||
G4EqEMFieldWithEDM(G4ElectroMagneticField *emField );
|
||||
|
||||
~G4EqEMFieldWithEDM();
|
||||
|
||||
void SetChargeMomentumMass(G4double particleCharge, // in e+ units
|
||||
G4double MomentumXc,
|
||||
G4double mass);
|
||||
|
||||
void EvaluateRhsGivenB(const G4double y[],
|
||||
const G4double Field[],
|
||||
G4double dydx[] ) const;
|
||||
// Given the value of the electromagnetic field, this function
|
||||
// calculates the value of the derivative dydx.
|
||||
|
||||
inline void SetAnomaly(G4double a) { anomaly = a; }
|
||||
inline G4double GetAnomaly() const { return anomaly; }
|
||||
// set/get magnetic anomaly
|
||||
|
||||
inline void SetEta(G4double n) { eta = n; }
|
||||
inline G4double GetEta() const { return eta; }
|
||||
// set/get EDM eta parameter
|
||||
|
||||
private:
|
||||
|
||||
G4double fElectroMagCof ;
|
||||
G4double fMassCof;
|
||||
|
||||
G4double omegac;
|
||||
G4double anomaly;
|
||||
G4double eta;
|
||||
G4double ParticleCharge;
|
||||
G4double E;
|
||||
G4double gamma;
|
||||
G4double beta;
|
||||
|
||||
};
|
||||
|
||||
#endif /* G4EQEMFIELDWITHEDM */
|
||||
@@ -23,8 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MagIntegratorStepper.hh,v 1.12 2006/09/20 09:31:01 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4MagIntegratorStepper.hh,v 1.14 2009/11/05 18:31:15 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-09-03 $
|
||||
//
|
||||
//
|
||||
// class G4MagIntegratorStepper
|
||||
@@ -74,13 +74,21 @@ class G4MagIntegratorStepper
|
||||
// Estimate the maximum distance of a chord from the true path
|
||||
// over the segment last integrated.
|
||||
|
||||
virtual void ComputeRightHandSide( const G4double y[], G4double dydx[] );
|
||||
// Must compute the RightHandSide as in the method below
|
||||
// Optionally can cache the input y[] and the dydx[] values computed.
|
||||
|
||||
inline void NormaliseTangentVector( G4double vec[6] );
|
||||
// Simple utility function to (re)normalise 'unit velocity' vector.
|
||||
|
||||
inline void NormalisePolarizationVector( G4double vec[12] );
|
||||
// Simple utility function to (re)normalise 'unit spin' vector.
|
||||
|
||||
inline void RightHandSide( const double y[], double dydx[] );
|
||||
// Utility method to supply the standard Evaluation of the
|
||||
// Right Hand side of the associated equation.
|
||||
|
||||
|
||||
inline G4int GetNumberOfVariables() const;
|
||||
// Get the number of variables that the stepper will integrate over.
|
||||
|
||||
|
||||
@@ -23,8 +23,8 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4MagIntegratorStepper.icc,v 1.10 2006/09/20 09:31:46 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-09-02 $
|
||||
// $Id: G4MagIntegratorStepper.icc,v 1.12 2009/03/25 15:29:02 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-03 $
|
||||
//
|
||||
|
||||
inline
|
||||
@@ -36,7 +36,8 @@ G4EquationOfMotion* G4MagIntegratorStepper::GetEquationOfMotion()
|
||||
inline void
|
||||
G4MagIntegratorStepper::SetEquationOfMotion(G4EquationOfMotion* newEquation)
|
||||
{
|
||||
if( newEquation != 0 ) {
|
||||
if( newEquation != 0 )
|
||||
{
|
||||
fEquation_Rhs= newEquation;
|
||||
}
|
||||
}
|
||||
@@ -54,12 +55,6 @@ G4int G4MagIntegratorStepper::GetNumberOfStateVariables() const
|
||||
return fNoStateVariables;
|
||||
}
|
||||
|
||||
// inline
|
||||
// void G4MagIntegratorStepper::SetNumberOfVariables(G4int newNo)
|
||||
// {
|
||||
// fNumberOfVariables = newNo;
|
||||
// }
|
||||
|
||||
inline
|
||||
void G4MagIntegratorStepper::RightHandSide( const double y[], double dydx[] )
|
||||
{
|
||||
@@ -69,11 +64,26 @@ void G4MagIntegratorStepper::RightHandSide( const double y[], double dydx[] )
|
||||
inline
|
||||
void G4MagIntegratorStepper::NormaliseTangentVector( G4double vec[6] )
|
||||
{
|
||||
double drds2 = vec[3]*vec[3]+vec[4]*vec[4]+vec[5]*vec[5];
|
||||
G4double drds2 = vec[3]*vec[3]+vec[4]*vec[4]+vec[5]*vec[5];
|
||||
|
||||
if( std::fabs(drds2 - 1.0) > 1.e-14 ){
|
||||
double normx = 1.0 / std::sqrt(drds2);
|
||||
for(int i=0;i<3;i++)
|
||||
vec[i+3] *= normx;
|
||||
}
|
||||
if( std::fabs(drds2 - 1.0) > 1.e-14 )
|
||||
{
|
||||
G4double normx = 1.0 / std::sqrt(drds2);
|
||||
for(G4int i=3;i<6;i++) { vec[i] *= normx; }
|
||||
}
|
||||
}
|
||||
|
||||
inline
|
||||
void G4MagIntegratorStepper::NormalisePolarizationVector( G4double vec[12] )
|
||||
{
|
||||
G4double drds2 = vec[9]*vec[9]+vec[10]*vec[10]+vec[11]*vec[11];
|
||||
|
||||
if( drds2 > 0. )
|
||||
{
|
||||
if( std::fabs(drds2 - 1.0) > 1.e-14 )
|
||||
{
|
||||
G4double normx = 1.0 / std::sqrt(drds2);
|
||||
for(G4int i=9;i<12;i++) { vec[i] *= normx; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * 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. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4NystromRK4.hh,v 1.3 2009/11/12 15:01:36 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-09-03 $
|
||||
//
|
||||
// class G4NystromRK4
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Integrate the equations of the motion of a particle in a magnetic field
|
||||
// using 4th Runge-Kutta-Nystrom method with errors estimation
|
||||
// (ATL-SOFT-PUB-2009-01)
|
||||
// Current form can be used only for 'pure' magnetic field.
|
||||
// Notes: 1) field must be time-independent.
|
||||
// 2) time is not integrated
|
||||
//
|
||||
// History:
|
||||
// - Created: I.Gavrilenko 15.05.2009 (as G4AtlasRK4)
|
||||
// - Adaptations: J. Apostolakis May-Nov 2009
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#ifndef G4NYSTROMRK4_HH
|
||||
#define G4NYSTROMRK4_HH
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4MagIntegratorStepper.hh"
|
||||
#include "G4Mag_EqRhs.hh"
|
||||
|
||||
class G4NystromRK4 : public G4MagIntegratorStepper
|
||||
{
|
||||
public:
|
||||
G4NystromRK4(G4Mag_EqRhs *EquationMotion, G4double distanceConstField=0.0);
|
||||
// Can be used only for Magnetic Fields - and for 6 variables (x,p)
|
||||
|
||||
~G4NystromRK4() ;
|
||||
|
||||
void Stepper(const G4double P [],
|
||||
const G4double dPdS[],
|
||||
G4double step ,
|
||||
G4double Po [],
|
||||
G4double Err []);
|
||||
// Single call for integration result and error
|
||||
// - Provides Error via analytical method
|
||||
|
||||
virtual void ComputeRightHandSide(const double P[],double dPdS[]);
|
||||
// Must compute RHS - and does caches result
|
||||
|
||||
void SetDistanceForConstantField( G4double length );
|
||||
G4double GetDistanceForConstantField() const;
|
||||
|
||||
G4int IntegratorOrder() const {return 4;}
|
||||
G4double DistChord() const;
|
||||
|
||||
private:
|
||||
|
||||
inline void getField (const G4double P[4]);
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Private data
|
||||
////////////////////////////////////////////////////////////////
|
||||
|
||||
G4Mag_EqRhs* m_fEq;
|
||||
G4double m_lastField[3];
|
||||
G4double m_fldPosition[4];
|
||||
G4double m_magdistance ;
|
||||
G4double m_magdistance2;
|
||||
G4double m_cof ;
|
||||
G4double m_mom ;
|
||||
G4double m_imom ;
|
||||
G4bool m_cachedMom ;
|
||||
G4double m_iPoint [3];
|
||||
G4double m_mPoint [3];
|
||||
G4double m_fPoint [3];
|
||||
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Inline methods
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
inline void G4NystromRK4::SetDistanceForConstantField( G4double length )
|
||||
{
|
||||
m_magdistance= length;
|
||||
m_magdistance2 = length*length;
|
||||
}
|
||||
|
||||
inline G4double G4NystromRK4::GetDistanceForConstantField() const
|
||||
{
|
||||
return m_magdistance;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Get value of magnetic field while checking distance from last stored call
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline void G4NystromRK4::getField (const G4double P[4])
|
||||
{
|
||||
|
||||
G4double dx = P[0]-m_fldPosition[0];
|
||||
G4double dy = P[1]-m_fldPosition[1];
|
||||
G4double dz = P[2]-m_fldPosition[2];
|
||||
|
||||
if((dx*dx+dy*dy+dz*dz) > m_magdistance2) {
|
||||
|
||||
m_fldPosition[0] = P[0];
|
||||
m_fldPosition[1] = P[1];
|
||||
m_fldPosition[2] = P[2];
|
||||
m_fldPosition[3] = P[3]; // Generally it is P[7] - changed convention !!
|
||||
m_fEq->GetFieldValue(m_fldPosition, m_lastField);
|
||||
}
|
||||
}
|
||||
#endif // G4NYSTROMRK4
|
||||
Reference in New Issue
Block a user