60     void operator()(
const JType<T>& type)
 
   63         result = 
dynamic_cast<T&
>(object).
Fit(fcn, option.c_str(), 
"same");
 
   65       catch(
const std::exception&) {}
 
   96 int main(
int argc, 
char **argv)
 
  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;\"");
 
  127     zap[
'O'] = 
make_field(option,      
"Fit option")                         = 
"";
 
  134   catch(
const exception &error) {
 
  135     FATAL(error.what() << endl);
 
  139   if (option.find(
'O') == string::npos) { option += 
"O"; }
 
  141   if (
debug ==  0 && option.find(
'Q') == string::npos) { option += 
"Q"; }
 
  147   TF2* fcn = 
new TF2(
"user", formula.c_str());
 
  151   if (fcn->IsZombie()) {
 
  152     FATAL(
"Function: " << formula << 
" is zombie." << endl);
 
  157     DEBUG(
"Input: " << *input << endl);
 
  162       ERROR(
"File: " << input->getFullFilename() << 
" not opened." << endl);
 
  166     const TRegexp regexp(input->getObjectName());
 
  168     TIter iter(dir->GetListOfKeys());
 
  170     for (TKey* key; (key = (TKey*) iter.Next()) != NULL; ) {
 
  172       const TString tag(key->GetName());
 
  174       DEBUG(
"Key: " << tag << 
" match = " << tag.Contains(regexp) << endl);
 
  178       if (tag.Contains(regexp) && 
isTObject(key)) {
 
  180         TObject* 
object = key->ReadObj();
 
  200           FATAL(error << endl);
 
  203         DEBUG(
"Start values " << object->GetName() << endl);
 
  205         for (
int i = 0; i != fcn->GetNpar(); ++i) {
 
  206           DEBUG(left << setw(12) << fcn->GetParName  (i) << 
' ' << 
 
  207                 SCIENTIFIC(12,5) << fcn->GetParameter(i) << endl);
 
  210         Double_t 
xmin = numeric_limits<Double_t>::max();
 
  211         Double_t 
xmax = numeric_limits<Double_t>::lowest();
 
  212         Double_t ymin = numeric_limits<Double_t>::max();
 
  213         Double_t ymax = numeric_limits<Double_t>::lowest();
 
  216           TH2* h2 = 
dynamic_cast<TH2*
>(object);
 
  219             xmin = min(xmin, h2->GetXaxis()->GetXmin());
 
  220             xmax = max(xmax, h2->GetXaxis()->GetXmax());
 
  221             ymin = min(ymin, h2->GetYaxis()->GetXmin());
 
  222             ymax = max(ymax, h2->GetYaxis()->GetXmax());
 
  227           TGraph2D* g2 = 
dynamic_cast<TGraph2D*
>(object);
 
  230             for (Int_t i = 0; i != g2->GetN(); ++i) {
 
  231               xmin = min(xmin, g2->GetX()[i]);
 
  232               xmax = max(xmax, g2->GetX()[i]);
 
  233               ymin = min(ymin, g2->GetY()[i]);
 
  234               ymax = max(ymax, g2->GetY()[i]);
 
  240           xmin = 
X.getLowerLimit();
 
  241           xmax = 
X.getUpperLimit();
 
  245           ymin = 
Y.getLowerLimit();
 
  246           ymax = 
Y.getUpperLimit();
 
  249         fcn->SetRange(xmin, ymin, xmax, ymax);
 
  251         if (option.find(
"R") == string::npos) {
 
  258         JFit fit(*
object, fcn, option);
 
  263         if (fit.result != -1) {
 
  267           NOTICE(
"Fit values  " << object->GetName() << endl);
 
  268           NOTICE(
"Fit formula " << formula           << endl);
 
  270           for (
int j = 0; 
j != fcn->GetNpar(); ++
j) {
 
  271             NOTICE(left << setw(12) << fcn->GetParName  (
j) << 
' '     << 
 
  272                    SCIENTIFIC(12,5) << fcn->GetParameter(
j) << 
" +/- " << 
 
  278           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 main(int argc, char *argv[])
 
int getParameter(const std::string &text)
Get parameter number from text string. 
 
TFitResultPtr Fit(TH1D *h)
 
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. 
 
I/O formatting auxiliaries. 
 
#define make_field(A,...)
macro to convert parameter to JParserTemplateElement object 
 
do set_variable OUTPUT_DIRECTORY $WORKDIR T
 
General purpose messaging. 
 
JObject_t & for_each(JObject_t &object, JType< JTypeList< JHead_t, JTail_t > > typelist)
For each data type method. 
 
Auxiliary class to define a range between two values. 
 
Utility class to parse command line options. 
 
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. 
 
Auxiliary data structure for floating point format specification. 
 
#define DEBUG(A)
Message macros. 
 
JFit()
Default constructor.