All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Functions
testPhysicalConstants.cc File Reference
#include <iostream>
#include <iomanip>
#include <sstream>
#include "larcoreobj/SimpleTypesAndConstants/PhysicalConstants.h"

Go to the source code of this file.

Functions

int main ()
 

Function Documentation

int main ( )

Definition at line 10 of file testPhysicalConstants.cc.

10  {
11 
12  int nbad=0;
13 
14  std::ostringstream os1, os2;
15  os1 << std::setprecision(8) << util::kRecombk;
16  os2 << "0.0486";
17  if( os1.str() != os2.str() ) {
18  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
19  nbad++;
20  }
21  os1.str(std::string());
22  os2.str(std::string());
23  os1 << std::setprecision(8) << util::kRecombA;
24  os2 << "0.8";
25  if( os1.str() != os2.str() ) {
26  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
27  nbad++;
28  }
29  os1.str(std::string());
30  os2.str(std::string());
31  os1 << std::fixed << std::showpoint << std::setprecision(3) << util::kModBoxA ;
32  os2 << "0.930";
33  if( os1.str() != os2.str() ) {
34  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
35  nbad++;
36  }
37  os1.str(std::string());
38  os2.str(std::string());
39  os1 << util::kModBoxB;
40  os2 << "0.212";
41  if( os1.str() != os2.str() ) {
42  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
43  nbad++;
44  }
45  os1.str(std::string());
46  os2.str(std::string());
47  os1 << util::kGeVToElectrons;
48  os2 << "42370000.000";
49  if( os1.str() != os2.str() ) {
50  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
51  nbad++;
52  }
53  os1.str(std::string());
54  os2.str(std::string());
55  os1 << std::setprecision(1) << util::kMeterToCentimeter;
56  os2 << "100.0";
57  if( os1.str() != os2.str() ) {
58  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
59  nbad++;
60  }
61  os1.str(std::string());
62  os2.str(std::string());
63  os1 << std::setprecision(4) << util::kCentimeterToMeter;
64  os2 << "0.0100";
65  if( os1.str() != os2.str() ) {
66  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
67  nbad++;
68  }
69  os1.str(std::string());
70  os2.str(std::string());
72  os2 << "0.0010";
73  if( os1.str() != os2.str() ) {
74  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
75  nbad++;
76  }
77  os1.str(std::string());
78  os2.str(std::string());
80  os2 << "1000.0000";
81  if( os1.str() != os2.str() ) {
82  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
83  nbad++;
84  }
85  os1.str(std::string());
86  os2.str(std::string());
87  os1 << std::setprecision(6) << util::keVToMeV;
88  os2 << "0.000001";
89  if( os1.str() != os2.str() ) {
90  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
91  nbad++;
92  }
93  os1.str(std::string());
94  os2.str(std::string());
95  os1 << std::setprecision(1) << util::kMeVToeV;
96  os2 << "1000000.0";
97  if( os1.str() != os2.str() ) {
98  std::cout << "compare --" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
99  nbad++;
100  }
101  //static constexpr double kBogusD = -999.; ///< obviously bogus double value
102  //static constexpr int kBogusI = -999; ///< obviously bogus integer value
103  //static constexpr float kBogusF = -999.; ///< obviously bogus float value
104  //static constexpr double quietCompiler = kBogusD*kBogusI*kBogusF*kRecombA*kRecombk*kGeVToElectrons;
105  os1.str(std::string());
106  os2.str(std::string());
107  os1 << std::setprecision(1) << util::kBogusD;
108  os2 << "-999.0";
109  if( os1.str() != os2.str() ) {
110  std::cout << "compare ->" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
111  nbad++;
112  }
113  os1.str(std::string());
114  os1 << std::setprecision(1) << util::kBogusF;
115  if( os1.str() != os2.str() ) {
116  std::cout << "compare ->" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
117  nbad++;
118  }
119  os1.str(std::string());
120  os2.str(std::string());
121  os1 << std::setprecision(1) << util::kBogusI;
122  os2 << "-999";
123  if( os1.str() != os2.str() ) {
124  std::cout << "compare ->" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
125  nbad++;
126  }
127  os1.str(std::string());
128  os2.str(std::string());
129  os1 << std::setprecision(1) << util::quietCompiler;
130  os2 << "-1642408503589454.5";
131  if( os1.str() != os2.str() ) {
132  std::cout << "compare ->" << os1.str() << "-- to --" << os2.str() << "--" << std::endl;
133  nbad++;
134  }
135 
136  // just exercise the conversion functions
138  util::DegreesToRadians(util::RadiansToDegrees(util::pi<double>()));
139  util::DegreesToRadians(util::RadiansToDegrees(util::pi<long double>()));
140 
141  return nbad;
142 
143 }
constexpr int kBogusI
obviously bogus integer value
constexpr double keVToMeV
1e6 eV = 1 MeV
constexpr double kGeVToElectrons
23.6eV per ion pair, 1e9 eV/GeV
constexpr double kModBoxB
Modified Box Beta in g/(MeV cm)*kV/cm.
constexpr T DegreesToRadians(T angle)
Converts the argument angle from degrees into radians.
constexpr double kCentimeterToMeter
constexpr double kMeterToKilometer
1000 m = 1 km
constexpr double kKilometerToMeter
constexpr double kMeVToeV
constexpr double quietCompiler
constexpr float kBogusF
obviously bogus float value
constexpr double kRecombk
constexpr T RadiansToDegrees(T angle)
Converts the argument angle from radians into degrees ( )
constexpr double kBogusD
obviously bogus double value
constexpr double kRecombA
A constant.
constexpr double kModBoxA
Modified Box Alpha.
constexpr double kMeterToCentimeter
1 m = 100 cm
BEGIN_PROLOG could also be cout