G4ExactHelixStepper.cc

Go to the documentation of this file.
```00001 //
00002 // ********************************************************************
00003 // * License and Disclaimer                                           *
00004 // *                                                                  *
00005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
00006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
00007 // * conditions of the Geant4 Software License,  included in the file *
00009 // * include a list of copyright holders.                             *
00010 // *                                                                  *
00011 // * Neither the authors of this software system, nor their employing *
00012 // * institutes,nor the agencies providing financial support for this *
00013 // * work  make  any representation or  warranty, express or implied, *
00014 // * regarding  this  software system or assume any liability for its *
00016 // * for the full disclaimer and the limitation of liability.         *
00017 // *                                                                  *
00018 // * This  code  implementation is the result of  the  scientific and *
00019 // * technical work of the GEANT4 collaboration.                      *
00020 // * By using,  copying,  modifying or  distributing the software (or *
00021 // * any work based  on the software)  you  agree  to acknowledge its *
00022 // * use  in  resulting  scientific  publications,  and indicate your *
00023 // * acceptance of all terms of the Geant4 Software license.          *
00024 // ********************************************************************
00025 //
00026 //
00027 // \$Id: G4ExactHelixStepper.cc 69786 2013-05-15 09:38:51Z gcosmo \$
00028 //
00029 //  Helix a-la-Explicity Euler: x_1 = x_0 + helix(h)
00030 //   with helix(h) being a helix piece of length h
00031 //   simplest approach for solving linear differential equations.
00032 //  Take the current derivative and add it to the current position.
00033 //
00034 //  As the field is assumed constant, an error is not calculated.
00035 //
00036 //  Author: J. Apostolakis, 28 Jan 2005
00037 //     Implementation adapted from ExplicitEuler of W.Wander
00038 // -------------------------------------------------------------------
00039
00040 #include "G4ExactHelixStepper.hh"
00041 #include "G4PhysicalConstants.hh"
00042 #include "G4ThreeVector.hh"
00043 #include "G4LineSection.hh"
00044
00045 G4ExactHelixStepper::G4ExactHelixStepper(G4Mag_EqRhs *EqRhs)
00046   : G4MagHelicalStepper(EqRhs),
00047     fBfieldValue(DBL_MAX, DBL_MAX, DBL_MAX),
00048     fPtrMagEqOfMot(EqRhs)
00049 {
00050   ;
00051 }
00052
00053 G4ExactHelixStepper::~G4ExactHelixStepper() {}
00054
00055 void
00056 G4ExactHelixStepper::Stepper( const G4double yInput[],
00057                               const G4double*,
00058                                     G4double hstep,
00059                                     G4double yOut[],
00060                                     G4double yErr[]      )
00061 {
00062    const G4int nvar = 6;
00063
00064    G4int i;
00065    G4ThreeVector Bfld_value;
00066
00067    MagFieldEvaluate(yInput, Bfld_value);
00069
00070   // We are assuming a constant field: helix is exact
00071   //
00072   for(i=0;i<nvar;i++)
00073   {
00074     yErr[i] = 0.0 ;
00075   }
00076
00077   fBfieldValue=Bfld_value;
00078 }
00079
00080 void
00081 G4ExactHelixStepper::DumbStepper( const G4double  yIn[],
00082                                         G4ThreeVector   Bfld,
00083                                         G4double  h,
00084                                         G4double  yOut[])
00085 {
00086   // Assuming a constant field: solution is a helix
00087
00089
00090   G4Exception("G4ExactHelixStepper::DumbStepper",
00091               "GeomField0002", FatalException,
00092               "Should not be called. Stepper must do all the work." );
00093 }
00094
00095
00096 // ---------------------------------------------------------------------------
00097
00098 G4double
00099 G4ExactHelixStepper::DistChord() const
00100 {
00101   // Implementation : must check whether h/R >  pi  !!
00102   //   If( h/R <  pi)   DistChord=h/2*std::tan(Ang_curve/4)
00103   //   Else             DistChord=R_helix
00104
00105   G4double distChord;
00106   G4double Ang_curve=GetAngCurve();
00107
00108   if (Ang_curve<=pi)
00109   {
00111   }
00112   else if(Ang_curve<twopi)
00113   {
00115   }
00116   else
00117   {