DD4hep - The AIDA detector description toolkit for high energy physics experiments
DD4hep  Rev:Unversioneddirectory
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SegmentationUtil.h
Go to the documentation of this file.
1 /*
2  * SegmentationUtil.h
3  *
4  * Created on: Oct 31, 2013
5  * Author: Christian Grefe, CERN
6  */
7 
8 #ifndef DDSegmentation_SEGMENTATIONUTIL_H_
9 #define DDSegmentation_SEGMENTATIONUTIL_H_
10 
11 #include <cmath>
12 #include <vector>
13 
14 namespace DD4hep {
15 namespace DDSegmentation {
16 namespace Util {
17 
24 
25 
29 
30 
32 double magFromXYZ(const Vector3D& position) {
33  return std::sqrt(position.X * position.X + position.Y * position.Y + position.Z * position.Z);
34 }
35 
37 double radiusFromXYZ(const Vector3D& position) {
38  return std::sqrt(position.X * position.X + position.Y * position.Y);
39 }
40 
42 double thetaFromXYZ(const Vector3D& position) {
43  return std::acos(position.Z / radiusFromXYZ(position));
44 }
45 
47 double phiFromXYZ(const Vector3D& position) {
48  return std::atan2(position.Y, position.X);
49 }
50 
54 
56 Vector3D positionFromRPhiZ(double r, double phi, double z) {
57  return Vector3D(r * std::cos(phi), r * std::sin(phi), z);
58 }
59 
61 double magFromRPhiZ(double r, double /* phi */, double z) {
62  return std::sqrt(r * r + z * z);
63 }
64 
66 double xFromRPhiZ(double r, double phi, double /* z */) {
67  return r * std::cos(phi);
68 }
69 
71 double yFromRPhiZ(double r, double phi, double /* z */) {
72  return r * std::sin(phi);
73 }
74 
76 double thetaFromRPhiZ(double r, double /* phi */, double z) {
77  return r * std::atan(z / r);
78 }
79 
83 
85 Vector3D positionFromRThetaPhi(double r, double theta, double phi) {
86  return Vector3D(r * std::cos(phi), r * std::sin(phi), r * std::tan(theta));
87 }
88 
90 Vector3D positionFromMagThetaPhi(double mag, double theta, double phi) {
91  double r = mag * sin(theta);
92  return Vector3D(r * std::cos(phi), r * std::sin(phi), mag * std::cos(theta));
93 }
94 
95 } /* namespace Util */
96 } /* namespace DDSegmentation */
97 } /* namespace DD4hep */
98 
99 #endif /* DDSegmentation_SEGMENTATIONUTIL_H_ */
double magFromXYZ(const Vector3D &position)
Conversions from Cartesian to cylindrical/spherical coordinates ///.
double radiusFromXYZ(const Vector3D &position)
calculates the radius in the xy-plane from Cartesian coordinates
Vector3D positionFromMagThetaPhi(double mag, double theta, double phi)
calculates the Cartesian position from spherical coordinates
double thetaFromXYZ(const Vector3D &position)
calculates the polar angle theta from Cartesian coordinates
double yFromRPhiZ(double r, double phi, double)
calculates y from cylindrical coordinates
double magFromRPhiZ(double r, double, double z)
calculates the radius in xyz from cylindrical coordinates
double phiFromXYZ(const Vector3D &position)
calculates the azimuthal angle phi from Cartesian coordinates
Simple container for a physics vector.
Definition: Segmentation.h:41
double xFromRPhiZ(double r, double phi, double)
calculates x from cylindrical coordinates
double thetaFromRPhiZ(double r, double, double z)
calculates the polar angle theta from cylindrical coordinates
Vector3D positionFromRThetaPhi(double r, double theta, double phi)
Conversions from spherical to Cartesian coordinates ///.
Vector3D positionFromRPhiZ(double r, double phi, double z)
Conversions from cylindrical to Cartesian coordinates ///.