Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:58:39

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 // G4MagIntegratorStepper inline methods implementation
0027 //
0028 // Author: J.Apostolakis, CERN - 15.01.1997
0029 // --------------------------------------------------------------------
0030 
0031 inline
0032 G4int G4MagIntegratorStepper::IntegrationOrder()
0033 {
0034   return fIntegrationOrder;
0035 }
0036    
0037 inline
0038 G4EquationOfMotion* G4MagIntegratorStepper::GetEquationOfMotion()
0039 {
0040   return fEquation_Rhs;
0041 } 
0042 
0043 inline
0044 const G4EquationOfMotion* G4MagIntegratorStepper::GetEquationOfMotion() const
0045 {
0046   return fEquation_Rhs;
0047 }
0048 
0049 inline
0050 void G4MagIntegratorStepper::SetEquationOfMotion(G4EquationOfMotion* newEq)
0051 {
0052   if( newEq != nullptr )
0053   {
0054     fEquation_Rhs = newEq;
0055   }
0056 } 
0057 
0058 inline
0059 unsigned long G4MagIntegratorStepper::GetfNoRHSCalls()
0060 {
0061   return fNoRHSCalls;
0062 }
0063 
0064 inline
0065 void G4MagIntegratorStepper::ResetfNORHSCalls()
0066 {
0067   fNoRHSCalls = 0;
0068 }
0069 
0070 inline
0071 G4bool G4MagIntegratorStepper::IsFSAL() const
0072 {
0073   return fIsFSAL;
0074 }
0075 
0076 inline
0077 void G4MagIntegratorStepper::SetIntegrationOrder(G4int order)
0078 {
0079   fIntegrationOrder = order;
0080 }
0081 
0082 inline
0083 void G4MagIntegratorStepper::SetFSAL(G4bool flag)
0084 {
0085   fIsFSAL = flag;
0086 }
0087 
0088 inline
0089 G4int G4MagIntegratorStepper::GetNumberOfVariables() const
0090 {
0091   return fNoIntegrationVariables;
0092 }
0093 
0094 
0095 inline
0096 G4int G4MagIntegratorStepper::GetNumberOfStateVariables() const
0097 {
0098   return fNoStateVariables;
0099 }
0100 
0101 inline
0102 void G4MagIntegratorStepper::RightHandSide(const G4double y[],
0103                                                  G4double dydx[]) const
0104 {
0105   fEquation_Rhs->RightHandSide(y, dydx);
0106   ++fNoRHSCalls; // IncrementRHSCalls();
0107 }
0108 
0109 inline
0110 void G4MagIntegratorStepper::RightHandSide(const G4double y[],
0111                                                  G4double dydx[],
0112                                                  G4double field[]) const
0113 {
0114   fEquation_Rhs->EvaluateRhsReturnB(y, dydx, field);
0115   ++fNoRHSCalls;
0116 }
0117 
0118 inline
0119 void G4MagIntegratorStepper::NormaliseTangentVector( G4double vec[6] )
0120 {
0121   G4double drds2 = vec[3]*vec[3]+vec[4]*vec[4]+vec[5]*vec[5];
0122 
0123   if( std::fabs(drds2 - 1.0) > 1.e-14 )
0124   {
0125     G4double normx = 1.0 / std::sqrt(drds2);
0126     for(auto i=3; i<6; ++i) { vec[i] *= normx; }
0127   }
0128 }
0129 
0130 inline
0131 void G4MagIntegratorStepper::NormalisePolarizationVector( G4double vec[12] )
0132 {
0133   G4double drds2 = vec[9]*vec[9]+vec[10]*vec[10]+vec[11]*vec[11];
0134 
0135   if( drds2 > 0. )
0136   {
0137     if( std::fabs(drds2 - 1.0) > 1.e-14 )
0138     {
0139       G4double normx = 1.0 / std::sqrt(drds2);
0140       for(auto i=9; i<12; ++i)  { vec[i] *= normx; }
0141     }
0142   }
0143 }