31#include "blmplacement.h"
32#include "cavitymodel.h"
36#include "elementtype.h"
42#include "parameters.h"
43#include "physicsbiasing.h"
48#include "scorermesh.h"
49#include "samplerplacement.h"
54int yyerror(
const char *);
55int yyerror2(
const char *s);
93 explicit Parser(std::string filename);
111 const std::string& name,
112 const std::string& start =
"",
113 const std::string& end =
"");
117 const std::string& start,
118 const std::string& end);
128 void add_sampler(
const std::string& name,
int count,
ElementType type, std::string samplerType, std::list<int>* samplerPartIDListIn =
nullptr);
130 template <
class C,
class Container=FastList<C>>
132 template <
class C,
class Container=FastList<C>>
133 void Add(
bool unique,
const std::string& className);
138 template <
class C,
class Container=FastList<C>>
141 const std::set<std::set<int>>& GetSamplerFilters()
const {
return samplerFilters;}
142 const std::map<int, std::set<int>>& GetSamplerFilterIDToSet()
const {
return samplerFilterIDToSet;}
147 const Element&
find_element(
const std::string& element_name)
const;
153 double property_lookup(
const std::string& element_name,
const std::string& property_name)
const;
159 bool InvalidSymbolName(
const std::string& s, std::string& errorReason);
161 Symtab *
symcreate(
const std::string& s);
163 Symtab *
symlook(
const std::string& s);
166 void Store(
double value);
167 void Store(
const std::string& name);
176 template <
class C,
typename T>
177 void SetValue(std::string property, T value);
180 double GetValue(std::string property);
183 std::list<T>* ArrayToList(Array*);
186 template <
typename T>
190 void Overwrite(
const std::string& objectName);
214 const std::string& samplerType,
215 double samplerRadius=0,
216 int particleSetID = -1);
218 void add_func(std::string name,
double (*func)(
double));
219 void add_var(std::string name,
double value,
int is_reserved = 0);
326 std::map<int, std::set<int>> samplerFilterIDToSet;
327 std::map<std::set<int>,
int> setToSamplerFilterID;
330 template <
class C,
typename T>
333 GetGlobal<C>().set_value(property, value);
339 return GetGlobal<C>().get_value(property);
343 std::list<T>* Parser::ArrayToList(
Array* arrayIn)
349 std::list<T>* result =
new std::list<T>();
350 const auto& doubleData = arrayIn->GetDataList();
351 for (
auto& value : doubleData)
352 {result->push_back((T)value);}
Representation of arrays used in tokens.
RF CavityModel class for parser.
Crystal class for parser.
List with Efficient Lookup.
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.
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
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.
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.
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)
Find object by name in list.
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.
Parser()=delete
No default constructor.
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.
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.