Set Range for RooFit

Dear ROOTers,
I have a problem with setting range in RooFit
As it’s said in the UserGuide, if I construct a RooGaussian gauss and a RooDataHist data, I can fit gauss to data simply using “gauss.fitTo(data)”.
If I want to set a range for the fitting, I can use “gauss.fitTo(data,Range(0,5))”.
But how can I fit the gauss in to seperate ranges?For example, in Range(0,5) and Range(6,7).
Thanks :slight_smile:

Hi,

If you want to use a composite range you should make a named range associated with the observable, e.g.

x.setRange(“R1”,0,5) ;
x.setRange(“R2”,6,7) ;

at which point you can refer to the symbolic names R1,R2 in your fitTo() call

gauss.fitTo(data,Range(“R1,R2”)) ;

See e.g. $ROOTSYS/tutorials/roofit/rf312_multirangefit.C for a complicate example with multiple disjoint ranges in multiple observables

Wouter

Hi Wouter,

Let me know if some update in the User’s Guide is required.

Olivier

Hi Olivier,

As far as I can tell this is correctly documented in the manual in pages 70-72.
Is anything missing there?

Wouter

As there was a user question I wondered if it was worth making some change in the User’s Guide to make it clearer. But if you think it is OK that’s fine for me too.

Thank you Wouter!
It really helps!
You are a good teacher!