This is a tool written in go to produce publication-quality plots from ROOT TTrees in an flexible and easy way. This tool is built on top of go-hep.org. The main supported features are:
- histograming variables over many samples and selections,
- displaying one or several signals (overlaid or stacked),
- sample normalisation using cross-section and/or luminosity and/or number of generated events,
- computing of new variables of arbitrary complexity,
- joint trees to the main one, as in
TTreeFriend
, - dumping
TTree
's withfloat64
and[]float64
branches, - concurent sample processings.
// Define samples
samples := []*ana.Sample{
ana.CreateSample("data", "data", `Data`, "data.root", "mytree"),
ana.CreateSample("bkg1", "bkg", `Proc 1`, "proc1.root", "mytree"),
ana.CreateSample("bkg2", "bkg", `Proc 2`, "proc2.root", "mytree"),
ana.CreateSample("bkg3", "bkg", `Proc 3`, "proc3.root", "mytree"),
}
// Define variables
variables := []*ana.Variable{
ana.NewVariable("plot1", ana.TreeVarBool("branchBool"), 2, 0, 2),
ana.NewVariable("plot2", ana.TreeVarF32("branchF32"), 25, 0, 1000),
ana.NewVariable("plot3", ana.TreeVarF64("branchF64"), 50, 0, 1000),
}
// Create analyzer object with some options
analyzer := ana.New(samples, variables, ana.WithHistoNorm(true))
// Produce plots and dump trees
analyzer.Run()
![]() |
![]() |
![]() |
Data/Background [code] | Unstacked signals [code] | Stacked signals [code] |
![]() |
![]() |
![]() |
Shape distortion [code] | Shape comparison [code] | Systematic variation [code] |
For 2M events and 60 variables, a comparison with similar ROOT-based code
(using t->Draw()
) gives:
ROOT -> 6 ms/kEvts
GOHEP -> 2 ms/kEvts
For 2M event and one variable (avoiding t->Draw()
repetition)
ROOT -> 0.4 ms/kEvts
GOHEP -> 0.1 ms/kEvts