Geant4 11.4.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4TQuadrupoleMagField.hh
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// G4TMagFieldEquation
27//
28// Class description:
29//
30// Templated version of motion of quadrupole magnetic field.
31// Enables testing of inlined code for field, equation, stepper, driver,
32// avoiding all virtual calls.
33// Adapted from G4QuadrupoleMagField.
34
35// Author: Josh Xie (CERN, Google Summer of Code 2014), June 2014
36// Supervisors: Sandro Wenzel, John Apostolakis (CERN)
37// --------------------------------------------------------------------
38#ifndef G4T_QUADRUPOLE_MAGFIELD_HH
39#define G4T_QUADRUPOLE_MAGFIELD_HH
40
41#include "G4ThreeVector.hh"
42#include "G4RotationMatrix.hh"
43#include "G4MagneticField.hh"
44
45/**
46 * @brief G4TQuadrupoleMagField is a templated version of G4QuadrupoleMagField.
47 */
48
50{
51 public:
52
54 {
55 fGradient = pGradient ;
56 fOrigin = G4ThreeVector( 0.0, 0.0, 0.0) ;
57 fpMatrix = &IdentityMatrix;
58 }
59
61 G4ThreeVector pOrigin,
62 G4RotationMatrix* pMatrix)
63 {
64 fGradient = pGradient ;
65 fOrigin = pOrigin ;
66 fpMatrix = pMatrix ;
67 }
68
69 virtual ~G4TQuadrupoleMagField() = default;
70
71 inline void GetFieldValue(const G4double y[7],
72 G4double B[3] ) const
73 {
75 y[0] - fOrigin.x(),
76 y[1] - fOrigin.y(),
77 y[2] - fOrigin.z());
78
80 fpMatrix->colX() * r_global,
81 fpMatrix->colY() * r_global,
82 fpMatrix->colZ() * r_global);
83
85 fGradient * r_local.y(),
86 fGradient * r_local.x(),
87 0);
88
90 fpMatrix->inverse().rowX() * B_local,
91 fpMatrix->inverse().rowY() * B_local,
92 fpMatrix->inverse().rowZ() * B_local);
93
94 B[0] = B_global.x() ;
95 B[1] = B_global.y() ;
96 B[2] = B_global.z() ;
97 }
98
100 {
101 //TODO: Can the fpMatrix be shared??
102 return new G4TQuadrupoleMagField(this->fGradient,
103 this->fOrigin,
104 this->fpMatrix);
105 }
106
107 private:
108
109 static G4RotationMatrix IdentityMatrix;
110
111 G4double fGradient;
112 G4ThreeVector fOrigin;
113 G4RotationMatrix* fpMatrix;
114};
115
116#endif
117
G4double B(G4double temperature)
CLHEP::HepRotation G4RotationMatrix
CLHEP::Hep3Vector G4ThreeVector
double G4double
Definition G4Types.hh:83
double z() const
double x() const
double y() const
G4TQuadrupoleMagField * Clone() const
G4TQuadrupoleMagField(G4double pGradient, G4ThreeVector pOrigin, G4RotationMatrix *pMatrix)
G4TQuadrupoleMagField(G4double pGradient)
virtual ~G4TQuadrupoleMagField()=default
void GetFieldValue(const G4double y[7], G4double B[3]) const