MPF.n1plotter module¶
Create “n-1” plots (plots where a set of cuts is applied except the
cut on the plotted distribution). This is in particular useful for
signal region optimization when used together with
SignificanceScanPlot
. However,
you can create every plot that
TreePlotter
can create.
To create multiple n-1 plots first set up a TreePlotter in the usual way - for Example:
from MPF.treePlotter import TreePlotter
tp = TreePlotter(plotType="SignificanceScanPlot", inputLumi=0.001, targetLumi=36.1,
cut="lep1Pt>35&&nLep_base==1&&nLep_signal==1",
weight="eventWeight*genWeight")
Afterwards add your backgrounds and signals in the usual way (have a look at treePlotter
).
Then create the N1Plotter and pass it your TreePlotter
:
from MPF.n1plotter import N1Plotter
np = N1Plotter(tp)
The output format can also be specified - for example:
np = N1Plotter(tp, outputFormat="<mydir>/{name}.pdf")
Now you can add several cuts (for each of which a plot should be
created). You can give arbitrary custom plotting options (see
TreePlotter
) for each cut. For Example:
np.addCut(varexp="met", value=350,
plotOptions=dict(xmin=0, xmax=1000, nbins=20))
np.addCut(varexp="met/meffInc30", value=0.1, name="met_over_meff",
plotOptions=dict(xmin=0, xmax=0.4, nbins=50))
If you choose to change a few options (like the cut value) afterwards
you can do that by using getCut()
. For Example:
np.getCut("met").value = 200
np.getCut("met_over_meff").value = 0.2
Finally create all the plots:
np.makePlots()
Or, alternatively, register them and plot them at once (using multiHistDrawer
):
np.makePlots(registerOnly=True)
tp.plotAll()
-
class
MPF.n1plotter.
Cut
(varexp, value, comparator='>', name=None, plotOptions=None, removeCuts=None)[source]¶ Parameters: - varexp – the expression to be plotted/cut on
- value – the cut value
- comparator – how to compare the varexp to the value?
- name – name for the cut (will be used to name the output
file and for referencing - see
getCut()
). If no name is given, the varexp will be used. - removeCuts – when creating the n-1 expression, in addition also remove these cuts
- plotOptions – dictionary of arbitrary options for the plot that corresponds to this cut
-
name
¶
-
class
MPF.n1plotter.
N1Plotter
(plotter, outputFormat='{name}.pdf')[source]¶ -
addCut
(*args, **kwargs)[source]¶ Add a cut for which an n-1 plot should be created. The arguments are passed to
Cut
.
-
getCut
(name)[source]¶ Get the cut referenced by the given name. You can use this to change the options for a particular cut. For example:
np.getCut("met").value = 200
-
getN1Expr
(*names)[source]¶ Return cut expression for all cuts except the ones referenced by the given names and the cuts that are supposed to be removed with them
-
makePlots
(registerOnly=False)[source]¶ Create all plots. If registerOnly is set, then the plots are only registered to the
TreePlotter
and can be plotted later by usingplotAll()
Returns the list of filenames plotted (or to be plotted)
-