Replacing PDF servers

Dear Roofit experts,

Is is possible to replace the sigma parameter of a RooGaussian PDF with another RooRealVar? For example:

[code]RooRealVar var(“var”, “var”, 0.5, 0, 1);
RooRealVar mean(“mean”, “mean”, 0.5, 0, 1);
RooRealVar mean(“sigma”, “sigma”, 0.1, 0, 1);
RooRealVar mean(“anotherSigma”, “anotherSigma”, 0.2, 0, 1);

RooGaussian gaussMod(“gaussMod”, “Gaussian model”, var, mean, sigma);

/* do something to replace sigma with anotherSigma */[/code]

I thought that the RooAbsArg::replaceServer() method would do the trick, but I can’t seem to make it work. If it is possible could somebody give an example of exactly how to go about it?

Many thanks,

Hugh

Dear Hugh,

I am not an expert but only another user who is currently struggling with a problem that might be related to yours. If I add a

gaussMod.printMultiline(std::cout, 1);

before and after the replaceServer statement, I see that apparently the servers are replaced but the corresponding “proxies” not…

Hopefully some RooFit expert can provide an explicit solution and maybe a bit more insight in this server/proxy business…

Cheers,
Sebastian

Hi Sebastian,

I actually worked out how to do this on my own. At least I think I did, I may have missed something! Anyway if I do the following (Note that in my first post the code wouldn’t have worked anyway because all the RooRealVars had mean as their identifier!) :

[code]RooRealVar var(“var”, “var”, 0.5, 0, 1);
RooRealVar mean(“mean”, “mean”, 0.5, 0, 1);
RooRealVar sigma(“sigma”, “sigma”, 0.1, 0, 1);
RooRealVar anotherSigma(“anotherSigma”, “anotherSigma”, 0.2, 0, 1);

RooGaussian gaussMod(“gaussMod”, “Gaussian model”, var, mean, sigma);

gaussMod.Print(“v”);

anotherSigma.setAttribute(“ORIGNAME:sigma”, true);
gaussMod->redirectServers(RooArgList(anotherSigma), false, true);

gaussMod.Print(“v”);[/code]

Then I see:

[quote]— RooAbsArg —
Value State: DIRTY
Shape State: DIRTY
Attributes:
Address: 0x101857e00
Clients:
Servers:
(0x1018e8000,V-) RooRealVar::var “var”
(0x101968a00,V-) RooRealVar::mean “mean”
(0x101969000,V-) RooRealVar::sigma "sigma"
Proxies:
x -> var
mean -> mean
sigma -> sigma
— RooAbsReal —

Plot label is “gaussMod”
— RooAbsPdf —
Cached value = 0

— RooAbsArg —
Value State: DIRTY
Shape State: DIRTY
Attributes:
Address: 0x101857e00
Clients:
Servers:
(0x1018e8000,V-) RooRealVar::var “var”
(0x101968a00,V-) RooRealVar::mean “mean”
(0x101969600,V-) RooRealVar::anotherSigma "anotherSigma"
Proxies:
x -> var
mean -> mean
sigma -> anotherSigma
— RooAbsReal —

Plot label is “gaussMod”
— RooAbsPdf —
Cached value = 0[/quote]

Hope that helps.

Cheers,

Hugh

Dear Hugh,

yes, this is helpful. It works - for my case too. I was also playing around already with the redirectServers method (instead of replaceServer) but hadn’t figured out yet how to set this ORIGNAME attribute correctly.

Thanks a lot!

Sebastian

It’s possible to do that in RooFit Factory tool.

root.cern.ch/root/html/RooFactoryWSTool.html

I think it uses the RooCustomizer for that:

root.cern.ch/root/html/RooCustomizer.html

Regards

– Gregory