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