BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
samplerplacement.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 SAMPLERPLACEMENT_H
20#define SAMPLERPLACEMENT_H
21
22#include <iomanip>
23#include <iostream>
24#include <list>
25#include <string>
26
27#include "published.h"
28
29namespace GMAD
30{
36 class SamplerPlacement : public Published<SamplerPlacement>
37 {
38 public:
39 std::string name;
40 std::string samplerType;
41 std::string referenceElement;
43 double s;
44 double x;
45 double y;
46 double z;
48 double phi;
49 double theta;
50 double psi;
53 double axisX;
54 double axisY;
55 double axisZ;
56 double angle;
58 bool axisAngle;
59
60 std::string apertureModel;
61 std::string shape;
62 double aper1;
63 double aper2;
64 double aper3;
65 double aper4;
66
67 double startAnglePhi;
68 double sweepAnglePhi;
69 double startAngleTheta;
70 double sweepAngleTheta;
71
72 // This should be std::list<int> but the parser only supports double for numerical types in a list.
74 std::list<double> partID;
76
80 void clear();
82 void print()const;
84 template <typename T>
85 void set_value(std::string property, T value);
86
87 private:
89 void PublishMembers();
90 };
91
92 template <typename T>
93 void SamplerPlacement::set_value(std::string property, T value)
94 {
95#ifdef BDSDEBUG
96 std::cout << "samplerplacement> Setting value " << std::setw(25) << std::left
97 << property << value << std::endl;
98#endif
99 // member method can throw runtime_error, catch and exit gracefully
100 try
101 {set(this,property,value);}
102 catch (const std::runtime_error&)
103 {
104 std::cerr << "Error: samplerplacement> unknown option \"" << property
105 << "\" with value " << value << std::endl;
106 exit(1);
107 }
108 }
109}
110
111#endif
Class that provides introspection to its members.
Definition: published.h:47
void set(SamplerPlacement *instance, const std::string &name, double value)
Definition: published.h:99
Sampler placement class for parser.
int referenceElementNumber
Index of repetition of element if there are multiple uses.
double phi
Euler angle for rotation.
std::string name
Name of this samplerplacement.
std::string referenceElement
Name of reference element w.r.t. to place to.
void set_value(std::string property, T value)
set methods by property name and value
void PublishMembers()
publish members
std::string samplerType
Plane, Cylinder, Sphere.
std::list< double > partID
List of PDG IDs of which particles to record for - default is empty, so all particles.
void print() const
print some properties
double theta
Euler angle for rotation.
double s
Curvilinear s position to place w.r.t..
double psi
Euler angle for rotation.
bool axisAngle
Flag to use the axis angle construction of rotation.
double x
Offset in x.
int partIDSetID
The unique ID of the particle set given by the parser.
double y
Offset in y.
Parser namespace for GMAD language. Combination of Geant4 and MAD.