Rebinning data in a multigraph


I wrote a macro to fit some peaks

The macro fits the ranges of the plot by a function, then I defined a totalFit function that is the sum of the functions used in each subrange.

@yus helped me to solve a bug here (Problems defining a multifit - #9 by faca87)

Here an example (maybe I’ve to improve the initial parameter, but for the moment it’s ok this plot)

I’ve one more question.

As you can see in the following figure,

they plotted the full spectrum that is the sum of S1+S2+S3+ S4+S5+S6 (small plots). To plot the full spectrum they rebinned in 28 days (as it is written in the caption).

I tried to rebin in this way:

int bindays=28;
int nbins = static_cast((x2 - x1) / bindays);


But I don’t see a decreasing in the number of points as in the figure of the article

multiflares.cpp (8.1 KB)

Hi again,

a TGraph (or TMultiGraph in your case) has no concept of “bins”. Only histograms do. A TAttAxis::SetNdivisions() has nothing to do with bins, it’s really about ticks. I suggest you either rework your text files or try using TGraph::GetHistogram() and rebin that.

Thank you @yus.
If I create a histogram using gethistogram, how to keep the correspondence on the y-axis? (i.e. do not alternate the flux values)?

Sorry, the TGraph::GetHistogram() won’t work here. It is always empty as explained at TGraph GetHistogram() - #2 by couet. You should try to create a histogram from your multigraph yourself.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.