30#include "blmplacement.h"
31#include "cavitymodel.h"
33#include "coolingchannel.h"
36#include "elementtype.h"
43#include "parameters.h"
44#include "physicsbiasing.h"
49#include "scorermesh.h"
50#include "samplerplacement.h"
55int yyerror(
const char *);
56int yyerror2(
const char *s);
95 explicit Parser(std::string filename);
116 const std::string& name,
117 const std::string& start =
"",
118 const std::string& end =
"");
122 const std::string& start,
123 const std::string& end);
136 void add_sampler(
const std::string& name,
int count,
ElementType type, std::string samplerType, std::list<int>* samplerPartIDListIn =
nullptr);
138 template <
class C,
class Container=FastList<C>>
140 template <
class C,
class Container=FastList<C>>
141 void Add(
bool unique,
const std::string& className);
148 template <
class C,
class Container=FastList<C>>
151 const std::set<std::set<int>>& GetSamplerFilters()
const {
return samplerFilters;}
152 const std::map<int, std::set<int>>& GetSamplerFilterIDToSet()
const {
return samplerFilterIDToSet;}
157 const Element&
find_element(
const std::string& element_name)
const;
163 double property_lookup(
const std::string& element_name,
const std::string& property_name)
const;
169 bool InvalidSymbolName(
const std::string& s, std::string& errorReason);
171 Symtab *
symcreate(
const std::string& s);
173 Symtab *
symlook(
const std::string& s);
176 void Store(
double value);
177 void Store(
const std::string& name);
186 template <
class C,
typename T>
187 void SetValue(std::string property, T value);
190 double GetValue(std::string property);
193 std::list<T>* ArrayToList(Array*);
196 template <
typename T>
200 void Overwrite(
const std::string& objectName);
220 std::string GetCallSequenceLog();
225 const std::string& samplerType,
226 double samplerRadius=0,
227 int particleSetID = -1);
229 void add_func(std::string name,
double (*func)(
double));
230 void add_var(std::string name,
double value,
int is_reserved = 0);
339 std::map<int, std::set<int>> samplerFilterIDToSet;
340 std::map<std::set<int>,
int> setToSamplerFilterID;
346 template <
class C,
typename T>
349 GetGlobal<C>().set_value(property, value);
355 return GetGlobal<C>().get_value(property);
359 std::list<T>* Parser::ArrayToList(
Array* arrayIn)
365 std::list<T>* result =
new std::list<T>();
366 const auto& doubleData = arrayIn->GetDataList();
367 for (
auto& value : doubleData)
368 {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::string > & get_sequences()
Get names of the available sequences.
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.
std::stringstream * call_sequence_log
execution log to understand call order (not an error or debug log)
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.
const FastList< Element > & get_sequence(const std::string &name, bool bExit=true)
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.
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.