Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // G4HelixExplicitEuler implementation << 23 // >> 24 // $Id: G4HelixExplicitEuler.cc,v 1.5 2003/10/31 14:35:54 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-07-01 $ >> 26 // 27 // 27 // 28 // Helix Explicit Euler: x_1 = x_0 + helix(h) 28 // Helix Explicit Euler: x_1 = x_0 + helix(h) 29 // with helix(h) being a helix piece of lengt << 29 // with helix(h) being a helix piece of length h 30 // Most simple approach for solving linear di << 30 // most simple approach for solving linear differential equations. 31 // Take the current derivative and add it to 31 // Take the current derivative and add it to the current position. 32 // 32 // 33 // Author: W.Wander <wwc@mit.edu>, 12.09.1997 << 33 // W.Wander <wwc@mit.edu> 12/09/97 34 // ------------------------------------------- 34 // ------------------------------------------------------------------- 35 35 36 #include "G4HelixExplicitEuler.hh" 36 #include "G4HelixExplicitEuler.hh" 37 #include "G4PhysicalConstants.hh" << 38 #include "G4ThreeVector.hh" 37 #include "G4ThreeVector.hh" 39 38 40 G4HelixExplicitEuler::G4HelixExplicitEuler(G4M << 39 void 41 : G4MagHelicalStepper(EqRhs) << 40 G4HelixExplicitEuler::DumbStepper( const G4double yIn[], 42 { << 41 G4ThreeVector Bfld, 43 } << 42 G4double h, 44 << 43 G4double yOut[]) 45 G4HelixExplicitEuler::~G4HelixExplicitEuler() << 46 << 47 void G4HelixExplicitEuler::Stepper( const G4do << 48 const G4do << 49 G4do << 50 G4do << 51 G4do << 52 { 44 { 53 // Estimation of the Stepping Angle << 45 AdvanceHelix(yIn, Bfld, h, yOut); 54 // << 55 G4ThreeVector Bfld; << 56 MagFieldEvaluate(yInput, Bfld); << 57 << 58 const G4int nvar = 6 ; << 59 G4double yTemp[8], yIn[8] ; << 60 G4ThreeVector Bfld_midpoint; << 61 << 62 // Saving yInput because yInput and yOut can << 63 // << 64 for(G4int i=0; i<nvar; ++i) << 65 { << 66 yIn[i] = yInput[i]; << 67 } << 68 << 69 G4double h = Step * 0.5; << 70 << 71 // Do full step and two half steps << 72 // << 73 G4double yTemp2[7]; << 74 AdvanceHelix(yIn, Bfld, h, yTemp2,yTemp); << 75 MagFieldEvaluate(yTemp2, Bfld_midpoint) ; << 76 AdvanceHelix(yTemp2, Bfld_midpoint, h, yOut) << 77 SetAngCurve(GetAngCurve() * 2); << 78 << 79 // Error estimation << 80 // << 81 for(G4int i=0; i<nvar; ++i) << 82 { << 83 yErr[i] = yOut[i] - yTemp[i]; << 84 } << 85 } << 86 46 87 G4double G4HelixExplicitEuler::DistChord() c << 47 // NormaliseTangentVector( yOut ); // this could harm more than it helps 88 { << 89 // Implementation : must check whether h/R > << 90 // If( h/R < pi) use G4LineSection::DistL << 91 // Else DistChord=R_helix << 92 // << 93 G4double distChord; << 94 G4double Ang_curve=GetAngCurve(); << 95 << 96 << 97 if(Ang_curve<=pi) << 98 { << 99 distChord=GetRadHelix()*(1-std::cos(0.5*An << 100 } << 101 else if(Ang_curve<twopi) << 102 { << 103 distChord=GetRadHelix()*(1+std::cos(0.5*(t << 104 } << 105 else << 106 { << 107 distChord=2.*GetRadHelix(); << 108 } << 109 << 110 return distChord; << 111 } << 112 << 113 void G4HelixExplicitEuler::DumbStepper( const << 114 << 115 << 116 << 117 { << 118 AdvanceHelix(yIn, Bfld, h, yOut); << 119 } 48 } 120 49