Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ShipSoft/FairShip/llms.txt
Use this file to discover all available pages before exploring further.
rootUtils is the standard histogram management library used across FairShip analysis scripts. It abstracts the boilerplate of creating, accumulating, and persisting ROOT histograms behind a simple dictionary-keyed interface: histograms are stored in plain Python dicts keyed by any hashable value (string or integer), so scripts never need to manage ROOT name registration manually. The module also provides file-validation utilities, an error-count accumulator, and EOS-aware file opening for CERN infrastructure.
readHists
int keys. For every TH2D or TH2F histogram loaded, readHists automatically creates _projx and _projy projection companions. If a histogram with the same key already exists in h, the newly read histogram is added to it via TH1::Add, enabling straightforward accumulation across multiple files.
All histograms are detached from their source file (SetDirectory(ROOT.gROOT)) so they persist after the file is closed.
Destination dictionary. Histograms are inserted or accumulated here. The dict is modified in place.
Path to the ROOT file. Paths beginning with
/eos are opened via the CERN EOS gateway: the prefix $EOSSHIP (an environment variable) is prepended to the path before opening.Optional filter list. When non-empty, only keys present in
wanted are loaded into h. Both string and integer keys are matched. Defaults to None (load everything).bookHist
h under key. The dimensionality is determined automatically from the values of nbinsy and nbinsz:
nbinsz > 0→TH3Dnbinsy > 0→TH2D- otherwise →
TH1D
key already exists in h, the existing histogram is reset rather than replaced, preserving its pointer identity.
Histogram registry dictionary. The new histogram is stored as
h[key].Dictionary key and ROOT histogram name. Integer or float keys are coerced to strings for the ROOT name. If
None, a warning is printed and the function returns without creating anything.ROOT histogram title string, supporting the
"title;x-axis;y-axis" semicolon-separated convention.Number of bins along the x-axis.
Lower edge of the x-axis range.
Upper edge of the x-axis range.
Number of bins along the y-axis. A value greater than 0 promotes the histogram to
TH2D. Defaults to 0 (1-D histogram).Lower edge of the y-axis range (only used when
nbinsy > 0).Upper edge of the y-axis range (only used when
nbinsy > 0).Number of bins along the z-axis. A value greater than 0 promotes the histogram to
TH3D. Defaults to 0.Lower edge of the z-axis range (only used when
nbinsz > 0).Upper edge of the z-axis range (only used when
nbinsz > 0).bookProf
TProfile and register it in h under key. If ymin and ymax are both provided they are passed to the TProfile constructor to restrict the y-range; otherwise the profile uses the full y-range.
Histogram registry dictionary.
Dictionary key and ROOT histogram name.
ROOT histogram title string.
Number of x bins.
Lower x-axis limit.
Upper x-axis limit.
Optional lower y-range restriction passed to
TProfile.Optional upper y-range restriction passed to
TProfile.Option string forwarded to the
TProfile constructor (e.g. "s" to store the spread).writeHists
TH* and TP* histograms (and optionally TCanvas objects) from the dictionary h to a ROOT file in RECREATE mode.
Dictionary of histograms to write. Objects without a ROOT
Class method are silently skipped.Destination ROOT file path. The file is created or overwritten (
RECREATE).When
True, TCanvas objects in h (class name containing "TC") are also written to the file in addition to histograms.bookCanvas
TCanvas, divide it into a cx × cy grid of pads, and register it in h under key. If key already exists in h the call is a no-op.
Dictionary to store the canvas.
Dictionary key and ROOT canvas name. If
None, a warning is printed.Canvas window title.
Canvas width in pixels.
Canvas height in pixels.
Number of pad columns.
Number of pad rows.
Error logging
rootUtils maintains a module-level Counter (_error_log) to accumulate non-fatal error messages. Use reportError to record incidents and errorSummary to print a summary at the end of a job.
reportError
s in the module-level error log.
Error message string to record. Repeated calls with the same string increment a counter rather than generating duplicate output.
errorSummary
File validation helpers
checkFileExists
cbmsim tree or ntuple data. Exits the process via sys.exit(1) if any file cannot be opened.
A single file path or a list of file paths. EOS paths beginning with
/eos are opened via $EOSSHIP. All files in a list must be of the same type."tree" if the file(s) contain a cbmsim tree, or "ntuple" otherwise.checkForBranch
cbmsim tree of one or more ROOT files. Raises FileNotFoundError if a file cannot be opened and ValueError if files in a list disagree on branch presence.
A single file path or a list of file paths to inspect.
The branch name to look for inside the
cbmsim tree.True if the branch is present in all supplied files, False if absent from all files.