Jpp test-rotations-old-533-g2bdbdb559
the software that should make you happy
Loading...
Searching...
No Matches
JSeaWater.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <cmath>
4
6
7#include "JLang/JManip.hh"
8
9#include "Jeep/JParser.hh"
10
11
12namespace {
13
14 /**
15 * Write atomic parameters of sea water to output stream.
16 *
17 * \param out output stream
18 * \param object atomic parameters
19 * \return output stream
20 */
21 inline std::ostream& operator<<(std::ostream& out, const JPHYSICS::JSeaWater::atom_type& object)
22 {
23 using namespace std;
24
25 return out << setw(2) << left << object.ps << right << ' '
26 << FIXED(5,1) << object.Z << ' '
27 << FIXED(5,1) << object.A << ' '
28 << FIXED(7,4) << object.f;
29 }
30}
31
32int main(int argc, char **argv)
33{
34 using namespace std;
35 using namespace JPP;
36
37 double precision;
38 int debug;
39
40 try {
41
42 JParser<> zap;
43
44 zap['p'] = make_field(precision) = 1.0e-10;
45 zap['d'] = make_field(debug) = 3;
46
47 zap(argc, argv);
48 }
49 catch(const exception &error) {
50 FATAL(error.what() << endl);
51 }
52
53
54 {
55 double F = 0.0;
56
57#ifndef RADIATION
58 const auto buffer = { JSeaWater::O, JSeaWater::H, JSeaWater::Na, JSeaWater::Cl };
59#else
60 const auto buffer = { JSeaWater::O, JSeaWater::H, JSeaWater::Na, JSeaWater::Cl, JSeaWater::Ca, JSeaWater::Mg, JSeaWater::K, JSeaWater::S };
61#endif
62 for (const auto& i : buffer) {
63
64 cout << i << endl;
65
66 F += i.f;
67 }
68
69 ASSERT(fabs(F - 1.0) <= precision, "Test total mass fraction " << SCIENTIFIC(12,3) << (F - 1.0));
70 }
71}
I/O manipulators.
#define ASSERT(A,...)
Assert macro.
Definition JMessage.hh:90
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
Utility class to parse command line options.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int main(int argc, char **argv)
Definition JSeaWater.cc:32
Utility class to parse command line options.
Definition JParser.hh:1698
std::ostream & operator<<(std::ostream &stream, const CLBCommonHeader &header)
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Definition JManip.hh:448
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488