49 JParser<> zap(
"Auxiliary program to model transition time distribution generator from data.");
63 catch(
const exception &error) {
64 FATAL(error.what() << endl);
68 const TRegexp regexp(
"V[0-9]+");
70 TString buffer(inputFile.c_str());
73 Ssiz_t pos = buffer.Index(regexp, &len);
78 buffer = buffer(pos+1, len-1);
92 ifstream
in(inputFile.c_str());
96 for (Double_t
x = 0.0,
y;
in >>
y;
x += xbin) {
100 EY.push_back(sqrt(y));
105 in.ignore(numeric_limits<streamsize>::max(),
'\n');
107 for (Double_t
x, y, dy, rms;
in >> x >> y >> dy >> rms; ) {
121 FATAL(
"Not enough points." << endl);
126 xbin = (
X[
N-1] -
X[0]) / (
N - 1);
128 NOTICE(
"Bin width [ns] " << xbin << endl);
133 TH1D h1(
"h1", NULL,
N,
X[0] - 0.5*xbin,
X[
N-1] + 0.5*xbin);
137 for (
int i = 0;
i !=
N; ++
i) {
138 h1.SetBinContent(
i+1,
Y [
i]);
139 h1.SetBinError (i+1, EY[i]);
145 TF1
f1(
"f1",
"[0]*exp(-0.5*(x-[1])*(x-[1])/([2]*[2])) + [3]");
152 Double_t
sigma = 2.0;
155 for (
int i = 0; i !=
N; ++
i) {
162 f1.SetParameter(0, ymax);
163 f1.SetParameter(1, x0);
165 f1.SetParameter(3, ymin);
168 h1.Fit(&
f1,
"LL",
"same", x0 - 5 *
sigma, x0 + 5 *
sigma);
173 ymax =
f1.GetParameter(0);
174 x0 =
f1.GetParameter(1);
176 ymin =
f1.GetParameter(3);
180 for (JVector_t::iterator x =
X.begin(); x !=
X.end(); ++
x) {
184 f1.SetParameter(1, x0 = 0);
187 f1.SetParameter(3, 1e-4 * ymax);
197 for (
int i = 0; i !=
N; ++
i) {
199 const Double_t x =
X[
i];
200 const Double_t y =
Y[
i];
204 if (x < x0 - 5.0 *
sigma)
206 else if (x > x0 + 5.0 *
sigma)
210 NOTICE(
"Number of pulses: " << yy << endl);
211 NOTICE(
"Pre-pulses: " << yl / yy << endl);
212 NOTICE(
"Delayed pulses: " << yr / yy << endl);
221 while (n1 !=
N - 1 &&
Y[n1] == 0) ++n1;
222 while (n2 != 0 &&
Y[n2] == 0) --n2;
228 FATAL(
"No non-zero data." << endl);
233 EX = JVector_t(EX.data() + n1, EX.data() + n2);
234 EY = JVector_t(EY.data() + n1, EY.data() + n2);
239 TGraphErrors g0(N,
X.data(),
Y.data(), EX.data(), EY.data());
252 for (
int i = 0; i !=
N; ++
i) {
254 const Double_t x =
g1.GetX()[
i];
255 const Double_t
f =
f1.Eval(x);
263 TGraphSmooth gs(
"gs");
265 TGraph* gout = gs.SmoothSuper(&
g1,
"", bass, span,
false,
g1.GetEY());
270 for (
int i = 0; i !=
N; ++
i) {
271 g1.GetY()[
i] = gout->GetY()[
i];
277 for (
int i = 0; i !=
N; ++
i) {
279 const Double_t x =
g1.GetX()[
i];
280 const Double_t f =
f1.Eval(x);
293 for (
int i = 0; i !=
N; ++
i) {
299 for (
int i = 0; i !=
N; ++
i) {
303 ofstream out(pdf.c_str());
305 const Double_t
xmin = g2.GetX()[ 0 ];
306 const Double_t
xmax = g2.GetX()[N-1];
308 for (Double_t x = xmin, dx = (xmax - xmin) /
numberOfBins; x <= xmax + 0.5*dx; x += dx) {
312 << showpos <<
FIXED(7,2) << x
314 << noshowpos <<
FIXED(6,4) << g2.Eval(x)
325 for (
int i = 0,
j = 1;
j !=
N; ++
i, ++
j) {
326 g2.GetY()[
j] += g2.GetY()[
i];
329 const Double_t ymin = g2.GetY()[ 0 ];
330 const Double_t ymax = g2.GetY()[N-1];
332 for (
int i = 0; i !=
N; ++
i) {
334 const Double_t x = g2.GetX()[
i];
335 const Double_t y = g2.GetY()[
i];
337 g2.GetX()[
i] = (y - ymin) / ymax;
338 g2.GetY()[
i] = x + 0.5 * xbin;
341 ofstream out(
cdf.c_str());
343 const Double_t xmin = 0.0;
344 const Double_t xmax = 1.0;
346 for (Double_t x = xmin, dx = (xmax - xmin) /
numberOfBins; x <= xmax + 0.5*dx; x += dx) {
350 << noshowpos <<
FIXED(6,4) << x
352 << showpos <<
FIXED(9,5) << g2.Eval(x)
364 const Double_t xmin =
X[ 0 ];
365 const Double_t xmax =
X[N-1];
366 const Double_t dx = (xmax -
xmin) / N;
368 TH1D h2(
"pmt", NULL, N, xmin - 0.5*dx, xmax + 0.5*dx);
374 for (
int i = 0; i !=
N; ++
i) {
380 for (
int i = 0; i !=
N; ++
i) {
382 h2.SetBinContent(i+1,
Y [i]/W);
383 h2.SetBinError (i+1, EY[i]/W);
Utility class to parse command line options.
then fatal Wrong number of arguments fi set_variable STRING $argv[1] set_variable DETECTORXY_TXT $WORKDIR $DETECTORXY_TXT tail read X Y CHI2 RMS printf optimum n $X $Y $CHI2 $RMS awk v Y
Auxiliary data structure for floating point format specification.
const JPolynome f1(1.0, 2.0, 3.0)
Function.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
then for FUNCTION in pdf npe cdf
then usage $script< input file >[option[primary[working directory]]] nWhere option can be N
then fatal The output file must have the wildcard in the e g root fi eval JPrintDetector a $DETECTOR O IDENTIFIER eval JPrintDetector a $DETECTOR O SUMMARY JAcoustics sh $DETECTOR_ID source JAcousticsToolkit sh CHECK_EXIT_CODE typeset A EMITTERS get_tripods $WORKDIR tripod txt EMITTERS get_transmitters $WORKDIR transmitter txt EMITTERS for EMITTER in
then JHobbit a $DETECTOR f
no fit printf nominal n $STRING awk v X
int numberOfBins
number of bins for average CDF integral of optical module
Double_t g1(const Double_t x)
Function.