16void rf619_discrete_profiling()
21 RooRealVar lambda1(
"lambda1",
"slope1", -0.025, -0.1, -0.02);
24 RooRealVar c0(
"c0",
"Cheby coeff 0", -1.0, -1.0, 1.0);
33 RooRealVar lambdaExtra(
"lambdaExtra",
"extra slope", -0.05, -1.0, -0.01);
34 RooExponential expoExtra(
"expoExtra",
"extra exponential",
x, lambdaExtra);
37 RooRealVar mean(
"mean",
"shared mean", 25, 0, 50);
38 RooRealVar sigmaG(
"sigmaG",
"Gaussian width", 2.0, 0.01, 5.0);
39 RooRealVar sigmaL(
"sigmaL",
"Landau width", 3.0, 1.0, 8.0);
41 RooGaussian gauss1(
"gauss1",
"Gaussian",
x, mean, sigmaG);
42 RooLandau landau1(
"landau1",
"Landau",
x, mean, sigmaL);
49 RooRealVar sigmaExtra(
"sigmaExtra",
"extra Gaussian width", 3.0, 1.0, 6.0);
50 RooGaussian gaussExtra(
"gaussExtra",
"extra Gaussian",
x, mean, sigmaExtra);
53 RooRealVar frac0(
"frac0",
"fraction for cat0", 0.7, 0.0, 1.0);
54 RooAddPdf addPdf0(
"addPdf0",
"multiPdf0 + extra expo",
RooArgList(multiPdf0, gaussExtra), frac0);
56 RooRealVar frac1(
"frac1",
"fraction for cat1", 0.5, 0.0, 1.0);
57 RooAddPdf addPdf1(
"addPdf1",
"multiPdf1 + extra gauss",
RooArgList(multiPdf1, expoExtra), frac1);
61 catIndex.defineType(
"cat0", 0);
62 catIndex.defineType(
"cat1", 1);
65 simPdf.addPdf(addPdf0,
"cat0");
66 simPdf.addPdf(addPdf1,
"cat1");
76 addPdf0.plotOn(frame0);
77 pdfIndex0.setIndex(1);
92 addPdf1.plotOn(frame1);
93 pdfIndex1.setIndex(1);
110 for (
int i = 0; i < data0->
numEntries(); ++i) {
112 catIndex.setLabel(
"cat0");
115 for (
int i = 0; i < data1->
numEntries(); ++i) {
117 catIndex.setLabel(
"cat1");
122 std::unique_ptr<RooAbsReal> nll1(simPdf.createNLL(*data));
125 minim.setStrategy(1);
127 minim.setPrintLevel(-1);
130 const int nMeanPoints = 40;
131 const double meanMin = 17;
132 const double meanMax = 33;
135 std::vector<std::vector<int>> combosToPlot;
136 for (
int i = 0; i < pdfIndex0.size(); ++i) {
137 for (
int j = 0; j < pdfIndex1.size(); ++j) {
138 combosToPlot.push_back({i, j});
143 TCanvas *
c =
new TCanvas(
"c_rf619",
"NLL vs Mean for Different Discrete Combinations", 1200, 400);
148 int markers[] = {20, 21, 22, 23, 33};
151 std::vector<TGraph *> graphs;
156 for (
size_t idx = 0; idx < combosToPlot.size(); ++idx) {
158 g->SetLineColor(
colors[idx % 5]);
159 g->SetMarkerColor(
colors[idx % 5]);
160 g->SetMarkerStyle(markers[idx % 5]);
161 g->SetTitle(
Form(
"Combo [%d,%d]", combosToPlot[idx][0], combosToPlot[idx][1]));
173 graphs.push_back(profileGraph);
176 for (
int i = 0; i < nMeanPoints; ++i) {
179 double meanVal = meanMin + i * (meanMax - meanMin) / (nMeanPoints - 1);
180 mean.setVal(meanVal);
183 for (
size_t comboIdx = 0; comboIdx < combosToPlot.size(); ++comboIdx) {
184 const auto &combo = combosToPlot[comboIdx];
187 pdfIndex0.setIndex(combo[0]);
188 pdfIndex1.setIndex(combo[1]);
192 pdfIndex0.setConstant(
true);
193 pdfIndex1.setConstant(
true);
194 mean.setConstant(
true);
198 minim.minimize(
"Minuit2",
"Migrad");
199 double nllVal = nll1->getVal();
202 graphs[comboIdx]->SetPoint(i, meanVal, nllVal);
205 pdfIndex0.setConstant(
false);
206 pdfIndex1.setConstant(
false);
207 mean.setConstant(
false);
211 mean.setConstant(
true);
214 minim.minimize(
"Minuit2",
"Migrad");
217 double profNLL = nll1->getVal();
218 graphs.back()->SetPoint(i, meanVal, profNLL);
222 gPad->SetLeftMargin(0.15);
230 gPad->SetLeftMargin(0.15);
237 gPad->SetLeftMargin(0.15);
240 for (
auto &
g : graphs) {
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
double getRealValue(const char *name, double defVal=0.0, bool verbose=false) const
Get value of a RooAbsReal stored in set with given name.
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1={}, const RooCmdArg &arg2={}, const RooCmdArg &arg3={}, const RooCmdArg &arg4={}, const RooCmdArg &arg5={}, const RooCmdArg &arg6={}, const RooCmdArg &arg7={}, const RooCmdArg &arg8={}) const
virtual Int_t numEntries() const
Return number of entries in dataset, i.e., count unweighted entries.
Efficient implementation of a sum of PDFs of the form.
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Object to represent discrete states.
Chebychev polynomial p.d.f.
Container class to hold unbinned data.
const RooArgSet * get(Int_t index) const override
Return RooArgSet with coordinates of event 'index'.
Landau distribution p.d.f.
Wrapper class around ROOT::Math::Minimizer that provides a seamless interface between the minimizer f...
The class RooMultiPdf allows for the creation of a RooMultiPdf object, which can switch between previ...
Plot frame and a container for graphics objects within that frame.
void SetTitle(const char *name) override
Set the title of the RooPlot to 'title'.
TObject * getObject(Int_t idx) const
Return the name of the object at slot 'idx' in this RooPlot.
void Draw(Option_t *options=nullptr) override
Draw this plot and all of the elements it contains.
Variable that can be changed from the outside.
Facilitates simultaneous fitting of multiple PDFs to subsets of a given dataset.
virtual void SetTitleOffset(Float_t offset=1)
Set distance between the axis and the axis title.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
void SetTitle(const char *title="") override
Set the title of the TNamed.
TLegendEntry * AddEntry(const TObject *obj, const char *label="", Option_t *option="lpf")
void Draw(Option_t *option="") override
Draw this box with its current attributes.
virtual void Add(TGraph *graph, Option_t *chopt="")
void Draw(Option_t *chopt="") override
Default Draw method for all objects.
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
RooCmdArg LineColor(TColorNumber color)
The namespace RooFit contains mostly switches that change the behaviour of functions of PDFs (or othe...