BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Static Private Attributes
GMAD::Parser Class Reference

Parser class. More...

#include <parser.h>

Inheritance diagram for GMAD::Parser:
Inheritance graph

Public Member Functions

virtual ~Parser ()
 Destructor.
 
 Parser ()
 Default contructor.
 
void quit ()
 Exit method.
 
void write_table (std::string *name, ElementType type, bool isLine=false)
 Method that transfers parameters to element properties.
 
void expand_sequences ()
 Expand all sequences define with 'line' into FastLists.
 
void expand_line (FastList< Element > &target, const std::string &name, const std::string &start="", const std::string &end="")
 
void expand_line (const std::string &name, const std::string &start, const std::string &end)
 Expand the main beamline as defined by the use command.
 
std::vector< std::string > & get_sequences ()
 Get names of the available sequences.
 
const FastList< Element > & get_sequence (const std::string &name, bool bExit=true)
 
int add_sampler_partIDSet (std::list< int > *samplerPartIDListIn)
 
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
 
template<class C , class Container = FastList<C>>
void Add ()
 Insert global object of parser class C in Container class.
 
template<class C , class Container = FastList<C>>
void Add (bool unique, const std::string &className)
 
template<class C >
C & GetGlobal ()
 Get global object of parser class C.
 
template<class C >
C * GetGlobalPtr ()
 
template<class C , class Container = FastList<C>>
Container & GetList ()
 Get list for parser class C.
 
const std::set< std::set< int > > & GetSamplerFilters () const
 
const std::map< int, std::set< int > > & GetSamplerFilterIDToSet () const
 
Element & find_element (const std::string &element_name)
 find element
 
const Element & find_element (const std::string &element_name) const
 find element (const)
 
const Element * find_element_safe (const std::string &element_name) const
 find element by pointer - nullptr if not found - searches element_list
 
const Element * find_placement_element_safe (const std::string &element_name) const
 search placement_element
 
double property_lookup (const std::string &element_name, const std::string &property_name) const
 access property of Element with element_name
 
void add_element_temp (const std::string &name, int number, bool pushfront, ElementType linetype)
 add element to temporary element sequence tmp_list
 
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
 
bool InvalidSymbolName (const std::string &s, std::string &errorReason)
 
Symtab * symcreate (const std::string &s)
 create new parser symbol
 
Symtab * symlook (const std::string &s)
 look up parser symbol
 
void ClearParams ()
 
template<class C , typename T >
void SetValue (std::string property, T value)
 Set value for parser class.
 
template<class C >
double GetValue (std::string property)
 Get value for parser class (only for doubles)
 
template<typename T >
std::list< T > * ArrayToList (Array *)
 
template<typename T >
void ExtendValue (const std::string &property, T value)
 Add value to be extended to object.
 
void Overwrite (const std::string &objectName)
 Overwrite object with current values.
 
void AddVariable (std::string *name)
 Add variable memory to variable list for memory management.
 
bool TryPrintingObject (const std::string &objectName) const
 
const FastList< Element > & GetBeamline () const
 
std::string GetCallSequenceLog ()
 
template<>
Aperture & GetGlobal ()
 
template<>
Aperture * GetGlobalPtr ()
 
template<>
FastList< Aperture > & GetList ()
 
template<>
Atom & GetGlobal ()
 
template<>
Atom * GetGlobalPtr ()
 
template<>
FastList< Atom > & GetList ()
 
template<>
Beam & GetGlobal ()
 
template<>
Beam * GetGlobalPtr ()
 
template<>
BLMPlacement & GetGlobal ()
 
template<>
BLMPlacement * GetGlobalPtr ()
 
template<>
FastList< BLMPlacement > & GetList ()
 
template<>
CavityModel & GetGlobal ()
 
template<>
CavityModel * GetGlobalPtr ()
 
template<>
FastList< CavityModel > & GetList ()
 
template<>
CoolingChannel & GetGlobal ()
 
template<>
CoolingChannel * GetGlobalPtr ()
 
template<>
FastList< CoolingChannel > & GetList ()
 
template<>
NewColour & GetGlobal ()
 
template<>
NewColour * GetGlobalPtr ()
 
template<>
FastList< NewColour > & GetList ()
 
template<>
Crystal & GetGlobal ()
 
template<>
Crystal * GetGlobalPtr ()
 
template<>
FastList< Crystal > & GetList ()
 
template<>
Field & GetGlobal ()
 
template<>
Field * GetGlobalPtr ()
 
template<>
FastList< Field > & GetList ()
 
template<>
Laser & GetGlobal ()
 
template<>
Laser * GetGlobalPtr ()
 
template<>
FastList< Laser > & GetList ()
 
template<>
Material & GetGlobal ()
 
template<>
Material * GetGlobalPtr ()
 
template<>
FastList< Material > & GetList ()
 
template<>
Modulator & GetGlobal ()
 
template<>
Modulator * GetGlobalPtr ()
 
template<>
FastList< Modulator > & GetList ()
 
template<>
Options & GetGlobal ()
 
template<>
Options * GetGlobalPtr ()
 
template<>
Parameters & GetGlobal ()
 
template<>
Parameters * GetGlobalPtr ()
 
template<>
Placement & GetGlobal ()
 
template<>
Placement * GetGlobalPtr ()
 
template<>
FastList< Placement > & GetList ()
 
template<>
PhysicsBiasing & GetGlobal ()
 
template<>
PhysicsBiasing * GetGlobalPtr ()
 
template<>
FastList< PhysicsBiasing > & GetList ()
 
template<>
Query & GetGlobal ()
 
template<>
Query * GetGlobalPtr ()
 
template<>
FastList< Query > & GetList ()
 
template<>
Region & GetGlobal ()
 
template<>
Region * GetGlobalPtr ()
 
template<>
FastList< Region > & GetList ()
 
template<>
SamplerPlacement & GetGlobal ()
 
template<>
SamplerPlacement * GetGlobalPtr ()
 
template<>
FastList< SamplerPlacement > & GetList ()
 
template<>
Scorer & GetGlobal ()
 
template<>
Scorer * GetGlobalPtr ()
 
template<>
FastList< Scorer > & GetList ()
 
template<>
ScorerMesh & GetGlobal ()
 
template<>
ScorerMesh * GetGlobalPtr ()
 
template<>
FastList< ScorerMesh > & GetList ()
 
template<>
Tunnel & GetGlobal ()
 
template<>
Tunnel * GetGlobalPtr ()
 
template<>
FastList< Tunnel > & GetList ()
 
template<>
void ExtendValue (const std::string &property, double value)
 
template<>
void ExtendValue (const std::string &property, std::string value)
 
template<>
void ExtendValue (const std::string &property, Array *value)
 
template<>
void Add (bool unique, const std::string &className)
 
void Store (double value)
 Add value to front of temporary list.
 
void Store (const std::string &name)
 Add value to front of temporary list.
 
void FillArray (Array *)
 
void FillString (Array *)
 
void PrintBeamline () const
 Print methods.
 
void PrintElements () const
 Print methods.
 
void PrintOptions () const
 Print methods.
 

Static Public Member Functions

static Parser * Instance (const std::string &filename)
 Constructor method.
 
static Parser * Instance ()
 Access method.
 

Data Fields

std::string current_line
 Name of beamline.
 
std::string current_start
 Name of beamline.
 
std::string current_end
 Name of beamline.
 

Protected Member Functions

 Parser (std::string filename)
 Constructor from filename.
 

Protected Attributes

Beam beam
 Beam instance;.
 
Options options
 General options.
 
FastList< Element > beamline_list
 Beamline.
 
FastList< Atom > atom_list
 List of parser defined instances of that object.
 
FastList< NewColour > colour_list
 List of parser defined instances of that object.
 
FastList< Crystal > crystal_list
 List of parser defined instances of that object.
 
FastList< CoolingChannel > coolingchannel_list
 List of parser defined instances of that object.
 
FastList< Field > field_list
 List of parser defined instances of that object.
 
FastList< Material > material_list
 List of parser defined instances of that object.
 
FastList< Query > query_list
 List of parser defined instances of that object.
 
FastList< Region > region_list
 List of parser defined instances of that object.
 
FastList< Tunnel > tunnel_list
 List of parser defined instances of that object.
 
FastList< PhysicsBiasing > xsecbias_list
 List of parser defined instances of that object.
 
FastList< Placement > placement_list
 List of parser defined instances of that object.
 
FastList< Laser > laser_list
 List of parser defined instances of that object.
 
FastList< CavityModel > cavitymodel_list
 List of parser defined instances of that object.
 
FastList< SamplerPlacement > samplerplacement_list
 List of parser defined instances of that object.
 
FastList< Scorer > scorer_list
 List of parser defined instances of that object.
 
FastList< ScorerMesh > scorermesh_list
 List of parser defined instances of that object.
 
FastList< Aperture > aperture_list
 List of parser defined instances of that object.
 
FastList< BLMPlacement > blm_list
 List of parser defined instances of that object.
 
FastList< Modulator > modulator_list
 List of parser defined instances of that object.
 

Private Member Functions

void Initialise ()
 Initialisation of parser functions and constants.
 
void ParseFile (FILE *f)
 Parse the input file and construct beamline_list and options.
 
void set_sampler (const std::string &name, int count, ElementType type, const std::string &samplerType, double samplerRadius=0, int particleSetID=-1)
 Set sampler.
 
void add_func (std::string name, double(*func)(double))
 Add function to parser.
 
void add_var (std::string name, double value, int is_reserved=0)
 
template<class C >
bool FindAndExtend (const std::string &objectName)
 Laser instance.
 
template<class C >
void ExtendObject (C &object)
 Extend object with maps.
 

Private Attributes

const int MAX_EXPAND_ITERATIONS = 50
 maximum number of nested lines
 
std::vector< std::list< Element > * > allocated_lines
 
std::map< std::string, double > extendedNumbers
 Map for options of type double for extending objects.
 
std::map< std::string, std::string > extendedStrings
 Map for options of type string for extending objects.
 
std::map< std::string, Array * > extendedVectors
 Map for options of type vector for extending objects.
 
FastList< Element > element_list
 List of all encountered elements.
 
FastList< Element > placement_elements
 
std::list< Element > tmp_list
 Temporary list.
 
std::vector< std::string > sequences
 Names of all defined sequences in the parser with 'line'.
 
std::map< std::string, FastList< Element > * > expandedSequences
 Cached copy of expanded sequences.
 
SymbolMap symtab_map
 Parser symbol map.
 
std::vector< std::string * > var_list
 Variable vector for memory storage.
 
std::set< std::set< int > > samplerFilters
 
std::map< int, std::set< int > > samplerFilterIDToSet
 
std::map< std::set< int >, int > setToSamplerFilterID
 
std::stringstream * call_sequence_log = new std::stringstream()
 execution log to understand call order (not an error or debug log)
 
std::list< double > tmparray
 temporary list for reading of arrays in parser
 
std::list< std::string > tmpstring
 temporary list for reading of arrays in parser
 
Parameters params
 The one instance we fill before appending to a list.
 
Atom atom
 The one instance we fill before appending to a list.
 
NewColour colour
 The one instance we fill before appending to a list.
 
Crystal crystal
 The one instance we fill before appending to a list.
 
CoolingChannel coolingchannel
 The one instance we fill before appending to a list.
 
Field field
 The one instance we fill before appending to a list.
 
Laser laser
 The one instance we fill before appending to a list.
 
Material material
 The one instance we fill before appending to a list.
 
PhysicsBiasing xsecbias
 The one instance we fill before appending to a list.
 
Placement placement
 The one instance we fill before appending to a list.
 
Query query
 The one instance we fill before appending to a list.
 
Region region
 The one instance we fill before appending to a list.
 
Tunnel tunnel
 The one instance we fill before appending to a list.
 
CavityModel cavitymodel
 The one instance we fill before appending to a list.
 
SamplerPlacement samplerplacement
 The one instance we fill before appending to a list.
 
Scorer scorer
 The one instance we fill before appending to a list.
 
ScorerMesh scorermesh
 The one instance we fill before appending to a list.
 
Aperture aperture
 The one instance we fill before appending to a list.
 
BLMPlacement blm
 The one instance we fill before appending to a list.
 
Modulator modulator
 The one instance we fill before appending to a list.
 

Static Private Attributes

static Parser * instance = nullptr
 Instance.
 

Detailed Description

Parser class.

Parser class that holds all objects and relevant methods

Singleton pattern

Author
Jochem Snuverink

Definition at line 80 of file parser.h.

Constructor & Destructor Documentation

◆ ~Parser()

Parser::~Parser ( )
virtual

Destructor.

Definition at line 142 of file parser.cc.

References allocated_lines, beamline_list, and instance.

◆ Parser() [1/2]

Parser::Parser ( )

Default contructor.

Definition at line 115 of file parser.cc.

References Initialise().

Referenced by Instance().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Parser() [2/2]

Parser::Parser ( std::string  filename)
explicitprotected

Constructor from filename.

Definition at line 154 of file parser.cc.

References Initialise(), instance, and ParseFile().

Here is the call graph for this function:

Member Function Documentation

◆ Add() [1/3]

template<class C , class Container >
void GMAD::Parser::Add ( )

Insert global object of parser class C in Container class.

Definition at line 1182 of file parser.cc.

◆ Add() [2/3]

template<>
void GMAD::Parser::Add ( bool  unique,
const std::string &  className 
)

Specialisation for Placements where we separately cache an Element. Note we can't do a partial specialisation so we have to do a full explicit one. Therefore we also have to be careful about the order we declare this because of where these functions are used. Also, we can't implement it in the header because we'd get multiple symbols. Therefore, declared here, but implemented in cc file with explicit instantiation of templates we need in rest of cc file.

Definition at line 1216 of file parser.cc.

References GMAD::Placement::bdsimElement, GMAD::Placement::clear(), GMAD::Placement::name, and GMAD::Placement::print().

Here is the call graph for this function:

◆ Add() [3/3]

template<class C , class Container >
void GMAD::Parser::Add ( bool  unique,
const std::string &  className 
)

Definition at line 1196 of file parser.cc.

◆ add_element_temp()

void Parser::add_element_temp ( const std::string &  name,
int  number,
bool  pushfront,
ElementType  linetype 
)

add element to temporary element sequence tmp_list

Definition at line 760 of file parser.cc.

References GMAD::Element::lst, tmp_list, and GMAD::Element::type.

◆ add_func()

void Parser::add_func ( std::string  name,
double(*)(double)  func 
)
private

Add function to parser.

Definition at line 809 of file parser.cc.

References GMAD::Symtab::Set(), GMAD::SymbolMap::symcreate(), and symtab_map.

Referenced by Initialise().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ add_sampler()

void Parser::add_sampler ( const std::string &  name,
int  count,
ElementType  type,
std::string  samplerType,
std::list< int > *  samplerPartIDListIn = nullptr 
)

insert a sampler into beamline_list

Definition at line 668 of file parser.cc.

References add_sampler_partIDSet(), and set_sampler().

Here is the call graph for this function:

◆ add_sampler_partIDSet()

int Parser::add_sampler_partIDSet ( std::list< int > *  samplerPartIDListIn)

Add a particle set for a sampler and return a unique integer ID for that set. If no list or empty list given, returns -1, the default for 'no filter'.

Definition at line 641 of file parser.cc.

References samplerFilters.

Referenced by add_sampler().

Here is the caller graph for this function:

◆ add_var()

void Parser::add_var ( std::string  name,
double  value,
int  is_reserved = 0 
)
private

Definition at line 818 of file parser.cc.

◆ AddVariable()

void Parser::AddVariable ( std::string *  name)

Add variable memory to variable list for memory management.

Definition at line 980 of file parser.cc.

References var_list.

◆ ArrayToList()

template<typename T >
std::list< T > * GMAD::Parser::ArrayToList ( Array *  arrayIn)

Definition at line 359 of file parser.h.

◆ ClearParams()

void Parser::ClearParams ( )

Reset parameters

Definition at line 884 of file parser.cc.

References GMAD::Parameters::flush(), params, and samplerFilters.

Here is the call graph for this function:

◆ copy_element_to_params()

int Parser::copy_element_to_params ( const std::string &  elementName)

copy properties from Element into params, returns element type as integer, returs _NONE if not found

Definition at line 791 of file parser.cc.

References find_element(), GMAD::Parameters::inherit_properties(), params, and GMAD::Element::type.

Here is the call graph for this function:

◆ expand_line() [1/2]

void Parser::expand_line ( const std::string &  name,
const std::string &  start,
const std::string &  end 
)

Expand the main beamline as defined by the use command.

Definition at line 359 of file parser.cc.

References beamline_list, and expand_line().

Here is the call graph for this function:

◆ expand_line() [2/2]

void Parser::expand_line ( FastList< Element > &  target,
const std::string &  name,
const std::string &  start = "",
const std::string &  end = "" 
)

Expand a sequence by name from start to end into the target list. This removes sublines from the beamline into one LINE.

Definition at line 368 of file parser.cc.

References GMAD::FastList< T >::begin(), GMAD::FastList< T >::clear(), element_list, GMAD::FastList< T >::end(), GMAD::FastList< T >::erase(), GMAD::FastList< T >::find(), find_element(), GMAD::FastList< T >::insert(), GMAD::Element::l, GMAD::Element::lst, MAX_EXPAND_ITERATIONS, GMAD::FastList< T >::push_back(), GMAD::FastList< T >::size(), and GMAD::Element::type.

Referenced by expand_line(), and expand_sequences().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ expand_sequences()

void Parser::expand_sequences ( )

Expand all sequences define with 'line' into FastLists.

Definition at line 347 of file parser.cc.

References expand_line(), expandedSequences, and sequences.

Referenced by ParseFile().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ExtendObject()

template<class C >
void Parser::ExtendObject ( C &  object)
private

Extend object with maps.

Definition at line 968 of file parser.cc.

References extendedNumbers, extendedStrings, and extendedVectors.

Referenced by FindAndExtend(), and Overwrite().

Here is the caller graph for this function:

◆ ExtendValue() [1/3]

template<>
void GMAD::Parser::ExtendValue ( const std::string &  property,
Array *  value 
)

Definition at line 1178 of file parser.cc.

◆ ExtendValue() [2/3]

template<>
void GMAD::Parser::ExtendValue ( const std::string &  property,
double  value 
)

Definition at line 1170 of file parser.cc.

◆ ExtendValue() [3/3]

template<>
void GMAD::Parser::ExtendValue ( const std::string &  property,
std::string  value 
)

Definition at line 1174 of file parser.cc.

◆ FillArray()

void Parser::FillArray ( Array *  array)

Fill array object from temporary list and clear temporary list

Definition at line 867 of file parser.cc.

References GMAD::Array::Copy(), and tmparray.

Here is the call graph for this function:

◆ FillString()

void Parser::FillString ( Array *  array)

Fill array object from temporary list and clear temporary list

Definition at line 875 of file parser.cc.

References GMAD::Array::Copy(), and tmpstring.

Here is the call graph for this function:

◆ find_element() [1/2]

Element & Parser::find_element ( const std::string &  element_name)

find element

Definition at line 694 of file parser.cc.

References element_list.

Referenced by copy_element_to_params(), expand_line(), and property_lookup().

Here is the caller graph for this function:

◆ find_element() [2/2]

const Element & Parser::find_element ( const std::string &  element_name) const

find element (const)

Definition at line 710 of file parser.cc.

References element_list.

◆ find_element_safe()

const Element * Parser::find_element_safe ( const std::string &  element_name) const

find element by pointer - nullptr if not found - searches element_list

Definition at line 737 of file parser.cc.

References element_list.

Referenced by BDSParser::GetElement().

Here is the caller graph for this function:

◆ find_placement_element_safe()

const Element * Parser::find_placement_element_safe ( const std::string &  element_name) const

search placement_element

Definition at line 723 of file parser.cc.

References placement_elements.

Referenced by BDSParser::GetPlacementElement().

Here is the caller graph for this function:

◆ FindAndExtend()

template<class C >
bool Parser::FindAndExtend ( const std::string &  objectName)
private

Laser instance.

Find object by name in list

Definition at line 953 of file parser.cc.

References GMAD::FastList< T >::end(), ExtendObject(), and GMAD::FastList< T >::find().

Here is the call graph for this function:

◆ get_sequence()

const FastList< Element > & Parser::get_sequence ( const std::string &  name,
bool  bExit = true 
)

Find the sequence defined in the parser and expand it if not already done so. Cache result in map of fastlists.

Definition at line 530 of file parser.cc.

References expandedSequences, and GMAD::FastList< T >::find().

Referenced by BDSParser::GetSequence().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_sequences()

std::vector< std::string > & Parser::get_sequences ( )

Get names of the available sequences.

Definition at line 524 of file parser.cc.

References sequences.

◆ GetBeamline()

const FastList< Element > & Parser::GetBeamline ( ) const

Beamline Access.

Definition at line 1073 of file parser.cc.

References beamline_list.

Referenced by BDSDetectorConstruction::BuildBeamlines(), and BDSDetectorConstruction::UpdateSamplerDiameterAndCountSamplers().

Here is the caller graph for this function:

◆ GetCallSequenceLog()

std::string Parser::GetCallSequenceLog ( )

Definition at line 1243 of file parser.cc.

◆ GetGlobal() [1/22]

template<>
Aperture & GMAD::Parser::GetGlobal ( )

Definition at line 1084 of file parser.cc.

◆ GetGlobal() [2/22]

template<>
Atom & GMAD::Parser::GetGlobal ( )

Definition at line 1088 of file parser.cc.

◆ GetGlobal() [3/22]

template<>
Beam & GMAD::Parser::GetGlobal ( )

Definition at line 1092 of file parser.cc.

◆ GetGlobal() [4/22]

template<>
BLMPlacement & GMAD::Parser::GetGlobal ( )

Definition at line 1095 of file parser.cc.

◆ GetGlobal() [5/22]

template<>
CavityModel & GMAD::Parser::GetGlobal ( )

Definition at line 1099 of file parser.cc.

◆ GetGlobal() [6/22]

template<>
CoolingChannel & GMAD::Parser::GetGlobal ( )

Definition at line 1103 of file parser.cc.

◆ GetGlobal() [7/22]

template<>
NewColour & GMAD::Parser::GetGlobal ( )

Definition at line 1107 of file parser.cc.

◆ GetGlobal() [8/22]

template<>
Crystal & GMAD::Parser::GetGlobal ( )

Definition at line 1111 of file parser.cc.

◆ GetGlobal() [9/22]

template<>
Field & GMAD::Parser::GetGlobal ( )

Definition at line 1115 of file parser.cc.

◆ GetGlobal() [10/22]

template<>
Laser & GMAD::Parser::GetGlobal ( )

Definition at line 1119 of file parser.cc.

◆ GetGlobal() [11/22]

template<>
Material & GMAD::Parser::GetGlobal ( )

Definition at line 1123 of file parser.cc.

◆ GetGlobal() [12/22]

template<>
Modulator & GMAD::Parser::GetGlobal ( )

Definition at line 1127 of file parser.cc.

◆ GetGlobal() [13/22]

template<>
Options & GMAD::Parser::GetGlobal ( )

Definition at line 1131 of file parser.cc.

◆ GetGlobal() [14/22]

template<>
Parameters & GMAD::Parser::GetGlobal ( )

Definition at line 1134 of file parser.cc.

◆ GetGlobal() [15/22]

template<>
Placement & GMAD::Parser::GetGlobal ( )

Definition at line 1137 of file parser.cc.

◆ GetGlobal() [16/22]

template<>
PhysicsBiasing & GMAD::Parser::GetGlobal ( )

Definition at line 1141 of file parser.cc.

◆ GetGlobal() [17/22]

template<>
Query & GMAD::Parser::GetGlobal ( )

Definition at line 1145 of file parser.cc.

◆ GetGlobal() [18/22]

template<>
Region & GMAD::Parser::GetGlobal ( )

Definition at line 1149 of file parser.cc.

◆ GetGlobal() [19/22]

template<>
SamplerPlacement & GMAD::Parser::GetGlobal ( )

Definition at line 1153 of file parser.cc.

◆ GetGlobal() [20/22]

template<>
Scorer & GMAD::Parser::GetGlobal ( )

Definition at line 1157 of file parser.cc.

◆ GetGlobal() [21/22]

template<>
ScorerMesh & GMAD::Parser::GetGlobal ( )

Definition at line 1161 of file parser.cc.

◆ GetGlobal() [22/22]

template<>
Tunnel & GMAD::Parser::GetGlobal ( )

Definition at line 1165 of file parser.cc.

◆ GetGlobalPtr() [1/22]

template<>
Aperture * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1085 of file parser.cc.

◆ GetGlobalPtr() [2/22]

template<>
Atom * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1089 of file parser.cc.

◆ GetGlobalPtr() [3/22]

template<>
Beam * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1093 of file parser.cc.

◆ GetGlobalPtr() [4/22]

template<>
BLMPlacement * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1096 of file parser.cc.

◆ GetGlobalPtr() [5/22]

template<>
CavityModel * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1100 of file parser.cc.

◆ GetGlobalPtr() [6/22]

template<>
CoolingChannel * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1104 of file parser.cc.

◆ GetGlobalPtr() [7/22]

template<>
NewColour * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1108 of file parser.cc.

◆ GetGlobalPtr() [8/22]

template<>
Crystal * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1112 of file parser.cc.

◆ GetGlobalPtr() [9/22]

template<>
Field * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1116 of file parser.cc.

◆ GetGlobalPtr() [10/22]

template<>
Laser * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1120 of file parser.cc.

◆ GetGlobalPtr() [11/22]

template<>
Material * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1124 of file parser.cc.

◆ GetGlobalPtr() [12/22]

template<>
Modulator * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1128 of file parser.cc.

◆ GetGlobalPtr() [13/22]

template<>
Options * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1132 of file parser.cc.

◆ GetGlobalPtr() [14/22]

template<>
Parameters * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1135 of file parser.cc.

◆ GetGlobalPtr() [15/22]

template<>
Placement * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1138 of file parser.cc.

◆ GetGlobalPtr() [16/22]

template<>
PhysicsBiasing * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1142 of file parser.cc.

◆ GetGlobalPtr() [17/22]

template<>
Query * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1146 of file parser.cc.

◆ GetGlobalPtr() [18/22]

template<>
Region * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1150 of file parser.cc.

◆ GetGlobalPtr() [19/22]

template<>
SamplerPlacement * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1154 of file parser.cc.

◆ GetGlobalPtr() [20/22]

template<>
Scorer * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1158 of file parser.cc.

◆ GetGlobalPtr() [21/22]

template<>
ScorerMesh * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1162 of file parser.cc.

◆ GetGlobalPtr() [22/22]

template<>
Tunnel * GMAD::Parser::GetGlobalPtr ( )

Definition at line 1166 of file parser.cc.

◆ GetList() [1/19]

template<>
FastList< Aperture > & GMAD::Parser::GetList ( )

Definition at line 1085 of file parser.cc.

◆ GetList() [2/19]

template<>
FastList< Atom > & GMAD::Parser::GetList ( )

Definition at line 1089 of file parser.cc.

◆ GetList() [3/19]

template<>
FastList< BLMPlacement > & GMAD::Parser::GetList ( )

Definition at line 1096 of file parser.cc.

◆ GetList() [4/19]

template<>
FastList< CavityModel > & GMAD::Parser::GetList ( )

Definition at line 1100 of file parser.cc.

◆ GetList() [5/19]

template<>
FastList< CoolingChannel > & GMAD::Parser::GetList ( )

Definition at line 1104 of file parser.cc.

◆ GetList() [6/19]

template<>
FastList< NewColour > & GMAD::Parser::GetList ( )

Definition at line 1108 of file parser.cc.

◆ GetList() [7/19]

template<>
FastList< Crystal > & GMAD::Parser::GetList ( )

Definition at line 1112 of file parser.cc.

◆ GetList() [8/19]

template<>
FastList< Field > & GMAD::Parser::GetList ( )

Definition at line 1116 of file parser.cc.

◆ GetList() [9/19]

template<>
FastList< Laser > & GMAD::Parser::GetList ( )

Definition at line 1120 of file parser.cc.

◆ GetList() [10/19]

template<>
FastList< Material > & GMAD::Parser::GetList ( )

Definition at line 1124 of file parser.cc.

◆ GetList() [11/19]

template<>
FastList< Modulator > & GMAD::Parser::GetList ( )

Definition at line 1128 of file parser.cc.

◆ GetList() [12/19]

template<>
FastList< Placement > & GMAD::Parser::GetList ( )

Definition at line 1138 of file parser.cc.

◆ GetList() [13/19]

template<>
FastList< PhysicsBiasing > & GMAD::Parser::GetList ( )

Definition at line 1142 of file parser.cc.

◆ GetList() [14/19]

template<>
FastList< Query > & GMAD::Parser::GetList ( )

Definition at line 1146 of file parser.cc.

◆ GetList() [15/19]

template<>
FastList< Region > & GMAD::Parser::GetList ( )

Definition at line 1150 of file parser.cc.

◆ GetList() [16/19]

template<>
FastList< SamplerPlacement > & GMAD::Parser::GetList ( )

Definition at line 1154 of file parser.cc.

◆ GetList() [17/19]

template<>
FastList< Scorer > & GMAD::Parser::GetList ( )

Definition at line 1158 of file parser.cc.

◆ GetList() [18/19]

template<>
FastList< ScorerMesh > & GMAD::Parser::GetList ( )

Definition at line 1162 of file parser.cc.

◆ GetList() [19/19]

template<>
FastList< Tunnel > & GMAD::Parser::GetList ( )

Definition at line 1166 of file parser.cc.

◆ GetSamplerFilterIDToSet()

const std::map< int, std::set< int > > & GMAD::Parser::GetSamplerFilterIDToSet ( ) const
inline

Definition at line 152 of file parser.h.

◆ GetSamplerFilters()

const std::set< std::set< int > > & GMAD::Parser::GetSamplerFilters ( ) const
inline

Definition at line 151 of file parser.h.

◆ GetValue()

template<class C >
double GMAD::Parser::GetValue ( std::string  property)

Get value for parser class (only for doubles)

Definition at line 353 of file parser.h.

◆ Initialise()

void Parser::Initialise ( )
private

Initialisation of parser functions and constants.

Definition at line 223 of file parser.cc.

References add_func(), GMAD::Parameters::flush(), and params.

Referenced by Parser(), and Parser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Instance() [1/2]

Parser * Parser::Instance ( )
static

Access method.

Definition at line 121 of file parser.cc.

References instance.

◆ Instance() [2/2]

Parser * Parser::Instance ( const std::string &  filename)
static

Constructor method.

Definition at line 131 of file parser.cc.

References instance, and Parser().

Here is the call graph for this function:

◆ InvalidSymbolName()

bool Parser::InvalidSymbolName ( const std::string &  s,
std::string &  errorReason 
)

Definition at line 828 of file parser.cc.

◆ Overwrite()

void Parser::Overwrite ( const std::string &  objectName)

Overwrite object with current values.

Definition at line 892 of file parser.cc.

References element_list, extendedNumbers, extendedStrings, extendedVectors, ExtendObject(), and xsecbias_list.

Here is the call graph for this function:

◆ ParseFile()

void Parser::ParseFile ( FILE *  f)
private

Parse the input file and construct beamline_list and options.

Definition at line 187 of file parser.cc.

References GMAD::SymbolMap::clear(), element_list, expand_sequences(), symtab_map, tmp_list, and var_list.

Referenced by Parser().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PrintBeamline()

void Parser::PrintBeamline ( ) const

Print methods.

Definition at line 987 of file parser.cc.

References beamline_list.

◆ PrintElements()

void Parser::PrintElements ( ) const

Print methods.

Definition at line 992 of file parser.cc.

References element_list.

◆ PrintOptions()

void Parser::PrintOptions ( ) const

Print methods.

Definition at line 997 of file parser.cc.

References options, and GMAD::OptionsBase::print().

Here is the call graph for this function:

◆ property_lookup()

double Parser::property_lookup ( const std::string &  element_name,
const std::string &  property_name 
) const

access property of Element with element_name

Definition at line 751 of file parser.cc.

References find_element(), and GMAD::Element::property_lookup().

Here is the call graph for this function:

◆ quit()

void Parser::quit ( )

Exit method.

Definition at line 314 of file parser.cc.

◆ set_sampler()

void Parser::set_sampler ( const std::string &  name,
int  count,
ElementType  type,
const std::string &  samplerType,
double  samplerRadius = 0,
int  particleSetID = -1 
)
private

Set sampler.

Definition at line 549 of file parser.cc.

References beamline_list.

Referenced by add_sampler().

Here is the caller graph for this function:

◆ SetValue()

template<class C , typename T >
void GMAD::Parser::SetValue ( std::string  property,
T  value 
)

Set value for parser class.

Definition at line 347 of file parser.h.

◆ Store() [1/2]

void Parser::Store ( const std::string &  name)

Add value to front of temporary list.

Definition at line 860 of file parser.cc.

References tmpstring.

◆ Store() [2/2]

void Parser::Store ( double  value)

Add value to front of temporary list.

Definition at line 853 of file parser.cc.

References tmparray.

◆ symcreate()

Symtab * Parser::symcreate ( const std::string &  s)

create new parser symbol

Definition at line 839 of file parser.cc.

References GMAD::SymbolMap::symcreate(), and symtab_map.

Here is the call graph for this function:

◆ symlook()

Symtab * Parser::symlook ( const std::string &  s)

look up parser symbol

Definition at line 846 of file parser.cc.

References GMAD::SymbolMap::symlook(), and symtab_map.

Here is the call graph for this function:

◆ TryPrintingObject()

bool Parser::TryPrintingObject ( const std::string &  objectName) const

Search each member vector for an object with the matching name. Return true if successfully printed.

Definition at line 1002 of file parser.cc.

References aperture_list, atom_list, blm_list, cavitymodel_list, colour_list, coolingchannel_list, crystal_list, field_list, laser_list, material_list, modulator_list, placement_list, query_list, region_list, samplerplacement_list, scorer_list, scorermesh_list, tunnel_list, and xsecbias_list.

◆ write_table()

void Parser::write_table ( std::string *  name,
ElementType  type,
bool  isLine = false 
)

Method that transfers parameters to element properties.

Definition at line 322 of file parser.cc.

References allocated_lines, element_list, GMAD::Element::l, GMAD::Element::lst, params, sequences, GMAD::Element::set(), tmp_list, and GMAD::Element::type.

Here is the call graph for this function:

Field Documentation

◆ allocated_lines

std::vector<std::list<Element>*> GMAD::Parser::allocated_lines
private

vector of defined lines for memory management

Definition at line 274 of file parser.h.

Referenced by write_table(), and ~Parser().

◆ aperture

Aperture GMAD::Parser::aperture
private

The one instance we fill before appending to a list.

Definition at line 294 of file parser.h.

◆ aperture_list

FastList<Aperture> GMAD::Parser::aperture_list
protected

List of parser defined instances of that object.

Definition at line 257 of file parser.h.

Referenced by BDSParser::GetApertures(), and TryPrintingObject().

◆ atom

Atom GMAD::Parser::atom
private

The one instance we fill before appending to a list.

Definition at line 278 of file parser.h.

◆ atom_list

FastList<Atom> GMAD::Parser::atom_list
protected

List of parser defined instances of that object.

Definition at line 241 of file parser.h.

Referenced by BDSParser::GetAtoms(), and TryPrintingObject().

◆ beam

Beam GMAD::Parser::beam
protected

◆ beamline_list

FastList<Element> GMAD::Parser::beamline_list
protected

Beamline.

Definition at line 239 of file parser.h.

Referenced by expand_line(), GetBeamline(), PrintBeamline(), set_sampler(), and ~Parser().

◆ blm

BLMPlacement GMAD::Parser::blm
private

The one instance we fill before appending to a list.

Definition at line 295 of file parser.h.

◆ blm_list

FastList<BLMPlacement> GMAD::Parser::blm_list
protected

List of parser defined instances of that object.

Definition at line 258 of file parser.h.

Referenced by BDSParser::GetBLMs(), and TryPrintingObject().

◆ call_sequence_log

std::stringstream* GMAD::Parser::call_sequence_log = new std::stringstream()
private

execution log to understand call order (not an error or debug log)

Definition at line 343 of file parser.h.

◆ cavitymodel

CavityModel GMAD::Parser::cavitymodel
private

The one instance we fill before appending to a list.

Definition at line 290 of file parser.h.

◆ cavitymodel_list

FastList<CavityModel> GMAD::Parser::cavitymodel_list
protected

List of parser defined instances of that object.

Definition at line 253 of file parser.h.

Referenced by BDSParser::GetCavityModels(), and TryPrintingObject().

◆ colour

NewColour GMAD::Parser::colour
private

The one instance we fill before appending to a list.

Definition at line 279 of file parser.h.

◆ colour_list

FastList<NewColour> GMAD::Parser::colour_list
protected

List of parser defined instances of that object.

Definition at line 242 of file parser.h.

Referenced by BDSParser::GetColours(), and TryPrintingObject().

◆ coolingchannel

CoolingChannel GMAD::Parser::coolingchannel
private

The one instance we fill before appending to a list.

Definition at line 281 of file parser.h.

◆ coolingchannel_list

FastList<CoolingChannel> GMAD::Parser::coolingchannel_list
protected

List of parser defined instances of that object.

Definition at line 244 of file parser.h.

Referenced by BDSParser::GetCoolingChannel(), BDSParser::GetCoolingChannelMap(), BDSParser::GetCoolingChannels(), and TryPrintingObject().

◆ crystal

Crystal GMAD::Parser::crystal
private

The one instance we fill before appending to a list.

Definition at line 280 of file parser.h.

◆ crystal_list

FastList<Crystal> GMAD::Parser::crystal_list
protected

List of parser defined instances of that object.

Definition at line 243 of file parser.h.

Referenced by BDSParser::GetCrystals(), and TryPrintingObject().

◆ current_end

std::string GMAD::Parser::current_end

Name of beamline.

Definition at line 215 of file parser.h.

◆ current_line

std::string GMAD::Parser::current_line

Name of beamline.

Definition at line 213 of file parser.h.

◆ current_start

std::string GMAD::Parser::current_start

Name of beamline.

Definition at line 214 of file parser.h.

◆ element_list

FastList<Element> GMAD::Parser::element_list
private

List of all encountered elements.

Definition at line 315 of file parser.h.

Referenced by expand_line(), find_element(), find_element(), find_element_safe(), Overwrite(), ParseFile(), PrintElements(), and write_table().

◆ expandedSequences

std::map<std::string, FastList<Element>*> GMAD::Parser::expandedSequences
private

Cached copy of expanded sequences.

Definition at line 329 of file parser.h.

Referenced by expand_sequences(), and get_sequence().

◆ extendedNumbers

std::map<std::string, double> GMAD::Parser::extendedNumbers
private

Map for options of type double for extending objects.

Definition at line 308 of file parser.h.

Referenced by ExtendObject(), and Overwrite().

◆ extendedStrings

std::map<std::string, std::string> GMAD::Parser::extendedStrings
private

Map for options of type string for extending objects.

Definition at line 310 of file parser.h.

Referenced by ExtendObject(), and Overwrite().

◆ extendedVectors

std::map<std::string, Array*> GMAD::Parser::extendedVectors
private

Map for options of type vector for extending objects.

Definition at line 312 of file parser.h.

Referenced by ExtendObject(), and Overwrite().

◆ field

Field GMAD::Parser::field
private

The one instance we fill before appending to a list.

Definition at line 282 of file parser.h.

◆ field_list

FastList<Field> GMAD::Parser::field_list
protected

List of parser defined instances of that object.

Definition at line 245 of file parser.h.

Referenced by BDSParser::GetFields(), and TryPrintingObject().

◆ instance

Parser * Parser::instance = nullptr
staticprivate

Instance.

Definition at line 99 of file parser.h.

Referenced by Instance(), Instance(), Parser(), and ~Parser().

◆ laser

Laser GMAD::Parser::laser
private

The one instance we fill before appending to a list.

Definition at line 283 of file parser.h.

◆ laser_list

FastList<Laser> GMAD::Parser::laser_list
protected

List of parser defined instances of that object.

Definition at line 252 of file parser.h.

Referenced by BDSParser::GetLasers(), and TryPrintingObject().

◆ material

Material GMAD::Parser::material
private

The one instance we fill before appending to a list.

Definition at line 284 of file parser.h.

◆ material_list

FastList<Material> GMAD::Parser::material_list
protected

List of parser defined instances of that object.

Definition at line 246 of file parser.h.

Referenced by BDSParser::GetMaterials(), and TryPrintingObject().

◆ MAX_EXPAND_ITERATIONS

const int GMAD::Parser::MAX_EXPAND_ITERATIONS = 50
private

maximum number of nested lines

Definition at line 267 of file parser.h.

Referenced by expand_line().

◆ modulator

Modulator GMAD::Parser::modulator
private

The one instance we fill before appending to a list.

Definition at line 296 of file parser.h.

◆ modulator_list

FastList<Modulator> GMAD::Parser::modulator_list
protected

List of parser defined instances of that object.

Definition at line 259 of file parser.h.

Referenced by BDSParser::GetModulators(), and TryPrintingObject().

◆ options

Options GMAD::Parser::options
protected

◆ params

Parameters GMAD::Parser::params
private

The one instance we fill before appending to a list.

Definition at line 277 of file parser.h.

Referenced by ClearParams(), copy_element_to_params(), Initialise(), and write_table().

◆ placement

Placement GMAD::Parser::placement
private

The one instance we fill before appending to a list.

Definition at line 286 of file parser.h.

◆ placement_elements

FastList<Element> GMAD::Parser::placement_elements
private

List of element definitions that are used in placements - keep separately a copy so that when we clear all the lists after expanding the lines we still have the element definitions we need

Definition at line 320 of file parser.h.

Referenced by find_placement_element_safe().

◆ placement_list

FastList<Placement> GMAD::Parser::placement_list
protected

List of parser defined instances of that object.

Definition at line 251 of file parser.h.

Referenced by BDSParser::GetPlacements(), and TryPrintingObject().

◆ query

Query GMAD::Parser::query
private

The one instance we fill before appending to a list.

Definition at line 287 of file parser.h.

◆ query_list

FastList<Query> GMAD::Parser::query_list
protected

List of parser defined instances of that object.

Definition at line 247 of file parser.h.

Referenced by BDSParser::GetQueries(), and TryPrintingObject().

◆ region

Region GMAD::Parser::region
private

The one instance we fill before appending to a list.

Definition at line 288 of file parser.h.

◆ region_list

FastList<Region> GMAD::Parser::region_list
protected

List of parser defined instances of that object.

Definition at line 248 of file parser.h.

Referenced by BDSParser::GetRegions(), and TryPrintingObject().

◆ samplerFilterIDToSet

std::map<int, std::set<int> > GMAD::Parser::samplerFilterIDToSet
private

Definition at line 339 of file parser.h.

◆ samplerFilters

std::set<std::set<int> > GMAD::Parser::samplerFilters
private

Set of unique sets of particle IDs. This will allow us to build up unique Sensitive detectors for particles later on.

Definition at line 338 of file parser.h.

Referenced by add_sampler_partIDSet(), and ClearParams().

◆ samplerplacement

SamplerPlacement GMAD::Parser::samplerplacement
private

The one instance we fill before appending to a list.

Definition at line 291 of file parser.h.

◆ samplerplacement_list

FastList<SamplerPlacement> GMAD::Parser::samplerplacement_list
protected

List of parser defined instances of that object.

Definition at line 254 of file parser.h.

Referenced by BDSParser::GetSamplerPlacements(), and TryPrintingObject().

◆ scorer

Scorer GMAD::Parser::scorer
private

The one instance we fill before appending to a list.

Definition at line 292 of file parser.h.

◆ scorer_list

FastList<Scorer> GMAD::Parser::scorer_list
protected

List of parser defined instances of that object.

Definition at line 255 of file parser.h.

Referenced by BDSParser::GetScorers(), and TryPrintingObject().

◆ scorermesh

ScorerMesh GMAD::Parser::scorermesh
private

The one instance we fill before appending to a list.

Definition at line 293 of file parser.h.

◆ scorermesh_list

FastList<ScorerMesh> GMAD::Parser::scorermesh_list
protected

List of parser defined instances of that object.

Definition at line 256 of file parser.h.

Referenced by BDSParser::GetScorerMeshes(), and TryPrintingObject().

◆ sequences

std::vector<std::string> GMAD::Parser::sequences
private

Names of all defined sequences in the parser with 'line'.

Definition at line 326 of file parser.h.

Referenced by expand_sequences(), get_sequences(), and write_table().

◆ setToSamplerFilterID

std::map<std::set<int>, int> GMAD::Parser::setToSamplerFilterID
private

Definition at line 340 of file parser.h.

◆ symtab_map

SymbolMap GMAD::Parser::symtab_map
private

Parser symbol map.

Definition at line 332 of file parser.h.

Referenced by add_func(), ParseFile(), symcreate(), and symlook().

◆ tmp_list

std::list<Element> GMAD::Parser::tmp_list
private

Temporary list.

Definition at line 323 of file parser.h.

Referenced by add_element_temp(), ParseFile(), and write_table().

◆ tmparray

std::list<double> GMAD::Parser::tmparray
private

temporary list for reading of arrays in parser

Definition at line 270 of file parser.h.

Referenced by FillArray(), and Store().

◆ tmpstring

std::list<std::string> GMAD::Parser::tmpstring
private

temporary list for reading of arrays in parser

Definition at line 271 of file parser.h.

Referenced by FillString(), and Store().

◆ tunnel

Tunnel GMAD::Parser::tunnel
private

The one instance we fill before appending to a list.

Definition at line 289 of file parser.h.

◆ tunnel_list

FastList<Tunnel> GMAD::Parser::tunnel_list
protected

List of parser defined instances of that object.

Definition at line 249 of file parser.h.

Referenced by BDSParser::GetTunnels(), and TryPrintingObject().

◆ var_list

std::vector<std::string*> GMAD::Parser::var_list
private

Variable vector for memory storage.

Definition at line 334 of file parser.h.

Referenced by AddVariable(), and ParseFile().

◆ xsecbias

PhysicsBiasing GMAD::Parser::xsecbias
private

The one instance we fill before appending to a list.

Definition at line 285 of file parser.h.

◆ xsecbias_list

FastList<PhysicsBiasing> GMAD::Parser::xsecbias_list
protected

List of parser defined instances of that object.

Definition at line 250 of file parser.h.

Referenced by BDSParser::GetBiasing(), BDSParser::GetBiasingVector(), Overwrite(), and TryPrintingObject().


The documentation for this class was generated from the following files: