Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JMath
JMath/JLegendre.cc
Go to the documentation of this file.
1
#include <string>
2
#include <iostream>
3
#include <iomanip>
4
5
#include "TRandom3.h"
6
7
#include "
JMath/JLegendre.hh
"
8
#include "
JMath/JMathSupportkit.hh
"
9
10
#include "
JTools/JQuantile.hh
"
11
12
#include "
Jeep/JParser.hh
"
13
#include "
Jeep/JMessage.hh
"
14
15
16
17
/**
18
* \file
19
*
20
* Example program to test Legendre polynome.
21
* \author mdejong
22
*/
23
int
main
(
int
argc,
char
**argv)
24
{
25
using namespace
std;
26
using namespace
JPP;
27
28
const
double
xmin = -10.0;
29
const
double
xmax = +10.0;
30
31
typedef
JLegendre<double> JLegendre_t;
32
33
unsigned
int
numberOfEvents;
34
unsigned
int
numberOfBins
;
35
JLegendre_t f1(xmin, xmax);
36
int
debug
;
37
38
try
{
39
40
JParser<>
zap(
"Example program to test Legendre polynome."
);
41
42
zap[
'n'
] =
make_field
(numberOfEvents) = 0;
43
zap[
'N'
] =
make_field
(
numberOfBins
) = 10;
44
zap[
'L'
] =
make_field
(f1);
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
map<double, double>
data;
55
56
for
(
unsigned
int
i = 0; i !=
numberOfBins
; ++i) {
57
58
const
double
x = xmin + i * (xmax - xmin) / (
numberOfBins
- 1);
59
60
data[x] = f1(x);
61
}
62
63
for
(
map<double, double>::const_iterator
i = data.begin(); i != data.end(); ++i) {
64
DEBUG
(
"data: "
<<
FIXED
(7,3) << i->first <<
' '
<<
FIXED
(7,3) << i->second << endl);
65
}
66
67
68
const
size_t
N
= 3;
69
70
JLegendre<double, N>
g1
(data.begin(), data.end());
71
72
for
(
size_t
n
= 0;
n
!=
N
+ 1; ++
n
) {
73
STATUS
(
"Legendre: "
<< setw(2) <<
n
<<
' '
<<
FIXED
(7,3) <<
g1
[
n
] << endl);
74
}
75
76
if
(numberOfEvents > 0) {
77
78
JQuantile Q;
79
80
for
(
unsigned
int
i = 0; i != numberOfEvents; ++i) {
81
82
const
double
x = gRandom->Uniform(xmin, xmax);
83
const
double
y = f1(x);
84
const
double
z =
g1
(x);
85
86
Q.put(y - z);
87
}
88
89
Q.print(cout);
90
}
91
92
return
0;
93
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1500
JMathSupportkit.hh
Auxiliary methods for mathematics.
std::map
Definition:
JSTDTypes.hh:16
STATUS
#define STATUS(A)
Definition:
JMessage.hh:63
JLegendre.hh
FIXED
Auxiliary data structure for floating point format specification.
Definition:
JManip.hh:445
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1961
debug
int debug
debug level
Definition:
JSirene.cc:63
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JParser.hh
Utility class to parse command line options.
n
alias put_queue eval echo n
Definition:
qlib.csh:19
JQuantile.hh
N
then usage $script[input file[working directory[option]]] nWhere option can be N
Definition:
JMuonPostfit.sh:37
numberOfBins
int numberOfBins
number of bins for average CDF integral of optical module
Definition:
JSirene.cc:64
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
g1
Double_t g1(const Double_t x)
Function.
Definition:
JQuantiles.cc:25
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5