RooSimultaneous Fit

Hi roofit experts,

I am trying to fit a Simultaneous pdf (Signal + Background) to my data where I fit the background and signal functions for different ranges. Can anyone tell me why the following code doesn’t work?


RooCategory cat(“cat”,“cat”);
cat.defineType(“Signal”);
cat.defineType(“Back”);

RooDataHist data(“data”,“data”,RooArgSet(x),histo); //histo is a TH1F histogram

RooSimultaneous simPdf(“simPdf”,“simPdf”);
simPdf.addPdf(Signal,“Signal”); //Signal is defined elswhere
simPdf.addPdf(Back,“Back”); //Back is also defined

x.setRange(“fitRange_Signal”,4904,4935);
x.setRange(“fitRange_Back”,4840,4902);

simPdf.fitTo(data, Range(“fitRange”), SplitRange());


I think maybe I am not understanding the use of categories in this particular case. I would be very greatful if anyone could help.

Thanks

Hi,

I dont know if that solves your problem but you might try to define your dataset also in categories. Something like that:

[code]

RooArgList args;
args.add(x);

RooCategory datacat(“datacat”,“datacat”)
datacat.defineType(“catname”);

map<std::string, RooDataSet*> datamap;
datamap[“catname”] = (RooDataSet*)dataSets;

RooDataSet * simData = new RooDataSet(“simdata”, “data for simultaneous fit”, args, Index(datacat), Import(datamap) );[/code]

Cheers,
Thomas