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