BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSFieldMagMultipoleOuterDual.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 "BDSFieldMagMultipoleOuterDual.hh"
19#include "BDSFieldMagMultipoleOuter.hh"
20
21#include "G4ThreeVector.hh"
22
23BDSFieldMagMultipoleOuterDual::BDSFieldMagMultipoleOuterDual(G4int orderIn,
24 G4double poleTipRadiusIn,
25 const BDSFieldMag* innerFieldIn,
26 G4bool kPositive,
27 G4double brho,
28 G4double separation,
29 G4bool secondFieldOnLeft,
30 G4bool secondFieldInverted,
31 G4double arbitraryScaling):
32 fieldBase(nullptr)
33{
34 fieldBase = new BDSFieldMagMultipoleOuter(orderIn, poleTipRadiusIn, innerFieldIn,
35 kPositive, brho, arbitraryScaling);
36 G4double offsetX = secondFieldOnLeft ? -separation : separation;
37 offset = G4ThreeVector(offsetX,0,0);
38 invertSecondField = secondFieldInverted;
39}
40
41BDSFieldMagMultipoleOuterDual::~BDSFieldMagMultipoleOuterDual()
42{
43 delete fieldBase;
44}
45
46G4ThreeVector BDSFieldMagMultipoleOuterDual::GetField(const G4ThreeVector& position,
47 const G4double t) const
48{
49 G4ThreeVector aSide = fieldBase->GetField(position, t);
50 G4ThreeVector shiftedPos = position + offset;
51 G4ThreeVector bSide = fieldBase->GetField(shiftedPos,t);
52 if (invertSecondField)
53 {
54 bSide *= -1.0; // opposite to whatever 'a' side
55 }
56 G4ThreeVector result = aSide + bSide;
57 return result;
58}
virtual G4ThreeVector GetField(const G4ThreeVector &position, const double t=0) const
Access the field value.
A simple parameterisation 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.