How to Replace for an existing RooKeyPDF the ProxyVariable

Dear all ,
I have a question concerning the RooKeysPDF and in general the pdfs creation.
Let’s say i saved to disk ( not in a RooWorkspace) a RooKeyPDF object i created using

   RooKeysPdf(const char *name, const char *title,
              RooAbsReal& x, RooRealVar& xdata, RooDataSet& data, Mirror mirror= NoMirror,
         Double_t rho=1);

having xdata = RooFormulaVar( x + ShiftParameter)

I want to rerun the code loading it from disk and replacing x with another RooRealVar.
In practice i need to be able given an existing RooKeysPDF to update the protected member
RooRealProxy _x;

Is there anything one can do or do I need to regenerate the RooKeysPDF from scratch ?
Basically my question is , i want to use the same analytical form of a PDF but simply replace the RooRealProxy _x variable over which the RooKeysPDF exists. This is similar to a use case where for example you create a RooKeyPDF from a variable “x” and then you want to use the same but for an observable “y” .

Thanks in advance

EDIT: for my use case, use a RooWorkSpace is not possible, since i want my fitting code to load parts of the fit which are created in different places at different time. So somehow it would be in my case as if I have 10 Workspaces , and among the 10 workspaces some variables are shared. So the idea would be to “align” the 10 workspaces variables and update all the dependencies they have

I think @moneta can help you.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.

I hope @moneta will reply once back at work, or maybe @jonas


I think you can try using a function like redirectServers, see


1 Like

thanks for pointing out this function, i give a try to see if it fit my needs and it works avoiding me to re-do all the time the rookeypdfs from scratch. I will post a minimal pseudo code example once i get this running and checking it works.