BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
placement.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 PLACEMENT_H
20#define PLACEMENT_H
21
22#include <iomanip>
23#include <iostream>
24#include <string>
25
26#include "published.h"
27
28namespace GMAD
29{
30 class BLMPlacement;
31 class Query;
32 class SamplerPlacement;
33 class ScorerMesh;
34
40 class Placement : public Published<Placement>
41 {
42 public:
43 std::string name;
44 std::string geometryFile;
45 std::string bdsimElement;
46 std::string sequence;
47 std::string referenceElement;
49 double s;
50 double x;
51 double y;
52 double z;
54 double phi;
55 double theta;
56 double psi;
59 double axisX;
60 double axisY;
61 double axisZ;
62 double angle;
64 bool sensitive;
65 bool axisAngle;
66 std::string side;
67 double sideOffset;
71
72 std::string fieldAll;
73
75 Placement();
77 void clear();
79 void print()const;
81 template <typename T>
82 void set_value(std::string property, T value);
83
85 Placement(const SamplerPlacement& samplerPlacement);
86 Placement(const ScorerMesh& scorerMesh);
87 Placement(const BLMPlacement& blmPlacement);
88 Placement(const Query& qu);
90
91 private:
93 void PublishMembers();
94 };
95
96 template <typename T>
97 void Placement::set_value(std::string property, T value)
98 {
99#ifdef BDSDEBUG
100 std::cout << "placement> Setting value " << std::setw(25) << std::left
101 << property << value << std::endl;
102#endif
103 // member method can throw runtime_error, catch and exit gracefully
104 try
105 {set(this,property,value);}
106 catch (const std::runtime_error&)
107 {
108 std::cerr << "Error: placement> unknown option \"" << property
109 << "\" with value " << value << std::endl;
110 exit(1);
111 }
112 }
113}
114
115#endif
blm for parser.
Definition: blmplacement.h:39
Placement class for parser.
Definition: placement.h:41
bool axisAngle
Flag to use the axis angle construction of rotation.
Definition: placement.h:65
double axisZ
Definition: placement.h:61
std::string fieldAll
Name of field object to apply to all of placement.
Definition: placement.h:72
bool sensitive
Whether to record hits or not.
Definition: placement.h:64
std::string name
Name of this placement.
Definition: placement.h:43
void clear()
reset
Definition: placement.cc:33
void print() const
print some properties
Definition: placement.cc:91
std::string side
which side to attach to: top, bottom, left, right.
Definition: placement.h:66
void set_value(std::string property, T value)
set methods by property name and value
Definition: placement.h:97
double theta
Euler angle for rotation.
Definition: placement.h:55
double sideOffset
Gap between side and component.
Definition: placement.h:67
double psi
Euler angle for rotation.
Definition: placement.h:56
double y
Offset in y.
Definition: placement.h:51
double s
Curvilinear s position to place w.r.t..
Definition: placement.h:49
double axisY
Definition: placement.h:60
bool dontReloadGeometry
Purposively don't reload for unique placements (must know what we're doing)
Definition: placement.h:70
std::string bdsimElement
Name of bdsim-built component to place instead of piece of geometry.
Definition: placement.h:45
void PublishMembers()
publish members
Definition: placement.cc:62
bool autoColour
Whether to auto colour the geometry.
Definition: placement.h:68
bool stripOuterVolume
Whether to place the world LV as a G4AssemblyVolume.
Definition: placement.h:69
std::string sequence
Name of sequence to place.
Definition: placement.h:46
std::string geometryFile
Geometry to load in format:path.
Definition: placement.h:44
double angle
Definition: placement.h:62
Placement()
constructor
Definition: placement.cc:27
double x
Offset in x.
Definition: placement.h:50
int referenceElementNumber
Index of repetition of element if there are multiple uses.
Definition: placement.h:48
double phi
Euler angle for rotation.
Definition: placement.h:54
std::string referenceElement
Name of reference element w.r.t. to place to.
Definition: placement.h:47
double axisX
Definition: placement.h:59
Class that provides introspection to its members.
Definition: published.h:47
void set(Placement *instance, const std::string &name, double value)
Definition: published.h:99
Query structure class for parser.
Definition: query.h:37
Sampler placement class for parser.
ScorerMesh class for parser.
Definition: scorermesh.h:38
Parser namespace for GMAD language. Combination of Geant4 and MAD.