Sharing parameters in fitting

Hello
I wish to fit two functions in two different ranges. For example, if I would like the two functions share their parameters, for example as follows:
f1 = a + bx
f2 = a
sin(x)
As above, the parameter “a” is shared between two functions fitting at two subranges. Can ROOT do this type of minimization process?

Simply implement a fit function like

Double_t myfunc(Double_t *x, Double_t *par) { if Ix[0] < something) return par[0] +par[1]*x[0]; else return par[0]*sin(x[0]); }
Rene