BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
tunnel.h
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#ifndef TUNNEL_H
20#define TUNNEL_H
21
22#include <iomanip>
23#include <iostream>
24#include <string>
25
26#include "published.h"
27
28namespace GMAD
29{
35 class Tunnel: public Published<Tunnel> {
36
37 public:
38 std::string name;
40 std::string type;
41
43 double aper1;
44 double aper2;
46 double offsetX, offsetY;
48 double thickness;
49 double soilThickness;
50 double floorOffset;
51
54
56 std::string material;
58 std::string soilMaterial;
59
61 std::string startElement, endElement;
62
64 Tunnel();
66 void clear();
68 void print()const;
70 template <typename T>
71 void set_value(std::string property, T value);
72
73 private:
75 void PublishMembers();
76 };
77
78 template <typename T>
79 void Tunnel::set_value(std::string property, T value)
80 {
81#ifdef BDSDEBUG
82 std::cout << "tunnel> Setting value " << std::setw(25) << std::left << property << value << std::endl;
83#endif
84 // member method can throw runtime_error, catch and exit gracefully
85 try
86 {set(this,property,value);}
87 catch(const std::runtime_error&)
88 {
89 std::cerr << "Error: tunnel> unknown option \"" << property << "\" with value " << value << "\"" << std::endl;
90 exit(1);
91 }
92 }
93}
94
95#endif
Class that provides introspection to its members.
Definition: published.h:47
void set(Tunnel *instance, const std::string &name, double value)
Definition: published.h:99
Tunnel class for parser.
Definition: tunnel.h:35
double aper1
radius, aperture parameters
Definition: tunnel.h:43
void PublishMembers()
Publish members.
Definition: tunnel.cc:52
std::string soilMaterial
soil
Definition: tunnel.h:58
std::string startElement
start and end element by name
Definition: tunnel.h:61
double thickness
tunnel geometry parameters
Definition: tunnel.h:48
int visible
visibility
Definition: tunnel.h:53
std::string material
material
Definition: tunnel.h:56
void set_value(std::string property, T value)
set methods by property name and value
Definition: tunnel.h:79
void clear()
reset
Definition: tunnel.cc:32
std::string name
Definition: tunnel.h:38
std::string type
geometry type
Definition: tunnel.h:40
Tunnel()
constructor
Definition: tunnel.cc:23
double offsetX
offset x and y
Definition: tunnel.h:46
void print() const
print some properties
Definition: tunnel.cc:71
Parser namespace for GMAD language. Combination of Geant4 and MAD.