ModelConfig Print loads snapshot

Hi,

I have noticed some very confusing behaviour of the ModelConfig::Print() method.

If the model has an associated snapshot, then that shapshot is loaded in order to print its contents. That means that adding a mc->Print() for information or debugging can alter the values in the workspace. I discovered this when I got different (incorrect) results when I enabled debugging output.

Surely a Print method should never change anything.

Another (minor) unconventional behaviour of ModelConfig’s Print() is that it only prints its output if RooMsgService has INFO messages enabled. For other classes, Print() always produces its output (unless the defaultPrintStream is directed elsewhere) and it’s up to the caller to decide whether to call Print. ModelConfig’s behaviour may sometimes be more convenient, but the non-standard behaviour is confusing when it sometimes doesn’t produce any output.

Tim.

Hi Tim,

I agree the Print method should be const and it is in did. Now you are saying that RooWorkspace::load snapshot() does it change the workspace ? I did not realize that, if this is the cue I will fix it.
I will also fix the printing on the right stream.

Thank you for reporting this,

Lorenzo

Hi Tim,

I have fixed this issue in both trunk and 5.34 (from revision 44697)

Thanks for reporting it

Lorenzo