RooFit User class Response function Pdf

Hello,

I am trying to write a user pdf that describes a distribution of a variable taking into account a detector response, response distribution. To the constructor I pass a true distribution and a response function. The true distribution is in the form of a RooGenericPdf and the response function I pass as an array, here each column describes how the true distribution varies due to the detection process.

The idea is to fit the response distribution to real data, then propagating the parameters of the fit to the theorised true distribution. However trying to fit the response distribution results in segmentation faults, I think this is because of the way the parameter values are propagated by the RooRealProxys. Below is minimal example code.

MyPdf.h

[code]/*****************************************************************************

  • Project: RooFit *
  •                                                                       *
    
  • This code was autogenerated by RooClassFactory *
    *****************************************************************************/

#ifndef MYPDF
#define MYPDF

#include “RooAbsPdf.h”
#include “RooRealProxy.h”
#include “RooCategoryProxy.h”
#include “RooAbsReal.h”
#include “RooAbsCategory.h”

#include “RooGaussian.h”

class MyPdf : public RooAbsPdf {
public:
MyPdf() {} ;
MyPdf(const char name, const char title,
RooAbsReal& _x,
RooAbsReal& _p0,
RooAbsReal& _p1,
RooGaussian
_gaus);
MyPdf(const MyPdf& other, const char
name=0) ;
virtual TObject* clone(const char* newname) const { return new MyPdf(*this,newname); }
inline virtual ~MyPdf() { }

protected:

RooRealProxy x ;
RooRealProxy p0 ;
RooRealProxy p1 ;
RooGaussian* m_gaus;
// RooGaussian* m_gaus;

Double_t evaluate() const ;

private:

ClassDef(MyPdf,1) // Your description goes here…
};

#endif[/code]

MyPdf.cxx

[code]/*****************************************************************************

  • Project: RooFit *
  •                                                                       * 
    
  • This code was autogenerated by RooClassFactory *
    *****************************************************************************/

// Your description goes here…

#include “Riostream.h”

#include “MyPdf.h”
#include “RooAbsReal.h”
#include “RooAbsCategory.h”
#include <math.h>
#include “TMath.h”

#include “RooGaussian.h”

ClassImp(MyPdf)

MyPdf::MyPdf(const char *name, const char title,
RooAbsReal& _x,
RooAbsReal& _p0,
RooAbsReal& _p1,
RooGaussian
_gaus) :
RooAbsPdf(name,title),
x(“x”,“x”,this,_x),
p0(“p0”,“p0”,this,_p0),
p1(“p1”,“p1”,this,_p1),
m_gaus(_gaus)
{
// m_gaus = new RooGaussian(“gaus”, “gaus”, _x, _p0, _p1);
}

MyPdf::MyPdf(const MyPdf& other, const char* name) :
RooAbsPdf(other,name),
x(“x”,this,other.x),
p0(“p0”,this,other.p0),
p1(“p1”,this,other.p1)
{
}

Double_t MyPdf::evaluate() const
{
// ENTER EXPRESSION IN TERMS OF VARIABLE ARGUMENTS HERE
return m_gaus->getVal(); // seg fault
return 1.0 ;
// return 1.*m_gaus;
} [/code]

How can I achieve this in a RooFit compatible way?

Thanks