BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
scorermesh.h
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2024.
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 SCORERMESH_H
20#define SCORERMESH_H
21
22#include <exception>
23#include <iomanip>
24#include <iostream>
25#include <sstream>
26#include <string>
27
28#include "published.h"
29
30namespace GMAD
31{
32 class SamplerPlacement;
33
39 class ScorerMesh : public Published<ScorerMesh>
40 {
41 public:
42 std::string name;
43 std::string scoreQuantity;
44 std::string geometryType;
45
46 int nx;
47 int ny;
48 int nz;
49 int nr;
50 int nphi;
51 int ne;
52 double xsize;
53 double ysize;
54 double zsize;
55 double rsize;
56 double eLow;
57 double eHigh;
58 std::string eScale;
60
61 // placement stuff
62 std::string sequence;
63 std::string referenceElement;
65 double s;
66 double x;
67 double y;
68 double z;
70 double phi;
71 double theta;
72 double psi;
75 double axisX;
76 double axisY;
77 double axisZ;
78 double angle;
80 bool axisAngle;
81
83 ScorerMesh();
85 void clear();
87 void print()const;
89 template <typename T>
90 void set_value(std::string property, T value, bool exceptionSafe = false);
91
92 private:
94 void PublishMembers();
95 };
96
97 template <typename T>
98 void ScorerMesh::set_value(std::string property, T value, bool exceptionSafe)
99 {
100#ifdef BDSDEBUG
101 std::cout << "scorermesh> Setting value " << std::setw(25) << std::left
102 << property << value << std::endl;
103#endif
104 // member method can throw runtime_error, catch and exit gracefully
105 try
106 {set(this,property,value);}
107 catch (const std::runtime_error&)
108 {
109 std::stringstream ss;
110 ss << "Error: scorermesh> unknown property \"" << property
111 << "\" with value \"" << value << "\" in definition \"" << this->name << "\"";
112 if (!exceptionSafe)
113 {throw std::invalid_argument(ss.str());}
114 else
115 {std::cout << ss.str() << std::endl;}
116 }
117 }
118}
119
120#endif
Class that provides introspection to its members.
Definition published.h:49
void set(ScorerMesh *instance, const std::string &name, double value)
Definition published.h:101
ScorerMesh class for parser.
Definition scorermesh.h:40
void clear()
reset
Definition scorermesh.cc:29
double phi
Euler angle for rotation.
Definition scorermesh.h:70
std::string referenceElement
Name of reference element w.r.t. to place to.
Definition scorermesh.h:63
int ny
Number of bins in y.
Definition scorermesh.h:47
int ne
Number of bins in E.
Definition scorermesh.h:51
int nx
Number of bins in x.
Definition scorermesh.h:46
int nphi
Number of bins in Phi.
Definition scorermesh.h:50
int nz
Number of bins in z.
Definition scorermesh.h:48
void print() const
print some properties
double s
Curvilinear s position to place w.r.t..
Definition scorermesh.h:65
std::string scoreQuantity
Name of scorer object to use.
Definition scorermesh.h:43
double psi
Euler angle for rotation.
Definition scorermesh.h:72
int referenceElementNumber
Index of repetition of element if there are multiple uses.
Definition scorermesh.h:64
std::string eScale
E scaling type.
Definition scorermesh.h:58
std::string name
Name of this placement.
Definition scorermesh.h:42
double xsize
X total width.
Definition scorermesh.h:52
ScorerMesh()
constructor
Definition scorermesh.cc:23
void PublishMembers()
publish members
Definition scorermesh.cc:66
double eHigh
E High limit.
Definition scorermesh.h:57
int nr
Number of bins in R.
Definition scorermesh.h:49
double eLow
E Low limit.
Definition scorermesh.h:56
double ysize
Y total width.
Definition scorermesh.h:53
void set_value(std::string property, T value, bool exceptionSafe=false)
set methods by property name and value
Definition scorermesh.h:98
std::string geometryType
Name of scorermesh geometry to use.
Definition scorermesh.h:44
double rsize
R total length.
Definition scorermesh.h:55
std::string sequence
Name of sequence to place.
Definition scorermesh.h:62
std::string eBinsEdgesFilenamePath
E bins edges filename path.
Definition scorermesh.h:59
double theta
Euler angle for rotation.
Definition scorermesh.h:71
double x
Offset in x.
Definition scorermesh.h:66
double zsize
Z total width.
Definition scorermesh.h:54
bool axisAngle
Flag to use the axis angle construction of rotation.
Definition scorermesh.h:80
double y
Offset in y.
Definition scorermesh.h:67
Parser namespace for GMAD language. Combination of Geant4 and MAD.