19#include "BDSArrayReflectionType.hh"
20#include "BDSFieldInfo.hh"
21#include "BDSFieldType.hh"
22#include "BDSIntegratorType.hh"
23#include "BDSInterpolatorType.hh"
24#include "BDSMagnetStrength.hh"
25#include "BDSModulatorInfo.hh"
26#include "BDSUtilities.hh"
29#include "G4RotationMatrix.hh"
30#include "G4ThreeVector.hh"
32#include "G4Transform3D.hh"
33#include "G4UserLimits.hh"
44 magnetStrength(nullptr),
45 provideGlobalTransform(false),
47 magneticFieldFilePath(
""),
50 magneticArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
51 electricFieldFilePath(
""),
54 electricArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
55 cacheTransforms(true),
65 secondFieldOnLeft(false),
66 magneticSubFieldName(
""),
67 electricSubFieldName(
""),
68 usePlacementWorldTransform(false),
69 modulatorInfo(nullptr),
70 transformBeamline(nullptr),
71 nameOfParserDefinition(
"")
78 G4bool provideGlobalTransformIn,
79 const G4Transform3D& transformIn,
80 const G4String& magneticFieldFilePathIn,
83 const G4String& electricFieldFilePathIn,
86 G4bool cacheTransformsIn,
89 G4double timeOffsetIn,
91 G4UserLimits* stepLimitIn,
92 G4double poleTipRadiusIn,
93 G4double beamPipeRadiusIn,
95 const G4String& magneticSubFieldNameIn,
96 const G4String& electricSubFieldNameIn):
97 fieldType(fieldTypeIn),
99 integratorType(integratorTypeIn),
100 magnetStrength(magnetStrengthIn),
101 provideGlobalTransform(provideGlobalTransformIn),
103 magneticFieldFilePath(magneticFieldFilePathIn),
104 magneticFieldFormat(magneticFieldFormatIn),
105 magneticInterpolatorType(magneticInterpolatorTypeIn),
106 magneticArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
107 electricFieldFilePath(electricFieldFilePathIn),
108 electricFieldFormat(electricFieldFormatIn),
109 electricInterpolatorType(electricInterpolatorTypeIn),
110 electricArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
111 cacheTransforms(cacheTransformsIn),
112 eScaling(eScalingIn),
113 bScaling(bScalingIn),
114 timeOffset(timeOffsetIn),
115 autoScale(autoScaleIn),
116 stepLimit(stepLimitIn),
117 poleTipRadius(poleTipRadiusIn),
118 beamPipeRadius(beamPipeRadiusIn),
119 chordStepMinimum(-1),
120 secondFieldOnLeft(leftIn),
121 magneticSubFieldName(magneticSubFieldNameIn),
122 electricSubFieldName(electricSubFieldNameIn),
123 usePlacementWorldTransform(false),
124 modulatorInfo(nullptr),
125 transformBeamline(nullptr),
126 nameOfParserDefinition(
"")
128 if (transformIn != G4Transform3D::Identity)
129 {
transform =
new G4Transform3D(transformIn);}
132 G4ThreeVector unitY(0,1,0);
133 G4ThreeVector unitYR = unitY.transform(transformIn.getRotation());
134 tilt = -(CLHEP::halfpi - unitYR.getPhi());
137BDSFieldInfo::~BDSFieldInfo()
139 delete magnetStrength;
146 fieldType(other.fieldType),
148 integratorType(other.integratorType),
149 provideGlobalTransform(other.provideGlobalTransform),
151 magneticFieldFilePath(other.magneticFieldFilePath),
152 magneticFieldFormat(other.magneticFieldFormat),
153 magneticInterpolatorType(other.magneticInterpolatorType),
154 magneticArrayReflectionTypeSet(other.magneticArrayReflectionTypeSet),
155 electricFieldFilePath(other.electricFieldFilePath),
156 electricFieldFormat(other.electricFieldFormat),
157 electricInterpolatorType(other.electricInterpolatorType),
158 electricArrayReflectionTypeSet(other.electricArrayReflectionTypeSet),
159 cacheTransforms(other.cacheTransforms),
160 eScaling(other.eScaling),
161 bScaling(other.bScaling),
162 timeOffset(other.timeOffset),
163 autoScale(other.autoScale),
164 poleTipRadius(other.poleTipRadius),
165 beamPipeRadius(other.beamPipeRadius),
166 chordStepMinimum(other.chordStepMinimum),
168 secondFieldOnLeft(other.secondFieldOnLeft),
169 magneticSubFieldName(other.magneticSubFieldName),
170 electricSubFieldName(other.electricSubFieldName),
171 usePlacementWorldTransform(other.usePlacementWorldTransform),
172 modulatorInfo(other.modulatorInfo),
173 transformBeamline(nullptr),
174 nameOfParserDefinition(other.nameOfParserDefinition)
179 if (other.magnetStrength)
182 {magnetStrength =
nullptr;}
185 {stepLimit =
new G4UserLimits(*other.stepLimit);}
187 {stepLimit =
nullptr;}
197 stepLimit = userLimitsIn;
203 if (stepLimit && (stepLimit !=
defaultUL))
205 G4UserLimits* old = stepLimit;
207 if (stepLimit == old)
209 if ((stepLimit != old) && (old !=
defaultUL))
213 {stepLimit =
new G4UserLimits(maximumStepSize);}
217 G4cout <<
"Reducing maximum step size of field definition \"" << nameOfParserDefinition
218 <<
"\" to " << maximumStepSize <<
" mm " << G4endl;
224 out <<
"Parser definition name: \"" << info.nameOfParserDefinition <<
"\"" << G4endl;
225 out <<
"Field type: " << info.fieldType << G4endl;
226 out <<
"Rigidity: " << info.brho << G4endl;
227 out <<
"Integrator: " << info.integratorType << G4endl;
228 out <<
"Global transform? " << info.provideGlobalTransform << G4endl;
229 out <<
"B map file: " << info.magneticFieldFilePath << G4endl;
230 out <<
"B map file format: " << info.magneticFieldFormat << G4endl;
231 out <<
"B interpolator " << info.magneticInterpolatorType << G4endl;
232 out <<
"B array reflection: " << info.magneticArrayReflectionTypeSet << G4endl;
233 out <<
"E map file: " << info.electricFieldFilePath << G4endl;
234 out <<
"E map file format: " << info.electricFieldFormat << G4endl;
235 out <<
"E interpolator " << info.electricInterpolatorType << G4endl;
236 out <<
"E array reflection: " << info.electricArrayReflectionTypeSet << G4endl;
237 out <<
"Transform caching: " << info.cacheTransforms << G4endl;
238 out <<
"E Scaling: " << info.eScaling << G4endl;
239 out <<
"B Scaling: " << info.bScaling << G4endl;
240 out <<
"t offset " << info.timeOffset << G4endl;
241 out <<
"Auto scale " << info.autoScale << G4endl;
244 out <<
"Chord Step Min: " << info.chordStepMinimum << G4endl;
245 out <<
"Tilt: " << info.
tilt << G4endl;
247 out <<
"Magnetic Sub Field " << info.magneticSubFieldName << G4endl;
248 out <<
"Electric Sub Field " << info.electricSubFieldName << G4endl;
249 if (info.modulatorInfo)
250 {out <<
"Modulator " << *(info.modulatorInfo) << G4endl;}
251 out <<
"Use Placement World Transform " << info.usePlacementWorldTransform << G4endl;
253 if (info.magnetStrength)
254 {out <<
"Magnet strength: " << *(info.magnetStrength) << G4endl;}
257 G4Track t = G4Track();
258 G4double maxStep = info.stepLimit->GetMaxAllowedStep(t);
259 out <<
"Step limit: " << maxStep << G4endl;
268 G4RotationMatrix rm =
transform->getRotation();
269 G4ThreeVector translation =
transform->getTranslation();
270 translation += translationIn;
271 G4Transform3D* newTransform =
new G4Transform3D(rm, translation);
294 transform =
new G4Transform3D(transformIn);
All info required to build complete field of any type.
G4double beamPipeRadius
Optional radius of beam pipe.
void UpdateUserLimitsLengthMaximumStepSize(G4double maximumStepSize, G4bool warn=false) const
static G4UserLimits * defaultUL
Cache of default user limits.
G4Transform3D * transformBeamline
Transform from curvilinear frame to this field - ie beam line bit only.
G4Transform3D TransformComplete() const
Compound transform of field + beam line transform.
void SetTransformBeamline(const G4Transform3D &transformIn)
Set the beam line transform.
G4double poleTipRadius
Radius at which point the field will be scaled to.
G4double tilt
Cache of tilt of field.
void SetTransform(const G4Transform3D &transformIn)
Set the field definition transform.
G4Transform3D Transform() const
Transform for the field definition only.
G4bool secondFieldOnLeft
Flag for case of two-beam field - if not left, it's right.
void Translate(const G4ThreeVector &translationIn)
G4Transform3D TransformBeamline() const
Transform from the curvilinear coordinates to the beam line component.
void SetUserLimits(G4UserLimits *userLimitsIn)
Delete and replace the user limits which this class owns (only if not default ul).
G4Transform3D * transform
Transform w.r.t. solid field will be attached to.
BDSFieldInfo()
Default constructor for zero field effectively.
Efficient storage of magnet strengths.
G4UserLimits * CreateUserLimits(G4UserLimits *defaultUL, G4double length, G4double fraction=1.6)