BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
region.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 REGION_H
20#define REGION_H
21
22#include <iomanip>
23#include <iostream>
24#include <string>
25
26#include "published.h"
27
28namespace GMAD
29{
35 class Region: public Published<Region>
36 {
37 public:
38 std::string name;
39
40 double defaultRangeCut;
41 double prodCutPhotons;
42 double prodCutElectrons;
43 double prodCutPositrons;
44 double prodCutProtons;
45
47 Region();
49 void clear();
51 void print()const;
53 template <typename T>
54 void set_value(std::string property, T value);
55
56 private:
58 void PublishMembers();
59 };
60
61 template <typename T>
62 void Region::set_value(std::string property, T value)
63 {
64#ifdef BDSDEBUG
65 std::cout << "region> Setting value " << std::setw(25) << std::left << property << value << std::endl;
66#endif
67 // member method can throw runtime_error, catch and exit gracefully
68 try {
69 set(this,property,value);
70 }
71 catch(const std::runtime_error&) {
72 std::cerr << "Error: region> unknown option \"" << property << "\" with value " << value << std::endl;
73 exit(1);
74 }
75 }
76}
77
78#endif
Class that provides introspection to its members.
Definition: published.h:47
void set(Region *instance, const std::string &name, double value)
Definition: published.h:99
Region class for parser.
Definition: region.h:36
void clear()
reset
Definition: region.cc:29
std::string name
name
Definition: region.h:38
void print() const
print some properties
Definition: region.cc:51
void PublishMembers()
publish members
Definition: region.cc:41
Region()
constructor
Definition: region.cc:23
void set_value(std::string property, T value)
set methods by property name and value
Definition: region.h:62
Parser namespace for GMAD language. Combination of Geant4 and MAD.