Skip to content

Write LaTeX yields table (same style as plotIt)

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

Closes https://gitlab.cern.ch/cp3-cms/bamboo/-/issues/63

As described in https://gitlab.cern.ch/cp3-cms/bamboo/-/issues/63#note_3639277, the way to use this is by adding one CutFlowReport to the plots list,

yields = CutFlowReport("yields")
plots.append(yields)

and adding selections to specific entries by adding a title, e.g.

yields.add(selHasMuMu, "With a dilepton pair")
yields.add(selHasElMu, "With a dilepton pair")
yields.add(selHasMuMu, "With a dimuon pair") # is allowed, no extra work in the event loop

As illustrated there, several selections can be added with the same title, then they will be added up, and a selection may be added several times, then there will be only one yield histogram, but it will be used for two entries in the table.

Other than that: the implementation is backwards-compatible, so construction from a list of selections (possibly with recursive=True) still works, but the row titles will be the selection names, so probably it's not the best ideas to mix these.

For the .tex output, the plotit python module from https://github.com/pieterdavid/mplbplot/tree/py3compat is required (see https://github.com/pieterdavid/mplbplot/pull/5 for more information). This is pure python, so can be done with pip install -e <path-to-clone> (then no reinstall is needed to update it).

Eras are handled in the same way as by plotIt, so it's easy to get per-era and combined yields tables, or both. The files are put in the output directory ({report.name}.tex for combined, {report.name}_{era}.tex for per-era, so the naming scheme is the same as for the plots directories).

Unrelated change: some of the plotIt-related methods in analysisutils used to take (eraMode, eras), but only use the list of eras (and would be called with a few different ones depending on eraMode), so they just take a list of eras now.

Still to do:

  • testing with more complex cases
  • documentation update
  • resolve the merge conflicts with https://gitlab.cern.ch/cp3-cms/bamboo/-/merge_requests/127 when that's in master
  • do something consistent when using a CutFlowReport and data-driven backgrounds together (the selection depends on the sample, currently) -> solution for now: ignore the data-driven (then selections are the same for all samples, and nothing special is needed, we can consider adding data-driven columns as future improvements)
  • remove -y from runPlotIt, eventually not needed, nothing will be done unless a plot is marked as for yields
  • (from @aguzel) deal with special characters in selection names
  • (from @swertz) add an option to rotate the table
Edited by Pieter David

Merge request reports