29{
32
33 string inputFile;
35 double error;
36 bool nobuoy;
37 bool old;
39
40 try {
41
42 JParser<> zap(
"Auxiliary application to fit mechanical constants.");
43
44 zap[
'f'] =
make_field(inputFile,
"input file; see https://git.km3net.de/calibration/input_tables");
46 zap[
'e'] =
make_field(error,
"uncertainty drag value") = 0.2;
47 zap[
'B'] =
make_field(nobuoy,
"fit without buoy");
48 zap[
'O'] =
make_field(old,
"ROOT fit based on minuit");
50
51 zap(argc, argv);
52 }
53 catch(const exception &error) {
54 FATAL(error.what() << endl);
55 }
56
57
59
60 double xmax = 0.0;
61 double ymax = 0.0;
62
63 {
64 ifstream in(inputFile.c_str());
65
66 string buffer;
67
69
70 DEBUG(
"Header " << buffer << endl);
71
73
75
76 for (
double x, y; in >>
x >>
y; ) {
77
79
81
82 if (x > xmax) {
85 }
86 }
87
88 in.close();
89 }
90
91
92
93
94 double Tx = ymax / xmax;
95 double a = (nobuoy ? 0.0 : 0.5 / xmax);
96 double b = (nobuoy ? 0.0 : 0.25 * xmax);
97
98
99
100
101 if (!old) {
102
104
105 typedef decltype(f1) function_type;
106
108
110
112
114
115 cout <<
"Error matrix:" << endl <<
result.V << endl;
116
120
121 } else {
122
123 TF1 f1("f1", "[0]*(x + [1]*log(1.0 - [2]*x))");
124
125 f1.SetParameter(0, Tx);
126 if (nobuoy) {
127 f1.FixParameter(1, b);
128 f1.FixParameter(2, a);
129 } else {
130 f1.SetParameter(1, b);
131 f1.SetParameter(2, a);
132 }
133
134 f1.SetParError(0, 0.05);
135 f1.SetParError(1, 1.0e-6);
136 f1.SetParError(2, 1.0e-1);
137
138
140
141 Tx = f1.GetParameter(0);
142 b = f1.GetParameter(1);
143 a = f1.GetParameter(2);
144 }
145
146
147 cout << inputFile << endl;
148
149 cout <<
"T_x = " <<
FIXED(5,2) << Tx <<
" [s^2/m^2] * v_x^2" << endl;
150
151 cout <<
"b [m] " <<
FIXED(7,3) << b << endl;
152 cout <<
"a [m^-1] " <<
FIXED(7,5) << a << endl;
153
154
156
158
160
161 out.Write();
162 out.Close();
163}
void setFormat(const JFormat_t &format)
Set format for given type.
#define DEBUG(A)
Message macros.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Double_t g1(const Double_t x)
Function.
Auxiliary class to specify white space character(s) in currect locale.
Utility class to parse command line options.
std::istream & getline(std::istream &in, JString &object)
Read string from input stream until end of line.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
void AddPoint(TGraph *g1, const Double_t x, const Double_t y)
Add point to TGraph.
JRootfit_t< JF1_t > Fit(const TH1 &h1, const JF1_t &f1, const index_list &ls=index_list(), const range_type &X=range_type())
Global fit fuction.
Auxiliary data structure for floating point format specification.
Termination class for polynomial function.