# How to "smooth"(approx.)TTree data before plotting a graph?

Hello,

I am looking for some function for approximating or smoothing the original data. The approximated data then I want to use for drawing a TGraph. Do have such a method in ROOT?

I had a look in TGraphSmooth. But for using smoother function from TGraph we should give a input graph. I tried the following:

TGraph *gr1 = new TGraph(T1->GetSelectedRows(),T1->GetV2(), T1->GetV1());
TGraphSmooth *gs = new TGraphSmooth(“normal”);
gr1 = gs->SmoothSuper(gr1,"",1); //After drawing a graph its doing “smoothing”

What I am looking for, is first smooth the original data and then plot it. Do anybody have an idea?

Thank you.

Hello,
I am still looking for the soluction. If somebody already done this before then please guide me.

Thank you.

Hi,

You need to use Approx(). Here is some sample code:

``````// Normalize selected data with super smoother
TGraph *grin, *grout;
TGraphSmooth *gs = new TGraphSmooth("supsmu");
grin = new TGraph(nin, yin, xin); //reference xin as y array!
grout = gs->SmoothSuper(grin, "" ,bass, span);

// Approximate y values for corresponding x values
TGraph *grnor, *grapp;
grnor = new TGraph(grout->GetN(), grout->GetX(), grout->GetY());
grapp = gs->Approx(grnor, fMethod, nout, yout, 0, 0, rule, f, fTies);

memcpy(yout, grapp->GetY(), nout*sizeof(Double_t));``````

Christian

Hello,

I tried SmoothSuper() and Approx() methods already. Let me explain my problem in detail.
My original code is:

T1->Draw("(a0+a2):T", ,“same”);
TGraph *gr1 = new TGraph(T1->GetSelectedRows(),T1->GetV2(), T1->GetV1());
TGraphSmooth *gs = new TGraphSmooth(“normal”);
gr1 = gs->SmoothSuper(gr1,"",1); [color=#FF0040]//Here for Smoothing the graph it needs to pass “gr1” as a agument. [/color]

This means, first need to create a graph and then that TGraph is get smooth by TGraphSmooth. But what I am looking for is: First smooth the data e.g: first smooth a0 and a2 and then plot a graph of smoothed data. So I am looking for [color=#FF0040]some method which will smooth the TTree data[/color].

Thank you.

Hello,

If somebody knows how to get it please let me know.

Thank you.

T1->Draw("(a0+a2):T"); // 2D scatter-plot
TGraph grin = (TGraph)gPad->GetPrimitive(“Graph”); // retrieve the result of Draw
TGraphSmooth *gs = new TGraphSmooth(“normal”);
TGraph *grout = gs->SmoothSuper(grin, “”, 1);

Hello,

Do ROOT have some method in which we can smooth only some specific part of the TGraph? Means can user give a rang for TGraph to smooth the data belongs to that rang only?

Thank you.

[quote=“Pree”]Hello,

Do ROOT have some method in which we can smooth only some specific part of the TGraph? Means can user give a rang for TGraph to smooth the data belongs to that rang only?

Thank you.[/quote]

Hello,
I have the same question here. Did you get the answer??

Thanks