Classes | |
class | DirectoryChanger |
Functions | |
def | ROOTloader |
Try to save the command line arguments from unconsiderate ROOT behaviour. More... | |
def | TVector2ToString |
Print vectors easily. More... | |
def | TVector3ToString |
def | TLorentzVectorToString |
def | splitROOTpath |
File management. More... | |
def | createROOTpath |
def | activateDirectory |
def | getROOTclass |
def | expandFileList |
this is not really specific to ROOT, but we often have ROOT file lists More... | |
Variables | |
string | __doc__ |
list | __all__ |
tuple | ROOT = ROOTloader() |
args | |
def ROOTutils.activateDirectory | ( | ROOTdir | ) |
Sets a directory with `DirectoryChanger`. Example: dir = outputFile.GetDirectory("plots") with activateDirectory(dir): for plot in plots: item.Write() # with
Definition at line 227 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
def ROOTutils.createROOTpath | ( | path, | |
fileMode = "UPDATE" |
|||
) |
Creates a complete ROOT directory path. The `path` is in the form: "/UNIX/path/to/file.root:internal/ROOT/directory/structure". The ROOT file `/UNIX/path/to/file.root` will be created with the specified `fileMode` (path may be relative), then the `TDirectoryFile` hierarchy `internal/ROOT/directory/structure` will be created under it. The return value is a pair `(file, dir)`, where `file` is a open `TFile` for `/UNIX/path/to/file.root` and `dir` is the `TDirectory` object of `structure`. Remember to keep track of `file`, or else python may close it compromising `dir` as well.
Definition at line 129 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
def ROOTutils.expandFileList | ( | fileListPath | ) |
this is not really specific to ROOT, but we often have ROOT file lists
Definition at line 261 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
def ROOTutils.getROOTclass | ( | classPath | ) |
Returns the object specified by `classPath` within ROOT module. Throws `AttributeError` if any object in the path is not available. Example: `getROOTclass('geo::GeometryCore')` returns `ROOT.geo.GeometryCore`.
Definition at line 243 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
def ROOTutils.ROOTloader | ( | ) |
Try to save the command line arguments from unconsiderate ROOT behaviour.
The ROOT interpreter likes to peek at the command line arguments and interpret them its own way. For example, an option `-b` will be interpreted to set ROOT in batch mode. Likewise, if a `--help` argument is present on the command line, the interpreter will print the ROOT help message and, even worse, halt the script. This is clearly not very friendly to the script. The initialization of the interpreter happens lazily the first time anything is read out of `ROOT` module: `import ROOT` is not enough, but pretty much everything after that involving ROOT is (exception: `ROOT.gROOT` will not trigger the interpreter, but trying to get anything out of `ROOT.gROOT` will). That makes it complicate to control when that happens. This function triggers the interpreter initialization after having removed all command line options, and finally restores them (we use a context manager to show that we know Python). The loaded module is returned. This function is called as soon as this module is imported. It is important that this happens as early as possible, possibly as a replacement of ROOT import, as: from ROOTutils import ROOT from ROOTutils import * import ROOTutils import ROOT or equivalent.
Definition at line 20 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
def ROOTutils.splitROOTpath | ( | path | ) |
File management.
Returns the specified path split into file path and ROOT directory path. The `path` is in the form: "/UNIX/path/to/file.root:internal/ROOT/directory/and/object". The returned value is a pair `(filePath, dirPath)`: in the example, that would be `("/UNIX/path/to/file.root", "internal/ROOT/directory/and/object")`. Note: for compatibility with some ROOT tradition, the separator ':' can be replaced by '/'
Definition at line 103 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
def ROOTutils.TLorentzVectorToString | ( | v | ) |
Definition at line 92 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
def ROOTutils.TVector2ToString | ( | v | ) |
Print vectors easily.
Definition at line 88 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
def ROOTutils.TVector3ToString | ( | v | ) |
Definition at line 90 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
list ROOTutils.__all__ |
Definition at line 10 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
string ROOTutils.__doc__ |
Definition at line 4 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
ROOTutils.args |
Definition at line 64 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.
tuple ROOTutils.ROOT = ROOTloader() |
Definition at line 83 of file icarusalg/icarusalg/gallery/helpers/python/ROOTutils.py.