How to set fit range in simultaneous fit?

Dear Root Community,

I was wondering what is the correct way to set a fit range or multiple fit ranges for a simultaneous fit? There are a few post regarding this topic and a page (p.71) dedicated to this in the RooFit User Manual, but I was not able to find a satisfying answer…

I created a minimal working example with 4x4 slices and some constraints:
fitComplete.cpp (11.6 KB)

However when applying a global fit range either the fit or the normalization in the plotting process fails and the results look off.

When trying the fit with individual ranges for each slice I receive an error message that the ranges are overlapping:

ERROR:Integration -- gauss_t0_e0 : integrating with respect to the variables (x) on the ranges  "fitRange_t0_e0,fitRange_t0_e1,..." is not possible because the ranges are overlapping
libc++abi: terminating due to uncaught exception of type std::invalid_argument: gauss_t0_e0 : integrating with respect to the variables (x) on the ranges  "fitRange_t0_e0,fitRange_t0_e1,..." is not possible because the ranges are overlapping

Is there a working example or tutorial where this is successfully done?

Best Regards,
Adrian

I guess @jonas can help.

Hello again,

Before this topic is closed, I just wanted to give a solution I found, as it might help others. It looks reasonable, but im not sure if what im doing is technically correct. This is the updated script:
fitComplete.cpp (9.4 KB)

The important part for fitting different ranges in each category / slice seems to be:

Range("fitRange"), EvalBackend("legacy")

in the fit statement.

I guess the Range("fitRange") lets RooFit internally searched for ranges with "fitRange" in the name and for example picks up "fitRange_t1_e1" for the respective slice / category "t1_e1".
With respect to this post I am not sure if SplitRange(true) should be used in this context, but from what I read its better not to use it here.

The EvalBackend("legacy") chose the likelihood evaluation method and without it the fit results look of. I can’t explain why this helps.

Thanks, Adrian