117 JParser<> zap(
"General purpose fit program for 2D ROOT objects.");
119 zap[
'f'] =
make_field(inputFile,
"<input file>:<object name>");
121 zap[
'F'] =
make_field(formula,
"fit formula, e.g: \"[0]+[1]*x\"");
122 zap[
'@'] =
make_field(startValues,
"start values, e.g: \"p0 = GetMaximum;\"");
128 zap[
'O'] =
make_field(option,
"Fit option") =
"";
135 catch(
const exception &error) {
136 FATAL(error.what() << endl);
140 if (option.find(
'O') == string::npos) { option +=
"O"; }
142 if (
debug == 0 && option.find(
'Q') == string::npos) { option +=
"Q"; }
148 TF3* fcn =
new TF3(
"user", formula.c_str());
152 if (fcn->IsZombie()) {
153 FATAL(
"Function: " << formula <<
" is zombie." << endl);
158 DEBUG(
"Input: " << *input << endl);
163 ERROR(
"File: " << input->getFullFilename() <<
" not opened." << endl);
167 const TRegexp regexp(input->getObjectName());
169 TIter iter(dir->GetListOfKeys());
171 for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
173 const TString tag(key->GetName());
175 DEBUG(
"Key: " << tag <<
" match = " << tag.Contains(regexp) << endl);
179 if (tag.Contains(regexp) &&
isTObject(key)) {
181 TObject*
object = key->ReadObj();
201 FATAL(error << endl);
204 DEBUG(
"Start values " << object->GetName() << endl);
206 for (
int i = 0; i != fcn->GetNpar(); ++i) {
207 DEBUG(left << setw(12) << fcn->GetParName (i) <<
' ' <<
208 SCIENTIFIC(12,5) << fcn->GetParameter(i) << endl);
211 Double_t
xmin = numeric_limits<Double_t>::max();
212 Double_t
xmax = numeric_limits<Double_t>::lowest();
213 Double_t ymin = numeric_limits<Double_t>::max();
214 Double_t ymax = numeric_limits<Double_t>::lowest();
215 Double_t zmin = numeric_limits<Double_t>::max();
216 Double_t zmax = numeric_limits<Double_t>::lowest();
219 TH3* h3 =
dynamic_cast<TH3*
>(object);
222 xmin = min(xmin, h3->GetXaxis()->GetXmin());
223 xmax = max(xmax, h3->GetXaxis()->GetXmax());
224 ymin = min(ymin, h3->GetYaxis()->GetXmin());
225 ymax = max(ymax, h3->GetYaxis()->GetXmax());
226 zmin = min(zmin, h3->GetZaxis()->GetXmin());
227 zmax = max(zmax, h3->GetZaxis()->GetXmax());
232 xmin =
X.getLowerLimit();
233 xmax =
X.getUpperLimit();
237 ymin =
Y.getLowerLimit();
238 ymax =
Y.getUpperLimit();
242 zmin =
Z.getLowerLimit();
243 zmax =
Z.getUpperLimit();
246 fcn->SetRange(xmin, ymin, zmin, xmax, ymax, zmax);
248 if (option.find(
"R") == string::npos) {
255 JFit fit(*
object, fcn, option);
260 if (fit.result != -1) {
264 NOTICE(
"Fit values " << object->GetName() << endl);
265 NOTICE(
"Fit formula " << formula << endl);
267 for (
int j = 0;
j != fcn->GetNpar(); ++
j) {
268 NOTICE(left << setw(12) << fcn->GetParName (
j) <<
' ' <<
269 SCIENTIFIC(12,5) << fcn->GetParameter(
j) <<
" +/- " <<
275 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
Type definition of range.
#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.
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
no fit printf nominal n $STRING awk v X
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
do set_variable MODULE getModule a $WORKDIR detector_a datx L $STRING JEditDetector a $WORKDIR detector_a datx M $MODULE setz o $WORKDIR detector_a datx JEditDetector a $WORKDIR detector_b datx M $MODULE setz o $WORKDIR detector_b datx done echo Output stored at $WORKDIR detector_a datx and $WORKDIR tripod_a txt JDrawDetector2D a $WORKDIR detector_a datx a $WORKDIR detector_b datx L BL o detector $FORMAT $BATCH JDrawDetector2D T $WORKDIR tripod_a txt T $WORKDIR tripod_b txt L BL o tripod $FORMAT $BATCH JCompareDetector a $WORKDIR detector_a datx b $WORKDIR detector_b datx o $WORKDIR abc root &dev null for KEY in X Y Z
Auxiliary data structure for floating point format specification.
#define DEBUG(A)
Message macros.