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) 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#ifndef TUNNEL_H
19#define TUNNEL_H
20
21#include <iomanip>
22#include <iostream>
23#include <string>
24
25#include "published.h"
26
27namespace GMAD
28{
34 class Tunnel: public Published<Tunnel> {
35
36 public:
37 std::string name;
39 std::string type;
40
42 double aper1;
43 double aper2;
45 double offsetX, offsetY;
47 double thickness;
48 double soilThickness;
49 double floorOffset;
50
53
55 std::string material;
57 std::string soilMaterial;
58
60 std::string startElement, endElement;
61
63 Tunnel();
65 void clear();
67 void print()const;
69 template <typename T>
70 void set_value(std::string property, T value, bool bExit = true);
71
72 private:
74 void PublishMembers();
75 };
76
77 template <typename T>
78 void Tunnel::set_value(std::string property, T value, bool bExit)
79 {
80#ifdef BDSDEBUG
81 std::cout << "tunnel> Setting value " << std::setw(25) << std::left << property << value << std::endl;
82#endif
83 // member method can throw runtime_error, catch and exit gracefully
84 try
85 {set(this,property,value);}
86 catch(const std::runtime_error&)
87 {
88 std::cerr << "Error: tunnel> unknown option \"" << property << "\" with value " << value << "\"" << std::endl;
89 if (bExit)
90 {exit(1);}
91 else
92 {
93 std::rethrow_exception(std::current_exception());} // to be caught by python
94 }
95 }
96 }
97
98#endif
Class that provides introspection to its members.
Definition published.h:48
void set(Tunnel *instance, const std::string &name, double value)
Definition published.h:100
Tunnel class for parser.
Definition tunnel.h:34
double aper1
radius, aperture parameters
Definition tunnel.h:42
void set_value(std::string property, T value, bool bExit=true)
set methods by property name and value
Definition tunnel.h:78
void PublishMembers()
Publish members.
Definition tunnel.cc:51
std::string soilMaterial
soil
Definition tunnel.h:57
std::string startElement
start and end element by name
Definition tunnel.h:60
double thickness
tunnel geometry parameters
Definition tunnel.h:47
int visible
visibility
Definition tunnel.h:52
std::string material
material
Definition tunnel.h:55
void clear()
reset
Definition tunnel.cc:31
std::string name
Definition tunnel.h:37
std::string type
geometry type
Definition tunnel.h:39
Tunnel()
constructor
Definition tunnel.cc:22
double offsetX
offset x and y
Definition tunnel.h:45
void print() const
print some properties
Definition tunnel.cc:70
Parser namespace for GMAD language. Combination of Geant4 and MAD.