/
gdml.go
114 lines (97 loc) · 2.69 KB
/
gdml.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright 2018 The go-hep Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Package gdml parses and interprets GDML files.
// Geometry Description Markup Language (GDML) files are specialized XML-based
// language files designed to describe the geometries of detectors associated
// with physics measurements.
//
// See:
// http://gdml.web.cern.ch/GDML/doc/GDMLmanual.pdf
//
package gdml
import "encoding/xml"
// Constant describes a named constant in a GDML file.
type Constant struct {
Name string `xml:"name,attr"`
Value float64 `xml:"value,attr"`
}
// Quantity is a constant with a unit.
type Quantity struct {
Name string `xml:"name,attr"`
Type string `xml:"type,attr"`
Value float64 `xml:"value,attr"`
Unit string `xml:"unit,attr"`
}
// Variable is a named value in a GDML file.
// Once defined, a variable can be used anywhere inside the file.
// The value of a variable is evaluated each time it is used.
type Variable struct {
Name string `xml:"name,attr"`
Value string `xml:"value,attr"`
}
type Position struct {
Name string `xml:"name,attr"`
X string `xml:"x,attr"`
Y string `xml:"y,attr"`
Z string `xml:"z,attr"`
Unit string `xml:"unit,attr"`
}
type Rotation struct {
Name string `xml:"name,attr"`
X string `xml:"x,attr"`
Y string `xml:"y,attr"`
Z string `xml:"z,attr"`
Unit string `xml:"unit,attr"`
}
type Scale struct {
Name string `xml:"name,attr"`
X string `xml:"x,attr"`
Y string `xml:"y,attr"`
Z string `xml:"z,attr"`
}
type Matrix struct {
Name string `xml:"name,attr"`
Cols int `xml:"coldim,attr"`
Values string `xml:"values,attr"`
}
type Isotope struct {
Name string `xml:"name,attr"`
Z int `xml:"Z,attr"`
N int `xml:"N,attr"`
Atom Atom `xml:"atom"`
}
type Element struct {
Name string `xml:"name,attr"`
Z int `xml:"Z,attr"`
Formula string `xml:"formula,attr"`
Atom Atom `xml:"atom"`
Fractions []Fraction `xml:"fraction"`
}
type Atom struct {
Type string `xml:"type,attr"`
Value float64 `xml:"value,attr"`
}
type Fraction struct {
Ref string `xml:"ref,attr"`
N float64 `xml:"n,attr"`
}
type Material struct {
Name string `xml:"name,attr"`
Z float64 `xml:"Z,attr"`
Formula string `xml:"formula,attr"`
Density Density `xml:"D"`
Atom Atom `xml:"atom"`
Composites []Composite `xml:"composite"`
Fractions []Fraction `xml:"fraction"`
}
type Density struct {
Value float64 `xml:"value,attr"`
}
type Composite struct {
N int `xml:"n,attr"`
Ref string `xml:"ref,attr"`
}
type Schema struct {
XMLName xml.Name `xml:"data"`
}