MPF.processProjector module

class MPF.processProjector.ProcessProjector(**kwargs)[source]

Bases: object

Serves as a base class for use cases where multiple histograms should be projected from trees - defined by process instances

Used by TreePlotter() and SignalGridProjector()

Parameters:
  • cut – Cut expression to be applied for all registered processes (default: “1”)
  • weight – Weight expression to be applied for all registered processes (default: “1”)
  • varexp – Expression to be used for filling histograms (default: “1”)
  • inputLumi – luminosity the trees are normalised to
  • targetLumi – luminosity the histograms should be scaled to
  • xmin – minimum on the x axis
  • xmax – maximum on the x axis
  • nbins – number of bins
  • binLowEdges – list of low edges of bins (in this case xmin, xmax and nbins are ignored)
  • useMultiHistDraw – use multiHistDrawer() when calling fillHists() (loop tree only once and fill all histograms) (default: True)
  • cutsDict – if this is given, fetch only yields for all cuts and create a histogram and yieldsDict for each process
addProcess(process)[source]

Add a Process()

addProcessTree(name, filename, treename, **kwargs)[source]

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
addSysTreeToProcess(nomProcessName, sysName, filename, treename, **kwargs)[source]

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 = {'binLowEdges': None, 'cut': '1', 'cutsDict': None, 'inputLumi': 1.0, 'nbins': 1, 'targetLumi': 1.0, 'useMultiHistDraw': True, 'varexp': '1', 'weight': '1', 'xmax': 2.0, 'xmin': 0.0}
fillHists(opt=None)[source]

Project histograms for all processes

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

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)[source]

Fill yields dicts from cutsDict

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

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

getProcess(processName)[source]
getProcesses(*selection)[source]
registerToProjector(*selection, **kwargs)[source]

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)[source]
setProcessOptions(processName, **kwargs)[source]

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