123     JParser<> zap(
"General purpose fit program for 1D ROOT objects.");
 
  125     zap[
'f'] = 
make_field(inputFile,   
"<input file>:<object name>");
 
  127     zap[
'F'] = 
make_field(formula,     
"fit formula, e.g: \"[0]+[1]*x\"");
 
  128     zap[
'@'] = 
make_field(startValues, 
"start values, e.g: \"p0 = GetMaximum;\"");
 
  135     zap[
'O'] = 
make_field(option,      
"Fit option")                              = 
"";
 
  141   catch(
const exception &error) {
 
  142     FATAL(error.what() << endl);
 
  146   if (option.find(
'O') == string::npos) { option += 
"O"; }
 
  147   if (option.find(
"R") == string::npos) { option += 
"R"; }
 
  148   if (option.find(
"S") == string::npos) { option += 
"S"; }
 
  150   if (
debug ==  0 && option.find(
'Q') == string::npos) { option += 
"Q"; }
 
  163   TF1* fcn = 
new TF1(
"user", formula.c_str());
 
  167   if (fcn->IsZombie()) {
 
  168     FATAL(
"Function: " << formula << 
" is zombie." << endl);
 
  173     DEBUG(
"Input: " << *input << endl);
 
  178       ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
  182     const TRegexp regexp(input->getObjectName());
 
  184     TIter iter(dir->GetListOfKeys());
 
  186     for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  188       const TString tag(key->GetName());
 
  190       DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
  194       if (tag.Contains(regexp) && 
isTObject(key)) {
 
  196         TObject* 
object = key->ReadObj();
 
  200           TProfile& h1 = 
dynamic_cast<TProfile&
>(*object);
 
  202           object = h1.ProjectionX();
 
  208           TH2& h2 = 
dynamic_cast<TH2&
>(*object);
 
  212             object = h2.ProjectionX(
"_px", 
 
  218             object = h2.ProjectionY(
"_py", 
 
  224             ERROR(
"For 2D histograms, use option option -P for projections." << endl);
 
  240           for (Int_t i = 0; i != fcn->GetNpar(); ++i) {
 
  241             fcn->SetParError (i, 0.0);
 
  257           FATAL(error << endl);
 
  260         DEBUG(
"Start values " << object->GetName() << endl);
 
  262         for (
int j = 0; 
j != fcn->GetNpar(); ++
j) {
 
  263           DEBUG(left << setw(12) << fcn->GetParName  (
j) << 
' ' << 
 
  267         Double_t 
xmin = numeric_limits<Double_t>::max();
 
  268         Double_t 
xmax = numeric_limits<Double_t>::lowest();
 
  271           TH1* h1 = 
dynamic_cast<TH1*
>(object);
 
  274             xmin = min(
xmin, h1->GetXaxis()->GetXmin());
 
  275             xmax = max(
xmax, h1->GetXaxis()->GetXmax());
 
  280           TGraph* 
g1 = 
dynamic_cast<TGraph*
>(object);
 
  283             for (Int_t i = 0; i != 
g1->GetN(); ++i) {
 
  300         const chrono::steady_clock::time_point t0 = chrono::steady_clock::now();
 
  302         JFit fit(*
object, fcn, option);
 
  306         const chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
 
  308         if (fit.result != -1) {
 
  312           NOTICE(
"Fit values  " << object->GetName() << endl);
 
  313           NOTICE(
"Fit formula " << formula           << endl);
 
  314           NOTICE(
"chi2/NDF "    << 
FIXED(7,3) << fit.result->Chi2() << 
'/' << fit.result->Ndf() << 
' ' << (fit.result->IsValid() ? 
"" : 
"failed") << endl);
 
  315           NOTICE(
"Number of calls " << fit.result->NCalls() << endl);
 
  316           NOTICE(
"Elapsed time [us] " << setw(8) << chrono::duration_cast<chrono::microseconds>(t1 - t0).count() << endl);
 
  318           for (
int j = 0; 
j != fcn->GetNpar(); ++
j) {
 
  319             NOTICE(left << setw(12) << fcn->GetParName  (
j) << 
' '     << 
 
  320                    SCIENTIFIC(12,5) << fcn->GetParameter(
j) << 
" +/- " << 
 
  326           WARNING(
"Object: not compatible with ROOT Fit." << endl);
 
#define DEBUG(A)
Message macros.
static JMinimizer minimizer
ROOT minimizer.
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object
Double_t g1(const Double_t x)
Function.
Exception for parsing value.
Wrapper class around string.
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.
TDirectory * getDirectory(const JRootObjectID &id)
Get TDirectory pointer.
bool isTObject(const TKey *key)
Check if given key corresponds to a TObject.
JObject_t & for_each(JObject_t &object, JType< JTypeList< JHead_t, JTail_t > > typelist)
For each data type method.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary data structure for floating point format specification.
Type definition of range.
Auxiliary class for a type holder.
Auxiliary data structure to define ROOT minimizer.
Empty structure for specification of parser element that is initialised (i.e. does not require input)...
Auxiliary data structure for floating point format specification.