BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
parserROOT.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "parserROOT.h"
19
20#include "parser.h"
21
22#include <cstdio>
23#include <list>
24
26int GMAD::GmadParser_c(char *name)
27{
28 Parser::Instance(std::string(name));
29 return 0;
30}
31
33{
34 return Parser::Instance()->GetBeamline().size();
35}
36
37const char* GMAD::GetName(int i)
38{
39 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
40 std::advance(it, i);
41 return (it->name).c_str();
42}
43
44int GMAD::GetType(int i)
45{
46 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
47 std::advance(it, i);
48 return static_cast<int>(it->type);
49}
50
51double GMAD::GetLength(int i)
52{
53 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
54 std::advance(it, i);
55 return it->l;
56}
57
58double GMAD::GetAngle(int i)
59{
60 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
61 std::advance(it, i);
62 return it->angle;
63}
64
65double* GMAD::GetKs(int i)
66{
67 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
68 std::advance(it, i);
69 double* result = new double[5];
70 result[0] = it->ks;
71 result[1] = it->k1;
72 result[2] = it->k2;
73 result[3] = it->k3;
74 result[4] = it->k4;
75 return result;
76}
77
78double GMAD::GetAper1(int i)
79{
80 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
81 std::advance(it, i);
82 return it->aper1;
83}
84
85double GMAD::GetAper2(int i)
86{
87 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
88 std::advance(it, i);
89 return it->aper2;
90}
91
92double GMAD::GetAper3(int i)
93{
94 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
95 std::advance(it, i);
96 return it->aper3;
97}
98
99double GMAD::GetAper4(int i)
100{
101 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
102 std::advance(it, i);
103 return it->aper4;
104}
105
106const char* GMAD::GetApertureType(int i)
107{
108 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
109 std::advance(it, i);
110 return (it->apertureType).c_str();
111}
112
114{
115 std::list<Element>::const_iterator it = Parser::Instance()->GetBeamline().begin();
116 std::advance(it, i);
117 return it->beampipeThickness;
118}
double GetBeampipeThickness(int)
Beam Pipe Thickness.
const char * GetName(int)
Name of element.
Definition parserROOT.cc:37
int GetType(int)
Type of element.
Definition parserROOT.cc:44
double * GetKs(int)
All magnetic ks.
Definition parserROOT.cc:65
double GetAper3(int)
Aperture 3.
Definition parserROOT.cc:92
double GetAper1(int)
Aperture 1.
Definition parserROOT.cc:78
double GetAper4(int)
Aperture 4.
Definition parserROOT.cc:99
int GmadParser_c(char *name)
Definition parserROOT.cc:26
int GetNElements()
Length of list.
Definition parserROOT.cc:32
double GetLength(int)
Length of element.
Definition parserROOT.cc:51
double GetAngle(int)
Angle of element.
Definition parserROOT.cc:58
const char * GetApertureType(int)
Aperture Type.
double GetAper2(int)
Aperture 2.
Definition parserROOT.cc:85