;;;;;;
;; General configuration options.
;;    PlotStyle:  Either a global matplotlib style name, or a style file in the base dir.
;;    Variable:   Variable to decompose.
;;    Weight:     Event weight. This is REQUIRED.
;;    Scale:      Scale factor to apply to the data
;;
;;    Lumi:       The luminosity when converted events -> cross-sections
;;    LumiUnc:    Uncertainty on the luminosity; range is from 0 to 1
;;    XSecUnits:  Units to display on limit plots.  This is cosmetic;
;;                  units should correspond to whatever units are used
;;                  for 'Lumi'.
;;;;;;
[General]
PlotStyle:       plot.mplstyle
Variable:                  Myy
Weight:                 weight
Scale:                       1

Lumi:                      0.0
LumiUnc:                  0.02
XSecUnits:              Events

;;;;;;
;; Input files. Format is
;;    DataSet : n
;; to keep every n'th event.
;;;;;;
[InputFiles]
Test:                        1
gausFunc89:                  5
gausFunc125:                25

;;;;;;
;; Cuts to apply.  The format is
;;    'name:  condition'
;; where condition can be a Python snippet referring to any variable in the dataset.
;;;;;;
[Cuts]
Mass:                 Myy > 60

;;;;;;
;; Parameters for the decomposition.  Note that most are fixed,
;;   but Alpha and Lambda are free and will be adjusted during
;;   optimization.
;;
;; Nbasis:      number of moments when calculating moments, yields, covariances
;; Nxfrm:       number of moments used as inputs to transformation
;; Ncheck:      max number of moments to consider as possible background
;;
;; x0:          Minimum mass cut.  There should be a corresponding cut in 'Cuts' above
;;                in order to guarantee consistency.
;;
;; Nthread:     Number of threads to use for array operations.
;;;;;;
[ExpDecompFactory]
Nthread:                     4

Nbasis:                   4096
Nxfrm:                     256
Ncheck:                     24

x0:                       60.0

;;;;;
;; Scan ranges for the hyperparameters 'Alpha' and 'Lambda'. These use
;; the syntax:
;;      (start) : (stop) : (# fine steps) : (# coarse steps)
;; The search region is delineated by 'start' and 'stop'.  Full decompositions
;; are performed on the coarse grid, and transformed decompositions are
;; produced on the fine grid.  The best set of parameters are used as the
;; initial point for a final optimization.  The final ':' and last parameter
;; may be omitted, in which case they default to 1.
;;;;;
[HyperParameterScan]
Alpha:       0.45 : 0.85 : 49 : 5
Lambda:       120 :   40 : 81 : 5

;;;;;;
;; Specification of signal models. 'func' is a function that describes
;; the signal shape, which takes argument 'x'.  Other parameters can be
;; specified in curly braces like {parameter}, and then later set as
;; configuration keys like:
;;
;;      parameter: 0.256
;;
;; The configuration blocks 'ParametricSignal: <name>' inherit from
;; 'ParametricSignalDefault'.  Any keys not specified in or overridden
;; by 'ParametricSignal: <name>' will be retrieved from 'ParametricSignalDefault'.
;;
;; If the ParametricSignal block DOES NOT have a 'Scan' key specified, it is
;; included in all decomposition, including during the hyperparameter
;; optimization.  If 'Scan' is specified, it should be a list or ndarray
;; containing a list of masses to consider.  The masses are exposed as
;; {Mass} when the block is evaluated, so the functions and their
;; parameters can be written as functions of {Mass} when necessary.
;;;;;;
[ParametricSignalDefault]
func:       np.exp( -(x - {mu})**2 / (2*{sigma}**2) )
NumPoints:  2**23

[ParametricSignal: Z]
mu:         89.5
sigma:      2.5
NumPoints:  2**26

[ParametricSignal: h]
mu:         125
sigma:      1.6
NumPoints:  2**25

[ParametricSignal: Res]
Scan:       60*np.cumprod((1.01,) * 337) / 1.01
mu:         {Mass}
sigma:      0.0128*{Mass}
NumPoints:  2**18

[ParametricSignal: 2.5%]
Scan:       60*np.cumprod((1.02,) * 180) / 1.02
mu:         {Mass}
sigma:      0.0250*{Mass}
NumPoints:  2**19

[ParametricSignal: 5.0%]
Scan:       60*np.cumprod((1.04,) * 93) / 1.04
mu:         {Mass}
sigma:      0.0500*{Mass}
NumPoints:  2**20

[ParametricSignal: 10.0%]
Scan:       60*np.cumprod((1.08,) *  50) / 1.08
mu:         {Mass}
sigma:      0.1000*{Mass}
NumPoints:  2**21



;;;;;
;; Plots.  Specify as many as you would like.  Each plot is specified in a block
;; with header
;;
;; [Plot : filename.pdf]
;;
;; The plot is saved in '<basedir>/Output/filename.pdf'.  Like the signal blocks,
;; all plot blocks inherit from 'PlotDefault'.
;;
;; There are several plot types available, specified by the 'Type' key:
;;    Estimators:  Draw signal shapes and the corresponding estimators. Use the
;;                 'signals' key to specifiy which signals to draw, and the 'Draw'
;;                 key to specify what to draw (signals, estimators, or residuals).
;;
;;    Moments:     Line / bar plot of the norm-squared of the moments for the data
;;                 and specified signal models.  The data is always drawn; signals
;;                 can be selectively specified using the 'Draw' key, just like
;;                 above. 'Style' can be set to either 'line' or 'bar'.
;;
;;    Fit:         Draw a histogram of the mass spectrum together with the decomposition.
;;                 The key 'Bins' should contain a list or ndarray of bin edges, in
;;                 order.  The plot will be drawn from the lower edge to the upper
;;                 edge, ignoring events outside the range.
;;
;;    Scan:        Draw a p-value and limit plot for the mass scans specified in
;;                 'Scans'.  You're allowed to choose any signal model above that
;;                 had a 'Scan' parameter specified.
;;
;; All of these have various keys available to adjust the cosmetic features of
;; the plot (titles, linear vs. log, etc.).  See below for examples.  The plot
;; code lives in Plots/Plots.py, so consult that for a full list of parameters.
;;;;;

[PlotDefault]
XLabel:    $M_{\gamma\gamma}$ (GeV)
LogX:      False
LogY:      True
Style:     errorbar
CMap:      copper
Residual:  True
ResYLim:   (-1.0, 1.0)

;;;;;
;; Compare the Higgs signal, the signal residual, and the minimum-variance estimator.
;;;;;
[Plot: estimators.pdf]
Type:       Estimators
Title:      Estimator Comparison for $Z$ and $h$
YLabel:     Arbitrary Units
Signals:    ("h", "Z")
Draw:       ("Signal", "Estimator")
Range:      (45, 345)
LogX:       False

;;;;;
;; Compare all the data moments to the Higgs signal and estimator.
;;;;;
[Plot: moments.pdf]
Type:       Moments
Title:      Moment Comparison - Data vs. Higgs
XLabel:     "Moment \#"
Signals:    ("h", )
Draw:       ("Signal", "Estimator")
Style:      line
Range:      (1, 2048)
LogX:       False
LogY:       True

[Plot: moments_Zh.pdf]
Type:       Moments
Title:      Moment Comparison - Data vs. Higgs and Z
XLabel:     "Moment \#"
Signals:    ("h", "Z")
Draw:       ("Estimator", )
Style:      line
Range:      (1, 384)
LogX:       False
LogY:       True

;;;;;
;; Draw the first 128 data moments.
;;;;;
[Plot: low_moments.pdf]
Type:       Moments
Title:      Data Moments
XLabel:     "Moment \#"
Style:      bar
Range:      (1, 128)
LogX:       False
LogY:       True


;;;;;
;; Make some plots of the fits
;;;;;
[Plot: full.pdf]
Type:      Fit
Title:     Full Spectrum
YLabel:    Events / GeV
Bins:      np.logspace(np.log10(60), np.log10(3060), 201)
LogX:      True
YLim:      (1e-5, 1e5)

[Plot: lowmass.pdf]
Type:      Fit
Title:     Low-Mass Region
YLabel:    Events / GeV
Bins:      np.linspace(60, 160, 101)
LogY:      False

[Plot: Zh.pdf]
Type:      Fit
Title:     Higgs / Z Region
YLabel:    Events / $0.5$GeV
Bins:      np.linspace(80, 130, 101)
LogY:      False

;;;;;
;; Overlay the Gaussian scan results, and produce individual plots too.
;;;;;
[Plot: gauss_overlay.pdf]
Type:      Scan
Title:     Gaussian Overlay
Scans:     ("10.0%", "5.0%", "2.5%", "Res",)
LogX:      True

[Plot: gauss_res.pdf]
Type:      Scan
Title:     Resolution Gaussian
Scans:     ("Res",)
LogX:      True

[Plot: gauss_25.pdf]
Type:      Scan
Title:     2.5\% Gaussian
Scans:     ("2.5%",)
LogX:      True

[Plot: gauss_50.pdf]
Type:      Scan
Title:     5\% Gaussian
Scans:     ("5.0%",)
LogX:      True

[Plot: gauss_100.pdf]
Type:      Scan
Title:     10\% Gaussian
Scans:     ("10.0%",)
LogX:      True

