Title: CLHEP Components
1CLHEP Components
2Geant4 and CLHEP
- Geant4 makes a rather substantial use of CLHEP
components - System of units
- Vector classes and matrices
- G4ThreeVector (typedef to Hep3Vector)
- G4RotationMatrix (typedef to HepRotation)
- G4LorentzVector (typedef to HepLorentzVector)
- G4LorentzRotation (typedef to HepLorentzRotation)
- Geometrical classes
- G4Plane3D (typedef to HepPlane3D)
- G4Transform3D (typedef to HepTransform3D)
- G4Normal3D (typedef to HepNormal3D)
- G4Point3D (typedef to HepPoint3D)
- G4Vector3D (typedef to HepVector3D)
3System of units
- Geant4 offers the possibility to choose and use
the units one prefers for any quantity - Geant4 uses an internal and consistent set of
units based on - millimeter (mm)
- nanosecond (ns)
- Mega electron Volt (MeV)
- Positron charge (eplus)
- Degree Kelvin (kelvin)
- Amount of substance (mole)
- Luminosity intensity (candela)
- Radian (radian)
- steradian (steradian)
4System of units (2)
- All the units are defined from the basic ones
- These definitions are available in the file
- source/global/management/include/SystemOfUnits
- and are now part of CLHEP
- The user is free to change the system of units to
be used by the kernel
millimetermm1 meter m 1000mm . m3
mmm ..
5System of units (3)
- Avoid hard coded data
- you better specify the unit of the data you are
going to introduce - The Geant4 code is written respecting these
specification and this makes the code independent
from the system of units chosen by the user - Be careful!!!
- Some built-in commands for the User interface
require the unit to be specified
G4double Size 15.km, KineticEnergy 90.3GeV,
density 11mg/cm3
G4double radius10.m // internally
converted radius10000 . G4double xposition
(radiuscos(alpharad))cm // is this really what
you want to do?? G4double yposition
(radiussin(alpharad))cm
/gun/energy 10 GeV
6System of units (4)
- To output the data on the unit you wish you must
DIVIDE the data by the corresponding unit - You can let Geant4 decide which is the most
appropriate unit to represent your data. It is
just sufficient to specify which category
(length, time, energy) does it belong to - You can print the whole table of units by using
the static function
cout ltlt KineticEnergy/KeV ltlt KeV ltltendl
cout ltlt G4BestUnit(StepSize, Length) ltltendl
G4UnitDefinitionPrintUnitsTable
7System of units (5)
- You may introduce new units if you wish
- by completing the file SystemOfUnits.hh
- by using the class G4UnitDefinition and creating
a new object of it - G4UnitDefinition (name, symbol, category, value)
include SystemOfUnits.hh static const G4double
inch 2.54cm
G4UnitDefinition (inch,in,Length,25.4mm)
83-Vectors
- Geant4 makes use of the CLHEP HepVector3D and
Hep3Vector for implementing several 3-dimensional
object (G4ThreeVector, G4ParticleMomentum) - The definition of a 3-vector is pretty
straightforward - G4ThreeVector pnew G4ThreeVector(10,20,100)
- Every component can be accessed very easily
- G4double pxp-gtx()
- and set very easily
- p-gtsetZ(50)
- the components in polar coordinates are give by
- phi(), theta(), mag()
- and set using
- setPhi(), setTheta(), setMag()
93-Vectors (2)
- They can be normalized
- p-gtunit()
- rotated around one of the cartesian axes
- p-gtrotateY(2.73)
- or around any other 3-vector
- p-gtrotate(1.57,G4ThreeVector(10,20,30))
- for reference
- CLHEP_BASE_DIR/include/CLHEP/Vector/ThreeVector.h
- wwwinfo.cern.ch/asd/lhc/clhep/manual/RefGuide/Ve
ctor/Hep3Vector.html
10Rotation Matrices
- Geant4 uses the rotation matrix implementation
which comes with CLHEP (HepRotation, typedefd
into G4RotationMatrix) - include G4RotationMatrix.hh
- .
- G4RotationMatrix rm new G4RotationMatrix
- You can then rotate about the coordinate axes
- rm-gtrotateX(45deg) // rotation about X
- and combine several rotations into a 3D one
- rm-gtrotateX(30deg)
- rm-gtrotateY(20deg)
11Rotation Matrices (2)
- You can rotate about a specified vector
- rm-gtrotate(45deg,Hep3Vector(1.,1.,.3))
- or specify the direction of the three cartesian
axes after the rotation - rm-gtrotateAxes( Hep3Vector(-sin(a),0,cos(a)),
- Hep3Vector(cos(a),0,sin(a)),
- Hep3Vector(0,1,0))
- a rotation matrix can be inverted by using the
invert method - rm-gtinvert()
12Rotation Matrices (3)
- The angles made by the rotated axes against the
original axes can be obtained with the set of
functions - phiX(),phiY(),phiZ(),thetaX(),thetaY(),thetaZ()
- or one can get the rotation angle and the
rotation axis (awkward) - G4double angle
- G4ThreeVector axis
- rm-gtgetAngleAxis(angle,axis)
- to reset a rotation matrix use the default
constructor - rmG4RotationMatrix()
- documentation at
- CLHEP_BASE_DIR/include/CLHEP/Vector/Rotation.h
- wwwinfo.cern.ch/asd/lhc/clhep/manual/RefGuide/Ve
ctor/HepRotation.html