BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSFieldMagMultipoleOuterDualOld.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 "BDSFieldMagMultipoleOuterDualOld.hh"
19#include "BDSFieldMagMultipoleOuterOld.hh"
20
21#include "G4ThreeVector.hh"
22
23BDSFieldMagMultipoleOuterDualOld::BDSFieldMagMultipoleOuterDualOld(G4int orderIn,
24 G4double poleTipRadiusIn,
25 const BDSFieldMag* innerFieldIn,
26 G4bool kPositive,
27 G4double separation,
28 G4bool secondFieldOnLeft,
29 G4double arbitraryScaling):
30 fieldBase(nullptr)
31{
32 fieldBase = new BDSFieldMagMultipoleOuterOld(orderIn, poleTipRadiusIn, innerFieldIn, kPositive, arbitraryScaling);
33 G4double offsetX = secondFieldOnLeft ? -separation : separation;
34 offset = G4ThreeVector(offsetX,0,0);
35}
36
37BDSFieldMagMultipoleOuterDualOld::~BDSFieldMagMultipoleOuterDualOld()
38{
39 delete fieldBase;
40}
41
42G4ThreeVector BDSFieldMagMultipoleOuterDualOld::GetField(const G4ThreeVector& position,
43 const G4double t) const
44{
45 G4ThreeVector aSide = fieldBase->GetField(position, t);
46 G4ThreeVector shiftedPos = position + offset;
47 G4ThreeVector bSide = fieldBase->GetField(shiftedPos,t);
48 bSide *= -1.0; // opposite to whatever 'a' side is
49 G4ThreeVector result = aSide + bSide;
50 return result;
51}
virtual G4ThreeVector GetField(const G4ThreeVector &position, const double t=0) const
Access the field value.
A simple paramaterisation of N-Pole outer yoke magnetic field.
virtual G4ThreeVector GetField(const G4ThreeVector &position, const double t=0) const
Access the field value.
Interface for static magnetic fields that may or may not be local.