31#include "blmplacement.h"
32#include "cavitymodel.h"
34#include "coolingchannel.h"
37#include "elementtype.h"
44#include "parameters.h"
45#include "physicsbiasing.h"
50#include "scorermesh.h"
51#include "samplerplacement.h"
56int yyerror(
const char *);
57int yyerror2(
const char *s);
96 explicit Parser(std::string filename);
115 const std::string& name,
116 const std::string& start =
"",
117 const std::string& end =
"");
121 const std::string& start,
122 const std::string& end);
132 void add_sampler(
const std::string& name,
int count,
ElementType type, std::string samplerType, std::list<int>* samplerPartIDListIn =
nullptr);
134 template <
class C,
class Container=FastList<C>>
136 template <
class C,
class Container=FastList<C>>
137 void Add(
bool unique,
const std::string& className);
144 template <
class C,
class Container=FastList<C>>
147 const std::set<std::set<int>>& GetSamplerFilters()
const {
return samplerFilters;}
148 const std::map<int, std::set<int>>& GetSamplerFilterIDToSet()
const {
return samplerFilterIDToSet;}
153 const Element&
find_element(
const std::string& element_name)
const;
159 double property_lookup(
const std::string& element_name,
const std::string& property_name)
const;
165 bool InvalidSymbolName(
const std::string& s, std::string& errorReason);
167 Symtab *
symcreate(
const std::string& s);
169 Symtab *
symlook(
const std::string& s);
172 void Store(
double value);
173 void Store(
const std::string& name);
182 template <
class C,
typename T>
183 void SetValue(std::string property, T value);
186 double GetValue(std::string property);
189 std::list<T>* ArrayToList(Array*);
192 template <
typename T>
196 void Overwrite(
const std::string& objectName);
220 const std::string& samplerType,
221 double samplerRadius=0,
222 int particleSetID = -1);
224 void add_func(std::string name,
double (*func)(
double));
225 void add_var(std::string name,
double value,
int is_reserved = 0);
337 std::map<int, std::set<int>> samplerFilterIDToSet;
338 std::map<std::set<int>,
int> setToSamplerFilterID;
341 template <
class C,
typename T>
344 GetGlobal<C>().set_value(property, value);
350 return GetGlobal<C>().get_value(property);
354 std::list<T>* Parser::ArrayToList(
Array* arrayIn)
360 std::list<T>* result =
new std::list<T>();
361 const auto& doubleData = arrayIn->GetDataList();
362 for (
auto& value : doubleData)
363 {result->push_back((T)value);}
Representation of arrays used in tokens.
RF CavityModel class for parser.
Cooling channel parameters.
Crystal class for parser.
List with Efficient Lookup.
Placement class for laser.
Modulator class for parser.
Colour definition for parser.
void Overwrite(const std::string &objectName)
Overwrite object with current values.
FastList< Atom > atom_list
List of parser defined instances of that object.
void Add()
Insert global object of parser class C in Container class.
Parser()
Default contructor.
std::vector< std::list< Element > * > allocated_lines
double property_lookup(const std::string &element_name, const std::string &property_name) const
access property of Element with element_name
FastList< BLMPlacement > blm_list
List of parser defined instances of that object.
std::vector< std::string > sequences
Names of all defined sequences in the parser with 'line'.
const int MAX_EXPAND_ITERATIONS
maximum number of nested lines
Laser laser
The one instance we fill before appending to a list.
Scorer scorer
The one instance we fill before appending to a list.
void ExtendValue(const std::string &property, T value)
Add value to be extended to object.
std::string current_line
Name of beamline.
void ExtendObject(C &object)
Extend object with maps.
FastList< Crystal > crystal_list
List of parser defined instances of that object.
FastList< Placement > placement_list
List of parser defined instances of that object.
Material material
The one instance we fill before appending to a list.
virtual ~Parser()
Destructor.
Atom atom
The one instance we fill before appending to a list.
Symtab * symlook(const std::string &s)
look up parser symbol
static Parser * Instance()
Access method.
std::map< std::string, FastList< Element > * > expandedSequences
Cached copy of expanded sequences.
FastList< Region > region_list
List of parser defined instances of that object.
FastList< Modulator > modulator_list
List of parser defined instances of that object.
void SetValue(std::string property, T value)
Set value for parser class.
FastList< NewColour > colour_list
List of parser defined instances of that object.
Parameters params
The one instance we fill before appending to a list.
int add_sampler_partIDSet(std::list< int > *samplerPartIDListIn)
FastList< Scorer > scorer_list
List of parser defined instances of that object.
FastList< Tunnel > tunnel_list
List of parser defined instances of that object.
FastList< Element > element_list
List of all encountered elements.
Container & GetList()
Get list for parser class C.
CoolingChannel coolingchannel
The one instance we fill before appending to a list.
void add_sampler(const std::string &name, int count, ElementType type, std::string samplerType, std::list< int > *samplerPartIDListIn=nullptr)
insert a sampler into beamline_list
C & GetGlobal()
Get global object of parser class C.
int copy_element_to_params(const std::string &elementName)
copy properties from Element into params, returns element type as integer, returs _NONE if not found
Crystal crystal
The one instance we fill before appending to a list.
bool TryPrintingObject(const std::string &objectName) const
Options options
General options.
Element & find_element(const std::string &element_name)
find element
FastList< Aperture > aperture_list
List of parser defined instances of that object.
Modulator modulator
The one instance we fill before appending to a list.
FastList< CoolingChannel > coolingchannel_list
List of parser defined instances of that object.
Tunnel tunnel
The one instance we fill before appending to a list.
void expand_line(FastList< Element > &target, const std::string &name, const std::string &start="", const std::string &end="")
FastList< PhysicsBiasing > xsecbias_list
List of parser defined instances of that object.
void write_table(std::string *name, ElementType type, bool isLine=false)
Method that transfers parameters to element properties.
FastList< ScorerMesh > scorermesh_list
List of parser defined instances of that object.
const Element * find_placement_element_safe(const std::string &element_name) const
search placement_element
void PrintElements() const
Print methods.
FastList< Element > placement_elements
std::vector< std::string * > var_list
Variable vector for memory storage.
FastList< Element > beamline_list
Beamline.
void add_element_temp(const std::string &name, int number, bool pushfront, ElementType linetype)
add element to temporary element sequence tmp_list
std::set< std::set< int > > samplerFilters
FastList< SamplerPlacement > samplerplacement_list
List of parser defined instances of that object.
Field field
The one instance we fill before appending to a list.
std::list< Element > tmp_list
Temporary list.
Query query
The one instance we fill before appending to a list.
Aperture aperture
The one instance we fill before appending to a list.
void AddVariable(std::string *name)
Add variable memory to variable list for memory management.
BLMPlacement blm
The one instance we fill before appending to a list.
std::map< std::string, std::string > extendedStrings
Map for options of type string for extending objects.
Region region
The one instance we fill before appending to a list.
std::string current_end
Name of beamline.
void ParseFile(FILE *f)
Parse the input file and construct beamline_list and options.
bool FindAndExtend(const std::string &objectName)
Laser instance.
SymbolMap symtab_map
Parser symbol map.
void PrintBeamline() const
Print methods.
const FastList< Element > & get_sequence(const std::string &name)
std::map< std::string, Array * > extendedVectors
Map for options of type vector for extending objects.
void set_sampler(const std::string &name, int count, ElementType type, const std::string &samplerType, double samplerRadius=0, int particleSetID=-1)
Set sampler.
double GetValue(std::string property)
Get value for parser class (only for doubles)
Symtab * symcreate(const std::string &s)
create new parser symbol
NewColour colour
The one instance we fill before appending to a list.
ScorerMesh scorermesh
The one instance we fill before appending to a list.
const FastList< Element > & GetBeamline() const
void PrintOptions() const
Print methods.
FastList< Field > field_list
List of parser defined instances of that object.
FastList< CavityModel > cavitymodel_list
List of parser defined instances of that object.
std::map< std::string, double > extendedNumbers
Map for options of type double for extending objects.
Placement placement
The one instance we fill before appending to a list.
std::list< double > tmparray
temporary list for reading of arrays in parser
CavityModel cavitymodel
The one instance we fill before appending to a list.
FastList< Query > query_list
List of parser defined instances of that object.
void Store(double value)
Add value to front of temporary list.
static Parser * instance
Instance.
PhysicsBiasing xsecbias
The one instance we fill before appending to a list.
FastList< Laser > laser_list
List of parser defined instances of that object.
void add_func(std::string name, double(*func)(double))
Add function to parser.
void Initialise()
Initialisation of parser functions and constants.
FastList< Material > material_list
List of parser defined instances of that object.
std::string current_start
Name of beamline.
const Element * find_element_safe(const std::string &element_name) const
find element by pointer - nullptr if not found - searches element_list
void expand_sequences()
Expand all sequences define with 'line' into FastLists.
std::list< std::string > tmpstring
temporary list for reading of arrays in parser
SamplerPlacement samplerplacement
The one instance we fill before appending to a list.
Physics biasing class for parser.
Placement class for parser.
Query structure class for parser.
Sampler placement class for parser.
ScorerMesh class for parser.
Class that hold the symbol table.
Parser namespace for GMAD language. Combination of Geant4 and MAD.
ElementType
types of elements
Parameters - Element class with booleans.