Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/Geant4/G4FieldUtils.hh was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 // ********************************************************************
0002 // * License and Disclaimer                                           *
0003 // *                                                                  *
0004 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0005 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0006 // * conditions of the Geant4 Software License,  included in the file *
0007 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0008 // * include a list of copyright holders.                             *
0009 // *                                                                  *
0010 // * Neither the authors of this software system, nor their employing *
0011 // * institutes,nor the agencies providing financial support for this *
0012 // * work  make  any representation or  warranty, express or implied, *
0013 // * regarding  this  software system or assume any liability for its *
0014 // * use.  Please see the license in the file  LICENSE  and URL above *
0015 // * for the full disclaimer and the limitation of liability.         *
0016 // *                                                                  *
0017 // * This  code  implementation is the result of  the  scientific and *
0018 // * technical work of the GEANT4 collaboration.                      *
0019 // * By using,  copying,  modifying or  distributing the software (or *
0020 // * any work based  on the software)  you  agree  to acknowledge its *
0021 // * use  in  resulting  scientific  publications,  and indicate your *
0022 // * acceptance of all terms of the Geant4 Software license.          *
0023 // ********************************************************************
0024 //
0025 // Helper namespace field_utils
0026 //
0027 // Description:
0028 //
0029 //  Simple methods to extract vectors from arrays in conventions of
0030 //  the magnetic field integration.
0031 
0032 // Author: Dmitry Sorokin, Google Summer of Code 2017
0033 // Supervision: John Apostolakis, CERN
0034 // --------------------------------------------------------------------
0035 #ifndef G4FIELD_UTILS_HH
0036 #define G4FIELD_UTILS_HH
0037 
0038 #include "G4FieldTrack.hh"
0039 #include "G4Types.hh"
0040 #include "G4ThreeVector.hh"
0041 
0042 namespace field_utils
0043 {
0044 
0045   using State = G4double[G4FieldTrack::ncompSVEC];
0046 
0047   template <unsigned int N>
0048   using ShortState = G4double[N];
0049    
0050   enum class Value3D
0051   {
0052     Position = 0,
0053     Momentum = 3,
0054     Spin = 9
0055   };
0056 
0057   enum class Value1D
0058   {
0059     KineticEnergy = 6,
0060     LabTime = 7,
0061     ProperTime = 8
0062   };
0063 
0064   template <typename ArrayType>
0065   G4double getValue(const ArrayType& array, Value1D value);
0066 
0067   template <typename ArrayType>
0068   G4double getValue2(const ArrayType& array, Value1D value);
0069 
0070   template <typename ArrayType>
0071   G4double getValue(const ArrayType& array, Value3D value);
0072 
0073   template <typename ArrayType>
0074   G4double getValue2(const ArrayType& array, Value3D value);
0075 
0076   template <typename ArrayType>
0077   G4ThreeVector makeVector(const ArrayType& array, Value3D value);
0078 
0079   G4double absoluteError(
0080     const G4double y[],
0081     const G4double yerr[],
0082     G4double hstep);
0083 
0084   G4double relativeError2(
0085     const G4double y[],
0086     const G4double yerr[],
0087     G4double hstep,
0088     G4double errorTolerance);
0089 
0090   G4double relativeError(
0091     const G4double y[],
0092     const G4double yerr[],
0093     G4double hstep,
0094     G4double errorTolerance);
0095 
0096   template <typename SourceArray, typename TargetArray>
0097   void setValue(const SourceArray& src, Value1D value, TargetArray& trg);
0098 
0099   template <typename SourceArray, typename TargetArray, typename ...TargetArrays>
0100   void setValue(const SourceArray& src, Value1D value,
0101                 TargetArray& trg, TargetArrays&... trgs);
0102 
0103   void copy(G4double dst[], const G4double src[],
0104             std::size_t size = G4FieldTrack::ncompSVEC);
0105 
0106   G4double inverseCurvatureRadius(G4double particleCharge,
0107                                   G4double momentum, G4double BField);
0108 
0109   template <typename T>
0110   T clamp(T value, T lo, T hi);
0111 
0112 } // field_utils
0113 
0114 #include "G4FieldUtils.icc"
0115 
0116 #endif