LHCbStyle
Packaged version of the lhcbStyle.C macro with a python wrapper and utilities.
Looking for just the macro itself? Click here
Installation
NB: if using lb-conda default, this package is already available.
Via package managers
The python module can be installed using pip:
pip install lhcbstyle
or conda (via conda-forge):
conda install -c conda-forge lhcbstyle
Installing the macro
NB: conda users can ignore this step. It is done automatically.
After installing the package with pip or from source, there is one last step
to install the lhcbStyle.C macro to ROOT's macro path. This is done using the
console command:
lhcbstyle install
The default directory is found using the PyROOT function gROOT.GetMacroDir(),
which is typically somewhere like /usr/share/root/macros or $ROOTSYS/macros.
If you don't have permission to write to this directory, or you want to install
the macro to a different ROOT installation, you can set the destination with an
environment variable:
ROOT_MACRO_DIR=/path/to/macros lhcbstyle install
or use the command-line option --macro-dir:
lhcbstyle install --macro-dir /path/to/macros
If your chosen path does not correspond to $ROOTSYS/macros, then you can add it
to ROOT's macro paths using your ~/.rootrc file. For example, if you installed
lhcbStyle.C to ~/.local/share/root/macros then add this line to ~/.rootrc:
Unix.*.Root.MacroPath: .:$(HOME)/.local/share/root/macros:$(ROOTSYS)/macros
Usage
In C++
With the macro successfully installed, you can call it in the usual way:
gROOT->ProcessLine(".L lhcbStyle.C");
lhcbStyle();
The function lhcbStyle() takes a boolean argument print_msg which controls
whether a message is printed to stdout upon setting the style.
The TPaveText (lhcbName), TText (lhcbLabel) and TLatex (lhcbLatex)
objects are now located in the LHCbStyle namespace.
For example, to draw the "LHCb" blurb on a plot, using the default position:
LHCbStyle::lhcbName->Draw("same");
The TStyle object (lhcbStyle) is also available in the same namespace.
For example, to adjust the style before calling lhcbStyle():
LHCbStyle::lhcbStyle->SetPadLeftMargin(0.16);
or after calling lhcbStyle():
gStyle->SetPadLeftMargin(0.16);
In python
Naturally, in PyROOT, you can execute the macro in much the same way as in C++:
ROOT.gROOT.ProcessLine(".L lhcbStyle.C")
ROOT.lhcbStyle()
However, the package includes a python class called LHCbStyle which adds
context management, allowing the use of the with keyword, e.g.:
from lhcbstyle import LHCbStyle
with LHCbStyle() as lbs:
can = ROOT.TCanvas()
hist = make_plot()
hist.Draw("E1")
lbs.lhcbName.Draw("same")
can.SaveAs("hist_lhcb.png")
From the command line
There is also a console command lhcbstyle plot which draws a plotable object
saved to a ROOT file.
The positional arguments are:
- the ROOT file to open
- the name of the
TObjectto draw - the output filename, without extension (optional, defaults to "plot")
The optional arguments are:
--draw-style,-D: option string to pass to theDraw()function--formats,-F: file extensions to save the plot as
Additionally an label can be added to the plot with one of:
--official: draw "LHCb" label--preliminary: draw "LHCb Preliminary" label--simulation: draw "LHCb Simulation" label--unofficial: draw "LHCb Unofficial" label--no-label: don't draw any label (default)
For example, to open plot.root, extract a TH1D called hist and draw with
error bars and save it as Fig1.pdf, Fig1.eps and Fig1.png:
lhcbstyle plot plot.root hist Fig1 --formats pdf eps png
See the full usage notes using
lhcbstyle plot -h
Contributing
Creating a development environment
ssh://git@gitlab.cern.ch:7999/lhcb-docs/lhcbstyle.git
cd lhcbstyle
mamba create --name test-env root pytest pip setuptools_scm
pip install -e .[testing]
pre-commit install
curl -o lb-check-copyright "https://gitlab.cern.ch/lhcb-core/LbDevTools/raw/master/LbDevTools/SourceTools.py?inline=false"
chmod +x lb-check-copyright
Running the tests:
pre-commit run --all-files
pytest
Metadata
Release files for lhcbstyle 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lhcbstyle-0.1.0.tar.gz | 23.5 kB | Without provenance | Details for lhcbstyle-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lhcbstyle-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for lhcbstyle-0.1.0-py3-none-any.whl |
Total release size: 45.1 kB
Release files / lhcbstyle-0.1.0.tar.gz
| Download URL | lhcbstyle-0.1.0.tar.gz |
|---|---|
| Size | 23.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e385afb6eb8afea177e6801d334cc855e774983cba48d9c1135a3fda96ead2d
|
|
BLAKE2b-256 checksum How to use checksums |
7213be0e4384a013a599f6a6629d6b9c7c058a5a577d9ad9054f048fa4bc83cb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10
|
Release files / lhcbstyle-0.1.0-py3-none-any.whl
| Download URL | lhcbstyle-0.1.0-py3-none-any.whl |
|---|---|
| Size | 21.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
868a637f42d965f725019b76a53d65e811e2378ff7731eed6b8b7f7dc661a81e
|
|
BLAKE2b-256 checksum How to use checksums |
89fd30c5189e7c7b5ec54f4fae7349871ed19c7a626f104b490f9a8e72b974e7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.7.10
|
Security for lhcbstyle 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.