[RooFit] Check if snapshot exist without showing ObjectHandling error

Typically, when one tries to check if a snapshot exists in a workspace, one can do

snapshot = workspace.getSnapshot("my_snapshot")
exist = True if snapshot else False


snapshot = workspace.loadSnapshot("my_snapshot")
exist = True if snapshot else False

However, both will show an error message like this:

[#0] ERROR:ObjectHandling -- RooWorkspace::loadSnapshot(combWS) no snapshot with name <snapshot_name> is available

Of course, you may just ignore the error or disable the error message using


But this is undesirable. I know there are indirect ways since ROOT 6.26, e.g.


My question is whether there is a way to simply check if a snapshot exists without triggering the ObjectHandling error message? If not I think it would make more sense if the getSnapshot method does not trigger such a message since we are not loading the snapshot anyway.

1 Like

@jonas can you have a look here?

Hi @AlkaidCheng, thanks for starting this discussion!

You’re absolutely right in my opinion, the ERROR message is redundant with returning a nullptr if no snapshots is found, and that it’s annoying for the usecase where you want to use getSnapshot() to check if a snapshot exists.

Also, a strong argument is that all these other accessors like pdf(), arg(), function() and war() don’t have this error message as well.

So I opened a PR to remove this error message, then you won’t see it anymore in ROOT 6.28:


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