Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-13 09:10:16

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: John 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 G4bool G4MagIntegratorStepper::isQSS() const
0078 {
0079   return fIsQSS;
0080 }
0081 
0082 inline
0083 void G4MagIntegratorStepper::SetIsQSS(G4bool val)
0084 {
0085   fIsQSS = val;
0086 }
0087 
0088 inline
0089 void G4MagIntegratorStepper::SetIntegrationOrder(G4int order)
0090 {
0091   fIntegrationOrder = order;
0092 }
0093 
0094 inline
0095 void G4MagIntegratorStepper::SetFSAL(G4bool flag)
0096 {
0097   fIsFSAL = flag;
0098 }
0099 
0100 inline
0101 G4int G4MagIntegratorStepper::GetNumberOfVariables() const
0102 {
0103   return fNoIntegrationVariables;
0104 }
0105 
0106 
0107 inline
0108 G4int G4MagIntegratorStepper::GetNumberOfStateVariables() const
0109 {
0110   return fNoStateVariables;
0111 }
0112 
0113 inline
0114 void G4MagIntegratorStepper::RightHandSide(const G4double y[],
0115                                                  G4double dydx[]) const
0116 {
0117   fEquation_Rhs->RightHandSide(y, dydx);
0118   ++fNoRHSCalls; // IncrementRHSCalls();
0119 }
0120 
0121 inline
0122 void G4MagIntegratorStepper::RightHandSide(const G4double y[],
0123                                                  G4double dydx[],
0124                                                  G4double field[]) const
0125 {
0126   fEquation_Rhs->EvaluateRhsReturnB(y, dydx, field);
0127   ++fNoRHSCalls;
0128 }
0129 
0130 inline
0131 void G4MagIntegratorStepper::NormaliseTangentVector( G4double vec[6] )
0132 {
0133   G4double drds2 = vec[3]*vec[3]+vec[4]*vec[4]+vec[5]*vec[5];
0134 
0135   if( std::fabs(drds2 - 1.0) > 1.e-14 )
0136   {
0137     G4double normx = 1.0 / std::sqrt(drds2);
0138     for(auto i=3; i<6; ++i) { vec[i] *= normx; }
0139   }
0140 }
0141 
0142 inline
0143 void G4MagIntegratorStepper::NormalisePolarizationVector( G4double vec[12] )
0144 {
0145   G4double drds2 = vec[9]*vec[9]+vec[10]*vec[10]+vec[11]*vec[11];
0146 
0147   if( drds2 > 0. )
0148   {
0149     if( std::fabs(drds2 - 1.0) > 1.e-14 )
0150     {
0151       G4double normx = 1.0 / std::sqrt(drds2);
0152       for(auto i=9; i<12; ++i)  { vec[i] *= normx; }
0153     }
0154   }
0155 }