Operations on histograms


I’d like to make some operation with histograms, belonging to two general classes:

  1. assemble many 1D (2D) histograms into a single 2D (3D) histogram

  2. perform a linear (or general) transformation on the coordinates of 2D (or 3D) histograms

An example of the first kind of use is the following: I’m making histograms of a given quantity over simulated data samples (QCD di-jets). Such samples are characterized by different generator-level pT ranges and I’d like to find the dependence on them. My idea is to setup a dimension “MC pT” with variable binning (actually, it happens to be a constant binning in log(pT)) and associate the histogram filled looping over each sample to its bin.

An example of the second type of operation is the following: I want to compare the trigger and offline measurements of a given quantity. If I fill a 2D histogram the scatter plot shows an almost linear correlation with a slope that is not 1 and some offset that is non zero. I’d like to rotate the scatter plot and translate the origin, so that vertical (or horitontal) slices are orthogonal to the “cigar” and give me the resolution.

I’m pretty sure that some trick already exists to make such operations, but was not able to find any hint.

Many thanks,
Diego Casadei


For your 1st question, see TH1::Merge(TCollection*)
For your second question, start from the variables in a Tree applying the necessary transformation.