MARLEY (Model of Argon Reaction Low Energy Yields) v2.0.0
A Monte Carlo event generator for tens-of-MeV neutrino interactions
Loading...
Searching...
No Matches
HepMC3::Units Class Reference

Stores units-related enums and conversion functions. More...

#include <Units.h>

Public Types

enum  LengthUnit { MM , CM }
 Position units. More...
 
enum  MomentumUnit { MEV , GEV }
 Momentum units. More...
 

Static Public Member Functions

template<typename T>
static void convert (T &m, LengthUnit from, LengthUnit to)
 Convert FourVector to different length unit.
 
template<typename T>
static void convert (T &m, MomentumUnit from, MomentumUnit to)
 Convert FourVector to different momentum unit.
 
static LengthUnit length_unit (const std::string &name)
 Get length unit based on its name.
 
static MomentumUnit momentum_unit (const std::string &name)
 Get momentum unit based on its name.
 
static std::string name (LengthUnit u)
 Get name of length unit.
 
static std::string name (MomentumUnit u)
 Get name of momentum unit.
 

Detailed Description

Stores units-related enums and conversion functions.

Manages units used by HepMC::GenEvent

Definition at line 26 of file Units.h.

Member Enumeration Documentation

◆ LengthUnit

Position units.

Definition at line 32 of file Units.h.

32{ MM, CM };

◆ MomentumUnit

Momentum units.

Definition at line 29 of file Units.h.

29{ MEV, GEV };

Member Function Documentation

◆ convert() [1/2]

template<typename T>
static void HepMC3::Units::convert ( T & m,
LengthUnit from,
LengthUnit to )
inlinestatic

Convert FourVector to different length unit.

Definition at line 96 of file Units.h.

96 {
97 if ( from == to ) return;
98
99 if ( from == CM ) {
100 // CM -> MM
101 m *= 10.0;
102 }
103 else if ( from == MM ) {
104 // MM -> CM
105 m *= 0.1;
106 }
107 }

◆ convert() [2/2]

template<typename T>
static void HepMC3::Units::convert ( T & m,
MomentumUnit from,
MomentumUnit to )
inlinestatic

Convert FourVector to different momentum unit.

Definition at line 81 of file Units.h.

81 {
82 if ( from == to ) return;
83
84 if ( from == GEV ) {
85 // GEV -> MEV
86 m *= 1000.;
87 }
88 else if ( from == MEV ) {
89 // MEV -> GEV
90 m *= 0.001;
91 }
92 }

Referenced by HepMC3::GenEvent::set_units().

◆ length_unit()

static LengthUnit HepMC3::Units::length_unit ( const std::string & name)
inlinestatic

Get length unit based on its name.

Definition at line 46 of file Units.h.

46 {
47 if ( name.compare(0,2,"CM") == 0 ) return CM;
48 if ( name.compare(0,2,"MM") == 0 ) return MM;
49
50 HEPMC3_ERROR_LEVEL(300,"Units::length_unit: unrecognised unit name: '" << name <<"', setting to CM" )
51
52 return CM;
53 }
static std::string name(MomentumUnit u)
Get name of momentum unit.
Definition Units.h:56

References name().

◆ momentum_unit()

static MomentumUnit HepMC3::Units::momentum_unit ( const std::string & name)
inlinestatic

Get momentum unit based on its name.

Definition at line 36 of file Units.h.

36 {
37 if ( name.compare(0,3,"GEV") == 0 ) return GEV;
38 if ( name.compare(0,3,"MEV") == 0 ) return MEV;
39
40 HEPMC3_ERROR_LEVEL(300,"Units::momentum_unit: unrecognised unit name: '" << name <<"', setting to GEV" )
41
42 return GEV;
43 }

References name().

◆ name() [1/2]

static std::string HepMC3::Units::name ( LengthUnit u)
inlinestatic

Get name of length unit.

Definition at line 68 of file Units.h.

68 {
69 switch(u) {
70 case MM:
71 return "MM";
72 case CM:
73 return "CM";
74 }
75
76 return "<UNDEFINED>";
77 }

◆ name() [2/2]

static std::string HepMC3::Units::name ( MomentumUnit u)
inlinestatic

Get name of momentum unit.

Definition at line 56 of file Units.h.

56 {
57 switch(u) {
58 case MEV:
59 return "MEV";
60 case GEV:
61 return "GEV";
62 }
63
64 return "<UNDEFINED>";
65 }

Referenced by length_unit(), HepMC3::Print::listing(), momentum_unit(), and HepMC3::WriterAscii::write_event().


The documentation for this class was generated from the following file: