1 / 12

CLHEP Components

CLHEP Components. Geant4 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)

lev
Download Presentation

CLHEP Components

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CLHEP Components

  2. Geant4 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)

  3. System 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)

  4. System of units (2) millimeter=mm=1; meter = m = 1000*mm; ……. m3 = m*m*m; …….. • 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

  5. System 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.3*GeV, density = 11*mg/cm3; G4double radius=10.*m; // internally converted: radius=10000 …. G4double xposition = (radius*cos(alpha*rad))*cm // is this really what you want to do?? G4double yposition = (radius*sin(alpha*rad))*cm /gun/energy 10 GeV

  6. System 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 << KineticEnergy/KeV << “ KeV “<<endl; cout << G4BestUnit(StepSize, “Length”) <<endl G4UnitDefinition::PrintUnitsTable

  7. System 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.54*cm; G4UnitDefinition (“inch”,”in”,”Length”,25.4*mm);

  8. 3-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 *p=new G4ThreeVector(10,20,100); • Every component can be accessed very easily: G4double px=p->x(); • and set very easily; p->setZ(50); • the components in polar coordinates are give by phi(), theta(), mag() • and set using: setPhi(), setTheta(), setMag()

  9. 3-Vectors (2) • They can be normalized: p->unit(); • rotated around one of the cartesian axes p->rotateY(2.73); • or around any other 3-vector p->rotate(1.57,G4ThreeVector(10,20,30)); • for reference: $CLHEP_BASE_DIR/include/CLHEP/Vector/ThreeVector.h wwwinfo.cern.ch/asd/lhc++/clhep/manual/RefGuide/Vector/Hep3Vector.html

  10. Rotation Matrices • Geant4 uses the rotation matrix implementation which comes with CLHEP (HepRotation, typedef’d into G4RotationMatrix) #include “G4RotationMatrix.hh” …. G4RotationMatrix *rm = new G4RotationMatrix; • You can then rotate about the coordinate axes: rm->rotateX(45*deg); // rotation about X • and combine several rotations into a 3D one: rm->rotateX(30*deg); rm->rotateY(20*deg);

  11. Rotation Matrices (2) • You can rotate about a specified vector rm->rotate(45*deg,Hep3Vector(1.,1.,.3)); • or specify the direction of the three cartesian axes after the rotation rm->rotateAxes( 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->invert();

  12. Rotation 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->getAngleAxis(angle,axis); • to reset a rotation matrix use the default constructor *rm=G4RotationMatrix(); • documentation at: $CLHEP_BASE_DIR/include/CLHEP/Vector/Rotation.h wwwinfo.cern.ch/asd/lhc++/clhep/manual/RefGuide/Vector/HepRotation.html

More Related