Contents
- Description
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- calcDistance(Vector3d, Vector3d, double, double)
- moveChildrenToMother(Geant4Basic)
- appendName(Geant4Basic, String)
- appendChildrenName(Geant4Basic, String)
- gemcStringAll(Geant4Basic)
- toMatrix(Vector3d)
- toVector3d(Matrix)
- toDoubleArray(Vector3d)
- toVector3D(double[])
- toVector3d(double[])
- createArrow(String, Vector3d, double, double, boolean, boolean, boolean)
- createArrow(String, Line3d, double, double, boolean, boolean, boolean)
- createArrow(String, double, double, double, boolean, boolean, boolean)
- convertRotationVectorToMatrix(double, double)
- convertRotationVectorToGeant(double, double)
- convertVectorDiffToAxisAngle(Vector3d, Vector3d)
- scalePosition(Geant4Basic, double)
- shiftPosition(Geant4Basic, double, double, double)
- subArraySum(int[], int)
- inputTaggedData(String, int)
- openOutputDataFile(String)
- writeLine(Writer, String)
- closeOutputDataFile(String, Writer)
Class Util
java.lang.Object
org.jlab.detector.geant4.v2.SVT.Util
Geometry Utility 
Universal class for a variety of useful methods.
- Vector manipulation: visualisation as volume, convert between Vector3D, Matrix and double[], convert difference to axis-angle rotation
- Volume manipulation: toString for GEMC, clone, append name, promote children, shift position, scale position
- Interfacing with Matrix to use appropriate rotation conversions for standard vectors and Geant
- File I/O
- Version:
- 1.1.2
- Author:
- pdavies
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic void
appendChildrenName
(Geant4Basic aVol, String aTag) Recursively appends the given tag to the name of the descendents of the given volume.static void
appendName
(Geant4Basic aVol, String aTag) Recursively appends the given tag to the name of the given volume and its descendents.static double[]
calcDistance
(Vector3d p0, Vector3d p1, double u0, double u1) Calculates the distance with uncertainty between two measured points.static void
closeOutputDataFile
(String aName, Writer aFile) Closes the given file.static double[]
convertRotationVectorToGeant
(double theta, double phi) Converts the given spherical angles to Tait-Bryan angles suitable for Geant4Basic rotations.static Matrix
convertRotationVectorToMatrix
(double theta, double phi) Converts the given spherical angles to a rotation matrix.static double[]
Calculates the difference between the two given direction vectors as an axis-angle rotation.static Geant4Basic
createArrow
(String aName, double aLen, double aCapRadius, double aPointerRadius, boolean aDisplayCapStart, boolean aDisplayPointer, boolean aDisplayCapEnd) Creates a cylinder, capped with two spheres, pointing in the direction of the given vector.static Geant4Basic
createArrow
(String aName, Vector3d aVec, double aCapRadius, double aPointerRadius, boolean aDisplayCapStart, boolean aDisplayPointer, boolean aDisplayCapEnd) static Geant4Basic
createArrow
(String aName, Line3d aLine, double aCapRadius, double aPointerRadius, boolean aDisplayCapStart, boolean aDisplayPointer, boolean aDisplayCapEnd) static String
gemcStringAll
(Geant4Basic aVol) Returns a string, in a format suitable for GEMC, of the given volume, including all children.static double[][]
inputTaggedData
(String aFilename, int recLen) Reads data from a file of the format: String, double[].static void
Replaces mother of children with mother of given volume, while preserving positions and rotations, and removes given volume from mother.static Writer
openOutputDataFile
(String aName) Opens a file ready for writing.static void
scalePosition
(Geant4Basic aVol, double aFactor) Recursively multiplies each position coordinate of the given volume and its children by the given scale factor.static void
shiftPosition
(Geant4Basic aVol, double aShiftX, double aShiftY, double aShiftZ) Deprecated.static int
subArraySum
(int[] aArray, int aIndex) Sums elements of aArray from 0 to (aIndex-1)static double[]
Converts the given vector to a double[] array.static Matrix
Converts the given vector to a column-based Matrix.static Vector3d
toVector3d
(double[] a) Converts the given double[] array to a vector.static Vector3d
toVector3d
(Matrix m) Converts the given column-based Matrix to a vector.static Vector3d
toVector3D
(double[] a) Converts the given double[] array to a vector.static void
Appends the given String to the given file.
-
Field Details
-
Constructor Details
-
Method Details
-
calcDistance
Calculates the distance with uncertainty between two measured points.- Parameters:
p0
- first pointp1
- second pointu0
- uncertainty in the measurement of the coordinates of the first pointu1
- uncertainty in the measurement of the coordinates of the second point- Returns:
- double[] an array containing a {value,uncertainty} pair
-
moveChildrenToMother
Replaces mother of children with mother of given volume, while preserving positions and rotations, and removes given volume from mother. Effectively promotes a given volume's children to the same rank as that volume in the tree hierarchy.- Parameters:
aVol
- volume whose children are to be moved
-
appendName
Recursively appends the given tag to the name of the given volume and its descendents.- Parameters:
aVol
- volumeaTag
- string to append
-
appendChildrenName
Recursively appends the given tag to the name of the descendents of the given volume.- Parameters:
aVol
- volumeaTag
- string to append
-
gemcStringAll
Returns a string, in a format suitable for GEMC, of the given volume, including all children.- Parameters:
aVol
- volume- Returns:
- String multiple lines of text
-
toMatrix
-
toVector3d
Converts the given column-based Matrix to a vector.- Parameters:
m
- matrix- Returns:
- Vector3D vector
- Throws:
IllegalArgumentException
- matrix wrong size
-
toDoubleArray
Converts the given vector to a double[] array.- Parameters:
v
- vector- Returns:
- double[] array
-
toVector3D
Converts the given double[] array to a vector.- Parameters:
a
- array- Returns:
- Vector3D vector
- Throws:
IllegalArgumentException
- array wrong size
-
toVector3d
Converts the given double[] array to a vector.- Parameters:
a
- array- Returns:
- Vector3d vector
- Throws:
IllegalArgumentException
- array wrong size
-
createArrow
public static Geant4Basic createArrow(String aName, Vector3d aVec, double aCapRadius, double aPointerRadius, boolean aDisplayCapStart, boolean aDisplayPointer, boolean aDisplayCapEnd) -
createArrow
public static Geant4Basic createArrow(String aName, Line3d aLine, double aCapRadius, double aPointerRadius, boolean aDisplayCapStart, boolean aDisplayPointer, boolean aDisplayCapEnd) -
createArrow
public static Geant4Basic createArrow(String aName, double aLen, double aCapRadius, double aPointerRadius, boolean aDisplayCapStart, boolean aDisplayPointer, boolean aDisplayCapEnd) Creates a cylinder, capped with two spheres, pointing in the direction of the given vector. Length of cylinder is equal to magnitude of vector.- Parameters:
aName
- subvolumes will have _arrow# appended to aNameaLen
- length of FIXMEaCapRadius
- radius of spherical capsaPointerRadius
- radius of cylindrical shaftaDisplayCapStart
- switch to show start capaDisplayPointer
- switch to show shaftaDisplayCapEnd
- switch to show end cap- Returns:
- Geant4Basic pseudo volume containing arrow components
-
convertRotationVectorToMatrix
Converts the given spherical angles to a rotation matrix. Tait-Bryan/Euler Intrinsic ZYX/Extrinsic XYZ.- Parameters:
theta
- elevation angle in radiansphi
- azimuth angle in radians- Returns:
- Matrix a column-based rotation matrix
-
convertRotationVectorToGeant
public static double[] convertRotationVectorToGeant(double theta, double phi) Converts the given spherical angles to Tait-Bryan angles suitable for Geant4Basic rotations. Tait-Bryan/Euler Intrinsic XYZ/Extrinsic ZYX. N.B. Geant = passive/alias, Java = active/alibi, so please negate the angles before passing to Geant4Basic.- Parameters:
theta
- elevation angle in radiansphi
- azimuth angle in radians- Returns:
- double[] xyz angles in radians
-
convertVectorDiffToAxisAngle
Calculates the difference between the two given direction vectors as an axis-angle rotation. http://math.stackexchange.com/questions/293116/rotating-one-3d-vector-to-another- Parameters:
a
- vectorb
- vector- Returns:
- double[] axis-angle rotation, format: { rx, ry, rz, ra }, angle in radians
-
scalePosition
Recursively multiplies each position coordinate of the given volume and its children by the given scale factor.- Parameters:
aVol
- volumeaFactor
- scale factor
-
shiftPosition
Deprecated.Translates the given volume's position by the given shifts.- Parameters:
aVol
- volumeaShiftX
- shiftaShiftY
- shiftaShiftZ
- shift
-
subArraySum
public static int subArraySum(int[] aArray, int aIndex) Sums elements of aArray from 0 to (aIndex-1)- Parameters:
aArray
- an array of intsaIndex
- a terminating index- Returns:
- int cumulative sum of elements
-
inputTaggedData
public static double[][] inputTaggedData(String aFilename, int recLen) throws IllegalArgumentException, IOException Reads data from a file of the format: String, double[].- Parameters:
aFilename
- name of filerecLen
- number of fields to read per record- Returns:
- double[][] array indexed as [record][field]
- Throws:
IllegalArgumentException
- null or empty filenameIOException
- incorrect record length
-
openOutputDataFile
Opens a file ready for writing. Terminates program if IOException occurs.- Parameters:
aName
- a file name- Returns:
- Writer a file handle
- Throws:
IllegalArgumentException
- null or empty filename
-
writeLine
-
closeOutputDataFile
-