BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSFieldEM.hh
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#ifndef BDSFIELDEM_H
19#define BDSFIELDEM_H
20
21#include "globals.hh" // geant4 types / globals
22#include "G4ElectroMagneticField.hh"
23#include "G4ThreeVector.hh"
24#include "G4Transform3D.hh"
25
26#include <utility>
27
28class BDSModulator;
29
39class BDSFieldEM: public G4ElectroMagneticField
40{
41public:
46 BDSFieldEM();
47 explicit BDSFieldEM(G4Transform3D transformIn);
48 virtual ~BDSFieldEM(){;}
49
52 virtual std::pair<G4ThreeVector,G4ThreeVector> GetField(const G4ThreeVector& position,
53 const G4double t = 0) const = 0;
54
57 virtual G4bool TimeVarying() const {return false;}
58
63 virtual void GetFieldValue(const G4double point[4],
64 G4double* field) const;
65
67 virtual std::pair<G4ThreeVector,G4ThreeVector> GetFieldTransformed(const G4ThreeVector& position,
68 const G4double t) const;
69
75 virtual void SetTransform(const G4Transform3D& transformIn);
76
78 virtual G4bool DoesFieldChangeEnergy() const {return true;}
79
81 void SetModulator(BDSModulator* modulatorIn) {modulator = modulatorIn;}
82
84 inline G4bool FiniteStrength() const {return finiteStrength;}
85
86protected:
88
90 G4Transform3D transform;
91
94
95private:
97 G4Transform3D inverseTransform;
98};
99
100#endif
Interface for BDSIM electro-magnetic fields that may or may not be local.
Definition BDSFieldEM.hh:40
void SetModulator(BDSModulator *modulatorIn)
Set the optional modulator.
Definition BDSFieldEM.hh:81
virtual G4bool TimeVarying() const
Definition BDSFieldEM.hh:57
G4Transform3D inverseTransform
The complimentary transform used to initially rotate the point of query.
Definition BDSFieldEM.hh:97
virtual void SetTransform(const G4Transform3D &transformIn)
Definition BDSFieldEM.cc:87
G4bool transformIsNotIdentity
Cache of whether to use transform at all.
Definition BDSFieldEM.hh:92
virtual std::pair< G4ThreeVector, G4ThreeVector > GetField(const G4ThreeVector &position, const G4double t=0) const =0
G4Transform3D transform
Transform to apply for the field relative to the local coordinates of the geometry.
Definition BDSFieldEM.hh:90
BDSModulator * modulator
Optional modulator;.
Definition BDSFieldEM.hh:93
virtual void GetFieldValue(const G4double point[4], G4double *field) const
Definition BDSFieldEM.cc:75
virtual std::pair< G4ThreeVector, G4ThreeVector > GetFieldTransformed(const G4ThreeVector &position, const G4double t) const
Get the field value after applying transform for local offset.
Definition BDSFieldEM.cc:43
G4bool FiniteStrength() const
Accessor.
Definition BDSFieldEM.hh:84
virtual G4bool DoesFieldChangeEnergy() const
Required overload by Geant4.
Definition BDSFieldEM.hh:78
G4bool finiteStrength
Flag to cache whether finite nor not.
Definition BDSFieldEM.hh:87
Base class for a modulator.