RooStringVar in RooWorkspace

Hi RooFit-ers!

Simple question: is there any dedicated method for handling RooStringVars in a RooWorkspace? Have a look at the following interactive session which illustrates my problem:

root [0] RooWorkspace* w = new RooWorkspace("w")

RooFit v3.60 -- Developed by Wouter Verkerke and David Kirkby
                Copyright (C) 2000-2013 NIKHEF, University of California & Stanford University
                All rights reserved, please read

(RooWorkspace *) 0x7fc4b4c55200
root [1] w->factory("myFavoriteThing['RooFit']")
(RooAbsArg *) 0x7fc4b5851600
root [2] w->Print()

RooWorkspace(w) w contents


root [3] //Seems to work although I couldn't find this factory syntax documented
root [4] //Now let's try to retrieve it...
root [5] w->var("myFavoriteThing")
(RooRealVar *) nullptr
root [6] //Hmm nope
root [7] w->arg("myFavoriteThing")
(RooAbsArg *) 0x7fc4b5851600
root [8] //Ahh there it is!
root [9] ((RooStringVar*)w->arg("myFavoriteThing"))->getVal()
(const char *) nullptr
root [10] //Oh...

The workaround is straightforward but mildly inconvenient when dealing with several strings: create a RooStringVar and import it into the workspace; use RooWorkspace::obj to fetch and cast to RooStringVar.

Is there a better solution?


I guess @moneta can help you with this.

Note that screen dumps are not very convenient, they prevent to do copy/paste :frowning:
You better post code as suggested here: Tips for Efficient and Successful Posting

Thanks Olivier, and sorry about the screenshot! I will edit my post…

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