RE: TF1 saving

From: Jakub Čermák <jakub_at_jcermak.cz>
Date: Tue, 2 Feb 2010 19:06:52 +0100


I see. The "gaus" case was there just for simplicity, real data are more complicated, so I'm using either string formula or C function. Anyway, I just hoped there is some way how to save the fitted function just as a formula and its parameters (which would be few bytes) in such complex framework like ROOT, because storing 100000s of histograms as plain array of the functions' values is not possible. I found out, that in case of string formula, I can call SetNpx function later, when viewing in ROOT Browser, and therefore get the nice smooth function again. So the stored fNpx points are redundant and useless, there the parameters and the formula must be stored there too, right? This is not ofc possible with the C function, but I can partially solve the space issue with storing the string formula function with low fNpx (4 is the minimum) and then "resample" it when viewing. It looks rather over-complicated, is there some better solution how to store large number of fitted histograms? I thought it's not a rare problem. And also setting fNpx in ROOT browser for a fitter function is complicated and not very user-friendly, but there is no way, how to achieve this without writing code in the CInt console, right?

And you didn't answered me why test2 (string formula) is much more slower than test3 (C function). Why is that?

S pozdravem / Best regards

Jakub Čermák
Institute of Experimental and Applied Physics

> -----Original Message-----
> From: Rene Brun [mailto:Rene.Brun_at_cern.ch]
> Sent: Tuesday, February 02, 2010 6:03 PM
> To: Jakub Čermák
> Cc: roottalk_at_cern.ch
> Subject: Re: [ROOT] TF1 saving
>
> Hi Jakub,
>
> When you use the case "gaus", this is a special hardwired case for TF1
> and fitting. Fitting is fast.
> When you use a general expression with a string, the fitting ignores
> that this is in fact a gaussian formula and it goes
> to a more general case as in teh case of a C function.
>
> In all cases, the TF1 object is stored at fNpx points, in your case
> 1000
> points for case 2 and case 3.
> For case 1 only 100 points (default value for fNpx) are stored, so your
> file temp1 is much smaller.
> The solution is to decrease fNpx to a smaller value.
>
> Currently there is no way to disable the storage of the fNpx points for
> the simple case "gaus". Simply reduce fNpx.
>
> Rene Brun
>
> Jakub Čermák wrote:
> > Hi Rene,
> > Thanks for your reply. I made very simple example illustrating my
> problem at http://regulus.utef.cvut.cz/~jcermak/my/example.c .
> > It shows all 3 approaches I tried (predefined gaus, custom formula
> and custom C function) and writes them into files. I couldn't #include
> <time.h> (CInt said it can't find it), so there is no measurement, but
> it can be clearly seen that test2 is much slower then previous.
> > Can you now see what I mean?
> >
> > And minor issue - why does the ROOT CInt crash after executing this
> script? This structure works at compiled code without problem.
> >
> > Best regards
> >
> > Jakub Čermák
> > Institute of Experimental and Applied Physics
> >
> >
> >> -----Original Message-----
> >> From: Rene Brun [mailto:Rene.Brun_at_cern.ch]
> >> Sent: Sunday, January 31, 2010 11:08 AM
> >> To: Jakub Čermák
> >> Cc: roottalk_at_cern.ch
> >> Subject: Re: [ROOT] TF1 saving
> >>
> >> Could you send the shortest possible RUNNING script with a data file
> >> containing your histogram and reproducing
> >> the time and space problem?
> >>
> >> Rene Brun
> >>
> >> Jakub Čermák wrote:
> >>
> >>> Hi Rooters,
> >>> I’ve lots of histograms with fitted functions, so started to care
> >>>
> >> about size of fitted functions (in the TFile) and speed of fitting.
> >>
> >>> When I use predefined function to fit, like gaus, the fitting is
> >>>
> >> quick and resulting TFile is relatively small. But I need to fit
> with
> >> more complex function, so I tried standard C function. The fitting
> was
> >> still quick, but the resulting TFile is now much bigger. Is it
> because
> >> it doesn’t store the formula with params but directly the values of
> the
> >> function, right? So it’s not a good solution for me.
> >>
> >>> So I rewrote the C function to string formula and I expected that
> it
> >>>
> >> would store just the formula and params, not „sampled“ function
> values.
> >> But I was wrong, the file was as big as when I used C function. And
> the
> >> fitting process was considerably slower than previous approaches.
> >>
> >>> So that’s my question – what’s the best solution to store
> histograms
> >>>
> >> fitted with custom function and keep the result file small and
> fitting
> >> process quick?
> >>
> >>> It's quite big issue for me, because there are few hundred of
> >>>
> >> thousands fitted histograms.
> >>
> >>> The fitting function is [0]*TMath::Gaus(max(min([3], [1]), x), [1],
> >>>
> >> [2])
> >>
> >>> Thanks in advance for good ideas :)
> >>>
> >>> Best regards
> >>>
> >>> Jakub Čermák
> >>>
> >>>
> >>>
> >>>
> >>>
> >
> >
> >
Received on Tue Feb 02 2010 - 19:07:03 CET

This archive was generated by hypermail 2.2.0 : Wed Feb 03 2010 - 11:50:02 CET