ROOT 5.20: Constraints and RooWorkspace documentation

Hi,

I just installed ROOT 5.20,

  • Is there any documentation about the way in which one can handle the constraints in RooFit?

  • The page root.cern.ch/root/html/RooConstraintSum.html mentions the inclusion of classes not in the ROOT distribution. How this is performed?
    I tried to include a custom class inheriting from RooRealVar together with its code but when i retrieve it, I only get a plain RooRealVar. Is there a solution?

Cheers,
Danilo

Hi Danilo,

I’ve added a tutorial macro on constraints in the 5.20 distribution.
You can find it in $ROOTSYS/tutorial/roofit/rf09_constraints.C

I’m somewhat confused on the second part of your mail. Did you
mean to refer to the HTML doc of RooWorkspace rather than RooConstraintSum?

In general, when you want to create your own function or p.d.f.
you should inherit from either RooAbsReal (a function) or RooAbsPdf
(which add support for normalization). RooRealVar is a concrete class for a variable, so inheriting from that is not the right thing to do when you want to write a function. The best way to get started is to use the
class factory to write a skeleton for you, e.g. RooClassFactory::makePdf(“pdfName”,“a,b,c,d”) ; where a,b,c,d are the names of the input arguments of your p.d.f. You will only have to fill in the actual function expression in terms of a,b,c,d in the evaluate() method in the .cxx file.
There exists also a makeFunction method to make a function rather than a p.d.f.

Wouter

Hi,

I realize I left out a piece. Once you have your custom class coded,
you can (as usual) compile and link it with your ROOT session using
ACliC.

You can then proceed to put an instance of this object in the workspace without further action. To have the code imported in the workspace as well you need to call RooWorkspace::importClassCode() between importing your object and writing the workspace to a file.

Once you open the workspace in a clean root session everything should
be handled transparently.

Wouter

Dear Wouter, thanks for your prompt and complete answer.
Still two points are not clear to me:

  1. The RooWorkspace::import methods allow only to import Roo* objects. How could I import a non roofit/Root-standard object?
  2. Beyond the comments about the choice to inherit from a RooRealVar, which i fully appreciated, why does the RooWorkspace “flattens” during the import/export procedure the instance of the Derived class to its Mother, the RooRealVar?

Cheers,
Danilo

Hi,
I post the solution I found. The problem was in my (wrong) implementation of the clone method. The signature was not the same of the one of the mother class therefore the objects were cloned as they were mere ROoRealVars.

Cheers,
Danilo