Hi,
OK, that’s actually the more difficult case. The simplest shot at this would use a RooGenericPdf
RooGenericPdf B("B","(x>5)*B1+(x<=5)*B2)",RooArgSet(x,B1,B2)) ;
But this has two issues: 1) Numeric integrals is always used for normalization and 2) you might have a discontuity in your pdf if B1(5) != B2(5). You might be able to improve if you would write a custom class,.e.g
RooClassFactory::makePdf(“RooGluePdf”,“f1,f2,x,xcut”) ;
which will write code for a dummy pdf class RooGluePdf that takes four RooAbsReal input arguments named f1,f2,x,cut. Here you can then put some smarter code in evaluate(), e.g.
RooGluePdf::evaluate() {
if (x<xcut) return f1 ;
if (x>=xcut) {
Double_t xsave = x ; // save present value of x
x = xcut ; // set x to xcut
Double_t ratio = f1/f2 ; // calculate f1(xcut)/f2(xcut)
x = xsave ; // restore x to original value
return f2*ratio ; // return f2(x)*f1(xcut)/f2(xcut)
}
}
You can then use this code by doing
root> .L RooGluePdf.cxx+
and then instantiate it as follows
RooGluePdf B("B","B",x,RooConst(5),B1,B2)) ;
Please be aware that the general problem is quite difficult. The above example does e.g. not handle the case where f1(xcut)=0 in a graceful way.
Wouter