I have a 2D plot (obtained from TTree) which I’ve dumped into a 2D histogram. I want to interpolate between data points and rebin to access the interpolated data. Using TProfile doesn’t seem to help as it only gives access to the original data, i.e. some bins will have value of 0. I’ve tried using Tgraph, and whilst displaying the interpolated plot is trivial, dumping it into a 2D histogram isn’t
See plots below to illustrate problem. So I guess I have two questions:
(a) is there a way to access intepolated data using TProfile
(b) If I went staight from TTree to TGraph, is there a way to dump the interpolated plot into a histogram with an arbitrary number of bins? See script below for one of the many options I tried.
Many thanks!
ttree ->Draw("y:x");
TGraph *g = new TGraph(nbins,tree->GetV1(),tree->GetV2())
g->Draw("ALP"); // this gives me plot (D)
// to dump into 2D histo
TH2F *h = new TH2F("h","h",nbinsx,x1,x2,nbinsy,y1,y1);
h->Draw();
g->Draw("ALP">>h); // This dosen't work!
erm… similar syntax will work for dumping a TTree/Ntuple plot into a histogram, so why not into a Tgraph? (I guess that’s probably a philosophical question - like asking why are apples and pears different)
But back to my original question, how can I dump my TGraph plot into a histogram so that I can access the interpolated data. I’ve searched the internet( and previous forum entries)…and the few proposed solutions I found seem really convoluted. Is there an elegant/simple solution that I’m missing. Please I need some help as I’m not expert ROOT.
Tried it. Works fine, but only for TH1 (x axis values increase with increasing n) and not TH2 (because my Y values decrease with increasing n). pity as I need to access Y bin values as well.
All is not lost however… as I’m thinking that a less elegant workaround could be to read in 2 separate Ntuple root files, each generated from the same data sample but with the x and y columns sorted in increasing order respectively