116 JParser<> zap(
"General purpose fit program using ROOT.");
118 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
120 zap[
'F'] =
make_field(formula,
"fit formula, e.g: \"[0]+[1]*x\"");
121 zap[
'@'] =
make_field(startValues,
"start values, e.g: \"p0 = GetMaximum;\"");
122 zap[
'='] =
make_field(fixedValues,
"fixed values, e.g: \"p0 = GetMaximum;\"");
123 zap[
'x'] =
make_field(X,
"abscissa range") = JRange_t();
124 zap[
'y'] =
make_field(
Y,
"abscissa range") = JRange_t();
125 zap[
'O'] =
make_field(option,
"Fit option") =
"";
132 catch(
const exception &error) {
133 FATAL(error.what() << endl);
137 if (option.find(
'O') == string::npos) { option +=
"O"; }
139 if (
debug == 0 && option.find(
'Q') == string::npos) { option +=
"Q"; }
145 TF2* fcn =
new TF2(
"user", formula.c_str());
149 if (fcn->IsZombie()) {
150 FATAL(
"Function: " << formula <<
" is zombie." << endl);
155 DEBUG(
"Input: " << *input << endl);
160 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
164 const TRegexp regexp(input->getObjectName());
166 TIter iter(dir->GetListOfKeys());
168 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
170 const TString tag(key->GetName());
172 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
176 if (tag.Contains(regexp)) {
178 TObject*
object = key->ReadObj();
194 FATAL(error << endl);
197 DEBUG(
"Start values " << object->GetName() << endl);
199 for (
int j = 0;
j != fcn->GetNpar(); ++
j) {
200 DEBUG(left << setw(12) << fcn->GetParName (
j) <<
' ' <<
204 Double_t xmin = numeric_limits<Double_t>::max();
205 Double_t xmax = numeric_limits<Double_t>::lowest();
206 Double_t ymin = numeric_limits<Double_t>::max();
207 Double_t ymax = numeric_limits<Double_t>::lowest();
210 TH2* h2 =
dynamic_cast<TH2*
>(object);
213 xmin = min(xmin, h2->GetXaxis()->GetXmin());
214 xmax = max(xmax, h2->GetXaxis()->GetXmax());
215 ymin = min(ymin, h2->GetYaxis()->GetXmin());
216 ymax = max(ymax, h2->GetYaxis()->GetXmax());
221 TGraph2D* g2 =
dynamic_cast<TGraph2D*
>(object);
224 for (Int_t i = 0; i != g2->GetN(); ++i) {
225 xmin = min(xmin, g2->GetX()[i]);
226 xmax = max(xmax, g2->GetX()[i]);
227 ymin = min(ymin, g2->GetY()[i]);
228 ymax = max(ymax, g2->GetY()[i]);
233 if (X != JRange_t()) {
234 xmin = X.getLowerLimit();
235 xmax = X.getUpperLimit();
238 if (
Y != JRange_t()) {
239 ymin =
Y.getLowerLimit();
240 ymax =
Y.getUpperLimit();
243 fcn->SetRange(xmin, ymin, xmax, ymax);
245 if (option.find(
"R") == string::npos) {
252 JFit fit(*
object, fcn, option);
257 if (fit.result != -1) {
261 NOTICE(
"Fit values " << object->GetName() << endl);
262 NOTICE(
"Fit formula " << formula << endl);
264 for (
int j = 0;
j != fcn->GetNpar(); ++
j) {
265 NOTICE(left << setw(12) << fcn->GetParName (
j) <<
' ' <<
266 SCIENTIFIC(12,5) << fcn->GetParameter(
j) <<
" +/- " <<
272 WARNING(
"Object: not compatible with ROOT Fit." << endl);
Utility class to parse command line options.
double getValue(const JScale_t scale)
Get numerical value corresponding to scale.
int getParameter(const std::string &text)
Get parameter number from text string.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary class for a type holder.
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
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
JObject_t & for_each(JObject_t &object, JType< JTypeList< JHead_t, JTail_t > > typelist)
For each data type method.
Wrapper class around string.
Exception for parsing value.
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
Auxiliary data structure for floating point format specification.
#define DEBUG(A)
Message macros.