pyROOT: access protected member of RooObject

I would need your help with a pyROOT/RooFit problem, maybe someone has an idea:
Basically I need to draw my RooCBShape in RooFit on my own, as a RooCurve.
In c++ that would work like that:

// define new RooCBShape to get access to protected member .. as evaluate() ..
class RooCBShapeD : public RooCBShape
   //Y::Y(int _x) : X(_x) {}
   RooCBShapeDerived(const char *name, const char *title, RooAbsReal& _m,
            RooAbsReal& _m0, RooAbsReal& _sigma,
            RooAbsReal& _alpha, RooAbsReal& _n) :
            RooCBShape(name, title, _m, _m0, _sigma, _alpha, _n)
   Double_t eval() { return RooCBShape::evaluate(); }   // OK


RooCurve* curve = new RooCurve();
for( unsigned int i = 0; i <= 2000; i++){
           Double_t val = ( Double_t(i) / 1000 );
           //std::cout << "[xVal pf CBS]: \t" << val << std::endl;
           RooRealVar  testVal("testVal","testVal", val );
           RooRealVar   mean("mean",    "mean", cbMean);
           RooRealVar   sigma("sigma",  "sigma",cbSig);
           RooRealVar   alpha("alpha",  "alpha",cbAlpha);
           RooRealVar   n("n",          "n",    cbN);

           RooCBShapeDerived   cbs("cbs", "Crystal Ball shape", testVal, mean, sigma, alpha, n);

           std::cout << "[yVal of CBS]: \t" << cbs.eval() << std::endl;
           curve->addPoint(val, cbs.eval());


One would need to create it’s own derived class to get access to the protected member of RooCBShape, as evaluate().

Translated to python it would look something like :

import os
import sys

from ROOT import TCanvas, TFile, gDirectory
from ROOT import gSystem
from ROOT import RooFit, RooRealVar, RooCurve, RooCBShape

class RooCBShapeDerived(RooCBShape):
    def __init__(self,name,title, m, m0, sigma, alpha, n):
        self._name = name
        self._title = title
        self._m = m
        self._m0 = m0
        self._sigma = sigma
        self._alpha = alpha
        self._n = n
    def eval(self) :
         return RooCBShape.evaluate()

## Create Canvas
print "---- Create Can ----" 
c = TCanvas("c","c",750, 750);;

cbMean    =1.0145
cbSig     =0.025
cbAlpha   =-0.555
cbN      =1.1731

curve = RooCurve()
for i in range(0,2000):
   val = i / 1000 
   print "[xVal of CBS]: \t",val 
   testVal= RooRealVar("testVal","testVal", val )
   mean=RooRealVar("mean",    "mean", cbMean)
   sigma=RooRealVar("sigma",  "sigma",cbSig)
   alpha=RooRealVar("alpha",  "alpha",cbAlpha)
   n=RooRealVar("n",          "n",    cbN)

   cbs=RooCBShapeDerived("cbs", "Crystal Ball shape", testVal, mean, sigma, alpha, n)

   print "[yVal of CBS]: \t", cbs.eval()
   curve.addPoint(val, cbs.eval());


But somehow my python version of the code does not work.
The error in python I am getting is the following

I don’t know why.

thanks for help,


protected (and private) members are not exported, even as in python there’s not any equivalent concept, as in the dictionaries the labels are there but not the addresses (i.e. the stub function is a no-op).

Best thing I can think of is the have an intermediate C++ class derived from RooCBShape that makes the function publicly available so that it shows up in the dictionary.