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
JGeometry3D
JOmega3D.cc
Go to the documentation of this file.
1
2
#include <string>
3
#include <iostream>
4
#include <iomanip>
5
#include <cmath>
6
7
#include "TROOT.h"
8
#include "TFile.h"
9
#include "TH1D.h"
10
#include "TRandom3.h"
11
12
#include "
JMath/JConstants.hh
"
13
#include "
JTools/JQuantile.hh
"
14
#include "
JTools/JRange.hh
"
15
#include "
JROOT/JRootToolkit.hh
"
16
17
#include "
JGeometry3D/JOmega3D.hh
"
18
19
#include "
Jeep/JParser.hh
"
20
#include "
Jeep/JMessage.hh
"
21
22
23
/**
24
* \file
25
*
26
* Example program to test JGEOMETRY3D::JOmega3D class.
27
* \author mdejong
28
*/
29
int
main
(
int
argc,
char
**argv)
30
{
31
using namespace
std;
32
using namespace
JPP;
33
34
string
outputFile
;
35
int
numberOfEvents;
36
JRange<double> range_Deg;
37
int
debug
;
38
39
try
{
40
41
JParser<>
zap(
"Example program to test JOmega3D class."
);
42
43
zap[
'o'
] =
make_field
(
outputFile
) =
""
;
44
zap[
'n'
] =
make_field
(numberOfEvents) = 100;
45
zap[
'G'
] =
make_field
(range_Deg) = JRange<double>(0.5, 10.5);
46
zap[
'd'
] =
make_field
(
debug
) = 3;
47
48
zap(argc, argv);
49
}
50
catch
(
const
exception &error) {
51
FATAL
(error.what() << endl);
52
}
53
54
55
const
int
N
= 10;
56
57
TH1D h0(
"h0[grid"
, NULL,
N
, range_Deg.getLowerLimit(), range_Deg.getUpperLimit());
58
TH1D h1(
"h1[RMS]"
, NULL,
N
, range_Deg.getLowerLimit(), range_Deg.getUpperLimit());
59
TH1D h2(
"h2[deviation]"
, NULL,
N
, range_Deg.getLowerLimit(), range_Deg.getUpperLimit());
60
61
62
vector<JOmega3D>
omega;
63
vector<JQuantile>
quantile;
64
65
for
(
int
i
= 1;
i
<= h0.GetNbinsX(); ++
i
) {
66
67
const
Double_t
x
= h0.GetBinCenter(
i
);
68
69
omega .push_back(JOmega3D(x *
PI
/180.0));
70
quantile.push_back(JQuantile());
71
}
72
73
74
for
(
int
i
= 0;
i
!= numberOfEvents; ++
i
) {
75
76
STATUS
(
"event: "
<< setw(10) <<
i
<<
'\r'
);
DEBUG
(endl);
77
78
const
double
theta = gRandom->Uniform(0.0,
PI
);
79
const
double
phi = gRandom->Uniform(0.0, 2*
PI
);
80
81
const
JAngle3D angle(theta, phi);
82
83
for
(
size_t
j
= 0;
j
!= omega.size(); ++
j
) {
84
85
const
int
pos = omega[
j
].find(angle);
86
const
double
dot = angle.getDot(omega[
j
][pos]);
87
88
quantile[
j
].put(acos(dot) * 180.0/
PI
);
89
}
90
}
91
STATUS
(endl);
92
93
94
for
(
int
i
= 1;
i
<= h0.GetNbinsX(); ++
i
) {
95
h0.SetBinContent(
i
, omega [
i
-1].size());
96
h1.SetBinContent(
i
, quantile[
i
-1].getSTDev());
97
h2.SetBinContent(
i
, quantile[
i
-1].getDeviation());
98
}
99
100
if
(
outputFile
!=
""
) {
101
102
TFile out(
outputFile
.c_str(),
"recreate"
);
103
104
out << h0 << h1 << h2;
105
106
out.Write();
107
out.Close();
108
}
109
110
for
(
int
i
= 1;
i
<= h2.GetNbinsX(); ++
i
) {
111
112
const
Double_t
x
= h2.GetBinCenter (
i
);
113
const
Double_t
y
= h2.GetBinContent(
i
);
114
115
NOTICE
(
"Grid test "
<< x <<
" [deg]: "
<< y <<
" [deg]."
<< endl);
116
ASSERT
(y < x / sqrt(2));
117
}
118
119
return
0;
120
}
JPARSER::JParser
Utility class to parse command line options.
Definition:
JParser.hh:1514
i
then rm i
Definition:
JEvtReweightGSeaGenParameterScan.sh:337
main
int main(int argc, char *argv[])
Definition:
Main.cc:15
STATUS
#define STATUS(A)
Definition:
JMessage.hh:63
outputFile
string outputFile
Definition:
JDAQTimesliceSelector.cc:37
std::vector
Definition:
JSTDTypes.hh:12
ASSERT
#define ASSERT(A,...)
Assert macro.
Definition:
JMessage.hh:90
makedeclinationtable.x
tuple x
Definition:
makedeclinationtable.py:44
JConstants.hh
Mathematical constants.
make_field
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Definition:
JParser.hh:1989
NOTICE
#define NOTICE(A)
Definition:
JMessage.hh:64
JMATH::PI
static const double PI
Mathematical constants.
Definition:
JMath/JConstants.hh:20
makedeclinationtable.y
tuple y
Definition:
makedeclinationtable.py:51
JMessage.hh
General purpose messaging.
FATAL
#define FATAL(A)
Definition:
JMessage.hh:67
JOmega3D.hh
JRootToolkit.hh
N
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
Definition:
JMuonPostfit.sh:40
JRange.hh
Auxiliary class to define a range between two values.
JParser.hh
Utility class to parse command line options.
JQuantile.hh
JTOOLS::j
int j
Definition:
JPolint.hh:703
debug
int debug
debug level
Definition:
archive-put-wiki-detectors.sh:92
DEBUG
#define DEBUG(A)
Message macros.
Definition:
JMessage.hh:62
Generated by
1.8.5