gonalyzer

package module
v0.0.0-...-46257ac Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2021 License: BSD-3-Clause Imports: 0 Imported by: 0

README

TTree GOnalyzer

Documentation

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 with float64 and []float64 branches,
  • concurent sample processings.

In a nutshell

// 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]

Performances

benchmarking

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

Documentation

Overview

Package gonalyzer exposes types and functions to ease the analysis of ROOT trees.

// 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"),
}

// 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)

// Produce plots
analyzer.Run()

There is also the possibility of doing cutflows in a simple way. Few lines of code can produce this ASCII table:

| Cut name              | Raw Yields                 | Weighted Yields            |
|                       |                 Abs    Rel |                 Abs    Rel |
|-----------------------|----------------------------|----------------------------|
| Electron channel      |         5526   100%   100% |     28230.59   100%   100% |
| pT > 10 GeV           |         5281    96%    96% |     28065.97    99%    99% |
| Phi < 2.0 rad         |         4312    78%    82% |     22874.73    81%    82% |

Directories

Path Synopsis
ana
Package allowing to wrap all needed element of a TTree plotting analysis
Package allowing to wrap all needed element of a TTree plotting analysis
demo
Package featuring a realistic example of analysis using ana package.
Package featuring a realistic example of analysis using ana package.
perf
Package allowing to benchmark performances of the ana package.
Package allowing to benchmark performances of the ana package.
cflow package exposes types allowing to perform a cut flow on a single file.
cflow package exposes types allowing to perform a cut flow on a single file.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL