Crombie Tools
PlotFitParameters.py
Go to the documentation of this file.
1 from .. import Load
2 
3 newFitPlotter = Load('PlotFitParameters')
4 plotter = newFitPlotter()
5 
6 def setupResolution(aPlotter=plotter, same_mean=True):
7  aPlotter.SetLooseFit('[2] * TMath::Gaus(x,[0],[1])')
8 
9  second_mean = '[0]' if same_mean else '[0] - [5]'
10 
11  first_gaussian = '[4]*[3]/[1]*TMath::Gaus(x,[0],[1])'
12  second_gaussian = '[4]*(1 - [3])/[2]*TMath::Gaus(x,%s,[2])' % second_mean
13 
14  aPlotter.SetFunction('%s + %s' % (first_gaussian, second_gaussian))
15  aPlotter.AddFunctionComponent(first_gaussian)
16  aPlotter.AddFunctionComponent(second_gaussian)
17 
18  aPlotter.AddMapping(0, 0)
19  aPlotter.AddMapping(1, 1, 0.8)
20  aPlotter.AddMapping(1, 2, 1.0)
21  aPlotter.AddMapping(2, 4, 10)
22 
24  aPlotter = newFitPlotter()
25  return setupResolution(aPlotter)
26 
27 def SetParameterLimits(plotter, is_loose, *args):
28  func = plotter.SetLooseLimits if is_loose else plotter.SetParameterLimits
29  for index, limits in enumerate(args):
30  if limits:
31  func(index, *limits)
32 
33 def SetGuesses(plotter, is_loose, *args):
34  func = plotter.SetLooseGuess if is_loose else plotter.SetInitialGuess
35  for index, guess in enumerate(args):
36  func(index, guess)