3## Drawing histograms in Python
9h =
ROOT.TH1D(
"h1",
"h1", 100, -5, 5)
10h.FillRandom(
"gaus", 10000)
16## Fitting histograms in Python
67myTF1 =
ROOT.
TF1(
"myFunction",
"[0] * pow(x, [1])", 0, 10)
83 Defines a Gaussian function
146# This will raise ValueError
147data = np.array([1.0, 2.0, 3.0])
148weights = np.array([0.5, 1.0]) # Wrong length!
149h.Fill(data, weights) # Raises ValueError: "Length mismatch: data length (3) != weights length (2)"
152The original Fill method functionality is preserved for non-NumPy arguments:
155# Traditional filling still works
156h.Fill(1.0) # Fill single value
157h.Fill(1.0, 2.0) # Fill single value with weight
160## Further Python fitting examples
161Further examples can be found in the tutorials:
162- [combinedFit.py](combinedFit_8py.html) performs a combined (simultaneous) fit of two 1D histograms with separate functions and some common parameters.
163- [fit1.py](fit1_8py.html) reads a `TF1` and 1D histogram (created and saved in an earlier example [fillrandom.py](fillrandom__8py.html)), and fits the histogram.
164- [fitConvolution.py](fitConvolution_8py.html) fits a 1D histogram to a convolution of two functions.
165- [fitNormSum.py](fitNormSum_8py.html) fits a 1D histogram to the normalized sum of two functions (here, a background exponential and a crystal ball function).
166- [multifit.py](multifit_8py.html) fits multiple functions to different ranges of a 1D histogram.
double Double_t
Double 8 bytes.
const char Option_t
Option string (const char)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
void SetParameters(TFitEditor::FuncParams_t &pars, TF1 *func)
Restore the parameters from pars into the function.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void input
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h length
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void when
void Draw(Option_t *option="") override
Draw a canvas.
Extends the ROOT::Fit::Result class with a TNamed inheritance providing easy possibility for I/O.
1-D histogram with a double per channel (see TH1 documentation)
1-D histogram with a float per channel (see TH1 documentation)
TH1 is the base class of all histogram classes in ROOT.
void Draw(Option_t *option="") override
Draw this histogram with options.
ROOT top level object description.
RooCmdArg Parameters(const RooArgSet ¶ms)
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
RVec< PromoteType< T > > exp(const RVec< T > &v)
h1 FillRandom("gaus", 30000)
TFitResultPtr Fit(FitObject *h1, TF1 *f1, Foption_t &option, const ROOT::Math::MinimizerOptions &moption, const char *goption, ROOT::Fit::DataRange &range)
void Print(std::ostream &os, const OptionType &opt)
void function(const Char_t *name_, T fun, const Char_t *docstring=0)
double polynomial(DoubleArray coeffs, int nCoeffs, int lowestOrder, double x)
In pdfMode, a coefficient for the constant term of 1.0 is implied if lowestOrder > 0.
void initialize(typename Architecture_t::Matrix_t &A, EInitialization m)
void Fill(float *output, float value, int size)
void Initialize(Bool_t useTMVAStyle=kTRUE)
constexpr Double_t C()
Velocity of light in .