Hammer  1.0.0
Helicity Amplitude Module for Matrix Element Reweighting
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Units.hh
Go to the documentation of this file.
1 ///
2 /// @file Units.hh
3 /// @brief Unit conversion factors
4 ///
5 
6 //**** This file is a part of the HAMMER library
7 //**** Copyright (C) 2016 - 2020 The HAMMER Collaboration
8 //**** HAMMER is licensed under version 3 of the GPL; see COPYING for details
9 //**** Please note the MCnet academic guidelines; see GUIDELINES for details
10 
11 // -*- C++ -*-
12 #ifndef HAMMER_MATH_UNITS
13 #define HAMMER_MATH_UNITS
14 
15 #include <map>
16 
17 namespace Hammer {
18 
19  static const double eV = 1.e-9;
20  static const double eV2 = eV*eV;
21  static const double keV = 1.e-6;
22  static const double keV2 = keV*keV;
23  static constexpr double MeV = 1.e-3;
24  static constexpr double MeV2 = MeV*MeV;
25  static constexpr double GeV = 1.;
26  static constexpr double GeV2 = GeV*GeV;
27  static const double TeV = 1.e3;
28  static const double TeV2 = TeV*TeV;
29 
30  // static const double cm =
31 
32  /// @brief Hammer class for dealing with units
33  ///
34  /// Organized as a singleton accessed by the `instance()` method
35  ///
36  /// @ingroup Math
37 
38  class Units {
39 
40  protected:
41  Units() {
42  }
43 
44  Units(const Units&) = delete;
45  Units& operator=(const Units&) = delete;
46  Units(Units&&) = delete;
47  Units& operator=(Units&&) = delete;
48  ~Units() = default;
49 
50  /// @brief
51  /// @return
52  static Units* getUnitsInstance();
53 
54  /// @brief initializes the units map
55  void init();
56 
57  public:
58  /// @brief
59  /// @return
60  static Units& instance();
61 
62  /// @brief
63  /// @return
64  double getUnitsRescalingToMC(std::string mcunits, std::string localunits) const;
65 
66  private:
67  static Units* _theUnits;
68 
69  std::map<std::string, double> _unitfactors;
70 
71  };
72 
73 } // namespace Hammer
74 
75 #endif
static const double keV2
Definition: Units.hh:22
static constexpr double MeV
Definition: Units.hh:23
void init()
initializes the units map
Definition: Units.cc:34
Hammer class for dealing with units.
Definition: Units.hh:38
static Units * _theUnits
Definition: Units.hh:67
static Units * getUnitsInstance()
Definition: Units.cc:22
~Units()=default
static const double TeV2
Definition: Units.hh:28
static constexpr double GeV
Definition: Units.hh:25
static constexpr double GeV2
Definition: Units.hh:26
static constexpr double MeV2
Definition: Units.hh:24
Units & operator=(const Units &)=delete
static Units & instance()
Definition: Units.cc:30
static const double eV
Definition: Units.hh:19
static const double TeV
Definition: Units.hh:27
static const double keV
Definition: Units.hh:21
static const double eV2
Definition: Units.hh:20
std::map< std::string, double > _unitfactors
Definition: Units.hh:69
double getUnitsRescalingToMC(std::string mcunits, std::string localunits) const
Definition: Units.cc:53