This tutorial illustrates how to use TProfiles in combination with the TDataFrame.
See the documentation of TProfile and TProfile2D to better understand the analogy of this code with the example one.
3 TDataFrame = ROOT.ROOT.Experimental.TDataFrame
7 def fill_tree(treeName, fileName):
9 d.Define(
"px",
"gRandom->Gaus()")\
10 .Define(
"py",
"gRandom->Gaus()")\
11 .Define(
"pz",
"sqrt(px * px + py * py)")\
12 .Snapshot(treeName, fileName)
17 fileName =
"tdf003_profiles.root"
19 fill_tree(treeName, fileName)
22 columns = ROOT.vector(
'string')()
23 columns.push_back(
"px")
24 columns.push_back(
"py")
25 columns.push_back(
"pz")
26 d = TDataFrame(treeName, fileName, columns)
29 hprof1d = d.Profile1D((
"hprof1d",
"Profile of pz versus px", 64, -4, 4))
30 hprof2d = d.Profile2D((
"hprof2d",
"Profile of pz versus px and py", 40, -4, 4, 40, -4, 4, 0, 20))
33 c1 = ROOT.TCanvas(
"c1",
"Profile histogram example", 200, 10, 700, 500)
35 c2 = ROOT.TCanvas(
"c2",
"Profile2D histogram example", 200, 10, 700, 500)
- Date
- February 2017
- Author
- Danilo Piparo
Definition in file tdf003_profiles.py.