Loading [MathJax]/extensions/tex2jax.js
Logo ROOT   6.16/01
Reference Guide
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
simple.cxx File Reference

Detailed Description

/*************************************************************************
* Copyright (C) 1995-2015, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#include "ROOT/RHist.hxx"
#include "ROOT/TFit.hxx"
#include "ROOT/TFile.hxx"
void simple()
{
using namespace ROOT;
// Create a 2D histogram with an X axis with equidistant bins, and a y axis
// with irregular binning.
Experimental::RAxisConfig xAxis(100, 0., 1.);
Experimental::RAxisConfig yAxis({0., 1., 2., 3., 10.});
Experimental::RH2D histFromVars(xAxis, yAxis);
// Or the short in-place version:
// Create a 2D histogram with an X axis with equidistant bins, and a y axis
// with irregular binning.
Experimental::RH2D hist({100, 0., 1.}, {{0., 1., 2., 3., 10.}});
// Fill weight 1. at the coordinate 0.01, 1.02.
hist.Fill({0.01, 1.02});
// Fit the histogram.
Experimental::TFunction<2> func([](const std::array<double, 2> &x, const std::span<double> par) {
return par[0] * x[0] * x[0] + (par[1] - x[1]) * x[1];
});
Experimental::TFitResult fitResult = Experimental::FitTo(hist, func, {{0., 1.}});
Experimental::TFilePtr file = Experimental::TFile::Recreate("hist.root");
file->Write("TheHist", hist);
}
Double_t x[n]
Definition: legend1.C:17
RHist< 2, double, RHistStatContent, RHistStatUncertainty > RH2D
Definition: RHist.hxx:292
TFitResult FitTo(const RHist< DIMENSIONS, PRECISION, STAT... > &hist, const TFunction< DIMENSIONS > &func, std::span< double > paramInit)
Definition: TFit.hxx:39
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
Definition: file.py:1
Date
2015-03-22
Warning
This is part of the ROOT 7 prototype! It will change without notice. It might trigger earthquakes. Feedback is welcome!
Author
Axel Naumann axel@.nosp@m.cern.nosp@m..ch

Definition in file simple.cxx.