BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
query.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 QUERY_H
20#define QUERY_H
21
22#include <iomanip>
23#include <iostream>
24#include <string>
25
26#include "published.h"
27
28namespace GMAD
29{
36 class Query: public Published<Query>
37 {
38 public:
39 std::string name;
40 int nx;
41 int ny;
42 int nz;
43 int nt;
44 double xmin;
45 double xmax;
46 double ymin;
47 double ymax;
48 double zmin;
49 double zmax;
50 double tmin;
51 double tmax;
52 std::string outfileMagnetic;
53 std::string outfileElectric;
54 std::string fieldObject;
55
58
59 bool overwriteExistingFiles;
60 bool printTransform;
61
62 bool drawArrows;
63 bool drawZeroValuePoints;
64 bool drawBoxes;
65 double boxAlpha;
66
67 std::string pointsFile;
68
69 // For 3d query in a real model - all the possible transform information required
70 std::string referenceElement;
72 double s;
73 double x;
74 double y;
75 double z;
77 double phi;
78 double theta;
79 double psi;
82 double axisX;
83 double axisY;
84 double axisZ;
85 double angle;
87 bool axisAngle;
88
92
94 Query();
96 void clear();
98 void print()const;
100 template <typename T>
101 void set_value(std::string property, T value);
102
103 private:
105 void PublishMembers();
106 };
107
108 template <typename T>
109 void Query::set_value(std::string property, T value)
110 {
111#ifdef BDSDEBUG
112 std::cout << "query> Setting value " << std::setw(25) << std::left << property << value << std::endl;
113#endif
114 // member method can throw runtime_error, catch and exit gracefully
115 try {
116 set(this,property,value);
117 }
118 catch(const std::runtime_error&) {
119 std::cerr << "Error: query> unknown option \"" << property << "\" with value " << value << std::endl;
120 exit(1);
121 }
122 }
123}
124
125#endif
Class that provides introspection to its members.
Definition: published.h:47
void set(Query *instance, const std::string &name, double value)
Definition: published.h:99
Query structure class for parser.
Definition: query.h:37
bool axisAngle
Flag to use the axis angle construction of rotation.
Definition: query.h:87
double tmax
T finish.
Definition: query.h:51
double zmin
Z start.
Definition: query.h:48
std::string referenceElement
Name of reference element w.r.t. to place to.
Definition: query.h:70
double xmax
X finish.
Definition: query.h:45
double s
Curvilinear s position to place w.r.t..
Definition: query.h:72
void clear()
Reset.
Definition: query.cc:29
double axisZ
Definition: query.h:84
void PublishMembers()
publish members
Definition: query.cc:79
Query()
Constructor.
Definition: query.cc:23
double y
Offset in y.
Definition: query.h:74
double angle
Definition: query.h:85
double theta
Euler angle for rotation.
Definition: query.h:78
void set_value(std::string property, T value)
Set methods by property name and value.
Definition: query.h:109
double zmax
Z finish.
Definition: query.h:49
double ymin
Y start.
Definition: query.h:46
double axisX
Definition: query.h:82
void print() const
Print some properties.
Definition: query.cc:129
std::string pointsFile
File with 3D points to use.
Definition: query.h:67
int nt
Number of samples in t.
Definition: query.h:43
int nz
Number of samples in z.
Definition: query.h:42
double xmin
X start.
Definition: query.h:44
bool queryMagneticField
Whether to query the magnetic field.
Definition: query.h:56
double psi
Euler angle for rotation.
Definition: query.h:79
int ny
Number of samples in y.
Definition: query.h:41
std::string name
Name of object.
Definition: query.h:39
bool checkParameters
Definition: query.h:91
int nx
Number of samples in x.
Definition: query.h:40
double z
Definition: query.h:75
double axisY
Definition: query.h:83
double phi
Euler angle for rotation.
Definition: query.h:77
std::string outfileMagnetic
Output file name.
Definition: query.h:52
double ymax
Y finish.
Definition: query.h:47
int referenceElementNumber
Index of repetition of element if there are multiple uses.
Definition: query.h:71
double x
Offset in x.
Definition: query.h:73
bool queryElectricField
Whether to query the electric field.
Definition: query.h:57
std::string fieldObject
Name of field to query.
Definition: query.h:54
double tmin
T start.
Definition: query.h:50
Parser namespace for GMAD language. Combination of Geant4 and MAD.