MPF.signalGridProjector module

class MPF.signalGridProjector.SignalGridProjector(**kwargs)[source]

Bases: MPF.processProjector.ProcessProjector

Use ProcessProjector for a whole signal grid where each signal point corresponds to one tree where the grid parameters can be parsed from the name.

Inheritance diagram of MPF.signalGridProjector.SignalGridProjector

Currently no further functionality of automatically creating plots is implemented, but the dictionaries created by getHarvestList can be used to make for example signal acceptance/efficiency plots or simple sensitivity projections for a whole signal grid.

The following parameters can also be given in getHarvestList and registerHarvestList and will overwrite the defaults for the particular list.

Example usage:

sp = SignalGridProjector(weight="eventWeight*genWeight")
sp.addProcessTree("ttbar", treePath, "ttbar_NoSys", style="background")
sp.addProcessTree("wjets", treePath, "wjets_NoSys", style="background")
sp.addSignalProcessesByRegex("GG_oneStep_(?P<mg>.*?)_(?P<mch>.*?)_(?P<mn>.*?)_NoSys", "GG_oneStep", treePathSignal)

harvest = sp.getHarvestList("GG_oneStep", cut="met>200&&mt>150")
Parameters:
  • pValueName – dictionary key for the “pValue” (default: “p0exp”)
  • pValueMode – which kind of “pValue” should be calculated. Currently BinomialExpP, SOverB and S is supported (default: “BinomialExpP”)
  • BinomialExpPFlatSys – add this flat (relative) systematic uncertainty to the MC stat. uncertainty when using BinomialExpP
  • customFunction – instead of using one of the predefined pValueModes use this custom function. The parameters given to the function are (signal, signalMCStatError, background, backgroundMCStatError).
addCalculatedVariable(varname, gridName, fun)[source]

Add a variable that is supposed to be calculated from the signal point parameters to the given signal grid.

Warning

Not implemented yet

Note: cuts on parameters are not supposed to be introduced here (better in the plotting step)

addProcess(process)

Add a Process()

addProcessTree(name, filename, treename, **kwargs)

Create and add a process from one tree in one file. The kwargs are passed to Process():

Parameters to be used for registerHist() for histograms created from the process:

Parameters:
  • style – (default: “background”)
  • color – (default: None)
  • lineColor – (default: None)
  • markerColor – (default: None)
  • fillColor – (default: None)
  • lineStyle – (default: None)
  • lineWidth – (default: None)
  • fillStyle – (default: None)
  • markerStyle – (default: None)
  • drawErrorBand – (default: False)
  • drawString – (default: None)
  • legendTitle – (default: None)
  • drawLegend – (default: True)
  • ratioDenominatorProcess – (default: None)
  • stackOnTop – (default: False)

The other parameters:

Parameters:
  • cut – cut/weight expression to be used only for this process
  • norm – normalise the resulting histograms to unity?
  • scale – scale resulting histogram by this factor
  • varexp – use this varexp for this process instead of the one used for all the other processes
  • normToProcess – normalise the histogram to the same integral as the given process (by name) before plotting (only used for hists of style “systematic” in TreePlotter)
  • sysTag – name of the systematic variation (mainly for internal use in ProcessProjector and TreePlotter)
  • noLumiNorm – don’t normalise this process to the luminosity configured
addSignalProcessesByRegex(regex, gridName, *paths, **processOpts)[source]

Add all signal points matching a regex. The regex should be able to return a groupdict containing the grid parameters and will be tried to match the tree names found in the given paths (matching the path names is not supported yet). The grid and its parameters are referenced later by the given gridName

addSysTreeToProcess(nomProcessName, sysName, filename, treename, **kwargs)

Create and add a process from one tree in one file and register it as a systematic variation for the nominal process. The kwargs are passed to Process()

Parameters:
  • nomProcessName – name of the nominal process
  • sysName – name of the systematic variation
  • treename – name of the tree
  • filename – path to the rootfile containing the tree
  • normToProcess – normalise the histogram to the same integral as the given process (by name) before plotting (only used in TreePlotter).
defaults = {'BinomialExpPFlatSys': None, 'customFunction': None, 'pValueMode': 'BinomialExpP', 'pValueName': 'p0exp'}
fillHists(opt=None)

Project histograms for all processes

Parameters:opt – if given use these options instead of the current ones (see getOpt())
fillHistsSysErrors()

Adds errors based on variational histograms for all processes to their histograms. Should only be used if variations are not correlated across different processes (e.g. don’t use it for TreePlotter - there is a treatment included for this via registerSysHist())

fillYieldsDicts(opt=None)

Fill yields dicts from cutsDict

Parameters:opt – if given use these options instead of the current ones (see getOpt())
getAllHarvestLists(**kwargs)[source]

Finally create all registered harvest lists. Returns a dict gridName -> registerKey -> harvestList

getHarvestList(gridName, **kwargs)[source]

Calculates the pValues for the given grid. Returns a “harvest list” of the form:

[
  {<pValueName> : pValue1, "parameter1" : "value1", "parameter2" : "value2", ...},
  {<pValueName> : pValue2, "parameter1" : "value1", "parameter2" : "value2", ...},
  ...
]

By default the pValue is calculated by BinomialExpP, using the MC stat uncertainty for the background. A flat background systematic can be given optionally. Alternatively you can specify a custom Function for p-value calculation with parameters (signal, signalMCStatError, background, backgroundMCStatError).

getOpt(**kwargs)

Get the namedtuple containing the current ProcessProjector() options, updated by the given arguments.

getProcess(processName)
getProcesses(*selection)
static getSignalPoints(*args, **kwargs)[source]

Returns a dictionary of matching group dicts (and rootfile paths where they were found) corresponding to the signal tree names that were found. For example:

regex = "w_(?P<m1>.*?)_(?P<m2>.*?)$"

will return a dict like:

{
  "w_2000_1000" : {"paths" : {"path1", "path2", ...}, "m1" : "2000", "m2" : "1000"},
  ...
}

ToDo: Add option to match by path name instead of tree name

getSignalProcessesGrid(gridName)[source]
getTotalBkgHist()[source]
registerHarvestList(gridName, registerKey, *selection, **kwargs)[source]

Register a plot to be plotted later. You can give a selection. For example if you pass “background” and use multiHistDraw later only the background processes will be projected by multiHistDraw (the rest will just use “usual” TTree::Draw). When you call getAllHarvestLists later the list will be referenced by the registerKey you have given.

registerToProjector(*selection, **kwargs)

Register hists for each process to the histProjector (to be filled later with multiHistDraw).

Mainly for internal use in registerPlot() and registerHarvestList()

Parameters:
  • opt – namedtuple containing ProcessProjector() options
  • selection – only register processes of this style(s) (like “background”)
setDefaults(**kwargs)
setProcessOptions(processName, **kwargs)

Change the options of an existing process - referenced by its name. Only change the given options, leave the existing ones