Home | News | Documentation | Download

TH2 x y projection interactive viewer


2D histograms are very useful for visualizing data, but are limited when it comes to quantify gradients and structures based on the color map, or when it comes to compare two different 2D histograms. Normally, one tends to project on the x or y axis, or to draw 1D profiles along a given direction.

Currently, the option SetShowProjection method is a helpful tool to do that analysis interactively. In this app, I extend this idea with a class that

  • does simultaneously x/y projections
  • allows interactive changing of the window width (instead of closing and regenerating the projection) and position
  • compares several 2D histograms (or rather their 1D projections) with corresponding checkboxes
  • it is not sensitive to the mouse position, which has always made SetShowProjection a tricky feature to use.

Hope it helps you!

Run as:

root -l
TH2* h2 = (TH2*)(TFile::Open("graphs.root")->Get("h2"));
TH2* h3 = (TH2*)(TFile::Open("graphs.root")->Get("h3"));
#include "TH2Viewer.cpp"
TH2Viewer* h2v = new TH2Viewer({h2,h3});

graphs.root (9.4 KB)
TH2Viewer.h (7.3 KB)
TH2Viewer.cpp (17.2 KB)

Ineractive x|y projection of TH2Fs

Attached version 2 with autozoom option.
TH2Viewer.h (7.9 KB)
TH2Viewer.cpp (21.9 KB)