Jpp
19.0.0
the software that should make you happy
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JFit
JFit/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
#include "
JFit/JLegendreEstimator.hh
"
10
11
#include "
JTools/JCollection.hh
"
12
#include "
JTools/JElement.hh
"
13
#include "
JTools/JQuantile.hh
"
14
15
#include "
Jeep/JParser.hh
"
16
#include "
Jeep/JMessage.hh
"
17
18
19
/**
20
* \file
21
*
22
* Example program to test Legendre polynome.
23
* \author mdejong
24
*/
25
int
main
(
int
argc,
char
**argv)
26
{
27
using namespace
std;
28
using namespace
JPP;
29
30
const
size_t
N
= 3;
31
32
typedef
JLegendre<double, N> JLegendre_t;
33
34
const
double
xmin
= -10.0;
35
const
double
xmax
= +10.0;
36
37
unsigned
int
numberOfEvents;
38
unsigned
int
numberOfBins
;
39
JLegendre_t
f1
(
xmin
,
xmax
);
40
double
precision;
41
int
debug
;
42
43
try
{
44
45
JParser<>
zap(
"Example program to test Legendre polynome."
);
46
47
zap[
'n'
] =
make_field
(numberOfEvents) = 1000;
48
zap[
'N'
] =
make_field
(
numberOfBins
) = 10;
49
zap[
'L'
] =
make_field
(f1);
50
zap[
'e'
] =
make_field
(precision) = 1.0e-10;
51
zap[
'd'
] =
make_field
(
debug
) = 3;
52
53
zap(argc, argv);
54
}
55
catch
(
const
exception &error) {
56
FATAL
(error.what() << endl);
57
}
58
59
60
typedef
JCollection< JElement2D<double, double> > collection_type;
61
62
collection_type
data
;
63
64
for
(
unsigned
int
i
= 0;
i
!=
numberOfBins
; ++
i
) {
65
66
const
double
x
=
xmin
+
i
* (
xmax
-
xmin
) / (
numberOfBins
- 1);
67
68
data
[
x
] =
f1
(x);
69
}
70
71
for
(collection_type::const_iterator
i
=
data
.begin();
i
!=
data
.end(); ++
i
) {
72
DEBUG
(
"data: "
<<
FIXED
(7,3) <<
i
->getX() <<
' '
<<
FIXED
(7,3) <<
i
->getY() << endl);
73
}
74
75
76
JEstimator<JLegendre_t>
g1
(
data
.begin(),
data
.end());
77
78
for
(
size_t
n
= 0;
n
!=
g1
.size(); ++
n
) {
79
STATUS
(
"Legendre: "
<< setw(2) <<
n
<<
' '
<<
FIXED
(7,3) <<
g1
[
n
] << endl);
80
}
81
82
83
JQuantile
Q
;
84
85
if
(numberOfEvents > 0) {
86
87
for
(
unsigned
int
i
= 0;
i
!= numberOfEvents; ++
i
) {
88
89
const
double
x
= gRandom->Uniform(
xmin
,
xmax
);
90
const
double
y
=
f1
(x);
91
const
double
z
=
g1
(x);
92
93
Q
.put(y - z);
94
}
95
96
DEBUG
(
Q
<< endl);
97
}
98
99
ASSERT
(numberOfEvents > 0);
100
101
ASSERT
(f1.size() ==
g1
.size());
102
103
for
(
size_t
n
= 0;
n
!=
g1
.size(); ++
n
) {
104
ASSERT
(fabs(f1[
n
] -
g1
[
n
]) <= precision,
"Legendre: "
<< setw(2) << n <<
' '
<<
FIXED
(7,3) <<
g1
[n]);
105
}
106
107
ASSERT
(fabs(
Q
.getMean()) <= precision);
108
109
ASSERT
(
Q
.getSTDev() <= precision);
110
111
return
0;
112
}
GAUSS_LEGENDRE::xmax
const double xmax
Definition:
JQuadrature.cc:24
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1711
JLegendreEstimator.hh
Linear fit of JMATH::JLegendre.
Q
Q(UTCMax_s-UTCMin_s)-livetime_s
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JMathSupportkit.hh
Auxiliary methods for mathematics.
JElement.hh
The elements in a collection are sorted according to their abscissa values and a given distance opera...
STATUS
#define STATUS(A)
Definition:
JMessage.hh:63
JLegendre.hh
FIXED
Auxiliary data structure for floating point format specification.
Definition:
JManip.hh:446
GAUSS_LEGENDRE::f1
const JPolynome f1(1.0, 2.0, 3.0)
Function.
JTOOLS::n
const int n
Definition:
JPolint.hh:786
i
then rm i
Definition:
JEvtReweightMupageParameterScan.sh:309
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition:
JMessage.hh:90
makedeclinationtable.x
tuple x
Definition:
makedeclinationtable.py:44
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:2158
JCollection.hh
General purpose class for a collection of sorted elements.
makedeclinationtable.y
tuple y
Definition:
makedeclinationtable.py:51
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
GAUSS_LEGENDRE::xmin
const double xmin
Definition:
JQuadrature.cc:23
z
then usage $script[energy[distance[z of PMT]]] fi case set_variable z
Definition:
JDrawPDF.sh:45
N
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition:
JMuonPostfit.sh:40
JParser.hh
Utility class to parse command line options.
JQuantile.hh
applications.data
tuple data
Definition:
applications.py:8
numberOfBins
int numberOfBins
number of bins for average CDF integral of optical module
Definition:
JSirene.cc:70
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
g1
Double_t g1(const Double_t x)
Function.
Definition:
JQuantiles.cc:25
Generated by
1.8.5