Skip to content

Commit

Permalink
Refined examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ponyisi committed Aug 14, 2020
1 parent bf4a2ed commit 9ef542c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
11 changes: 8 additions & 3 deletions histgrinder/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@

def transform_function_divide_ROOT(inputs):
""" This function returns the ratio of two ROOT histograms """
assert len(inputs) == 1
# there should only be one match at a time. inputs[0] will describe that match.
assert len(inputs) == 1 # for testing
# inputs[0] is a pair of (dict describing the regex matches, list of histograms)
# so we expect inputs[0][1] to be a pair, should have length 2
assert len(inputs[0][1]) == 2
cl = inputs[0][1][0].Clone()
cl.Divide(inputs[0][1][1])
return [cl]


def transform_function_divide2_ROOT(inputs):
""" This function returns the ratio of two ROOT histograms """
assert len(inputs) == 10
cl = inputs[0][1][0].Clone()
cl.Clear()
for o in inputs:
Expand All @@ -24,7 +29,7 @@ def transform_function_rms_ROOT(inputs):
""" This function returns the ratio of two ROOT histograms """
import ROOT
rv = ROOT.TH1F('RMS', 'RMS of gaussians', 40, 0, 2)
plots = [_[1][0] for _ in inputs] # all plots passed as first element of list
plots = [_[1][0] for _ in inputs] # all plots passed as first element of list
for plot in plots:
rv.Fill(plot.GetRMS())
return [plot]
return [plot]
10 changes: 9 additions & 1 deletion resources/example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@ Output: [ 'gauRMS' ]
Function: histgrinder.example.transform_function_rms_ROOT
#Here is how you would pass parameters
#Parameters: { variable: eta, binedges: [-2.5,-2.0,-1.5,-1.0,-0.5,0.0,0.5,1.0,1.5,2.0,2.5] }
Description: Testing3
Description: Testing3
---
# This function takes the ratio of one pair of histograms
Input: [ 'gaussians/gaus_72', 'gaussians/gaus_18' ]
Output: [ 'gauDivSpecial' ]
Function: histgrinder.example.transform_function_divide_ROOT
#Here is how you would pass parameters
#Parameters: { variable: eta, binedges: [-2.5,-2.0,-1.5,-1.0,-0.5,0.0,0.5,1.0,1.5,2.0,2.5] }
Description: Testing4

0 comments on commit 9ef542c

Please sign in to comment.