17 #include <sys/times.h> 22 int main(
int argc,
char **argv) {
27 gStyle->SetCanvasBorderMode(0);
28 gStyle->SetCanvasColor(10);
29 gStyle->SetFrameFillColor(10);
30 gStyle->SetFrameBorderMode(0);
31 gStyle->SetPadColor(0);
32 gStyle->SetTitleColor(1);
33 gStyle->SetStatColor(0);
34 gStyle->SetFillColor(0);
35 gStyle->SetFuncWidth(1);
36 gStyle->SetLineWidth(1);
37 gStyle->SetLineColor(1);
38 gStyle->SetPalette(1, 0);
44 TH1F xvarHist(
"xvarHist",
"", xvar.getNumBins(), xvar.getLowerLimit(), xvar.getUpperLimit());
46 xvarHist.SetStats(
false);
51 for(
int i = 0; i < 100000; ++i) {
52 xvar.setValue(donram.Gaus(0.2, 1.1));
54 if(donram.Uniform() < 0.1)
55 xvar.setValue(donram.Uniform(xvar.getLowerLimit(), xvar.getUpperLimit()));
57 if(fabs(xvar.getValue()) > 5) {
63 xvarHist.Fill(xvar.getValue());
67 Variable xmean{
"xmean", 0, 1, -10, 10};
68 Variable xsigm{
"xsigm", 1, 0.5, 1.5};
74 Variable sigFrac{
"sigFrac", 0.9, 0.75, 1.00};
76 AddPdf total{
"total", {sigFrac}, {&signal, &backgr}};
82 TH1F pdfHist(
"pdfHist",
"", xvar.getNumBins(), xvar.getLowerLimit(), xvar.getUpperLimit());
83 TH1F sigHist(
"sigHist",
"", xvar.getNumBins(), xvar.getLowerLimit(), xvar.getUpperLimit());
84 TH1F bkgHist(
"bkgHist",
"", xvar.getNumBins(), xvar.getLowerLimit(), xvar.getUpperLimit());
86 pdfHist.SetStats(
false);
87 sigHist.SetStats(
false);
88 bkgHist.SetStats(
false);
92 for(
int i = 0; i < xvar.getNumBins(); ++i) {
93 double step = (xvar.getUpperLimit() - xvar.getLowerLimit()) / xvar.getNumBins();
94 xvar.setValue(xvar.getLowerLimit() + (i + 0.5) * step);
99 std::vector<std::vector<double>> pdfVals = total.getCompProbsAtDataPoints();
107 pdfHist.Fill(xvar.getValue(), pdfVals[0][i]);
108 sigHist.Fill(xvar.getValue(), pdfVals[1][i]);
109 bkgHist.Fill(xvar.getValue(), pdfVals[2][i]);
110 totalPdf += pdfVals[0][i];
113 for(
int i = 0; i < xvar.getNumBins(); ++i) {
114 double val = pdfHist.GetBinContent(i + 1);
117 pdfHist.SetBinContent(i + 1, val);
118 val = sigHist.GetBinContent(i + 1);
120 val *= sigFrac.getValue();
122 sigHist.SetBinContent(i + 1, val);
123 val = bkgHist.GetBinContent(i + 1);
125 val *= (1.0 - sigFrac.getValue());
127 bkgHist.SetBinContent(i + 1, val);
130 xvarHist.SetMarkerStyle(8);
131 xvarHist.SetMarkerSize(0.5);
133 pdfHist.SetLineColor(kBlue);
134 pdfHist.SetLineWidth(3);
135 pdfHist.Draw(
"lsame");
136 sigHist.SetLineColor(kBlue);
137 sigHist.SetLineStyle(kDashed);
138 sigHist.SetLineWidth(3);
139 sigHist.Draw(
"lsame");
140 bkgHist.SetLineColor(kRed);
141 bkgHist.SetLineWidth(3);
142 bkgHist.Draw(
"lsame");
143 foo.SaveAs(
"xhist.png");
size_t getNumEvents() const
Special class for observables. Used in DataSets.
__host__ void setData(DataSet *data)
int main(int argc, char **argv)
ROOT::Minuit2::FunctionMinimum fit()
This runs the fit.
#define GOOFIT_PARSE(app,...)
void loadEvent(size_t idx)
Set all the variables to the current event values.