Hi,
in the following example I can store and retrieve a simple RooExponential (and generate toys based on it), but the same crashes when using RooDecay (uncomment #define USEROODECAY at the top of the file). Am I doing something wrong? Help would be greatly appreciated!
cheers,
Alex
//#define USEROODECAY
#include "RooDataSet.h"
#include "RooRealVar.h"
#include "RooGaussModel.h"
#include "RooDecay.h"
#include "RooExponential.h"
#include "RooAbsPdf.h"
#include "RooFit.h"
#include "RooWorkspace.h"
#include "RooConstVar.h"
#include <iomanip>
void MakeModel(RooWorkspace *ws);
void CreateToy(RooWorkspace *ws);
void WorkspaceTest()
{
RooWorkspace *wspace = new RooWorkspace("myWS");
MakeModel(wspace);
CreateToy(wspace);
}
void MakeModel(RooWorkspace *ws)
{
Double_t Tau=1.0,Smear=1.0;
Double_t lowProperTimeRange=1.0, highProperTimeRange=15.0;
RooRealVar properTime("properTime", "c#tau", lowProperTimeRange, highProperTimeRange, "ps");
RooConstVar DecayConst("eDecayConst", "Decay Constant", -1.0/Tau);
#ifdef USEROODECAY
RooRealVar GaussianSmearBias("GaussianSmearBias","Gaussian Smear Bias",0.0);
GaussianSmearBias.setConstant();
RooRealVar GaussianSmearSigma("GaussianSmearSigma","Gaussian Smear Sigma",Smear);
RooGaussModel SmearModel("CombinatorialLifeTimeSmear","Lifetime Smear",properTime,GaussianSmearBias,GaussianSmearSigma);
RooDecay LifeTimeModel("CombinatorialLifeTimeModel", "Lifetime model",properTime, DecayConst,SmearModel,RooDecay::DoubleSided);
#else
RooExponential LifeTimeModel("LifeTimeModel","Expo model",properTime,DecayConst);
#endif
ws->import(LifeTimeModel);
}
void CreateToy(RooWorkspace *ws)
{
std::cout << "Dataset creation" << std::endl;
Int_t nEvents=100;
RooAbsPdf *model = ws->pdf("LifeTimeModel");
RooRealVar *properTime = ws->var("properTime");
RooDataSet *data = model->generate(RooArgSet(*properTime), nEvents);
std::cout << "import to workspace" << std::endl;
ws->import(*data);
}