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 "BDSUtilities.hh"
28#include "G4RotationMatrix.hh"
29#include "G4ThreeVector.hh"
31#include "G4Transform3D.hh"
32#include "G4UserLimits.hh"
43 magnetStrength(nullptr),
44 provideGlobalTransform(false),
46 magneticFieldFilePath(
""),
49 magneticArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
50 electricFieldFilePath(
""),
53 electricArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
54 cacheTransforms(true),
64 secondFieldOnLeft(false),
65 magneticSubFieldName(
""),
66 electricSubFieldName(
""),
67 usePlacementWorldTransform(false),
68 transformBeamline(nullptr),
69 nameOfParserDefinition(
"")
76 G4bool provideGlobalTransformIn,
77 const G4Transform3D& transformIn,
78 const G4String& magneticFieldFilePathIn,
81 const G4String& electricFieldFilePathIn,
84 G4bool cacheTransformsIn,
87 G4double timeOffsetIn,
89 G4UserLimits* stepLimitIn,
90 G4double poleTipRadiusIn,
91 G4double beamPipeRadiusIn,
93 const G4String& magneticSubFieldNameIn,
94 const G4String& electricSubFieldNameIn):
95 fieldType(fieldTypeIn),
97 integratorType(integratorTypeIn),
98 magnetStrength(magnetStrengthIn),
99 provideGlobalTransform(provideGlobalTransformIn),
101 magneticFieldFilePath(magneticFieldFilePathIn),
102 magneticFieldFormat(magneticFieldFormatIn),
103 magneticInterpolatorType(magneticInterpolatorTypeIn),
104 magneticArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
105 electricFieldFilePath(electricFieldFilePathIn),
106 electricFieldFormat(electricFieldFormatIn),
107 electricInterpolatorType(electricInterpolatorTypeIn),
108 electricArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
109 cacheTransforms(cacheTransformsIn),
110 eScaling(eScalingIn),
111 bScaling(bScalingIn),
112 timeOffset(timeOffsetIn),
113 autoScale(autoScaleIn),
114 stepLimit(stepLimitIn),
115 poleTipRadius(poleTipRadiusIn),
116 beamPipeRadius(beamPipeRadiusIn),
117 chordStepMinimum(-1),
118 secondFieldOnLeft(leftIn),
119 magneticSubFieldName(magneticSubFieldNameIn),
120 electricSubFieldName(electricSubFieldNameIn),
121 usePlacementWorldTransform(false),
122 transformBeamline(nullptr),
123 nameOfParserDefinition(
"")
125 if (transformIn != G4Transform3D::Identity)
126 {
transform =
new G4Transform3D(transformIn);}
129 G4ThreeVector unitY(0,1,0);
130 G4ThreeVector unitYR = unitY.transform(transformIn.getRotation());
131 tilt = -(CLHEP::halfpi - unitYR.getPhi());
134BDSFieldInfo::~BDSFieldInfo()
136 delete magnetStrength;
143 fieldType(other.fieldType),
145 integratorType(other.integratorType),
146 provideGlobalTransform(other.provideGlobalTransform),
148 magneticFieldFilePath(other.magneticFieldFilePath),
149 magneticFieldFormat(other.magneticFieldFormat),
150 magneticInterpolatorType(other.magneticInterpolatorType),
151 magneticArrayReflectionTypeSet(other.magneticArrayReflectionTypeSet),
152 electricFieldFilePath(other.electricFieldFilePath),
153 electricFieldFormat(other.electricFieldFormat),
154 electricInterpolatorType(other.electricInterpolatorType),
155 electricArrayReflectionTypeSet(other.electricArrayReflectionTypeSet),
156 cacheTransforms(other.cacheTransforms),
157 eScaling(other.eScaling),
158 bScaling(other.bScaling),
159 timeOffset(other.timeOffset),
160 autoScale(other.autoScale),
161 poleTipRadius(other.poleTipRadius),
162 beamPipeRadius(other.beamPipeRadius),
163 chordStepMinimum(other.chordStepMinimum),
165 secondFieldOnLeft(other.secondFieldOnLeft),
166 magneticSubFieldName(other.magneticSubFieldName),
167 electricSubFieldName(other.electricSubFieldName),
168 usePlacementWorldTransform(other.usePlacementWorldTransform),
169 transformBeamline(nullptr),
170 nameOfParserDefinition(other.nameOfParserDefinition)
175 if (other.magnetStrength)
178 {magnetStrength =
nullptr;}
181 {stepLimit =
new G4UserLimits(*other.stepLimit);}
183 {stepLimit =
nullptr;}
193 stepLimit = userLimitsIn;
199 if (stepLimit && (stepLimit !=
defaultUL))
201 G4UserLimits* old = stepLimit;
203 if (stepLimit == old)
205 if ((stepLimit != old) && (old !=
defaultUL))
209 {stepLimit =
new G4UserLimits(maximumStepSize);}
213 G4cout <<
"Reducing maximum step size of field definition \"" << nameOfParserDefinition
214 <<
"\" to " << maximumStepSize <<
" mm " << G4endl;
220 out <<
"Parser definition name: \"" << info.nameOfParserDefinition <<
"\"" << G4endl;
221 out <<
"Field type: " << info.fieldType << G4endl;
222 out <<
"Rigidity: " << info.brho << G4endl;
223 out <<
"Integrator: " << info.integratorType << G4endl;
224 out <<
"Global transform? " << info.provideGlobalTransform << G4endl;
225 out <<
"B map file: " << info.magneticFieldFilePath << G4endl;
226 out <<
"B map file format: " << info.magneticFieldFormat << G4endl;
227 out <<
"B interpolator " << info.magneticInterpolatorType << G4endl;
228 out <<
"B array reflection: " << info.magneticArrayReflectionTypeSet << G4endl;
229 out <<
"E map file: " << info.electricFieldFilePath << G4endl;
230 out <<
"E map file format: " << info.electricFieldFormat << G4endl;
231 out <<
"E interpolator " << info.electricInterpolatorType << G4endl;
232 out <<
"E array reflection: " << info.electricArrayReflectionTypeSet << G4endl;
233 out <<
"Transform caching: " << info.cacheTransforms << G4endl;
234 out <<
"E Scaling: " << info.eScaling << G4endl;
235 out <<
"B Scaling: " << info.bScaling << G4endl;
236 out <<
"t offset " << info.timeOffset << G4endl;
237 out <<
"Auto scale " << info.autoScale << G4endl;
240 out <<
"Chord Step Min: " << info.chordStepMinimum << G4endl;
241 out <<
"Tilt: " << info.
tilt << G4endl;
243 out <<
"Magnetic Sub Field " << info.magneticSubFieldName << G4endl;
244 out <<
"Electric Sub Field " << info.electricSubFieldName << G4endl;
245 out <<
"Use Placement World Transform " << info.usePlacementWorldTransform << G4endl;
246 if (info.magnetStrength)
247 {out <<
"Magnet strength: " << *(info.magnetStrength) << G4endl;}
250 G4Track t = G4Track();
251 G4double maxStep = info.stepLimit->GetMaxAllowedStep(t);
252 out <<
"Step limit: " << maxStep << G4endl;
261 G4RotationMatrix rm =
transform->getRotation();
262 G4ThreeVector translation =
transform->getTranslation();
263 translation += translationIn;
264 G4Transform3D* newTransform =
new G4Transform3D(rm, translation);
287 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)