ROOT for Google Colab

Pre-built ROOT binaries optimized for Google Colab environments

Try Example Notebook

📚 What is that?

Setting up ROOT in Google Colab has traditionally been a time-consuming process that can take hours away from your valuable research time. This project eliminates these installation hurdles by providing ready-to-use, optimized ROOT binaries that work seamlessly with Colab's environment.

Instead of wrestling with build configurations or waiting for lengthy compilations, you can now have ROOT up and running in your Colab notebook within seconds. The project pre-built binaries are automatically maintained to stay compatible with Colab's Python versions and include all commonly used features while maintaining optimal performance.

🔧 Available Builds

Loading available builds from GitHub...

🛠 Build Features

Included Components

  • ✅ Python bindings (PyROOT)
  • ✅ RooFit statistical analysis package
  • ✅ MathMore libraries
  • ✅ Multithreading support (IMT)
  • ✅ SSL and XML support
  • ✅ XRootD support (built-in)
  • ✅ ROOT 7 features
  • ✅ 3D Graphics (graf3d)
  • ✅ PYTHIA8 integration
  • ✅ Fortran support
  • ✅ Thread support

Excluded

  • ❌ OpenGL support
  • ❌ Vector Detection Technology (VDT)
  • ❌ SQLite support
  • ❌ GDML support
  • ❌ Davix
  • ❌ FITS I/O
  • ❌ Table support
  • ❌ Testing modules
  • ❌ Debug symbols

🚀 Detailed Usage Guide

Select Your Configuration

Choose your ROOT and Python version combination. The code examples below will update automatically.

1. Initial Setup

# Loading configuration...

2. Basic Data Analysis

# Create and fill a histogram
import ROOT

# Create a 1D histogram
h1 = ROOT.TH1F("h1", "Gaussian Distribution;X;Entries", 100, -5, 5)

# Fill with random numbers
for i in range(10000):
    h1.Fill(ROOT.gRandom.Gaus(0, 1))

# Customize appearance
h1.SetLineColor(ROOT.kBlue)
h1.SetFillColor(ROOT.kBlue - 10)

# Draw and save
c1 = ROOT.TCanvas("c1", "Canvas", 800, 600)
h1.Draw("hist")
c1.Draw()

3. Data Fitting

# Create a more complex example with fitting
import ROOT
import numpy as np

# Create data with two peaks
h2 = ROOT.TH1F("h2", "Double Gaussian;X;Entries", 100, -10, 10)

# Fill with two Gaussians
for i in range(5000):
    h2.Fill(ROOT.gRandom.Gaus(-2, 1.5))
for i in range(3000):
    h2.Fill(ROOT.gRandom.Gaus(3, 0.8))

# Define fit function
fit_func = ROOT.TF1("fit_func", "gaus(0) + gaus(3)", -10, 10)
fit_func.SetParameters(2000, -2, 1.5, 1000, 3, 0.8)

# Perform fit
h2.Fit(fit_func, "R")

# Draw results
c2 = ROOT.TCanvas("c2", "Fit Canvas", 800, 600)
h2.Draw()
c2.Draw()

4. Advanced Visualization

# Create a 2D histogram
h3 = ROOT.TH2F("h3", "2D Gaussian;X;Y", 50, -5, 5, 50, -5, 5)

# Fill with correlated random numbers
for i in range(50000):
    x = ROOT.gRandom.Gaus(0, 1)
    y = ROOT.gRandom.Gaus(0.5 * x, 0.5)
    h3.Fill(x, y)

# Create canvas and draw
c3 = ROOT.TCanvas("c3", "2D Canvas", 800, 800)

# Set color scheme and draw options
ROOT.gStyle.SetPalette(ROOT.kBird)
h3.Draw("colz")

# Add color scale
c3.SetRightMargin(0.15)
c3.Draw()

⚠️ Known Issues

SSL Certificate Issues

If you encounter SSL certificate validation errors when using ROOT in Google Colab, this typically occurs due to missing or outdated SSL libraries. You can resolve this by installing the required SSL package:

!wget http://archive.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2_amd64.deb
!sudo dpkg -i libssl1.1_1.1.1f-1ubuntu2_amd64.deb
!rm libssl1.1_1.1.1f-1ubuntu2_amd64.deb

Other Common Issues

  • If ROOT fails to import after installation, try restarting your Colab runtime
  • If you need any of the excluded features, you will need to build ROOT with them
  • Building ROOT in the same Colab runtime will take most of the runtime allocation time