Setting a RooRealVar to constant

This feels like a silly question, but is there a way to set a RooRealVar to constant after it’s been initialized as a value over a range?

For example

Example.C (969 Bytes)

I have two functions; Create(), and Read(). Create() makes a basic model, generates some data, does a basic fit, saves it all to a workspace. Read() gets that workspace, updates the mean variables value by setting it, and then setting the a restrictive range.

This is functional, but it doesn’t feel like a good solution. What if I don’t want to update the value of mean? What if I want to leave it to the previously fit value, just leave it constant there? Is this the only way to set a RooRealVar to constant? or is there a better solution?


Thanks for the code and the interesting post.
If the usage of a ROOT: RooConstVar Class Reference is not adequate for you, I’d like to ask the opinion of @moneta and @jonas , our RooFit experts.



To fix a RooRealVar to a value, that will not be changed when fitting the model, you need to use


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