Logo ROOT   6.21/01
Reference Guide
TGeoUnit.cxx
Go to the documentation of this file.
1 // @(#)root/geom:$Id$
2 // Author: Markus Frank 25/06/19
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 /** \class TGeoUnit
13 \ingroup Geometry_classes
14 
15 Base class describing materials.
16 
17 */
18 #include "TError.h"
19 #include "TGeoSystemOfUnits.h"
20 #include "TGeant4SystemOfUnits.h"
21 
22 namespace {
23  static bool s_type_changed = false;
24  union _unit_type {
25  TGeoUnit::UnitType tgeo_unit_type;
27  _unit_type(TGeoUnit::UnitType t) { tgeo_unit_type = t; }
29 }
30 
31 TGeoUnit::UnitType TGeoUnit::unitType() {
32  return s_unit_type.tgeo_unit_type;
33 }
34 
35 TGeoUnit::UnitType TGeoUnit::setUnitType(UnitType new_type) {
36  UnitType tmp = s_unit_type.tgeo_unit_type;
37  if ( !s_type_changed || new_type == s_unit_type.tgeo_unit_type ) {
38  s_unit_type.tgeo_unit_type = new_type;
39  s_type_changed = true;
40  return tmp;
41  }
42  Fatal("TGeoUnit","The system of units may only be changed once at the beginning of the program!");
43  return tmp;
44 }
45 
47  return s_unit_type.tgeant4_unit_type;
48 }
49 
51  UnitType tmp = s_unit_type.tgeant4_unit_type;
52  if ( !s_type_changed || new_type == s_unit_type.tgeant4_unit_type ) {
53  s_unit_type.tgeant4_unit_type = new_type;
54  s_type_changed = true;
55  return tmp;
56  }
57  Fatal("TGeoUnit","The system of units may only be changed once at the beginning of the program!");
58  return tmp;
59 }
UnitType setUnitType(UnitType new_type)
Set the currently used unit type (Only ONCE possible)
TGeoBBoxEditor s_unit_type
void Fatal(const char *location, const char *msgfmt,...)
TGeant4Unit::UnitType tgeant4_unit_type
Definition: TGeoUnit.cxx:25
UnitType
System of units flavor. Must be kept in sync with TGeoUnits::UnitType.
UnitType unitType()
Access the currently set units type.
TGeoUnit::UnitType tgeo_unit_type
Definition: TGeoUnit.cxx:24
_unit_type(TGeoUnit::UnitType t)
Definition: TGeoUnit.cxx:26
UnitType setUnitType(UnitType new_type)
Set the currently used unit type (Only ONCE possible)
Definition: TGeoUnit.cxx:50
UnitType unitType()
Access the currently set units type.
Definition: TGeoUnit.cxx:46