Package: lhcbstyle
LHCbStylePackaged version of thelhcbStyle.Cmacro with a python wrapper and utilities.Looking for just the macro itself?Click hereInstallationNB: if usinglb-conda default, this package is already available.Via package managersThe python module can be installed usingpip:pipinstalllhcbstyleorconda(viaconda-forge):condainstall-cconda-forgelhcbstyleInstalling the macroNB:condausers can ignore this step. It is done automatically.After installing the package withpipor from source, there is one last step
to install thelhcbStyle.Cmacro to ROOT's macro path. This is done using the
console command:lhcbstyleinstallThe default directory is found using the PyROOT functiongROOT.GetMacroDir(),
which is typically somewhere like/usr/share/root/macrosor$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/macroslhcbstyleinstallor use the command-line option--macro-dir:lhcbstyleinstall--macro-dir/path/to/macrosIf your chosen path does not correspond to$ROOTSYS/macros, then you can add it
to ROOT's macro paths using your~/.rootrcfile. For example, if you installedlhcbStyle.Cto~/.local/share/root/macrosthen add this line to~/.rootrc:Unix.*.Root.MacroPath: .:$(HOME)/.local/share/root/macros:$(ROOTSYS)/macrosUsageIn C++With the macro successfully installed, you can call it in the usual way:gROOT->ProcessLine(".L lhcbStyle.C");lhcbStyle();The functionlhcbStyle()takes a boolean argumentprint_msgwhich controls
whether a message is printed to stdout upon setting the style.TheTPaveText(lhcbName),TText(lhcbLabel) andTLatex(lhcbLatex)
objects are now located in theLHCbStylenamespace.For example, to draw the "LHCb" blurb on a plot, using the default position:LHCbStyle::lhcbName->Draw("same");TheTStyleobject (lhcbStyle) is also available in the same namespace.For example, to adjust the style before callinglhcbStyle():LHCbStyle::lhcbStyle->SetPadLeftMargin(0.16);or after callinglhcbStyle():gStyle->SetPadLeftMargin(0.16);In pythonNaturally, 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 calledLHCbStylewhich adds
context management, allowing the use of thewithkeyword, e.g.:fromlhcbstyleimportLHCbStylewithLHCbStyle()aslbs:can=ROOT.TCanvas()hist=make_plot()hist.Draw("E1")lbs.lhcbName.Draw("same")can.SaveAs("hist_lhcb.png")From the command lineThere is also a console commandlhcbstyle plotwhich draws a plotable object
saved to a ROOT file.The positional arguments are:the ROOT file to openthe name of theTObjectto drawthe 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 asAdditionally 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 openplot.root, extract aTH1Dcalledhistand draw with
error bars and save it asFig1.pdf,Fig1.epsandFig1.png:lhcbstyleplotplot.roothistFig1--formatspdfepspngSee the full usage notes usinglhcbstyleplot-hContributingCreating a development environmentssh://git@gitlab.cern.ch:7999/lhcb-docs/lhcbstyle.gitcdlhcbstyle
mambacreate--nametest-envrootpytestpipsetuptools_scm
pipinstall-e.[testing]pre-commitinstall
curl-olb-check-copyright"https://gitlab.cern.ch/lhcb-core/LbDevTools/raw/master/LbDevTools/SourceTools.py?inline=false"chmod+xlb-check-copyrightRunning the tests:pre-commitrun--all-files
pytest