BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
crystal.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 CRYSTAL_H
19#define CRYSTAL_H
20
21#include <iomanip>
22#include <iostream>
23#include <string>
24
25#include "published.h"
26
27namespace GMAD
28{
35 class Crystal: public Published<Crystal>
36 {
37 public:
38 std::string name;
39 std::string material;
40 std::string data;
41 std::string shape;
42 double lengthX;
43 double lengthY;
44 double lengthZ;
45 double sizeA;
46 double sizeB;
47 double sizeC;
48 double alpha;
49 double beta;
50 double gamma;
51 int spaceGroup;
54 double miscutAngleY;
55
57 Crystal();
59 void clear();
61 void print()const;
63 template <typename T>
64 void set_value(std::string property, T value, bool bExit = true);
65
66 private:
68 void PublishMembers();
69 };
70
71 template <typename T>
72 void Crystal::set_value(std::string property, T value, bool bExit)
73 {
74#ifdef BDSDEBUG
75 std::cout << "crystal> Setting value " << std::setw(25) << std::left << property << value << std::endl;
76#endif
77 // member method can throw runtime_error, catch and exit gracefully
78 try
79 {set(this,property,value);}
80 catch (const std::runtime_error&)
81 {
82 std::cerr << "Error: crystal> unknown option \"" << property << "\" with value \"" << value << "\"" << std::endl;
83 if(bExit)
84 exit(1);
85 else
86 std::rethrow_exception(std::current_exception());
87 }
88 }
89}
90
91#endif
Crystal class for parser.
Definition crystal.h:36
void clear()
Reset.
Definition crystal.cc:28
std::string name
Name of object.
Definition crystal.h:38
double lengthX
X size.
Definition crystal.h:42
void PublishMembers()
publish members
Definition crystal.cc:49
std::string shape
Which geometry to create.
Definition crystal.h:41
void print() const
Print some properties.
Definition crystal.cc:70
double bendingAngleYAxis
Bending angle about Y axis.
Definition crystal.h:52
Crystal()
Constructor.
Definition crystal.cc:22
double lengthZ
Z size.
Definition crystal.h:44
std::string data
Which channelling data to use.
Definition crystal.h:40
double bendingAngleZAxis
Bending angle about Z axis.
Definition crystal.h:53
std::string material
Material of crystal.
Definition crystal.h:39
double lengthY
Y size.
Definition crystal.h:43
void set_value(std::string property, T value, bool bExit=true)
Set methods by property name and value.
Definition crystal.h:72
Class that provides introspection to its members.
Definition published.h:48
void set(Crystal *instance, const std::string &name, double value)
Definition published.h:100
Parser namespace for GMAD language. Combination of Geant4 and MAD.