-
Notifications
You must be signed in to change notification settings - Fork 67
Slice Fitting
Here's a basic example of how to fit slices of a 2 dimensional histogram(H2F).
ParallelSliceFitter fitter = new ParallelSliceFitter(histogram);
fitter.fitSlicesX();
canvas.draw(fitter.getMeanSlices());
In some cases where not all of the slices in 2D histogram have large statistics for the fit to be reliable it is convenient to limit the fits only to the bins with sufficient statistics. To do this one could use:
// only fit slices containing 250 or more events
fitter.setMinEvents(250);
fitter.fitSlicesX();
Here's a list of methods that return GraphErrors objects:
fitter.getMeanSlices();
fitter.getSigmaSlices();
fitter.getAmpSlices();
fitter.getChi2Slices();
fitter.getP0Slices();
For now I've limited the ParallelSliceFitter to just a few modes, ones with well defined initial parameters. If there are any requests please post them on the issues page.
- Gaussian
- Gaussian + Zeroth order polynomial
- Gaussian + First order polynomial
- Gaussian + Second order polynomial
- Gaussian + Third order polynomial
This example shows how to set the background mode. You can also use integers to set the background type instead of using the static constants in ParallelSliceFitter (P1_BG = 1). The default is no background.
fitter.setBackgroundOrder(ParallelSliceFitter.P1_BG);
I created a simple tabbed pane to show a fit summary and also the fits themselves. The tabbed pane can be accessed directly from the fitter in case you would like to embed it in a GUI.
//To get the pane itself
fitter.getInspectFitsPane()
//To have it pop out in it's own window
fitter.inspectFits();
To set the # of threads, it defaults to the number of threads available on your local machine.
fitter.setNthreads(nthreads);
You can also set the min and max of the fit range for the slices. The range applies to all slices.
//Disables autorange for the minimum only
fitter.setMin(min);
//Disables autorange for the maximum only
fitter.setMax(max);
//Disables autorange for both
fitter.setRange(min, max);
Setting the fit mode
//Fit Options
//N = sqrt(N) for point error
//W = weight all points equally (ignore error)
//Future: L = Binned log likelihood
fitter.SetFitOptions("N");
You can also access all of these features through right clicking on a pad containing an H2F object. This will pop up a window with the fit inspector in it.