Skip to content

A few helpers, freezing systematics for an expression

Pieter David requested to merge piedavid/bamboo:helpersandfixes_202105 into master

One fix (IPython.start_ipython, which is a bit heavier, but doesn't have the problem that it forgets some locals), and a few helper functions that may be generally useful (came up in a discussion with @fbury ):

  • op.typeOf: get the C++ type of an expression or proxy
  • op.getSystematicVariations: list the systematic variations affecting an expression
  • op.forSystematicVariation: freeze an expression for a specific variation

The last one is the interesting one ;-) . It can be useful to disable variations for an expression without duplication of the user code. This works, but more testing is welcome:

% bambooRun -i --module=../examples/nanozmumu.py:NanoZMuMu ../examples/test1.yml --output=nanozmm_test1

In [1]: j0pt = tree.Jet[0].pt

In [2]: j0pt_fr = op.forSystematicVariation(j0pt, "jet", "nominal")

In [3]: op.getSystematicVariations(j0pt_fr)
Out[3]: {}

In [4]: op.getSystematicVariations(j0pt)
Out[4]:
{'jet': ['jer0up',
  'jer0down',
  'jer1up',
  'jer1down',
  'jer2up',
  'jer2down',
...
Edited by Pieter David

Merge request reports