19#include "BDSArrayReflectionType.hh"
20#include "BDSFieldInfo.hh"
21#include "BDSFieldInfoExtra.hh"
22#include "BDSFieldType.hh"
23#include "BDSIntegratorType.hh"
24#include "BDSInterpolatorType.hh"
25#include "BDSMagnetStrength.hh"
26#include "BDSModulatorInfo.hh"
27#include "BDSUtilities.hh"
30#include "G4RotationMatrix.hh"
31#include "G4ThreeVector.hh"
33#include "G4Transform3D.hh"
34#include "G4UserLimits.hh"
45 magnetStrength(nullptr),
46 provideGlobalTransform(false),
48 magneticFieldFilePath(
""),
51 magneticArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
52 electricFieldFilePath(
""),
55 electricArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
56 cacheTransforms(true),
66 secondFieldOnLeft(false),
67 magneticSubFieldName(
""),
68 electricSubFieldName(
""),
69 usePlacementWorldTransform(false),
70 modulatorInfo(nullptr),
71 ignoreUpdateOfMaximumStepSize(false),
73 transformBeamline(nullptr),
75 nameOfParserDefinition(
"")
82 G4bool provideGlobalTransformIn,
83 const G4Transform3D& transformIn,
84 const G4String& magneticFieldFilePathIn,
87 const G4String& electricFieldFilePathIn,
90 G4bool cacheTransformsIn,
93 G4double timeOffsetIn,
95 G4UserLimits* stepLimitIn,
96 G4double poleTipRadiusIn,
97 G4double beamPipeRadiusIn,
99 const G4String& magneticSubFieldNameIn,
100 const G4String& electricSubFieldNameIn):
101 fieldType(fieldTypeIn),
103 integratorType(integratorTypeIn),
104 magnetStrength(magnetStrengthIn),
105 provideGlobalTransform(provideGlobalTransformIn),
107 magneticFieldFilePath(magneticFieldFilePathIn),
108 magneticFieldFormat(magneticFieldFormatIn),
109 magneticInterpolatorType(magneticInterpolatorTypeIn),
110 magneticArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
111 electricFieldFilePath(electricFieldFilePathIn),
112 electricFieldFormat(electricFieldFormatIn),
113 electricInterpolatorType(electricInterpolatorTypeIn),
114 electricArrayReflectionTypeSet(BDSArrayReflectionTypeSet()),
115 cacheTransforms(cacheTransformsIn),
116 eScaling(eScalingIn),
117 bScaling(bScalingIn),
118 timeOffset(timeOffsetIn),
119 autoScale(autoScaleIn),
120 stepLimit(stepLimitIn),
121 poleTipRadius(poleTipRadiusIn),
122 beamPipeRadius(beamPipeRadiusIn),
123 chordStepMinimum(-1),
124 secondFieldOnLeft(leftIn),
125 magneticSubFieldName(magneticSubFieldNameIn),
126 electricSubFieldName(electricSubFieldNameIn),
127 usePlacementWorldTransform(false),
128 modulatorInfo(nullptr),
129 ignoreUpdateOfMaximumStepSize(false),
131 transformBeamline(nullptr),
133 nameOfParserDefinition(
"")
135 if (transformIn != G4Transform3D::Identity)
136 {
transform =
new G4Transform3D(transformIn);}
139 G4ThreeVector unitY(0,1,0);
140 G4ThreeVector unitYR = unitY.transform(transformIn.getRotation());
141 tilt = -(CLHEP::halfpi - unitYR.getPhi());
144BDSFieldInfo::~BDSFieldInfo()
146 delete magnetStrength;
154 fieldType(other.fieldType),
156 integratorType(other.integratorType),
157 provideGlobalTransform(other.provideGlobalTransform),
159 magneticFieldFilePath(other.magneticFieldFilePath),
160 magneticFieldFormat(other.magneticFieldFormat),
161 magneticInterpolatorType(other.magneticInterpolatorType),
162 magneticArrayReflectionTypeSet(other.magneticArrayReflectionTypeSet),
163 electricFieldFilePath(other.electricFieldFilePath),
164 electricFieldFormat(other.electricFieldFormat),
165 electricInterpolatorType(other.electricInterpolatorType),
166 electricArrayReflectionTypeSet(other.electricArrayReflectionTypeSet),
167 cacheTransforms(other.cacheTransforms),
168 eScaling(other.eScaling),
169 bScaling(other.bScaling),
170 timeOffset(other.timeOffset),
171 autoScale(other.autoScale),
172 poleTipRadius(other.poleTipRadius),
173 beamPipeRadius(other.beamPipeRadius),
174 chordStepMinimum(other.chordStepMinimum),
176 secondFieldOnLeft(other.secondFieldOnLeft),
177 magneticSubFieldName(other.magneticSubFieldName),
178 electricSubFieldName(other.electricSubFieldName),
179 usePlacementWorldTransform(other.usePlacementWorldTransform),
180 modulatorInfo(other.modulatorInfo),
181 ignoreUpdateOfMaximumStepSize(other.ignoreUpdateOfMaximumStepSize),
182 isThin(other.isThin),
183 transformBeamline(nullptr),
185 nameOfParserDefinition(other.nameOfParserDefinition)
190 if (other.magnetStrength)
193 {magnetStrength =
nullptr;}
196 {stepLimit =
new G4UserLimits(*other.stepLimit);}
198 {stepLimit =
nullptr;}
204 {extraInfo = other.extraInfo->
Clone();}
211 stepLimit = userLimitsIn;
220 if (stepLimit && (stepLimit !=
defaultUL))
222 G4UserLimits* old = stepLimit;
224 if (stepLimit == old)
226 if ((stepLimit != old) && (old !=
defaultUL))
230 {stepLimit =
new G4UserLimits(maximumStepSize);}
234 G4cout <<
"Reducing maximum step size of field definition \"" << nameOfParserDefinition
235 <<
"\" to " << maximumStepSize <<
" mm " << G4endl;
241 out <<
"Parser definition name: \"" << info.nameOfParserDefinition <<
"\"" << G4endl;
242 out <<
"Field type: " << info.fieldType << G4endl;
243 out <<
"Rigidity: " << info.brho << G4endl;
244 out <<
"Integrator: " << info.integratorType << G4endl;
245 out <<
"Global transform? " << info.provideGlobalTransform << G4endl;
246 out <<
"B map file: " << info.magneticFieldFilePath << G4endl;
247 out <<
"B map file format: " << info.magneticFieldFormat << G4endl;
248 out <<
"B interpolator " << info.magneticInterpolatorType << G4endl;
249 out <<
"B array reflection: " << info.magneticArrayReflectionTypeSet << G4endl;
250 out <<
"E map file: " << info.electricFieldFilePath << G4endl;
251 out <<
"E map file format: " << info.electricFieldFormat << G4endl;
252 out <<
"E interpolator " << info.electricInterpolatorType << G4endl;
253 out <<
"E array reflection: " << info.electricArrayReflectionTypeSet << G4endl;
254 out <<
"Transform caching: " << info.cacheTransforms << G4endl;
255 out <<
"E Scaling: " << info.eScaling << G4endl;
256 out <<
"B Scaling: " << info.bScaling << G4endl;
257 out <<
"t offset " << info.timeOffset << G4endl;
258 out <<
"Auto scale " << info.autoScale << G4endl;
261 out <<
"Chord Step Min: " << info.chordStepMinimum << G4endl;
262 out <<
"Tilt: " << info.
tilt << G4endl;
264 out <<
"Magnetic sub field " << info.magneticSubFieldName << G4endl;
265 out <<
"Electric sub field " << info.electricSubFieldName << G4endl;
266 if (info.modulatorInfo)
267 {out <<
"Modulator " << *(info.modulatorInfo) << G4endl;}
268 out <<
"Use placement world transform " << info.usePlacementWorldTransform << G4endl;
270 if (info.magnetStrength)
271 {out <<
"Magnet strength: " << *(info.magnetStrength) << G4endl;}
274 G4Track t = G4Track();
275 G4double maxStep = info.stepLimit->GetMaxAllowedStep(t);
276 out <<
"Step limit: " << maxStep << G4endl;
278 out <<
"extra info " << (info.extraInfo ?
"present" :
"not present") << G4endl;
286 G4RotationMatrix rm =
transform->getRotation();
287 G4ThreeVector translation =
transform->getTranslation();
288 translation += translationIn;
289 G4Transform3D* newTransform =
new G4Transform3D(rm, translation);
294G4double BDSFieldInfo::SynchronousT()
const
299 {
return (*magnetStrength)[
"synchronousT0"];}
320 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.
G4bool ignoreUpdateOfMaximumStepSize
To be used when enforcing a larger maximum step size value.
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 SetFieldAsThin()
Set thin to allow geant tracking error controls to be set seperately for thin elements.
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)