BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSFieldMagSkew.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSFieldMagSkew.hh"
19
20#include "globals.hh"
21#include "G4RotationMatrix.hh"
22
24 G4double angle):
25 field(fieldIn)
26{
27 rotation = new G4RotationMatrix();
28 antiRotation = new G4RotationMatrix();
29 rotation->rotateZ(angle);
30 antiRotation->rotateZ(-angle);
31
33}
34
35BDSFieldMagSkew::~BDSFieldMagSkew()
36{
37 delete rotation;
38 delete antiRotation;
39}
40
41G4ThreeVector BDSFieldMagSkew::GetField(const G4ThreeVector &position,
42 const G4double t) const
43{
44 G4ThreeVector rotatedPosition(position);
45 rotatedPosition = rotatedPosition.transform(*rotation);
46 G4ThreeVector normalField = field->GetField(rotatedPosition, t);
47 return (*antiRotation)*normalField;
48}
G4RotationMatrix * rotation
The rotation matrix used to rotate the coordinates.
G4RotationMatrix * antiRotation
The opposite rotation matrix used to transform the resultant field vector.
BDSFieldMagSkew()=delete
Private default constructor to force use of supplied ones.
BDSFieldMag *const field
virtual G4ThreeVector GetField(const G4ThreeVector &position, const G4double t=0) const
Get the field - local coordinates, and rotated.
Interface for static magnetic fields that may or may not be local.
G4bool FiniteStrength() const
Accessor.
virtual G4ThreeVector GetField(const G4ThreeVector &position, const G4double t=0) const =0
G4bool finiteStrength
Flag to cache whether finite nor not.