Jpp
Main Page
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
examples
JTools
JQuantile.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <iomanip>
5
6
#include "TRandom.h"
7
8
#include "
JTools/JQuantile.hh
"
9
10
#include "
Jeep/JParser.hh
"
11
#include "
Jeep/JMessage.hh
"
12
13
14
/**
15
* \file
16
*
17
* Example program to test JTOOLS::JQuantile calculation.
18
* \author mdejong
19
*/
20
int
main
(
int
argc,
char
**argv)
21
{
22
using namespace
std;
23
24
int
numberOfEvents;
25
double
x;
26
double
sigma;
27
UInt_t seed;
28
int
debug
;
29
30
try
{
31
32
JParser<>
zap(
"Example program to test quantile calculation."
);
33
34
zap[
'n'
] =
make_field
(numberOfEvents);
35
zap[
'x'
] =
make_field
(x) = 0.0;
36
zap[
's'
] =
make_field
(sigma) = 1.0;
37
zap[
'S'
] =
make_field
(seed) = 0;
38
zap[
'd'
] =
make_field
(
debug
) = 3;
39
40
zap(argc, argv);
41
}
42
catch
(
const
exception &error) {
43
FATAL
(error.what() << endl);
44
}
45
46
if
(numberOfEvents < 2) {
47
FATAL
(
"Fatal error: number of events "
<< numberOfEvents << endl);
48
}
49
50
gRandom->SetSeed(seed);
51
52
JTOOLS::JQuantile
quantile;
53
54
// fill
55
56
for
(
int
i = 0; i != numberOfEvents; ++i) {
57
quantile.
put
(gRandom->Gaus(x, sigma));
58
}
59
60
61
NOTICE
(
"quantity "
<<
"calculated"
<<
" | "
<<
" true "
<< endl);
62
NOTICE
(
"mean "
<< fixed << showpos << setw(10) << quantile.getMean() <<
" | "
<< setw(10) << x << endl);
63
NOTICE
(
"RMS "
<< fixed << showpos << setw(10) << quantile.getSTDev() <<
" | "
<< setw(10) << sigma << endl);
64
}
65
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1410
JTOOLS::JQuantile::put
void put(const double x, const double w=1.0)
Put value.
Definition:
JQuantile.hh:77
JTOOLS::JQuantile
Quantile calculator.
Definition:
JQuantile.hh:34
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1836
NOTICE
#define NOTICE(A)
Definition:
JMessage.hh:62
debug
int debug
debug level
Definition:
JSirene.cc:59
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:65
JParser.hh
Utility class to parse command line options.
JQuantile.hh
main
int main(int argc, char *argv[])
Definition:
Main.cpp:15
Generated by
1.8.5