BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSFieldMagDipoleHardEdgeMuonCooler.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 "BDSDebug.hh"
19#include "BDSFieldMagDipoleHardEdgeMuonCooler.hh"
20#include "BDSMagnetStrength.hh"
21#include "BDSUtilities.hh"
22
23#include "globals.hh"
24#include "G4ThreeVector.hh"
25#include "G4Types.hh"
26
27#include "CLHEP/Units/PhysicalConstants.h"
28#include "CLHEP/Units/SystemOfUnits.h"
29
30#include <algorithm>
31#include <cmath>
32
33BDSFieldMagDipoleHardEdgeMuonCooler::BDSFieldMagDipoleHardEdgeMuonCooler(G4double strength,
34 G4double apertureRadius,
35 G4double coilLength
36 ):
37 D(2*apertureRadius),
38 halfLength(0.5*coilLength),
39 B0(strength)
40 {;}
41
42G4ThreeVector BDSFieldMagDipoleHardEdgeMuonCooler::GetField(const G4ThreeVector& position,
43 const G4double /*t*/) const
44{
45 G4double z = position.z();
46 G4double rho = position.perp();
47
48 G4double By = 0;
49
50 if (rho > D*0.5 || std::abs(z) > halfLength)
51 { return G4ThreeVector();}
52 else
53 { By = B0;}
54
55 G4ThreeVector result = G4ThreeVector(0,By,0);
56 return result;
57}
58
59
G4double D
Private default constructor to ensure use of supplied constructor.
virtual G4ThreeVector GetField(const G4ThreeVector &position, const G4double t=0) const
Calculate the field value.