[RooFit] A easy way to save the initial values and set them


I just want to do the fitting in a Loop, and I hope that the initial values of the parameters would be the same for each entry. But you know, the fitting would change the value of the parameters…

I guess there must be a easy way to do this somewhere, Maybe two lines would be enough, but how?-:slight_smile:

// save the values

// set the initial values.


Thank you very much.


There is an easy way. To save the ‘original’ values you first do this

// Get list of parameters of a p.d.f given set of observables
RooArgSet* params = pdf.getParameters(observables) ;

// Make a snapshot of the parameterlist
RooArgSet* savedParams = params->snapshot() ;

Then in your fitting loop you can restore at any point the
p.d.f parameters to the save values as follows

*params = *savedParams ;