BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
aperture.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 APERTURE_H
19#define APERTURE_H
20
21#include <iomanip>
22#include <iostream>
23#include <string>
24#include <vector>
25
26#include "published.h"
27#include "beamBase.h"
28
29namespace GMAD
30{
36 class Aperture: public Published<Aperture>
37 {
38 public:
39 std::string name;
40 std::string apertureType;
41 double aper1;
42 double aper2;
43 double aper3;
44 double aper4;
45
47 Aperture();
49 void clear();
51 void print() const;
53 template<typename T>
54 void set_value(std::string name, T value, bool bExit = true);
55
56 private:
58 void PublishMembers();
59 };
60
61 template<typename T>
62 void Aperture::set_value(std::string property, T value, bool bExit)
63 {
64#ifdef BDSDEBUG
65 std::cout << "aperture> setting value " << std::setw(25) << std::left
66 << property << value << std::endl;
67#endif
68 // member method can throw runtime_error, catch and exit gracefully
69 try
70 {set(this, property, value);}
71 catch (const std::runtime_error&)
72 {
73 std::cerr << "Error: aperture> unknown option \"" << property
74 << "\" with value \"" << value << "\"" << std::endl;
75 if (bExit)
76 {exit(1);}
77 else
78 {std::rethrow_exception(std::current_exception());}
79 }
80 }
81}
82
83#endif
Aperture class.
Definition aperture.h:37
Aperture()
Constructor.
Definition aperture.cc:22
void PublishMembers()
publish members
Definition aperture.cc:38
void print() const
Print some properties.
Definition aperture.cc:54
void set_value(std::string name, T value, bool bExit=true)
Set methods by property name and value.
Definition aperture.h:62
void clear()
Reset.
Definition aperture.cc:28
Class that provides introspection to its members.
Definition published.h:48
void set(Aperture *instance, const std::string &name, double value)
Definition published.h:100
Parser namespace for GMAD language. Combination of Geant4 and MAD.