38{
41
43
44 string inputFile;
48 string pdf;
50 JRange_t T_ns;
52
53 try {
54
55 JParser<> zap(
"Auxiliary program to model transition time distribution generator from data.");
56
57 zap[
'f'] =
make_field(inputFile,
"input file (output from JPulsar)");
61 zap[
'P'] =
make_field(pdf,
"PDF output file; for inclusion in JPMTTransitTimeProbability.hh") =
"";
62 zap[
'C'] =
make_field(
cdf,
"CDF output file; for inclusion in JPMTTransitTimeGenerator.hh") =
"";
63 zap[
'T'] =
make_field(T_ns,
"time range for PDF and CDF") = JRange_t(-20.0, +100.0);
65
67 }
68 catch(const exception &error) {
70 }
71
72
74
75 TFile in(inputFile.c_str(),
"exist");
76
77 if (!in.IsOpen()) {
78 FATAL(
"File " << inputFile <<
" not opened." <<
endl);
79 }
80
81 h1 =
dynamic_cast<TH1D*
>(in.Get(
h0_1));
82
85 }
86
87
88
89
90 TF1 f1("f1", "[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2])) + [3]");
91
92
93
98
99 for (
Int_t i = 1; i <= h1->GetNbinsX(); ++i) {
100
103
107 }
108 }
109
110 f1.SetParameter(0,
ymax);
111 f1.SetParameter(1, x0);
112 f1.SetParameter(2, sigma);
113 f1.SetParameter(3,
ymin);
114
115
116
117 h1->Fit(&f1, "LL", "same", x0 - 5 * sigma, x0 + 5 * sigma);
118
119
120
121 ymax = f1.GetParameter(0);
122 x0 = f1.GetParameter(1);
123 sigma = f1.GetParameter(2);
124 ymin = f1.GetParameter(3);
125
126
127
128
132
135
136 for (
Int_t i = 1; i <= h1->GetNbinsX(); ++i) {
137
140
141 if (T_ns(x - x0)) {
142
144
145 if (x < x0 - 5.0 * sigma)
147 else if (x > x0 + 5.0 * sigma)
149
150 } else {
151
154 }
155 }
156
159 }
160
161
162
166
170
171
172
173
175
180
181 for (
Int_t i = 1; i <= h1->GetNbinsX(); ++i) {
182
183 const Double_t x = h1->GetBinCenter (i) - x0;
184 const Double_t y = h1->GetBinContent(i) - y0;
185
186 if (T_ns(x)) {
187 X .push_back(x);
188 Y .push_back(y);
189 EX.push_back(0.0);
190 EY.push_back(sqrt(y));
191 }
192 }
193
194 const int N = X.size();
195
196 if (N <= 25) {
198 }
199
200
201 TGraphErrors
g0(N, X.data(), Y.data(), EX.data(), EY.data());
202
204
206
208
209
210
211
212 for (int i = 0; i != N; ++i) {
213
216
219 }
220
221
222
223
225
227
228
229
230
231 for (int i = 0; i != N; ++i) {
232 g1.GetY()[i] =
gout->GetY()[i];
233 }
234
235
236
237
238 for (int i = 0; i != N; ++i) {
239
242
245 }
246
247
248 if (pdf != "") {
249
250
251
253
255
256 for (int i = 0; i != N; ++i) {
257 W += g2.GetY()[i];
258 }
259
260 for (int i = 0; i != N; ++i) {
261 g2.GetY()[i] /= W;
262 }
263
264 ofstream out(pdf.c_str());
265
266 out <<
"\t// produced by JLegolas.cc" <<
endl;
267
268 const Double_t xmin = T_ns.getLowerLimit();
269 const Double_t xmax = T_ns.getUpperLimit();
271
273
275
276 if (y < 0.0) {
278 }
279
280 out << "\t(*this)"
281 << "["
283 << "] = "
286 }
287
288 out.close();
289 }
290
292
293
294
296
297 for (int i = 0; i+1 != N; ++i) {
298 g2.GetY()[i+1] += g2.GetY()[i];
299 }
300
301 {
302 const Double_t xmin = g2.GetX()[ 0 ];
303 const Double_t xmax = g2.GetX()[N-1];
305
308
309 for (int i = 0; i != N; ++i) {
310
313
315 g2.GetY()[i] =
x + 0.5 *
dx;
316 }
317 }
318
319 ofstream out(
cdf.c_str());
320
321 out <<
"\t// produced by JLegolas.cc" <<
endl;
322
326
328
329 out << "\t(*this)"
330 << "["
332 << "] = "
335 }
336
337 out.close();
338 }
339
340
342
343
344
348
350
351 h2.Sumw2();
352
353
354
356
357 for (int i = 0; i != N; ++i) {
358 W += Y[i];
359 }
360
362
363 for (int i = 0; i != N; ++i) {
364
365 h2.SetBinContent(i+1, Y [i]/W);
366 h2.SetBinError (i+1, EY[i]/W);
367
370 }
371
373
374 h1->Write();
375 h2.Write();
378
379 out.Write();
380 out.Close();
381 }
382}
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Double_t g1(const Double_t x)
Function.
Template definition of a multi-dimensional oscillation probability interpolation table.
Utility class to parse command line options.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.