Skip to content

Use Combine

The same installation supports notebooks, an activated terminal, single isolated commands, and an interactive Combine shell.

In a notebook

Choose the combine-v11 kernel, displayed as:

Python 3 (CMSSW_16_0_0 + Combine v11.0.0)

The kernel provides both CMSSW Python packages and Combine executables:

import os
import ROOT
import HiggsAnalysis.CombinedLimit.PhysicsModel

print(os.environ["CMSSW_VERSION"])
print(ROOT.gROOT.GetVersion())

Command-line tools can be invoked with subprocess:

import subprocess

subprocess.run(
    ["combine", "-M", "AsymptoticLimits", "card.txt", "--run", "blind"],
    check=True,
)

Paths and outputs are relative to the notebook's working directory unless the command supplies another path.

In the current terminal

Explicitly switch the terminal from SWAN's LCG environment to the pinned CMSSW environment:

source activate.sh
combine --help
text2workspace.py --help
combineTool.py --help

After activation, the shell intentionally uses CMSSW's Python and shared libraries. Open another terminal if you also need the untouched SWAN/LCG environment.

Run one isolated command

Use combine-run when you do not want to alter the calling shell:

./bin/combine-run combine -M AsymptoticLimits card.txt --run blind

The helper activates the pinned runtime in its own process and then replaces itself with the requested command.

Open an interactive Combine shell

./bin/combine-shell

You can also pass a command directly:

./bin/combine-shell python3 -c 'import ROOT; print(ROOT.gROOT.GetVersion())'

Validate the installation again

Run the installed-runtime check at any time:

./scripts/check_setup.sh

It checks the exact tag, imports, utilities, and a real blind asymptotic-limit workflow. The temporary datacard and ROOT output are deleted automatically.

Keep workflows portable

  • Build paths from COMBINE_SWAN_ROOT rather than embedding another user's EOS path.
  • Use CMSSW_BASE when you need the active CMSSW area.
  • Keep analysis inputs and final outputs outside the generated CMSSW_16_0_0 tree.
  • Do not source activate.sh from swan_env.sh; the parent notebook server must retain its own Python runtime.
  • Rerun scripts/install_kernel.sh after moving or renaming the checkout.