Import Geant4 9.0.0 source tree
This commit is contained in:
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4CashKarpRKF45.cc,v 1.14 2006/06/29 18:23:29 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// The Cash-Karp Runge-Kutta-Fehlberg 4/5 method is an embedded fourth
|
||||
// order method (giving fifth-order accuracy) for the solution of an ODE.
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4ChordFinder.cc,v 1.47 2006/06/29 18:23:32 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// 25.02.97 John Apostolakis, design and implimentation
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4ClassicalRK4.cc,v 1.12 2006/06/29 18:23:37 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4DELPHIMagField.cc,v 1.6 2006/06/29 18:23:39 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "G4DELPHIMagField.hh"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4ElectricField.cc,v 1.2 2006/06/29 18:23:42 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4ElectroMagneticField.cc,v 1.3 2006/06/29 18:23:44 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4EqMagElectricField.cc,v 1.13 2006/06/29 18:23:46 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// This is the standard right-hand side for equation of motion.
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4EquationOfMotion.cc,v 1.9 2006/06/29 18:23:48 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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: G4ErrorMag_UsualEqRhs.cc,v 1.1 2007/05/16 12:54:02 gcosmo Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "G4ErrorMag_UsualEqRhs.hh"
|
||||
#include "G4ErrorPropagatorData.hh"
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
|
||||
G4ErrorMag_UsualEqRhs::G4ErrorMag_UsualEqRhs( G4MagneticField* MagField )
|
||||
: G4Mag_UsualEqRhs( MagField )
|
||||
{
|
||||
}
|
||||
|
||||
G4ErrorMag_UsualEqRhs::~G4ErrorMag_UsualEqRhs()
|
||||
{
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
void
|
||||
G4ErrorMag_UsualEqRhs::EvaluateRhsGivenB( const G4double y[],
|
||||
const G4double B[3],
|
||||
G4double dydx[] ) const
|
||||
{
|
||||
|
||||
G4Mag_UsualEqRhs::EvaluateRhsGivenB(y, B, dydx );
|
||||
|
||||
if(G4ErrorPropagatorData::GetErrorPropagatorData()->GetMode()
|
||||
== G4ErrorMode_PropBackwards)
|
||||
{
|
||||
G4double momentum_mag_square = sqr(y[3]) + sqr(y[4]) + sqr(y[5]);
|
||||
G4double inv_momentum_magnitude = 1.0 / std::sqrt( momentum_mag_square );
|
||||
|
||||
G4double cof = FCof()*inv_momentum_magnitude;
|
||||
|
||||
dydx[3] = cof*(y[4]*(-B[2]) - y[5]*(-B[1])) ;
|
||||
dydx[4] = cof*(y[5]*(-B[0]) - y[3]*(-B[2])) ;
|
||||
dydx[5] = cof*(y[3]*(-B[1]) - y[4]*(-B[0])) ;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4ExactHelixStepper.cc,v 1.4 2006/06/29 18:23:50 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// $Id: G4ExactHelixStepper.cc,v 1.6 2007/05/18 15:49:18 tnikitin Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// Helix a-la-Explicity Euler: x_1 = x_0 + helix(h)
|
||||
// with helix(h) being a helix piece of length h
|
||||
@@ -53,6 +53,7 @@ G4ExactHelixStepper::G4ExactHelixStepper(G4Mag_EqRhs *EqRhs)
|
||||
for(i=0;i<nvar;i++) {
|
||||
fYInSav[i]= DBL_MAX;
|
||||
}
|
||||
fPtrMagEqOfMot=EqRhs;
|
||||
}
|
||||
|
||||
G4ExactHelixStepper::~G4ExactHelixStepper() {}
|
||||
@@ -76,9 +77,7 @@ G4ExactHelixStepper::Stepper( const G4double yInput[],
|
||||
}
|
||||
|
||||
MagFieldEvaluate(yInput, Bfld_value) ;
|
||||
fBfieldValue= Bfld_value; // Save it for chord if needed.
|
||||
fLastStepSize = hstep; // ditto
|
||||
|
||||
|
||||
// DumbStepper(yIn, Bfld_value, hstep, yTemp);
|
||||
AdvanceHelix(yInput, Bfld_value, hstep, yOut);
|
||||
|
||||
@@ -87,8 +86,10 @@ G4ExactHelixStepper::Stepper( const G4double yInput[],
|
||||
yErr[i] = 0.0 ;
|
||||
}
|
||||
|
||||
yInitialEHS = G4ThreeVector( yInput[0], yInput[1], yInput[2]);
|
||||
yFinalEHS = G4ThreeVector( yOut[0], yOut[1], yOut[2]);
|
||||
yInitialEHS = G4ThreeVector( yInput[0], yInput[1], yInput[2]);
|
||||
yFinalEHS = G4ThreeVector( yOut[0], yOut[1], yOut[2]);
|
||||
fBfieldValue=Bfld_value;
|
||||
fLastStepSize=hstep;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -104,28 +105,31 @@ G4ExactHelixStepper::DumbStepper( const G4double yIn[],
|
||||
"EHS:NoDumbStepper", FatalException, "Stepper must do all the work." );
|
||||
}
|
||||
|
||||
G4double
|
||||
G4ExactHelixStepper::DistChord() const
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
G4double G4ExactHelixStepper::DistChord() const
|
||||
{
|
||||
// Method below is good only for < 2 pi ---> TO-DO
|
||||
const G4int nvar = 6 ;
|
||||
// Implementation : must check whether h/R > pi !!
|
||||
// If( h/R < pi) DistChord=h/2*tan(Ang_curve/4)
|
||||
// Else DistChord=R_helix
|
||||
//
|
||||
G4double distChord;
|
||||
G4double H_helix;
|
||||
H_helix=fLastStepSize;
|
||||
G4double Ang_curve=GetAngCurve();
|
||||
if(Ang_curve<pi){
|
||||
|
||||
distChord=0.5*H_helix*std::tan(0.25*Ang_curve);
|
||||
|
||||
// Calculate yMidPoint
|
||||
G4double hHalf = fLastStepSize * 0.5;
|
||||
G4ThreeVector Bfld_initial= fBfieldValue;
|
||||
G4double yStart[7], yMid[7] ;
|
||||
|
||||
G4int i;
|
||||
for(i=0;i<nvar;i++) yStart[i]= fYInSav[i];
|
||||
|
||||
// Do the half step
|
||||
// DumbStepper(yStart, Bfld_initial, hHalf, yMid);
|
||||
AdvanceHelix(yStart, Bfld_initial, hHalf, yMid);
|
||||
G4ThreeVector yMidPointEHS = G4ThreeVector( yMid[0], yMid[1], yMid[2]);
|
||||
|
||||
return G4LineSection::Distline( yMidPointEHS, yInitialEHS, yFinalEHS );
|
||||
// This is a class method that gives distance of Mid
|
||||
// from the Chord between the Initial and Final points.
|
||||
}
|
||||
else{
|
||||
distChord=GetRadHelix();
|
||||
|
||||
}
|
||||
|
||||
return distChord;
|
||||
|
||||
}
|
||||
|
||||
G4int
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4ExplicitEuler.cc,v 1.8 2006/06/29 18:23:53 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// Explicit Euler: x_1 = x_0 + h * dx_0
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4FieldManager.cc,v 1.14 2006/06/29 18:23:55 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4FieldTrack.cc,v 1.13 2006/06/29 18:23:58 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4HarmonicPolMagField.cc,v 1.6 2006/06/29 18:24:00 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4HelixExplicitEuler.cc,v 1.6 2006/06/29 18:24:02 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// Helix Explicit Euler: x_1 = x_0 + helix(h)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4HelixHeum.cc,v 1.6 2006/06/29 18:24:04 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// Simple Heum:
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4HelixImplicitEuler.cc,v 1.6 2006/06/29 18:24:06 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// Helix Implicit Euler:
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * 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. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// class G4HelixMixedStepper
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// G4HelixMixedStepper split the Method used for Integration in two:
|
||||
//
|
||||
// If Stepping Angle ( h / R_curve) < pi/3 use Classical RK4Stepper
|
||||
// Else use HelixExplicitEuler Stepper
|
||||
//
|
||||
// History:
|
||||
// Derived from ExactHelicalStepper 18/05/07
|
||||
//
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
#include "G4HelixMixedStepper.hh"
|
||||
#include "G4ClassicalRK4.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
G4HelixMixedStepper::G4HelixMixedStepper(G4Mag_EqRhs *EqRhs)
|
||||
: G4MagHelicalStepper(EqRhs)
|
||||
|
||||
{
|
||||
|
||||
fRK4Stepper= new G4ClassicalRK4(EqRhs);
|
||||
}
|
||||
|
||||
G4HelixMixedStepper::~G4HelixMixedStepper() {
|
||||
delete(fRK4Stepper);
|
||||
}
|
||||
void G4HelixMixedStepper::Stepper( const G4double yInput[7],
|
||||
const G4double dydx[7],
|
||||
G4double Step,
|
||||
G4double yOut[7],
|
||||
G4double yErr[])
|
||||
|
||||
{
|
||||
|
||||
//Estimation of the Stepping Angle
|
||||
|
||||
G4ThreeVector Bfld;
|
||||
MagFieldEvaluate(yInput, Bfld);
|
||||
|
||||
G4double Bmag = Bfld.mag();
|
||||
const G4double *pIn = yInput+3;
|
||||
G4ThreeVector initVelocity= G4ThreeVector( pIn[0], pIn[1], pIn[2]);
|
||||
G4double velocityVal = initVelocity.mag();
|
||||
G4double R_1;
|
||||
G4double Ang_curve;
|
||||
|
||||
R_1=std::abs(GetInverseCurve(velocityVal,Bmag));
|
||||
Ang_curve=R_1*Step;
|
||||
SetAngCurve(Ang_curve);
|
||||
fLastStepSize=Step;
|
||||
|
||||
if(Ang_curve<0.33*pi){
|
||||
|
||||
fRK4Stepper->Stepper(yInput,dydx,Step,yOut,yErr);
|
||||
|
||||
}
|
||||
else{
|
||||
const G4int nvar = 6 ;
|
||||
G4int i;
|
||||
G4double yTemp[7], yIn[7] ;
|
||||
G4ThreeVector Bfld_midpoint;
|
||||
// Saving yInput because yInput and yOut can be aliases for same array
|
||||
for(i=0;i<nvar;i++) yIn[i]=yInput[i];
|
||||
|
||||
G4double h = Step * 0.5;
|
||||
|
||||
// Do two half steps
|
||||
AdvanceHelix(yIn, Bfld, h, yTemp);
|
||||
MagFieldEvaluate(yTemp, Bfld_midpoint) ;
|
||||
AdvanceHelix(yTemp, Bfld_midpoint, h, yOut);
|
||||
// Do a full step
|
||||
h = Step ;
|
||||
AdvanceHelix(yIn, Bfld, h, yTemp);
|
||||
// Error estimation
|
||||
for(i=0;i<nvar;i++) {
|
||||
yErr[i] = yOut[i] - yTemp[i] ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
G4HelixMixedStepper::DumbStepper( const G4double yIn[],
|
||||
G4ThreeVector Bfld,
|
||||
G4double h,
|
||||
G4double yOut[])
|
||||
{
|
||||
|
||||
|
||||
AdvanceHelix(yIn, Bfld, h, yOut);
|
||||
|
||||
|
||||
|
||||
}
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
G4double G4HelixMixedStepper::DistChord() const
|
||||
{
|
||||
// Implementation : must check whether h/R > 2 pi !!
|
||||
// If( h/R < pi) use G4LineSection::DistLine
|
||||
// Else DistChord=R_helix
|
||||
//
|
||||
G4double distChord;
|
||||
G4double H_helix;
|
||||
H_helix=fLastStepSize;
|
||||
G4double Ang_curve=GetAngCurve();
|
||||
|
||||
if(Ang_curve<pi){
|
||||
|
||||
distChord=0.5*H_helix*std::tan(0.25*Ang_curve);
|
||||
|
||||
}
|
||||
else{
|
||||
distChord=GetRadHelix();
|
||||
}
|
||||
|
||||
return distChord;
|
||||
|
||||
}
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4HelixSimpleRunge.cc,v 1.7 2006/06/29 18:24:08 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// Simple Runge:
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4ImplicitEuler.cc,v 1.9 2006/06/29 18:24:11 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// Implicit Euler:
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4LineCurrentMagField.cc,v 1.6 2006/06/29 18:24:13 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
#include "G4LineCurrentMagField.hh"
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4LineSection.cc,v 1.10 2006/06/29 18:24:16 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4MagErrorStepper.cc,v 1.13 2006/06/29 18:24:18 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4MagHelicalStepper.cc,v 1.17 2007/04/26 06:26:54 tnikitin Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
// $Id: G4MagHelicalStepper.cc,v 1.19 2007/05/18 15:48:42 tnikitin Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
@@ -42,6 +42,7 @@ G4MagHelicalStepper::G4MagHelicalStepper(G4Mag_EqRhs *EqRhs)
|
||||
// position & velocity
|
||||
{
|
||||
fPtrMagEqOfMot = EqRhs;
|
||||
|
||||
}
|
||||
|
||||
G4MagHelicalStepper::~G4MagHelicalStepper()
|
||||
@@ -55,7 +56,7 @@ void
|
||||
G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
|
||||
G4ThreeVector Bfld,
|
||||
G4double h,
|
||||
G4double yHelix[]) const
|
||||
G4double yHelix[])
|
||||
{
|
||||
// const G4int nvar = 6;
|
||||
|
||||
@@ -69,7 +70,9 @@ G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
|
||||
G4double B_d_P; // B_perp;
|
||||
G4double Theta; // , Theta_1;
|
||||
G4double R_1;
|
||||
G4double R_Helix;
|
||||
G4double CosT2, SinT2, CosT, SinT;
|
||||
//G4double CosT, SinT;
|
||||
G4ThreeVector positionMove, endTangent;
|
||||
|
||||
G4double Bmag = Bfld.mag();
|
||||
@@ -78,15 +81,19 @@ G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
|
||||
G4double velocityVal = initVelocity.mag();
|
||||
G4ThreeVector initTangent = (1.0/velocityVal) * initVelocity; // .unit();
|
||||
|
||||
// fCof = fUnitConstant*particleCharge/MomentumXc;
|
||||
G4double particleCharge = fPtrMagEqOfMot->FCof() / (eplus*c_light);
|
||||
G4double fCoefficient = (fUnitConstant / velocityVal) * particleCharge;
|
||||
R_1=GetInverseCurve(velocityVal,Bmag);
|
||||
|
||||
// for too small magnetic fields there is no curvature
|
||||
// (include momentum here) FIXME
|
||||
|
||||
if( Bmag < 1e-12 ) {
|
||||
LinearStep( yIn, h, yHelix );
|
||||
if( (std::fabs(R_1) < 1e-10)||(Bmag<1e-12) ) {
|
||||
LinearStep( yIn, h, yHelix );
|
||||
// Store and/or calculate parameters for chord distance.
|
||||
|
||||
SetAngCurve(1.);
|
||||
SetCurve(h);
|
||||
SetRadHelix(0.);
|
||||
|
||||
} else {
|
||||
// Bnorm = Bfld.unit();
|
||||
Bnorm = (1.0/Bmag)*Bfld;
|
||||
@@ -104,16 +111,8 @@ G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
|
||||
|
||||
// B_v_P = std::sqrt( 1 - B_d_P * B_d_P); // Fraction of P perp to B
|
||||
|
||||
// calculate the radius^-1 of the helix and the stepping angle
|
||||
|
||||
// R_1 = - fPtrMagEqOfMot->FCof() * Bmag; // / B_v_P - but this cancels
|
||||
R_1 = - fCoefficient * Bmag; // / B_v_P - but this cancels
|
||||
|
||||
// again in Theta - so we don't need it.
|
||||
if( std::fabs(R_1) < 1e-10 ) {
|
||||
LinearStep( yIn, h, yHelix );
|
||||
} else {
|
||||
|
||||
// calculate the stepping angle
|
||||
|
||||
Theta = R_1 * h; // * B_v_P;
|
||||
|
||||
// Trigonometrix
|
||||
@@ -152,7 +151,17 @@ G4MagHelicalStepper::AdvanceHelix( const G4double yIn[],
|
||||
yHelix[5] = velocityVal * endTangent.z();
|
||||
|
||||
// Store and/or calculate parameters for chord distance.
|
||||
}
|
||||
|
||||
G4ThreeVector B_x_P_x_B = B_x_P.cross(Bnorm);
|
||||
G4double ptan=B_x_P_x_B.dot(initVelocity);
|
||||
G4double particleCharge = fPtrMagEqOfMot->FCof() / (eplus*c_light);
|
||||
R_Helix =std::abs( ptan/(fUnitConstant * particleCharge*Bmag));
|
||||
|
||||
SetAngCurve(std::abs(Theta));
|
||||
SetCurve(std::abs(R));
|
||||
SetRadHelix(R_Helix);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -176,14 +185,14 @@ G4MagHelicalStepper::Stepper( const G4double yInput[],
|
||||
|
||||
G4double yTemp[7], yIn[7] ;
|
||||
G4ThreeVector Bfld_initial, Bfld_midpoint;
|
||||
|
||||
|
||||
// Saving yInput because yInput and yOut can be aliases for same array
|
||||
|
||||
for(i=0;i<nvar;i++) yIn[i]=yInput[i];
|
||||
|
||||
G4double h = hstep * 0.5;
|
||||
|
||||
MagFieldEvaluate(yIn, Bfld_initial) ;
|
||||
MagFieldEvaluate(yIn, Bfld_initial) ;
|
||||
|
||||
// Do two half steps
|
||||
DumbStepper(yIn, Bfld_initial, h, yTemp);
|
||||
@@ -212,9 +221,9 @@ G4MagHelicalStepper::Stepper( const G4double yInput[],
|
||||
}
|
||||
#endif
|
||||
|
||||
yInitial = G4ThreeVector( yIn[0], yIn[1], yIn[2]);
|
||||
yInitial = G4ThreeVector( yIn[0], yIn[1], yIn[2]);
|
||||
yFinal = G4ThreeVector( yOut[0], yOut[1], yOut[2]);
|
||||
|
||||
|
||||
return ;
|
||||
}
|
||||
|
||||
@@ -222,10 +231,20 @@ G4MagHelicalStepper::Stepper( const G4double yInput[],
|
||||
G4double
|
||||
G4MagHelicalStepper::DistChord() const
|
||||
{
|
||||
// Soon: must check whether h/R > 2 pi !!
|
||||
// Method below is good only for < 2 pi
|
||||
// Check whether h/R > pi !!
|
||||
// Method DistLine is good only for < pi
|
||||
|
||||
return G4LineSection::Distline( yMidPoint, yInitial, yFinal );
|
||||
// This is a class method that gives distance of Mid
|
||||
// from the Chord between the Initial and Final points.
|
||||
G4double Ang=GetAngCurve();
|
||||
|
||||
if(Ang<pi){
|
||||
return G4LineSection::Distline( yMidPoint, yInitial, yFinal );
|
||||
// This is a class method that gives distance of Mid
|
||||
// from the Chord between the Initial and Final points.
|
||||
|
||||
}
|
||||
else{
|
||||
|
||||
return GetRadHelix();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4MagIntegratorDriver.cc,v 1.46 2007/05/10 10:10:31 japost Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
// $Id: G4MagIntegratorDriver.cc,v 1.48 2007/06/04 15:30:22 tnikitin Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
@@ -41,7 +41,7 @@
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
#include "globals.hh"
|
||||
#include "geomdefs.hh" // for kCarTolerance
|
||||
#include "G4GeometryTolerance.hh"
|
||||
#include <iomanip>
|
||||
#include "G4MagIntegratorDriver.hh"
|
||||
#include "G4FieldTrack.hh"
|
||||
@@ -154,10 +154,14 @@ G4MagInt_Driver::AccurateAdvance(G4FieldTrack& y_current,
|
||||
|
||||
// Ensure that hstep > 0
|
||||
if( hstep <= 0.0 ) {
|
||||
G4cerr << " Hstep is " << hstep << G4endl;
|
||||
if(hstep==0.0){ G4cerr << " G4MagIntegratorDriver::AccurateAdvance(): Hstep is " << hstep << G4endl;
|
||||
return succeeded;
|
||||
}
|
||||
else{
|
||||
G4Exception("G4MagInt_Driver::AccurateAdvance()",
|
||||
"Requested Integration Step is zero or negative: it must be positive",
|
||||
FatalException, "Requested-Step-not-Positive.");
|
||||
"Requested Integration Step is negative: it must be positive",
|
||||
FatalException, "Requested-Step-is-Negative");
|
||||
}
|
||||
}
|
||||
|
||||
y_current.DumpToArray( ystart );
|
||||
@@ -427,7 +431,7 @@ G4MagInt_Driver::WarnEndPointTooFar (G4double endPointDist,
|
||||
maxRelError_last_printed = maxRelError;
|
||||
|
||||
if( dbg
|
||||
&& (h > kCarTolerance)
|
||||
&& (h > G4GeometryTolerance::GetInstance()->GetSurfaceTolerance())
|
||||
&& ( (dbg>1) || prNewMax || (endPointDist >= h*(1.+eps) ) )
|
||||
){
|
||||
static G4int noWarnings = 0;
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4MagIntegratorStepper.cc,v 1.11 2006/06/29 18:24:34 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4Mag_EqRhs.cc,v 1.11 2006/06/29 18:24:36 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// This is the standard right-hand side for equation of motion
|
||||
// in a pure Magnetic Field .
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4Mag_SpinEqRhs.cc,v 1.12 2006/06/29 18:24:39 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// This is the standard right-hand side for equation of motion.
|
||||
// This version of the right-hand side includes the three components
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4Mag_UsualEqRhs.cc,v 1.12 2006/06/29 18:24:42 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// This is the 'standard' right-hand side for the equation of motion
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4MagneticField.cc,v 1.3 2006/06/29 18:24:44 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// --------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4QuadrupoleMagField.cc,v 1.4 2006/06/29 18:24:46 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// $Id: G4RKG3_Stepper.cc,v 1.12 2007/04/26 12:23:55 tnikitin Exp $
|
||||
// GEANT4 tag $Name: geant4-08-03 $
|
||||
// $Id: G4RKG3_Stepper.cc,v 1.14 2007/05/18 12:44:28 tnikitin Exp $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
|
||||
@@ -36,8 +36,9 @@
|
||||
G4RKG3_Stepper::G4RKG3_Stepper(G4Mag_EqRhs *EqRhs)
|
||||
: G4MagIntegratorStepper(EqRhs,6)
|
||||
{
|
||||
// G4Exception("G4RKG3_Stepper::G4RKG3_Stepper()", "NotImplemented",
|
||||
// FatalException, "Stepper not yet available.");
|
||||
|
||||
fPtrMagEqOfMot=EqRhs;
|
||||
|
||||
}
|
||||
|
||||
G4RKG3_Stepper::~G4RKG3_Stepper()
|
||||
@@ -51,33 +52,27 @@ void G4RKG3_Stepper::Stepper( const G4double yInput[7],
|
||||
G4double yErr[])
|
||||
{
|
||||
G4double B[3];
|
||||
// G4double yderiv[6];
|
||||
// G4double alpha2, beta2;
|
||||
G4int nvar = 6 ;
|
||||
// G4double beTemp2, beta2=0;
|
||||
|
||||
G4int i;
|
||||
G4double by15 = 1. / 15. ; // was 0.066666666 ;
|
||||
|
||||
G4double yTemp[7], dydxTemp[6], yIn[7] ;
|
||||
// Saving yInput because yInput and yOut can be aliases for same array
|
||||
for(i=0;i<nvar;i++) yIn[i]=yInput[i];
|
||||
|
||||
G4double h = Step * 0.5;
|
||||
|
||||
hStep=Step;
|
||||
// Do two half steps
|
||||
|
||||
|
||||
// To obtain B1 ...
|
||||
// GetEquationOfMotion()->GetFieldValue(yIn,B);
|
||||
// G4RKG3_Stepper::StepWithEst(yIn, dydx, Step, yOut,alpha2, beta2, B1, B2 );
|
||||
|
||||
StepNoErr(yIn, dydx,h, yTemp,B) ;
|
||||
// RightHandSide(yTemp,dydxTemp) ;
|
||||
GetEquationOfMotion()->EvaluateRhsGivenB(yTemp,B,dydxTemp) ;
|
||||
StepNoErr(yTemp,dydxTemp,h,yOut,B); // ,beTemp2) ;
|
||||
// beta2 += beTemp2;
|
||||
// beta2 *= 0.5;
|
||||
//Store Bfld for DistChord Calculation
|
||||
for(i=0;i<3;i++)BfldIn[i]=B[i];
|
||||
|
||||
// RightHandSide(yTemp,dydxTemp) ;
|
||||
|
||||
GetEquationOfMotion()->EvaluateRhsGivenB(yTemp,B,dydxTemp) ;
|
||||
StepNoErr(yTemp,dydxTemp,h,yOut,B);
|
||||
|
||||
// Store midpoint, chord calculation
|
||||
|
||||
fyMidPoint = G4ThreeVector( yTemp[0], yTemp[1], yTemp[2]);
|
||||
@@ -92,16 +87,12 @@ void G4RKG3_Stepper::Stepper( const G4double yInput[7],
|
||||
yOut[i] += yErr[i]*by15 ; // Provides 5th order of accuracy
|
||||
}
|
||||
|
||||
// for(i=0;i<ncomp;i++)
|
||||
// {
|
||||
// fyInitial[i] = yIn[i];
|
||||
// fyFinal[i] = yOut[i];
|
||||
// }
|
||||
//Store values for DistChord method
|
||||
|
||||
fyInitial = G4ThreeVector( yIn[0], yIn[1], yIn[2]);
|
||||
fyInitial = G4ThreeVector( yIn[0], yIn[1], yIn[2]);
|
||||
fpInitial = G4ThreeVector( yIn[3], yIn[4], yIn[5]);
|
||||
fyFinal = G4ThreeVector( yOut[0], yOut[1], yOut[2]);
|
||||
// beta2 += beTemp2 ;
|
||||
// beta2 *= 0.5 ;
|
||||
|
||||
// NormaliseTangentVector( yOut ); // Deleted
|
||||
}
|
||||
|
||||
@@ -140,7 +131,7 @@ void G4RKG3_Stepper::StepNoErr(const G4double tIn[7],
|
||||
G4double tOut[7],
|
||||
G4double B[3] ) // const
|
||||
|
||||
{
|
||||
{
|
||||
|
||||
// Copy and edit the routine above, to delete alpha2, beta2, ...
|
||||
G4double K1[7],K2[7],K3[7],K4[7] ;
|
||||
@@ -156,6 +147,7 @@ void G4RKG3_Stepper::StepNoErr(const G4double tIn[7],
|
||||
|
||||
// GetEquationOfMotion()->EvaluateRhsReturnB(tIn,dydx,B1) ;
|
||||
// Correction for momentum not a velocity
|
||||
// Need the protection !!! must be not zero
|
||||
mom=std::sqrt(tIn[3]*tIn[3]+tIn[4]*tIn[4]+tIn[5]*tIn[5]);
|
||||
|
||||
for(i=0;i<3;i++)
|
||||
@@ -201,23 +193,71 @@ void G4RKG3_Stepper::StepNoErr(const G4double tIn[7],
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
G4double G4RKG3_Stepper::DistChord() const
|
||||
{
|
||||
// Soon: must check whether h/R > 2 pi !!
|
||||
// Method below is good only for < 2 pi
|
||||
// Implementation : must check whether h/R > pi !!
|
||||
// If( h/R < pi) use G4LineSection::DistLine
|
||||
// Else use DistChord=R_helix
|
||||
G4double distChord,distLine;
|
||||
|
||||
if (fyInitial != fyFinal) {
|
||||
distLine= G4LineSection::Distline(fyMidPoint,fyInitial,fyFinal );
|
||||
|
||||
distChord = distLine;
|
||||
}else{
|
||||
distChord = (fyMidPoint-fyInitial).mag();
|
||||
}
|
||||
|
||||
|
||||
//Calculation of R_helix and R_curv
|
||||
G4double R_helix;
|
||||
G4double R_curv;
|
||||
G4double H_helix=hStep;
|
||||
G4double Bmag=BfldIn.mag();
|
||||
|
||||
G4ThreeVector initVelocity= fpInitial;
|
||||
G4double velocityVal = initVelocity.mag();
|
||||
G4ThreeVector initTangent = (1.0/velocityVal) * initVelocity; // .unit();
|
||||
|
||||
const G4double fUnitConstant = 0.299792458 * (GeV/(tesla*m));
|
||||
G4double particleCharge = fPtrMagEqOfMot->FCof() / (eplus*c_light);
|
||||
G4double fCoefficient = (fUnitConstant ) * particleCharge;
|
||||
|
||||
// for too small field there is no curvature
|
||||
|
||||
if( Bmag>1e-12 ) {
|
||||
|
||||
// Bnorm = Bfld.unit();
|
||||
G4ThreeVector Bnorm = (1.0/Bmag)*BfldIn;
|
||||
|
||||
// calculate the direction of the force
|
||||
|
||||
G4ThreeVector B_x_P = Bnorm.cross(initTangent);
|
||||
|
||||
// parallel and perp vectors
|
||||
|
||||
G4ThreeVector B_x_P_x_B = B_x_P.cross(Bnorm);
|
||||
G4double ptan=B_x_P_x_B.dot(initVelocity);
|
||||
|
||||
R_helix =std::abs(( 1./fCoefficient)* ptan/Bmag);
|
||||
R_curv=std::abs(( 1./fCoefficient)* velocityVal/Bmag);
|
||||
|
||||
// G4cout<<"Bfld="<<BfldIn<<" Momentum="<<velocityVal<<" DirectionM="<<initTangent<<G4endl;
|
||||
// G4cout<<"R_helix="<<R_helix/mm<<" mm R_curv="<<R_curv/mm<<" BxP="<< B_x_P<<" BxPxP="<<B_x_P_x_B<<G4endl;
|
||||
}
|
||||
else{
|
||||
|
||||
R_helix=0.;
|
||||
R_curv=H_helix;
|
||||
}
|
||||
|
||||
// DistChord Calculation
|
||||
if(std::abs(H_helix/R_curv)<pi){
|
||||
if (fyInitial != fyFinal) {
|
||||
distLine= G4LineSection::Distline(fyMidPoint,fyInitial,fyFinal );
|
||||
distChord = distLine;
|
||||
}else{
|
||||
distChord = (fyMidPoint-fyInitial).mag();
|
||||
}
|
||||
}
|
||||
else{
|
||||
distChord=R_helix;
|
||||
}
|
||||
// G4cout<<"distChord="<<distChord<<" hstep="<<H_helix<<" Helix/R ="<<std::abs(H_helix/R_curv)<<" R_helix="<<R_helix<<G4endl;
|
||||
return distChord;
|
||||
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4SimpleHeum.cc,v 1.8 2006/06/29 18:24:51 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// Simple Heum:
|
||||
// x_1 = x_0 + h *
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4SimpleRunge.cc,v 1.10 2006/06/29 18:24:53 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
// Simple Runge:
|
||||
//
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4UniformElectricField.cc,v 1.12 2006/06/29 18:24:56 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
// $Id: G4UniformMagField.cc,v 1.11 2006/06/29 18:24:58 gunter Exp $
|
||||
// GEANT4 tag $Name: geant4-08-02 $
|
||||
// GEANT4 tag $Name: geant4-09-00 $
|
||||
//
|
||||
//
|
||||
// Class for creation of uniform Magnetic Field
|
||||
|
||||
Reference in New Issue
Block a user