LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
energy.h
Go to the documentation of this file.
1 
18 #ifndef LARDATAALG_UTILITIES_QUANTITIES_ENERGY_H
19 #define LARDATAALG_UTILITIES_QUANTITIES_ENERGY_H
20 
21 // LArSoft libraries
23 
24 // C/C++ standard libraries
25 #include <ratio>
26 #include <string_view>
27 
28 //------------------------------------------------------------------------------
29 namespace util::quantities {
30 
31  namespace units {
32 
33  using namespace std::string_view_literals; // for operator""sv()
34 
35  struct ElectronVolt : public concepts::UnitBase {
36  static constexpr auto symbol = "eV"sv;
37  static constexpr auto name = "electronvolt"sv;
38  };
39 
40  } // namespace units
41 
42  // -- BEGIN Particle energy --------------------------------------------------
58 
61  template <typename R, typename T = double>
63 
64  //
65  // electronvolt
66  //
68  template <typename T = double>
70 
73 
74  //
75  // microelectronvolt
76  //
78  template <typename T = double>
80 
83 
84  //
85  // millielectronvolt
86  //
88  template <typename T = double>
90 
93 
94  //
95  // kiloelectronvolt
96  //
98  template <typename T = double>
100 
103 
104  //
105  // megaelectronvolt
106  //
108  template <typename T = double>
110 
113 
114  //
115  // gigaelectronvolt
116  //
118  template <typename T = double>
120 
123 
124  //
125  // teraelectronvolt
126  //
128  template <typename T = double>
130 
133 
135  // -- END Particle energy ----------------------------------------------------
136 
154  namespace energy_literals {
155 
156  // @{
158  constexpr electronvolt operator""_eV(long double v)
159  {
160  return electronvolt{static_cast<double>(v)};
161  }
162  constexpr electronvolt operator""_eV(unsigned long long int v)
163  {
164  return electronvolt{static_cast<double>(v)};
165  }
166  // @}
167 
168  // @{
170  constexpr microelectronvolt operator""_ueV(long double v)
171  {
172  return microelectronvolt{static_cast<double>(v)};
173  }
174  constexpr microelectronvolt operator""_ueV(unsigned long long int v)
175  {
176  return microelectronvolt{static_cast<double>(v)};
177  }
178  // @}
179 
180  // @{
182  constexpr millielectronvolt operator""_meV(long double v)
183  {
184  return millielectronvolt{static_cast<double>(v)};
185  }
186  constexpr millielectronvolt operator""_meV(unsigned long long int v)
187  {
188  return millielectronvolt{static_cast<double>(v)};
189  }
190  // @}
191 
192  // @{
194  constexpr kiloelectronvolt operator""_keV(long double v)
195  {
196  return kiloelectronvolt{static_cast<double>(v)};
197  }
198  constexpr kiloelectronvolt operator""_keV(unsigned long long int v)
199  {
200  return kiloelectronvolt{static_cast<double>(v)};
201  }
202  // @}
203 
204  // @{
206  constexpr megaelectronvolt operator""_MeV(long double v)
207  {
208  return megaelectronvolt{static_cast<double>(v)};
209  }
210  constexpr megaelectronvolt operator""_MeV(unsigned long long int v)
211  {
212  return megaelectronvolt{static_cast<double>(v)};
213  }
214  // @}
215 
216  // @{
218  constexpr gigaelectronvolt operator""_GeV(long double v)
219  {
220  return gigaelectronvolt{static_cast<double>(v)};
221  }
222  constexpr gigaelectronvolt operator""_GeV(unsigned long long int v)
223  {
224  return gigaelectronvolt{static_cast<double>(v)};
225  }
226  // @}
227 
228  // @{
230  constexpr teraelectronvolt operator""_TeV(long double v)
231  {
232  return teraelectronvolt{static_cast<double>(v)};
233  }
234  constexpr teraelectronvolt operator""_TeV(unsigned long long int v)
235  {
236  return teraelectronvolt{static_cast<double>(v)};
237  }
238  // @}
239 
240  } // energy_literals
241 
242 } // namespace util::quantities
243 
244 //------------------------------------------------------------------------------
245 
246 #endif // LARDATAALG_UTILITIES_QUANTITIES_ENERGY_H
A value measured in the specified unit.
Definition: quantities.h:554
Numeric variable proxies with embedded unit of measurement.
Types of variables with a unit.
Definition: intervals.h:20