Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
JSphere3D.cc
Go to the documentation of this file.
1#include <string>
2#include <iostream>
3#include <iomanip>
4
5#include "JTools/JMapList.hh"
11
12#include "Jeep/JPrint.hh"
13#include "Jeep/JParser.hh"
14#include "Jeep/JMessage.hh"
15
16
17/**
18 * \file
19 *
20 * Example program to test 3D integration of sphere.
21 * \author mdejong
22 */
23int main(int argc, char **argv)
24{
25 using namespace std;
26
27 unsigned int numberOfBins;
28 int debug;
29
30 try {
31
32 JParser<> zap("Example program to test 3D integration of sphere.");
33
34 zap['N'] = make_field(numberOfBins) = 101;
35 zap['d'] = make_field(debug) = 3;
36
37 zap(argc, argv);
38 }
39 catch(const exception &error) {
40 FATAL(error.what() << endl);
41 }
42
43
44 using namespace JPP;
45
46
47 const double R = 1.0;
48
49 typedef JGridPolint3Function1D_t JFunction1D_t;
50 typedef JMapList<JPolint3FunctionalGridMap> JMaplist_t;
51 typedef JMultiFunction<JFunction1D_t, JMaplist_t> JMultiFunction_t;
52
53
54 JMultiFunction_t ga;
55 JMultiFunction_t gb;
56
57 const double xmin = -R * 1.05;
58 const double xmax = +R * 1.05;
59 const double dx = (xmax - xmin) / (numberOfBins - 1);
60
61 for (double x = xmin; x < xmax + 0.5*dx; x += dx) {
62 for (double y = xmin; y < xmax + 0.5*dx; y += dx) {
63
64 const double z = R*R - x*x - y*y;
65
66 if (z > 0.0) {
67 ga[x][y] = -sqrt(z);
68 gb[x][y] = +sqrt(z);
69 } else {
70 ga[x][y] = 0.0;
71 gb[x][y] = 0.0;
72 }
73 }
74 }
75
76 ga.compile();
77 gb.compile();
78
79 cout << "Volume (real) " << SCIENTIFIC(12,4) << 4.0*PI*R*R*R/3.0 << endl;
80 cout << "Volume (calc) " << SCIENTIFIC(12,4) << getIntegral(gb) - getIntegral(ga) << endl;
81}
Various implementations of functional maps.
General purpose messaging.
#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
I/O formatting auxiliaries.
int numberOfBins
number of bins for average CDF integral of optical module
Definition JSirene.cc:73
int main(int argc, char **argv)
Definition JSphere3D.cc:23
This include file contains various recursive methods to operate on multi-dimensional collections.
Utility class to parse command line options.
Definition JParser.hh:1698
Multidimensional interpolation method.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Type definition of a 3rd degree polynomial interpolation based on a JGridCollection with result type ...
Map list.
Definition JMapList.hh:25
Auxiliary data structure for floating point format specification.
Definition JManip.hh:488