Hello Experts,
I have a fairly simple piece of code used to build a RooBCPGenDecay. I do not think the technical details of the fit matter too much. Basically, the code crashes when I try to run the fit over the weighted dataset: wtestDS (see the last line of code). Am I importing the unweighted data incorrectly? I.e. Does the weighted
dataset lose the information about the 2 categories?
The second to last line of code works: i.e fitting to the original unweighted dataset.
The test_weight.ascii file is located here:
http://www.slac.stanford.edu/~cschill/test_weight.ascii
#include <RooRealVar.h>
#include <RooCategory.h>
#include <RooDataSet.h>
#include <RooTruthModel.h>
#include <RooBCPGenDecay.h>
#include <RooPlot.h>
#include <RooGlobalFunc.h>
#include <RooSimultaneous.h>
#include <RooSimPdfBuilder.h>
#include <RooArgSet.h>
#include <TString.h>
#include <TCanvas.h>
using namespace RooFit;
void rhoGamFit()
{
RooRealVar dt("dt","dt",-10,10);
RooCategory tag("tag","tag");
tag.defineType("B0",1);
tag.defineType("B0B",-1);
RooCategory tagcat("tagcat","tagcat");
tagcat.defineType("08T0",0);
tagcat.defineType("08T1",63);
tagcat.defineType("08T2",64);
tagcat.defineType("08T3",65);
tagcat.defineType("08T4",66);
tagcat.defineType("08T5",67);
tagcat.defineType("08T6",68);
RooRealVar wt("wt","wt",-100,100);
RooArgList obs("obs");
obs.add(dt);
obs.add(tag);
obs.add(tagcat);
obs.add(wt);
TString file = "test_weight.ascii";
RooDataSet* testDS = RooDataSet::read(file.Data(),obs,"Q");
RooDataSet wtestDS("wtestDS","wtestDS",obs,Import(*testDS),WeightVar("wt"));
RooRealVar tau("tau","tau",1.53);
RooRealVar dm("dm","dm",0.507);
RooRealVar w("w","w",0.0282);
RooRealVar S("S","S",0,-1,1);
RooRealVar C("C","C",0,-1,1);
RooRealVar dw("dw","dw",0.0027);
RooRealVar mu("mu","mu",0.0);
RooTruthModel sigRes("sigRes","sigRes",dt);
RooBCPGenDecay sigPdf("sigPdf","sigPdf",dt,tag,tau,dm,w,C,S,dw,mu,sigRes);
RooSimPdfBuilder builder(sigPdf);
RooArgSet* config = builder.createProtoBuildConfig();
config->readFromFile("config.txt");
RooSimultaneous* simPdf = builder.buildPdf(*config,obs);
//works
simPdf->fitTo(*testDS);
//crashes
simPdf->fitTo(wtestDS,SumW2Error(kTRUE));
}
The config.txt file for the RooSimPdfBuilder is:
--- config.txt ----------------
physModels = sigPdf
splitCats = tagcat
sigPdf = tagcat : w,dw
-------------------------------
Thanks for your help,
Chris S.