VGM Version 5.3
Loading...
Searching...
No Matches
Units.cxx
Go to the documentation of this file.
1// $Id$
2
3// -----------------------------------------------------------------------
4// The ClhepVGM package of the Virtual Geometry Model
5// Copyright (C) 2007, Ivana Hrivnacova
6// All rights reserved.
7//
8// For the licensing terms see vgm/LICENSE.
9// Contact: ivana@ipno.in2p3.fr
10// -----------------------------------------------------------------------
11
12//
13// Class Units
14// ------------------
15// Conversion from CLHEP physical units to VGM units..
16//
17// Author: Ivana Hrivnacova; IPN Orsay
18
19#include "ClhepVGM/Units.h"
20
21#include "CLHEP/Units/SystemOfUnits.h"
22
23#include <cstdlib>
24#include <iostream>
25
26using CLHEP::atmosphere;
27using CLHEP::cm;
28using CLHEP::cm3;
29using CLHEP::deg;
30using CLHEP::g;
31using CLHEP::kelvin;
32using CLHEP::mm;
33using CLHEP::mole;
34
35//
36// static const data members
37//
38
39const double ClhepVGM::Units::fgkLength = 1. / mm;
40const double ClhepVGM::Units::fgkAngle = 1. / deg;
41const double ClhepVGM::Units::fgkMassDensity = 1. / (g / cm3);
42const double ClhepVGM::Units::fgkAtomicWeight = 1. / (g / mole);
43const double ClhepVGM::Units::fgkTemperature = 1. / kelvin;
44const double ClhepVGM::Units::fgkPressure = 1. / atmosphere;
45
46//_____________________________________________________________________________
51
52//_____________________________________________________________________________
57
58//
59// public functions
60//
61
62//_____________________________________________________________________________
64{
65 if (axis == VGM::kXAxis || axis == VGM::kYAxis || axis == VGM::kZAxis ||
66 axis == VGM::kRho || axis == VGM::kRadial3D) {
67
68 return Length();
69 }
70
71 if (axis == VGM::kPhi || axis == VGM::kSphTheta) {
72 return Angle();
73 }
74
75 // axis == kUndefined
76 std::cerr << " ClhepVGM::Units::AxisUnit:" << std::endl;
77 std::cerr << " Undefined axis" << std::endl;
78 std::cerr << "*** Error: Aborting execution ***" << std::endl;
79 exit(1);
80}
81
82//_____________________________________________________________________________
83double ClhepVGM::Units::Length() { return fgkLength; }
84
85//_____________________________________________________________________________
86double ClhepVGM::Units::Length(double clhepUnit)
87{
88 return fgkLength * clhepUnit;
89}
90
91//_____________________________________________________________________________
92double ClhepVGM::Units::Angle() { return fgkAngle; }
93
94//_____________________________________________________________________________
95double ClhepVGM::Units::Angle(double clhepUnit) { return fgkAngle * clhepUnit; }
96
97//_____________________________________________________________________________
98double ClhepVGM::Units::MassDensity() { return fgkMassDensity; }
99
100//_____________________________________________________________________________
101double ClhepVGM::Units::MassDensity(double clhepUnit)
102{
103 return fgkMassDensity * clhepUnit;
104}
105
106//_____________________________________________________________________________
107double ClhepVGM::Units::AtomicWeight() { return fgkAtomicWeight; }
108
109//_____________________________________________________________________________
110double ClhepVGM::Units::AtomicWeight(double clhepUnit)
111{
112 return fgkAtomicWeight * clhepUnit;
113}
114
115//_____________________________________________________________________________
116double ClhepVGM::Units::Temperature() { return fgkTemperature; }
117
118//_____________________________________________________________________________
119double ClhepVGM::Units::Temperature(double clhepUnit)
120{
121 return fgkTemperature * clhepUnit;
122}
123
124//_____________________________________________________________________________
125double ClhepVGM::Units::Pressure() { return fgkPressure; }
126
127//_____________________________________________________________________________
128double ClhepVGM::Units::Pressure(double clhepUnit)
129{
130 return fgkPressure * clhepUnit;
131}
virtual ~Units()
Definition Units.cxx:53
static double Temperature()
Return CLHEP default temperature unit in VGM unit.
Definition Units.cxx:116
static double AtomicWeight()
Return CLHEP default atomic weight unit in VGM units.
Definition Units.cxx:107
static double MassDensity()
Return CLHEP default mass density unit in VGM units.
Definition Units.cxx:98
static double Pressure()
Return CLHEP default pressure unit in VGM unit.
Definition Units.cxx:125
static double Length()
Return CLHEP default length unit in VGM units.
Definition Units.cxx:83
static double Angle()
Return CLHEP default angle unit in VGM units.
Definition Units.cxx:92
static double AxisUnit(VGM::Axis axis)
Convert CLHEP default unit for given axis type in VGM units.
Definition Units.cxx:63
VGM Axis enumeration.
@ kRho
Definition Axis.h:38
@ kPhi
Definition Axis.h:40
@ kYAxis
Definition Axis.h:36
@ kRadial3D
Definition Axis.h:39
@ kXAxis
Definition Axis.h:35
@ kZAxis
Definition Axis.h:37
@ kSphTheta
Definition Axis.h:41