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