58{
60
62 int numberOfEvents;
65 bool subtract;
67
68 try {
69
70 JParser<> zap(
"Example program to test 1D histogram.");
71
78
79 zap(argc, argv);
80 }
81 catch(const exception &error) {
82 FATAL(error.what() << endl);
83 }
84
85
86 if (numberOfEvents <= 0) {
87 FATAL(
"No events." << endl);
88 }
89
91
92
93 const Int_t nx = 1000;
94 const Double_t
xmin = -5.0;
95 const Double_t
xmax = +5.0;
96
97
99
101
102
103
104
107 else
109
110
111
112
113 for (int i = 0; i != numberOfEvents; ++i) {
114 histogram.
fill(gRandom->Gaus(0.0, 1.0), 1.0);
115 }
116
117 histogram.
div((
double) numberOfEvents);
118
119
120
121
123
124
125
127
129
131
132
134
136
138
139 f1.setExceptionHandler(
new JFunction1D_t::JDefaultResult(
JMATH::zero));
140 F1.setExceptionHandler(
new JFunction1D_t::JDefaultResult(
JMATH::zero));
141
142
144
145 TH1D h0("h0", NULL, nx, xmin, xmax);
146 TH1D h1("h1", NULL, nx, xmin, xmax);
147 TH1D h2("h2", NULL, nx, xmin, xmax);
148
149 TH1D i0("i0", NULL, nx, xmin, xmax);
150 TH1D i1("i1", NULL, nx, xmin, xmax);
151
152 for (int i = 1; i <= h0.GetNbinsX(); ++i) {
153
154 const Double_t
x = h0.GetBinCenter(i);
155
156 h0.SetBinContent(i,
g1(x));
157 i0.SetBinContent(i,
G1(x));
158
159 try {
160 h1.SetBinContent(i, get_value(
F1(x).fp));
161 h2.SetBinContent(i, get_value(
f1(x)));
162 i1.SetBinContent(i, get_value(
F1(x)));
163 }
164 catch(const exception& error) {
165 ERROR(error.what() << endl);
166 }
167 }
168
169 if (subtract) {
170 h1.Add(&h0, -1.0);
171 h2.Add(&h0, -1.0);
172 i1.Add(&i0, -1.0);
173 }
174
175 out.Write();
176 out.Close();
177}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Double_t g1(const Double_t x)
Function.
Double_t G1(const Double_t x)
Integral of method g1.
int numberOfBins
number of bins for average CDF integral of optical module
Utility class to parse command line options.
const JPolynome F1
Integral.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
static const JZero zero
Function object to assign zero value.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).