TIMBER  beta
Tree Interface for Making Binned Events with RDataFrame
Public Member Functions | Public Attributes | List of all members
HistGroup Class Reference

Stores histograms with dedicated function to use TH1/2/3 methods in a batch. More...

Inheritance diagram for HistGroup:
Inheritance graph
[legend]
Collaboration diagram for HistGroup:
Collaboration graph
[legend]

Public Member Functions

def __getitem__ (self, key, lazy=False)
 Get value from key as you would with dictionary. More...
 
def __init__ (self, name)
 Constructor. More...
 
def Add (self, name, item, meta={})
 Add histogram to the group. More...
 
def Do (self, THmethod, argsTuple=())
 Batch act on histograms using ROOT TH1/2/3 methods. More...
 
def Merge (self)
 Merge together the histograms in the group. More...
 
- Public Member Functions inherited from Group
def __add__ (self, other)
 Adds two Groups together. More...
 
def __getitem__ (self, key)
 Get value from key as you would with dictionary. More...
 
def __init__ (self, name)
 Constructor. More...
 
def __setitem__ (self, key, value)
 Set key-value pair as you would with dictionary. More...
 
def Add (self, name, item, meta={}, makeCopy=False)
 Add item to Group with a name. More...
 
def Clone (self, name)
 Clone the current group with a new name. More...
 
def Drop (self, name, makeCopy=False)
 Drop item from Group with provided name/key. More...
 
def keys (self)
 Gets list of keys from Group. More...
 
def values (self)
 Gets list of values from Group. More...
 

Public Attributes

 type
 str Set to 'hist' so group is treated as histograms. More...
 
- Public Attributes inherited from Group
 item_meta
 OrderedDict() More...
 
 items
 OrderedDict() More...
 
 name
 str More...
 
 type
 string More...
 

Detailed Description

Stores histograms with dedicated function to use TH1/2/3 methods in a batch.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  name 
)

Constructor.

Parameters
name(str): Name for instance.

Member Function Documentation

◆ __getitem__()

def __getitem__ (   self,
  key,
  lazy = False 
)

Get value from key as you would with dictionary.

If lazy == False and the stored value is a histogram pointer, return the actual histogram. Ex. val = mygroup["item_name"]

Parameters
key(obj): Key for name/key in Group.
lazy(bool): Access only the pointer, not the histogram (avoids execution of loop).
Returns
obj Item for given key.

◆ Add()

def Add (   self,
  name,
  item,
  meta = {} 
)

Add histogram to the group.

Internal group name will match the histogram name if not otherwise specified but note that this will cause an RDataFrame loop to happen!

Parameters
name(str): Name of histogram to use as key. Cannot access name of histogram from the pointer or it will execute the loop.
item(TH1): Histogram to add.
meta(dict): Meta information to associate with the histogram like "xtitle", "ytitle", "ztitle" that can be shipped for later use so that the loop does not execute.
Returns
None

◆ Do()

def Do (   self,
  THmethod,
  argsTuple = () 
)

Batch act on histograms using ROOT TH1/2/3 methods.

Parameters
THmethod(str): String of the ROOT TH1/2/3 method to use.
argsTuple(tuple): Tuple of arguments to pass to THmethod.
Returns
HistGroup or None: New HistGroup with THmethod applied if THmethod does not return None; else None.

Examples

To scale all histograms by 0.5

myHistGroup.Do("Scale",(0.5))

◆ Merge()

def Merge (   self)

Merge together the histograms in the group.

Returns
TH1 Merged histogram.

Member Data Documentation

◆ type

type

str Set to 'hist' so group is treated as histograms.


The documentation for this class was generated from the following file: