Jpp
18.0.0-rc.4
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
JTools
JPolfit1D.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 "
JLang/JException.hh
"
8
#include "
JMath/JPolynome.hh
"
9
#include "
JTools/JPolfit.hh
"
10
#include "
JTools/JPolint.hh
"
11
#include "
JTools/JElement.hh
"
12
#include "
JTools/JGridCollection.hh
"
13
#include "
JTools/JGrid.hh
"
14
#include "
JTools/JQuantile.hh
"
15
#include "
JTools/JToolsToolkit.hh
"
16
17
#include "
Jeep/JPrint.hh
"
18
#include "
Jeep/JParser.hh
"
19
#include "
Jeep/JMessage.hh
"
20
21
22
/**
23
* \file
24
*
25
* Example program to test 1D Legendre interpolation of a polynome.
26
* \author mdejong
27
*/
28
int
main
(
int
argc,
char
**argv)
29
{
30
using namespace
std;
31
using namespace
JPP;
32
33
unsigned
int
numberOfEvents;
34
unsigned
int
numberOfBins
;
35
JPolynome
f1
;
36
double
sigma
;
37
double
P
;
38
int
debug
;
39
40
try
{
41
42
JParser<>
zap(
"Example program to test 1D Legendre interpolation of a polynome."
);
43
44
zap[
'n'
] =
make_field
(numberOfEvents) = 0;
45
zap[
'N'
] =
make_field
(
numberOfBins
) = 21;
46
zap[
'P'
] =
make_field
(
f1
);
47
zap[
's'
] =
make_field
(
sigma
) = 0.0;
48
zap[
'p'
] =
make_field
(
P
) = 0.0;
49
zap[
'd'
] =
make_field
(
debug
) = 3;
50
51
zap(argc, argv);
52
}
53
catch
(
const
exception &error) {
54
FATAL
(error.what() << endl);
55
}
56
57
58
const
int
N
= 7;
// number of points for Legendre interpolation
59
const
int
M = 3;
// degree of Legendre polynome
60
61
typedef
JPolfitFunction1D<
N
,
62
M,
63
JElement2D<double, double>,
64
JGridCollection,
65
double
> JFunction1D_t;
66
67
JFunction1D_t
g1
;
68
69
JPolintFunction1D<M,
70
JElement2D<double, double>,
71
JGridCollection,
72
double
> h1;
73
74
const
double
xmin
= -10.0;
75
const
double
xmax
= +10.0;
76
77
const
JGrid<double> grid(
numberOfBins
,
xmin
,
xmax
);
78
79
for
(
int
i
= 0;
i
!= grid.getSize(); ++
i
) {
80
81
const
double
x
= grid.getX(
i
);
82
83
g1
[
x
]=
f1
(x) + (
sigma
> 0.0 && gRandom->Rndm() <
P
? gRandom->Gaus(0.0,
sigma
) : 0.0);
84
}
85
86
copy
(
g1
, h1);
87
88
g1
.compile();
89
h1.compile();
90
91
for
(JFunction1D_t::const_iterator
i
=
g1
.begin();
i
!=
g1
.end(); ++
i
) {
92
DEBUG
(
FIXED
(12,5) <<
i
->getX() <<
' '
<<
FIXED
(12,5) <<
i
->getY() << endl);
93
}
94
95
96
if
(numberOfEvents != 0) {
97
98
JQuantile
Q
[2];
99
100
for
(
unsigned
int
i
= 0;
i
!= numberOfEvents; ++
i
) {
101
102
const
double
x
= gRandom->Uniform(
xmin
,
xmax
);
103
const
double
y
=
f1
(x);
104
const
double
u
=
g1
(x);
105
const
double
v
= h1(x);
106
107
DEBUG
(
FIXED
(12,5) << x <<
FIXED
(12,5) << y <<
FIXED
(12,5) << u << endl);
108
109
Q[0].put(u - y);
110
Q[1].put(v - y);
111
}
112
113
Q[0].print(cout);
114
Q[1].print(cout,
false
);
115
}
116
117
return
0;
118
}
JPolint.hh
GAUSS_LEGENDRE::xmax
const double xmax
Definition:
JQuadrature.cc:24
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
JException.hh
Exceptions.
i
then rm i
Definition:
JEvtReweightGSeaGenParameterScan.sh:337
Q
Q(UTCMax_s-UTCMin_s)-livetime_s
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
JElement.hh
The elements in a collection are sorted according to their abscissa values and a given distance opera...
FIXED
Auxiliary data structure for floating point format specification.
Definition:
JManip.hh:446
JGridCollection.hh
GAUSS_HERMITE::sigma
const double sigma[]
Definition:
JQuadrature.cc:74
GAUSS_LEGENDRE::f1
const JPolynome f1(1.0, 2.0, 3.0)
Function.
JPolynome.hh
JPrint.hh
I/O formatting auxiliaries.
makedeclinationtable.x
tuple x
Definition:
makedeclinationtable.py:44
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
JToolsToolkit.hh
This include file contains various recursive methods to operate on multi-dimensional collections...
JGrid.hh
makedeclinationtable.y
tuple y
Definition:
makedeclinationtable.py:51
JPolfit.hh
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
GAUSS_LEGENDRE::xmin
const double xmin
Definition:
JQuadrature.cc:23
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
JAANET::copy
void copy(const Head &from, JHead &to)
Copy header from from to to.
Definition:
JHead.cc:162
JTOOLS::v
data_type v[N+1][M+1]
Definition:
JPolint.hh:777
JTOOLS::u
double u[N+1]
Definition:
JPolint.hh:776
numberOfBins
int numberOfBins
number of bins for average CDF integral of optical module
Definition:
JSirene.cc:69
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
P
then $DIR JPlotNPE PDG P
Definition:
JPlotNPE-PDG.sh:62
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