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