19#include "elementtype.h"
20#include "parameters.h"
34 void print(
const std::list<Element>& l,
int ident=0)
86 publish(
"fieldModulator", &Element::fieldModulator);
136 publish(
"magnetGeometryType", &Element::magnetGeometryType);
137 publish(
"horizontalWidth", &Element::horizontalWidth);
138 publish(
"outerDiameter", &Element::horizontalWidth);
140 publish(
"yokeOnInside", &Element::yokeOnInside);
146 publish(
"xsize", &Element::xsize);
148 publish(
"xsizeOut", &Element::xsizeOut);
150 publish(
"xsizeLeft", &Element::xsizeLeft);
154 publish(
"jawTiltLeft", &Element::jawTiltLeft);
158 publish(
"xsize2", &Element::xsize2);
160 publish(
"offsetX2", &Element::offsetX2);
170 publish(
"screenXSize", &Element::screenXSize);
200 publish(
"theta", &Element::theta);
202 publish(
"axisX", &Element::axisX);
203 publish(
"axisY", &Element::axisY);
204 publish(
"axisZ", &Element::axisZ);
205 publish(
"axisAngle", &Element::axisAngle);
227 publish(
"wireLength", &Element::wireLength);
228 publish(
"wireOffsetX", &Element::wireOffsetX);
229 publish(
"wireOffsetY", &Element::wireOffsetY);
230 publish(
"wireOffsetZ", &Element::wireOffsetZ);
231 publish(
"wireAngle", &Element::wireAngle);
277 publish(
"material", &Element::material);
278 publish(
"outerMaterial", &Element::material);
281 publish(
"markAsCollimator", &Element::markAsCollimator);
291 publish(
"crystalLeft", &Element::crystalLeft);
292 publish(
"crystalRight", &Element::crystalRight);
293 publish(
"crystalBoth", &Element::crystalBoth);
294 publish(
"crystalAngleYAxisLeft" , &Element::crystalAngleYAxisLeft);
295 publish(
"crystalAngleYAxisRight", &Element::crystalAngleYAxisRight);
299 attribute_map_list_double[
"knl"] = &
knl;
300 attribute_map_list_double[
"ksl"] = &
ksl;
320 return (
type == ElementType::_TRANSFORM3D ||
321 type == ElementType::_MARKER ||
322 type == ElementType::_LINE ||
323 type == ElementType::_REV_LINE);
328 for(
int i=0;i<ident;i++)
331 std::cout << name <<
" : " <<
type << std::endl;
333 {std::cout <<
"l = " <<
l <<
"m" << std::endl;}
334 if (horizontalWidth > 0)
335 {std::cout <<
"horizontalWidth = " << horizontalWidth <<
"m" << std::endl;}
338 std::cout <<
"samplerType = " <<
samplerType <<
"\n"
345 case ElementType::_SBEND:
346 case ElementType::_RBEND:
348 std::cout <<
"B = " <<
B << std::endl
349 <<
"angle = " <<
angle << std::endl
350 <<
"k1 = " <<
k1 << std::endl;
353 case ElementType::_QUAD:
354 {std::cout <<
"k1 = " <<
k1 << std::endl;
break;}
355 case ElementType::_SEXTUPOLE:
356 {std::cout <<
"k2 = " <<
k2 << std::endl;
break;}
357 case ElementType::_OCTUPOLE:
358 {std::cout <<
"k3 = " <<
k3 << std::endl;
break;}
359 case ElementType::_DECAPOLE:
360 {std::cout <<
"k4 = " <<
k4 << std::endl;
break;}
361 case ElementType::_SOLENOID:
362 {std::cout <<
"ks = " <<
ks << std::endl;
break;}
363 case ElementType::_MULT:
364 case ElementType::_THINMULT:
366 std::cout <<
" , knl={";
367 for (
auto value :
knl)
368 {std::cout << value <<
", ";}
369 std::cout <<
"}, ksl={";
370 for (
auto value :
ksl)
371 {std::cout << value <<
", ";}
372 std::cout <<
"}" << std::endl;
375 case ElementType::_ECOL:
376 case ElementType::_RCOL:
377 case ElementType::_BMCOL:
378 case ElementType::_JCOL:
379 case ElementType::_JCOLTIP:
381 std::cout <<
"x half aperture = " << xsize <<
" m" << std::endl
382 <<
"y half aperture = " <<
ysize <<
" m" << std::endl
383 <<
"material = \"" << material <<
"\"" << std::endl;
386 case ElementType::_ELEMENT:
388 std::cout <<
"horizontalWidth: " << horizontalWidth <<
"m" << std::endl
390 <<
"fieldAll: " <<
fieldAll << std::endl;
393 case ElementType::_RF:
394 case ElementType::_RFX:
395 case ElementType::_RFY:
397 std::cout <<
"E (voltage): " <<
E <<
" V" << std::endl
398 <<
"gradient (e field): " <<
gradient <<
" V/m" << std::endl
401 <<
"frequency: " <<
frequency <<
" Hz" << std::endl
402 <<
"phase: " <<
phase <<
" rad" << std::endl;
405 case ElementType::_CT:
407 std::cout <<
"dicomDataPath: " <<
dicomDataPath << std::endl;
408 std::cout <<
"dicomDataFile: " <<
dicomDataFile << std::endl;
411 case ElementType::_AWAKESCREEN:
413 std::cout <<
"twindow = " <<
twindow*1e6 <<
" um" << std::endl
414 <<
"tscint = " <<
tscint*1e6 <<
" um" << std::endl
420 case ElementType::_AWAKESPECTROMETER:
422 std::cout <<
"twindow = " <<
twindow*1e6 <<
" um" << std::endl
423 <<
"tscint = " <<
tscint*1e6 <<
" um" << std::endl
424 <<
"screenPSize = " <<
screenPSize*1e6 <<
" um" << std::endl
427 <<
"tmount = " <<
tmount*1e6 <<
" um" << std::endl
432 case ElementType::_LASERWIREOLD:
434 std::cout <<
"lambda= " <<
wavelength <<
"m" << std::endl
435 <<
"xSigma= " << xsize <<
"m" << std::endl
436 <<
"ySigma= " <<
ysize <<
"m" << std::endl
437 <<
"xdir= " <<
xdir << std::endl
438 <<
"ydir= " <<
ydir << std::endl
439 <<
"zdir= " <<
zdir << std::endl;
442 case ElementType::_SCREEN:
444 std::cout <<
"angle= " <<
angle <<
"rad" << std::endl;
447 case ElementType::_TRANSFORM3D:
449 std::cout <<
"xdir= " <<
xdir <<
"m" << std::endl
450 <<
"ydir= " <<
ydir <<
"m" << std::endl
451 <<
"zdir= " <<
zdir <<
"m" << std::endl
452 <<
"phi= " << phi <<
"rad" << std::endl
453 <<
"theta= " << theta <<
"rad" << std::endl
454 <<
"psi= " <<
psi <<
"rad" << std::endl;
457 case ElementType::_GABORLENS:
459 std::cout <<
"b= " <<
B <<
"T" << std::endl
460 <<
"kg= " <<
kg << std::endl;
469 case ElementType::_RBEND:
470 case ElementType::_SBEND:
471 case ElementType::_QUAD:
472 case ElementType::_SEXTUPOLE:
473 case ElementType::_OCTUPOLE:
474 case ElementType::_DECAPOLE:
475 case ElementType::_SOLENOID:
476 case ElementType::_MULT:
477 case ElementType::_THINMULT:
478 case ElementType::_AWAKESPECTROMETER:
479 case ElementType::_MUONSPOILER:
480 case ElementType::_HKICKER:
481 case ElementType::_VKICKER:
482 case ElementType::_KICKER:
483 case ElementType::_TKICKER:
484 case ElementType::_UNDULATOR:
485 case ElementType::_RF:
486 case ElementType::_RFX:
487 case ElementType::_RFY:
489 std::cout <<
"scaling = " <<
scaling << std::endl;
492 std::cout <<
"fieldModulator = \"" << fieldModulator <<
"\"" << std::endl;
495 case ElementType::_MUONCOOLER:
511 type = ElementType::_NONE;
580 magnetGeometryType =
"";
706 markAsCollimator =
false;
719 crystalAngleYAxisLeft = 0;
720 crystalAngleYAxisRight = 0;
725 scalingFieldOuterSet =
false;
734 {value = get<double>(
this,property_name);}
735 catch (
const std::runtime_error&)
737 std::cerr <<
"element.cc> Error: unknown property \"" << property_name
738 <<
"\" (only works on numerical properties)" << std::endl;
752 if (params.
setMap.at(
"angle"))
754 else if (params.
setMap.at(
"scalingFieldOuter"))
755 {scalingFieldOuterSet =
true;}
760 for (
auto& i : params.
setMap)
764 std::string
property = i.first;
769 catch(
const std::runtime_error&)
771 std::cerr <<
"Error: parser> unknown property \"" <<
property
772 <<
"\" for element " << name << std::endl;
777 if (property ==
"bias")
779 std::stringstream ss(
bias);
788 else if (property ==
"biasMaterial")
794 else if (property ==
"biasVacuum")
800 else if (property ==
"biasMaterialLV")
811 std::string samplerNameIn,
812 double samplerRadiusIn,
816 {std::cout <<
"WARNING: overwriting already defined sampler info for element: " << name << std::endl;}
826 auto search1 = attribute_map_list_int.find(property);
827 if (search1 != attribute_map_list_int.end())
833 auto search2 = attribute_map_list_double.find(property);
834 if (search2 != attribute_map_list_double.end())
840 auto search3 = attribute_map_list_string.find(property);
841 if (search3 != attribute_map_list_string.end()) {
846 std::cerr <<
"Error: parser> unknown element option \"" <<
property <<
"\", or doesn't expect vector type" << std::endl;
850 {std::rethrow_exception(std::current_exception());}
853#if __cplusplus >= 201703L
855 std::list<std::variant<bool, int, double, std::string>> retval;
858 auto search1 = attribute_map_list_int.find(property);
859 if (search1 != attribute_map_list_int.end()) {
860 retval.resize((*search1).second->size());
861 std::copy((*search1).second->begin(),(*search1).second->end(), retval.begin());
865 auto search2 = attribute_map_list_double.find(property);
866 if (search2 != attribute_map_list_double.end()) {
867 retval.resize((*search2).second->size());
868 std::copy((*search2).second->begin(),(*search2).second->end(), retval.begin());
872 auto search3 = attribute_map_list_string.find(property);
873 if (search3 != attribute_map_list_string.end()) {
874 retval.resize((*search3).second->size());
875 std::copy((*search3).second->begin(),(*search3).second->end(), retval.begin());
Representation of arrays used in tokens.
void set_vector(Container< std::string, std::allocator< std::string > > &dst) const
Copy symbols into STL string containers.
std::string current_line
Name of beamline.
static Parser * Instance()
Access method.
void publish(const std::string &name, T C::*mp)
Make pointer to member from class C and type T with accessible with a name.
void set(C *instance, const std::string &name, double value)
Parser namespace for GMAD language. Combination of Geant4 and MAD.
ElementType
types of elements
double property_lookup(std::string property_name) const
double hkick
fractional delta px for hkicker
std::string dicomDataFile
for CT, file for DICOM construction data
std::string spec
Arbitrary specification to pass to beamline builder.
void print(int ident=0) const
print method
std::string biasMaterial
temporary string for bias setting
double twindow
thickness of window
double aper4
beampipe information, new aperture model
double hgap
half distance of pole separation for purposes of fringe fields - 'half gap'
void set(const Parameters ¶ms)
set method from Parameters structure
void PublishMembers()
publish members so these can be looked up from parser
std::string beampipeMaterial
beampipe information, new aperture model
std::string samplerType
element has a sampler of this type (default "none")
double ysize2
size of the beam mask second aperture
double laserOffsetTheta
for laserwire
double rmat33
rmatrix elements, only 4x4
double rmat11
rmatrix elements, only 4x4
double rmat43
rmatrix elements, only 4x4
double laserOffsetPhi
for laserwire
std::list< std::string > layerMaterials
for screen
std::string userParameters
String for passing user parameters through.
double scaling
Overall scaling of field strength.
std::string cavityFieldType
Name for type of field to use in a cavity.
double windowScreenGap
air gap between window and screen
std::string tipMaterial
tip material
double gradient
for rf cavities in V / m
double degraderOffset
for degrader
bool isSpecial() const
check if element is of a special type
double aper2
beampipe information, new aperture model
double anodeLength
for gabor lens
double fintx
fringe field integral at the dipole exit
double kick4
rmatrix elements, only 4x4
std::list< Element > * lst
in case the element is a list itself (line)
double rmat42
rmatrix elements, only 4x4
double aper1
beampipe information, new aperture model
double rmat41
rmatrix elements, only 4x4
double h2
output pole face curvature for bends
std::string outerShape
'rectangular' or 'circular'. used in gascap and bmcol
double laserOffsetY
for laserwire
double awakeMagnetOffsetX
for AWAKE spectrometer
double zdir
for 3d transform and laser
double h1
input pole face curvature for bends
std::string namedVacuumVolumes
For imported geometry - identify vacuum volumes.
std::string biasMaterialLV
temporary string for bias setting
double anodeThickness
for gabor lens
bool stripOuterVolume
For Element. Make it an assembly.
double screenPSize
for AWAKE spectrometer
double xdir
for 3d transform and laser
double rmat34
rmatrix elements, only 4x4
double psi
for 3d transforms
double rmat31
rmatrix elements, only 4x4
double wedgeLength
for degrader
double vhRatio
ratio of vertial to horizontal for some magnets
double rmat22
rmatrix elements, only 4x4
double fintxK2
second fringe field integral at the dipole exit - for TRANSPORT matching
std::string userTypeName
User component element type name.
double offsetY2
offset of the beam mask second aperture
double kick3
rmatrix elements, only 4x4
double rmat24
rmatrix elements, only 4x4
double tOffset
time offset used for phase calculation (ns)
std::list< std::string > biasMaterialList
double fint
fringe field integral at the dipole entrance
double xsizeRight
individual collimator jaw half widths
std::string bias
temporary string for bias setting
double coilWidthFraction
Fraction of available h space the coil will take up.
double rmat44
rmatrix elements, only 4x4
std::string fieldAll
Field for everything.
double electrodeRadius
for gabor lens
double jawTiltRight
jaw collimator jaw tilts (angle in x-z plane)
std::string region
region with range cuts
double wireDiameter
@[ for wirescanner
double tmount
thickness of the screen mount
std::list< double > ksl
skew multipole expansion
int numberWedges
for degrader
double kick1
rmatrix elements, only 4x4
std::list< std::string > biasMaterialLVList
physics biasing list for specific LVs
std::string getPublishedName(const std::string &name) const
returns 'official' member name for property
std::list< double > knl
multipole expansion coefficients
std::string windowmaterial
for AWAKE spectrometer
double e2
output pole face rotation for bends
double phase
phase of rf cavity (rad)
double ysizeOut
collimator aperture or laser spotsize for laser
std::string fieldVacuum
Vacuum field.
bool autoColour
Automagically colour the external geometry.
double angle
bending angle
double electrodeThickness
for gabor lens
int hStyle
-1 = unset; 0 = false (ie c style); 1 = true, use hstyle
std::string geometryFile
For Element. File for external geometry.
std::string vacuumMaterial
beampipe information, new aperture model
double vkick
fractional delta py for vkicker
double laserOffsetZ
for laserwire
double E
voltage for rf cavities in V that will be assumed over length l
double coilHeightFraction
Fraction of availalbe v space the coil will take up.
std::list< int > layerIsSampler
for screen
double laserOffsetX
for laserwire
bool elementLengthIsArcLength
For Element. Treat the length as arc length, if not chord.
double screenEndZ
for AWAKE spectrometer
double ysize
collimator aperture or laser spotsize for laser
std::string coolingDefinition
For muon cooler.
double rmat23
rmatrix elements, only 4x4
std::string colour
Override colour for certain items.
double rmat13
rmatrix elements, only 4x4
double anodeRadius
for gabor lens
double materialThickness
for degrader
double kick
fractional delta p for either h or v kicker
double rmat14
rmatrix elements, only 4x4
double beampipeThickness
beampipe information, new aperture model
std::string dicomDataPath
for CT, file for DICOM construction data
double wavelength
for laser wire and 3d transforms
double minimumKineticEnergy
minimum kinetic energy for user limits - respected on element by element basis
std::string scintmaterial
for AWAKE spectrometer
double ydir
for 3d transform and laser
double undulatorMagnetHeight
for undulator
void setSamplerInfo(std::string samplerType, std::string samplerName, double samplerRadius, int samplerParticleSetIDIn=-1)
set sampler info
double tipThickness
for jaw collimator with tip
std::string cavityModel
Name of geometry model object for rfconstantinz cavities.
void set_value_array(const std::string &property, Array *value, bool bExit=true)
Set method for lists.
double e1
input pole face rotation for bends
std::list< std::variant< bool, int, double, std::string > > get_value_array(const std::string &)
Get method for lists.
std::string fieldOuter
Outer field.
std::string laserBeam
for laserwire
double undulatorPeriod
for undulator
std::string biasVacuum
temporary string for bias setting
double electrodeLength
for gabor lens
std::map< std::string, std::string > alternativeNames
map that translates between alternative parser names for members, could be made static
double tilt2
tilt of the beam mask second aperture
double undulatorGap
for undulator
double poleStartZ
for AWAKE spectrometer
double fintK2
second fringe field integral at the dipole entrance - for TRANSPORT matching
std::string mountmaterial
for AWAKE spectrometer
double aper3
beampipe information, new aperture model
ElementType type
element enum
std::list< std::string > biasVacuumList
physics biasing list for the vacuum
std::list< double > layerThicknesses
for screen
double scalingFieldOuter
Extra arbitrary scaling for outer field - compounded with 'scaling'.
std::string samplerName
name of sampler (default empty)
double degraderHeight
for degrader
double tscint
thickness of scintillating part of screen
double screenWidth
for AWAKE spectrometer
double frequency
frequency for rf cavity in Hz
double kick2
rmatrix elements, only 4x4
double rmat12
rmatrix elements, only 4x4
std::string apertureType
beampipe information, new aperture model
double rmat21
rmatrix elements, only 4x4
double rmat32
rmatrix elements, only 4x4
Parameters - Element class with booleans.
std::map< std::string, bool > setMap
Map that holds booleans for every member of element.