56 typedef JTriggeredFileScanner_t::multi_pointer_type multi_pointer_type;
61 JLimit_t& numberOfEvents = inputFile.getLimit();
74 JParser<> zap(
"Utility program to determine energy correction.");
76 zap[
'f'] =
make_field(inputFile,
"event file(s) or histogram file");
80 zap[
'F'] =
make_field(formula,
"fit formula, e.g: \"[0]+[1]*x\"") =
"";
90 catch(
const exception& error) {
101 if (inputFile.size() == 1) {
103 in = TFile::Open(inputFile[0].c_str(),
"READ");
105 if (in !=
NULL && in->IsOpen()) {
106 h2 = (
TH2D*) in->Get(
"h2");
118 while (inputFile.hasNext()) {
122 multi_pointer_type ps = inputFile.next();
143 if (evt->begin() == __end) {
153 tb.move(
tb.getIntersection(
ta.getPosition()), getSpeedOfLight(), gWater);
155 if (
ta.getE() > 0.0 &&
tb.getE() > 0.0) {
164 const Int_t nx = h2->GetXaxis()->GetNbins();
165 const Double_t xmin = h2->GetXaxis()->GetXmin();
166 const Double_t xmax = h2->GetXaxis()->GetXmax();
167 const Int_t ny = h2->GetYaxis()->GetNbins();
186 const Double_t x = h2->GetYaxis()->GetBinCenter(
iy);
191 h0->SetBinContent(
iy, y);
192 h0->SetBinError (
iy, z);
205 const Double_t x = h0->GetXaxis()->GetBinCenter(
iy);
219 TF1 f1(
"f1",
"(x < [1]) * [0]*TMath::Gaus(x,[1],[2]) + (x >= [1]) * ([0] * (1.0 - [3])*TMath::Gaus(x,[1],[2]) + [3]*[0])");
221 const double sigma = 0.7 * Q.
getSTDev();
223 f1.SetParameter(0, y0);
224 f1.SetParameter(1, x0);
225 f1.SetParameter(2, sigma);
226 f1.SetParameter(3, 0.05);
227 f1.SetParLimits(3, 0.0, 1.0);
232 FATAL(
"Invalid TFitResultPtr " << h0->GetName() <<
endl);
238 <<
FIXED(6,3) << h2->GetXaxis()->GetBinCenter(
ix) <<
' '
239 <<
FIXED(6,3) << x0 <<
" -> "
240 <<
FIXED(6,3) << f1.GetParameter(1) <<
' '
241 <<
FIXED(6,3) << sigma <<
" -> "
242 <<
FIXED(6,3) << f1.GetParameter(2) <<
' '
245 << (
result->IsValid() ?
"" :
"failed") <<
endl;
249 h1.SetBinContent(
ix, f1.GetParameter(1));
250 h1.SetBinError (
ix, f1.GetParError (1));
259 f1 =
new TF1(
"f1", formula.c_str());
261 if (f1->IsZombie()) {
262 FATAL(
"Function: " << formula <<
" is zombie." <<
endl);
279 if (option.find(
'S') == string::npos) { option +=
"S"; }
293 <<
"x >= " <<
FIXED(5,3) << xmax
301 x[0] = h1.GetXaxis()->GetBinCenter(
ix);
302 y[0] = h1.GetBinContent(
ix);
303 z[0] = h1.GetBinError (
ix);
305 if (z[0] == 0.0 || !X(x[0])) {
311 <<
"x >= " <<
FIXED(5,3) << x[0]
313 <<
"x < " <<
FIXED(5,3) << x[1]
316 <<
"(" <<
FIXED(5,3) << y[0] <<
" + " <<
FIXED(5,3) << (y[1] - y[0]) <<
" * (x - " <<
FIXED(5,3) << x[0] <<
") / " <<
FIXED(5,3) << (x[1] - x[0]) <<
")";
329 <<
"x < " <<
FIXED(5,3) << x[1]
332 <<
"(" <<
FIXED(5,3) << y[0] <<
" + " <<
FIXED(5,3) << (y[1] - y[0]) <<
" * (x - " <<
FIXED(5,3) << x[0] <<
") / " <<
FIXED(5,3) << (x[1] - x[0]) <<
")";
335 string buffer = os.str();
339 for (string::iterator i = buffer.begin(); i != buffer.end(); ++i) {
345 f1 =
new TF1(
"f1", buffer.c_str(), xmin, xmax);
347 h1.GetListOfFunctions()->Add(f1);
355 out << *h2 <<
H0 << h1;
361 out << *(f1->GetFormula());
Auxiliary class to test history.