Jpp 19.3.0-rc.5
the software that should make you happy
Loading...
Searching...
No Matches
JSphere3D.cc File Reference

Example program to test 3D integration of sphere. More...

#include <string>
#include <iostream>
#include <iomanip>
#include "JTools/JMapList.hh"
#include "JTools/JFunction1D_t.hh"
#include "JTools/JFunctionalMap_t.hh"
#include "JTools/JMultiFunction.hh"
#include "JTools/JToolsToolkit.hh"
#include "JTools/JFunctionalMap.hh"
#include "Jeep/JPrint.hh"
#include "Jeep/JParser.hh"
#include "Jeep/JMessage.hh"

Go to the source code of this file.

Functions

int main (int argc, char **argv)
 

Detailed Description

Example program to test 3D integration of sphere.

Author
mdejong

Definition in file JSphere3D.cc.

Function Documentation

◆ main()

int main ( int argc,
char ** argv )

Definition at line 23 of file JSphere3D.cc.

24{
25 using namespace std;
26 using namespace JPP;
27
28 unsigned int numberOfBins;
29 int debug;
30
31 try {
32
33 JParser<> zap("Example program to test 3D integration of sphere.");
34
35 zap['N'] = make_field(numberOfBins) = 101;
36 zap['d'] = make_field(debug) = 3;
37
38 zap(argc, argv);
39 }
40 catch(const exception &error) {
41 FATAL(error.what() << endl);
42 }
43
44
45 const double R = 1.0;
46
47 typedef JGridPolint3Function1D_t JFunction1D_t;
48 typedef JMapList<JPolint3FunctionalGridMap> JMaplist_t;
49 typedef JMultiFunction<JFunction1D_t, JMaplist_t> JMultiFunction_t;
50
51
52 JMultiFunction_t ga;
53 JMultiFunction_t gb;
54
55 const double xmin = -R * 1.05;
56 const double xmax = +R * 1.05;
57 const double dx = (xmax - xmin) / (numberOfBins - 1);
58
59 for (double x = xmin; x < xmax + 0.5*dx; x += dx) {
60 for (double y = xmin; y < xmax + 0.5*dx; y += dx) {
61
62 const double z = R*R - x*x - y*y;
63
64 if (z > 0.0) {
65 ga[x][y] = -sqrt(z);
66 gb[x][y] = +sqrt(z);
67 } else {
68 ga[x][y] = 0.0;
69 gb[x][y] = 0.0;
70 }
71 }
72 }
73
74 ga.compile();
75 gb.compile();
76
77 cout << "Volume (real) " << SCIENTIFIC(12,4) << 4.0*PI*R*R*R/3.0 << endl;
78 cout << "Volume (calc) " << SCIENTIFIC(12,4) << getIntegral(gb) - getIntegral(ga) << endl;
79}
#define FATAL(A)
Definition JMessage.hh:67
int debug
debug level
Definition JSirene.cc:72
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition JParser.hh:2142
int numberOfBins
number of bins for average CDF integral of optical module
Definition JSirene.cc:73
Utility class to parse command line options.
Definition JParser.hh:1698
Multidimensional interpolation method.
const double xmax
const double xmin
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
JContainer_t::ordinate_type getIntegral(const JContainer_t &input)
Get integral of input data points.
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