Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
LikelihoodIntervalPlot.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2
3/*************************************************************************
4 * Project: RooStats *
5 * Package: RooFit/RooStats *
6 * Authors: *
7 * Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke *
8 *************************************************************************
9 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
10 * All rights reserved. *
11 * *
12 * For the licensing terms see $ROOTSYS/LICENSE. *
13 * For the list of contributors see $ROOTSYS/README/CREDITS. *
14 *************************************************************************/
15
16
17/** \class RooStats::LikelihoodIntervalPlot
18 \ingroup Roostats
19
20 This class provides simple and straightforward utilities to plot a LikelihoodInterval
21 object.
22
23*/
24
26
27#include <algorithm>
28#include <iostream>
29#include <cmath>
30
31#include "TROOT.h"
32#include "TLine.h"
33#include "TObjArray.h"
34#include "TList.h"
35#include "TGraph.h"
36#include "TPad.h"
37#include "TCanvas.h"
38// need chisquare_quantile function - can use mathcore implementation
39// for plotting not crucial that is less precise
41
42
43#include "RooRealVar.h"
44#include "RooPlot.h"
45#include "RooMsgService.h"
46#include "RooProfileLL.h"
47#include "TF1.h"
48
49/// ClassImp for building the THtml documentation of the class
50using namespace std;
51
53
54using namespace RooStats;
55
56////////////////////////////////////////////////////////////////////////////////
57/// LikelihoodIntervalPlot default constructor
58/// with default parameters
59
61{
62 fInterval = 0;
63 fNdimPlot = 0;
64 fParamsPlot = 0;
65 fColor = 0;
66 fFillStyle = 4050; // half transparent
67 fLineColor = 0;
68 fMaximum = -1;
69 fNPoints = 0; // default depends if 1D or 2D
70 // default is variable range
71 fXmin = 0;
72 fXmax = -1;
73 fYmin = 0;
74 fYmax = -1;
75 fPrecision = -1; // use default
76 fPlotObject = 0;
77}
78
79////////////////////////////////////////////////////////////////////////////////
80/// LikelihoodIntervalPlot copy constructor
81
83{
84 fInterval = theInterval;
87 fColor = 0;
88 fLineColor = 0;
89 fFillStyle = 4050; // half transparent
90 fMaximum = -1;
91 fNPoints = 0; // default depends if 1D or 2D
92 // default is variable range
93 fXmin = 0;
94 fXmax = -1;
95 fYmin = 0;
96 fYmax = -1;
97 fPrecision = -1; // use default
98 fPlotObject = 0;
99}
100
101////////////////////////////////////////////////////////////////////////////////
102/// LikelihoodIntervalPlot destructor
103
105{
106}
107
108////////////////////////////////////////////////////////////////////////////////
109
111{
112 fInterval = theInterval;
115
116 return;
117}
118
119////////////////////////////////////////////////////////////////////////////////
120
122{
123 fNdimPlot = params->getSize();
124 fParamsPlot = (RooArgSet*) params->clone((std::string(params->GetName())+"_clone").c_str());
125
126 return;
127}
128
129
130////////////////////////////////////////////////////////////////////////////////
131/// draw the log of the profiled likelihood function in 1D with the interval or
132/// as a 2D plot with the contours.
133/// Higher dimensional intervals cannot be drawn. One needs to call
134/// SetPlotParameters to project interval in 1 or 2dim
135///
136/// ### Options for drawing 1D intervals
137///
138/// For 1D problem the log of the profiled likelihood function is drawn by default in a RooPlot as a
139/// RooCurve
140/// The plotting range (default is the full parameter range) and the precision of the RooCurve
141/// can be specified by using SetRange(x1,x2) and SetPrecision(eps).
142/// SetNPoints(npoints) can also be used (default is npoints=100)
143/// Optionally the function can be drawn as a TF1 (option="tf1") obtained by sampling the given npoints
144/// in the given range
145///
146/// ### Options for drawing 2D intervals
147///
148/// For 2D case, a contour and optionally the profiled likelihood function is drawn by sampling npoints in
149/// the given range. A 2d histogram of nbinsX=nbinsY = sqrt(npoints) is used for sampling the profiled likelihood.
150/// The contour can be obtained by using Minuit or by the sampled histogram,
151/// If using Minuit, the number of points specifies the number of contour points. If using an histogram the number of
152/// points is approximately the total number of bins of the histogram.
153/// Possible options:
154/// - minuit/nominuit: use minuit for computing the contour
155/// - hist/nohist : sample in an histogram the profiled likelihood
156///
157/// Note that one can have both a drawing of the sampled likelihood and of the contour using minuit.
158/// The default options is "minuit nohist"
159/// The sampled histogram is drawn first by default using the option "colz" and then 8 probability contours at
160/// these CL are drawn: { 0.1,0.3,0.5,0.683,0.95,0.9973,0.9999366575,0.9999994267} re-drawing the histogram with the
161/// option "cont3"
162///
163/// The drawn object (RooPlot or sampled histogram) is saved in the class and can be retrieved using GetPlottedObject()
164/// In this way the user can eventually customize further the plot.
165/// Note that the class does not delete the plotted object. It needs, if needed, to be deleted by the user
166
168{
169 // we need to check if parameters to plot is different than parameters of interval
170 RooArgSet* intervalParams = fInterval->GetParameters();
171 RooArgSet extraParams;
172 for (auto const *arg : *fParamsPlot) {
173 if (!intervalParams->contains(*arg) ) {
174 ccoutE(InputArguments) << "Parameter " << arg->GetName() << "is not in the list of LikelihoodInterval parameters "
175 << " - do not use for plotting " << std::endl;
176 fNdimPlot--;
177 extraParams.add(*arg);
178 }
179 }
180 if (extraParams.getSize() > 0)
181 fParamsPlot->remove(extraParams,true,true);
182
183 if(fNdimPlot > 2){
184 ccoutE(InputArguments) << "LikelihoodIntervalPlot::Draw(" << GetName()
185 << ") ERROR: contours for more than 2 dimensions not implemented!" << std::endl;
186 return;
187 }
188
189 // if the number of parameters to plot is less to the number of parameters of the LikelihoodInterval
190 // we need to re-do the profile likelihood function, otherwise those parameters will not be profiled
191 // when plotting
192 RooAbsReal* newProfile = 0;
193 RooAbsReal* oldProfile = fInterval->GetLikelihoodRatio();
194 if (fNdimPlot != intervalParams->getSize() ) {
195 RooProfileLL * profilell = dynamic_cast<RooProfileLL*>(oldProfile);
196 if (!profilell) return;
197 RooAbsReal & nll = profilell->nll();
198 newProfile = nll.createProfile(*fParamsPlot);
199 }
200 else {
201 newProfile = oldProfile;
202 }
203
204 auto *myparam = static_cast<RooRealVar*>((*fParamsPlot)[0]);
205
206 // do a dummy evaluation around minimum to be sure profile has right minimum
209 newProfile->getVal();
210 }
211
212 // analyze options
213 TString opt = options;
214 opt.ToLower();
215
216 TString title = GetTitle();
217 int nPoints = fNPoints;
218
219 if(fNdimPlot == 1) {
220
221 // 1D drawing options
222 // use RooPLot for drawing the 1D PL
223 // if option is TF1 use TF1 for drawing
224 bool useRooPlot = opt.Contains("rooplot") || ! (opt.Contains("tf1"));
225 opt.ReplaceAll("rooplot","");
226 opt.ReplaceAll("tf1","");
227
228
229 // if (title.Length() == 0)
230 // title = "- log profile likelihood ratio";
231
232 if (nPoints <=0) nPoints = 100; // default in 1D
233
234 const double xcont_min = fInterval->LowerLimit(*myparam);
235 const double xcont_max = fInterval->UpperLimit(*myparam);
236
237 RooRealVar* myarg = (RooRealVar *) newProfile->getVariables()->find(myparam->GetName());
238 double x1 = myarg->getMin();
239 double x2 = myarg->getMax();
240
241 // default color values
242 if (fColor == 0) fColor = kBlue;
243 if (fLineColor == 0) fLineColor = kGreen;
244
245 RooPlot * frame = 0;
246
247 // use TF1 for drawing the function
248 if (!useRooPlot) {
249
250 // set a first estimate of range including 2 times upper and lower limit
251 double xmin = std::max( x1, 2*xcont_min - xcont_max);
252 double xmax = std::min( x2, 2*xcont_max - xcont_min);
253 if (fXmin < fXmax) { xmin = fXmin; xmax = fXmax; }
254
255 TF1 * tmp = newProfile->asTF(*myarg);
256 assert(tmp != 0);
257 tmp->SetRange(xmin, xmax);
258 tmp->SetNpx(nPoints);
259
260 // clone the function to avoid later to sample it
261 TF1 * f1 = (TF1*) tmp->Clone();
262 delete tmp;
263
264 f1->SetTitle(title);
265 TString name = TString(GetName()) + TString("_PLL_") + TString(myarg->GetName());
266 f1->SetName(name);
267
268 // set range for displaying x values where function <= fMaximum
269 // if no range is set amd
270 // if no reasonable value found maintain first estimate
271 x1 = xmin; x2 = xmax;
272 if (fMaximum > 0 && fXmin >= fXmax ) {
273 double x0 = f1->GetX(0, xmin, xmax);
274 // check that minimum is between xmin and xmax
275 if ( x0 > x1 && x0 < x2) {
276 x1 = f1->GetX(fMaximum, xmin, x0);
277 x2 = f1->GetX(fMaximum, x0, xmax);
279 //std::cout << "setting range to " << x1 << " , " << x2 << " x0 = " << x0 << std::endl;
280 }
281 }
282
283 f1->SetRange(x1,x2);
284
285
287 f1->GetXaxis()->SetTitle(myarg->GetName());
288 f1->GetYaxis()->SetTitle(Form("- log #lambda(%s)",myparam->GetName()));
289 f1->Draw(opt);
291
292 }
293 else {
294 // use a RooPlot for drawing the PL function
295 double xmin = myparam->getMin(); double xmax = myparam->getMax();
296 if (fXmin < fXmax) { xmin = fXmin; xmax = fXmax; }
297
298 // set nbins (must be used in combination with precision )
299 // the curve will evaluate 2 * nbins if precision is > 1
300 int prevBins = myarg->getBins();
301 myarg->setBins(fNPoints);
302
303 // want to set range on frame not function
304 frame = myarg->frame(xmin,xmax,nPoints);
305 // for ycutoff line
306 x1= xmin;
307 x2=xmax;
308 frame->SetTitle(title);
309 frame->GetYaxis()->SetTitle(Form("- log #lambda(%s)",myparam->GetName()));
310 // frame->GetYaxis()->SetTitle("- log profile likelihood ratio");
311
312
313 // plot
314 RooCmdArg cmd;
316 newProfile->plotOn(frame,cmd,RooFit::LineColor(fColor));
317
318 frame->SetMaximum(fMaximum);
319 frame->SetMinimum(0.);
320
321 myarg->setBins(prevBins);
322 fPlotObject = frame;
323 }
324
325
326 //myarg->setVal(xcont_max);
327 //const double Yat_Xmax = newProfile->getVal();
329
330 TLine *Yline_cutoff = new TLine(x1,Yat_Xmax,x2,Yat_Xmax);
331 TLine *Yline_min = new TLine(xcont_min,0.,xcont_min,Yat_Xmax);
332 TLine *Yline_max = new TLine(xcont_max,0.,xcont_max,Yat_Xmax);
333
334 Yline_cutoff->SetLineColor(fLineColor);
335 Yline_min->SetLineColor(fLineColor);
336 Yline_max->SetLineColor(fLineColor);
337
338 if (!useRooPlot) {
339 // need to draw the line
340 Yline_cutoff->Draw();
341 Yline_min->Draw();
342 Yline_max->Draw();
343 }
344 else {
345 // add line in the RooPlot
346 frame->addObject(Yline_min);
347 frame->addObject(Yline_max);
348 frame->addObject(Yline_cutoff);
349 frame->Draw(opt);
350 }
351
352
353 return;
354 }
355
356 // case of 2 dimensions
357
358 else if(fNdimPlot == 2){
359
360 //2D drawing options
361
362 // use Minuit for drawing the contours of the PL (default case)
363 bool useMinuit = !opt.Contains("nominuit");
364 // plot histogram in 2D
365 bool plotHist = !opt.Contains("nohist");
366 opt.ReplaceAll("nominuit","");
367 opt.ReplaceAll("nohist","");
368 if (opt.Contains("minuit") ) useMinuit= true;
369 if (useMinuit) plotHist = false; // switch off hist by default in case of Minuit
370 if (opt.Contains("hist") ) plotHist= true;
371 opt.ReplaceAll("minuit","");
372 opt.ReplaceAll("hist","");
373
374 auto *myparamY = static_cast<RooRealVar*>((*fParamsPlot)[1]);
375
376 double cont_level = ROOT::Math::chisquared_quantile(fInterval->ConfidenceLevel(),fNdimPlot); // level for -2log LR
377 cont_level = cont_level/2; // since we are plotting -log LR
378
379 RooArgList params(*newProfile->getVariables());
380 // set values and error for the POI to the best fit values
381 for (int i = 0; i < params.getSize(); ++i) {
382 RooRealVar & par = (RooRealVar &) params[i];
383 RooRealVar * fitPar = (RooRealVar *) (fInterval->GetBestFitParameters()->find(par.GetName() ) );
384 if (fitPar) {
385 par.setVal( fitPar->getVal() );
386 }
387 }
388 // do a profile evaluation to start from the best fit values of parameters
389 newProfile->getVal();
390
391 if (title.Length() == 0)
392 title = TString("Contour of ") + TString(myparamY->GetName() ) + TString(" vs ") + TString(myparam->GetName() );
393 // add also labels
394 title = TString::Format("%s;%s;%s",title.Data(),myparam->GetName(),myparamY->GetName());
395
396 if (nPoints <=0) nPoints = 40; // default in 2D
397
398 double xmin = myparam->getMin(); double xmax = myparam->getMax();
399 double ymin = myparamY->getMin(); double ymax = myparamY->getMax();
400 if (fXmin < fXmax) { xmin = fXmin; xmax = fXmax; }
401 if (fYmin < fYmax) { ymin = fYmin; ymax = fYmax; }
402
403
404 if (!useMinuit || plotHist) {
405
406 // find contour from a scanned histogram of points
407
408 // draw directly the TH2 from the profile LL
409 TString histName = TString::Format("_hist2D__%s_%s",myparam->GetName(),myparamY->GetName() );
410 int nBins = int( std::sqrt(double(nPoints)) + 0.5 );
411 TH2* hist2D = new TH2D(histName, title, nBins, xmin, xmax, nBins, ymin, ymax );
412 newProfile->fillHistogram(hist2D, RooArgList(*myparam,*myparamY), 1, 0, false, 0, false);
413
414 hist2D->SetTitle(title);
415 hist2D->SetStats(false);
416
417 //need many color levels for drawing with option colz
418 if (plotHist) {
419
420 const int nLevels = 51;
421 double contLevels[nLevels];
422 contLevels[0] = 0.01;
423 double maxVal = (fMaximum > 0) ? fMaximum : hist2D->GetMaximum();
424 for (int k = 1; k < nLevels; ++k) {
425 contLevels[k] = k*maxVal/double(nLevels-1);
426 }
427 hist2D->SetContour(nLevels,contLevels);
428
429 if (fMaximum>0) hist2D->SetMaximum(fMaximum);
430
431 hist2D->DrawClone("COLZ");
432 }
433
434
435 //need now less contours for drawing with option cont
436
437 const int nLevels = 8;
438 double contLevels[nLevels];
439 // last 3 are the 3,4,5 sigma levels
440 double confLevels[nLevels] = { 0.1,0.3,0.5,0.683,0.95,0.9973,0.9999366575,0.9999994267};
441 for (int k = 0; k < nLevels; ++k) {
442 //contLevels[k] = 0.5*ROOT::Math::chisquared_quantile(1.-2.*ROOT::Math::normal_cdf_c(nSigmaLevels[k],1),2);
443 contLevels[k] = 0.5*ROOT::Math::chisquared_quantile(confLevels[k],2);
444 }
445 hist2D->SetContour(nLevels,contLevels);
446 if (fLineColor) hist2D->SetLineColor(fLineColor);
447
448 // default options for drawing a second histogram
449 TString tmpOpt = opt;
450 tmpOpt.ReplaceAll("same","");
451 if (tmpOpt.Length() < 3) opt += "cont3";
452 // if histo is plotted draw on top
453 if (plotHist) opt += TString(" same");
454 hist2D->Draw(opt.Data());
455 gPad->Update();
456
457 // case of plotting contours without minuit
458 if (!useMinuit) {
459
460 // set levels of contours if make contours without minuit
461 TH2 * h = (TH2*) hist2D->Clone();
462 h->SetContour(1,&cont_level);
463
464 TVirtualPad * currentPad = gPad;
465 // o a temporary draw to get the contour graph
466 TCanvas * tmpCanvas = new TCanvas("tmpCanvas","tmpCanvas");
467 h->Draw("CONT LIST");
468 gPad->Update();
469
470 // get graphs from the contours
471 TObjArray *contoursOrig = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours");
472 // CLONE THE LIST IN CASE IT GETS DELETED
473 TObjArray *contours = 0;
474 if (contoursOrig) contours = (TObjArray*) contoursOrig->Clone();
475
476 delete tmpCanvas;
477 delete h;
478 gPad = currentPad;
479
480
481 // in case of option CONT4 I need to re-make the Pad
482 if (tmpOpt.Contains("cont4")) {
483 double bm = gPad->GetBottomMargin();
484 double lm = gPad->GetLeftMargin();
485 double rm = gPad->GetRightMargin();
486 double tm = gPad->GetTopMargin();
487 double x1 = hist2D->GetXaxis()->GetXmin();
488 double y1 = hist2D->GetYaxis()->GetXmin();
489 double x2 = hist2D->GetXaxis()->GetXmax();
490 double y2 = hist2D->GetYaxis()->GetXmax();
491
492 TPad *null=new TPad("null","null",0,0,1,1);
493 null->SetFillStyle(0);
494 null->SetFrameFillStyle(0);
495 null->Draw();
496 null->cd();
497 null->Range(x1-(x2-x1)*(lm/(1-rm-lm)),
498 y1-(y2-y1)*(bm/(1-tm-lm)),
499 x2+(x2-x1)*(rm/(1-rm-lm)),
500 y2+(y2-y1)*(tm/(1-tm-lm)));
501
502 gPad->Update();
503 }
504
505
506 if (contours) {
507 int ncontours = contours->GetSize();
508 for (int icont = 0; icont < ncontours; ++icont) {
509 TList * contourList = (TList*)contours->At(icont);
510 if (contourList && contourList->GetSize() > 0) {
511 for(auto * gr : static_range_cast<TGraph*>(*contourList)) {
514 gr->SetLineWidth(3);
515 if (fColor) {
517 gr->Draw("FL");
518 }
519 else
520 gr->Draw("L");
521 }
522 }
523 }
524 }
525 else {
526 ccoutE(InputArguments) << "LikelihoodIntervalPlot::Draw(" << GetName()
527 << ") ERROR: no contours found in ListOfSpecial" << std::endl;
528 }
529
530 fPlotObject = hist2D;
531
532 }
533 }
534 if (useMinuit) {
535
536 // find contours using Minuit
537 TGraph * gr = new TGraph(nPoints+1);
538
539 int ncp = fInterval->GetContourPoints(*myparam, *myparamY, gr->GetX(), gr->GetY(),nPoints);
540
541 if (int(ncp) < nPoints) {
542 std::cout << "Warning - Less points calculated in contours np = " << ncp << " / " << nPoints << std::endl;
543 for (int i = ncp; i < nPoints; ++i) gr->RemovePoint(i);
544 }
545 // add last point to same as first one to close the contour
546 gr->SetPoint(ncp, gr->GetX()[0], gr->GetY()[0] );
547 if (!opt.Contains("c")) opt.Append("L"); // use by default option L if C is not specified
548 // draw first a dummy 2d histogram gfor the axis
549 if (!opt.Contains("same") && !plotHist) {
550
551 TH2F* hist2D = new TH2F("_hist2D",title, nPoints, xmin, xmax, nPoints, ymin, ymax );
552 hist2D->GetXaxis()->SetTitle(myparam->GetName());
553 hist2D->GetYaxis()->SetTitle(myparamY->GetName());
554 hist2D->SetBit(TH1::kNoStats); // do not draw statistics
555 hist2D->SetFillStyle(fFillStyle);
556 hist2D->SetMaximum(1); // to avoid problem with subsequents draws
557 hist2D->Draw("AXIS");
558 }
560 if (fColor) {
561 // draw contour as filled area (add option "F")
563 opt.Append("F");
564 }
565 gr->SetLineWidth(3);
566 if (opt.Contains("same")) gr->SetFillStyle(fFillStyle); // put transparent
567 gr->Draw(opt);
568 TString name = TString("Graph_of_") + TString(fInterval->GetName());
569 gr->SetName(name);
570
571 if (!fPlotObject) fPlotObject = gr;
572 else if (fPlotObject->IsA() != TH2D::Class() ) fPlotObject = gr;
573
574 }
575
576 // draw also the minimum
577 const RooArgSet * bestFitParams = fInterval->GetBestFitParameters();
578 if (bestFitParams) {
579 TGraph * gr0 = new TGraph(1);
580 double x0 = bestFitParams->getRealValue(myparam->GetName());
581 double y0 = bestFitParams->getRealValue(myparamY->GetName());
582 gr0->SetPoint(0,x0,y0);
583 gr0->SetMarkerStyle(33);
584 if (fColor) {
585 if (fColor != kBlack) gr0->SetMarkerColor(fColor+4);
586 else gr0->SetMarkerColor(kGray);
587 }
588 gr0->Draw("P");
589 delete bestFitParams;
590 }
591
592
593
594 }
595
596 // need to delete if a new profileLL was made
597 if (newProfile != oldProfile) delete newProfile;
598
599 return;
600}
#define h(i)
Definition RSha256.hxx:106
#define ccoutE(a)
const char Option_t
Definition RtypesCore.h:66
#define ClassImp(name)
Definition Rtypes.h:377
@ kGray
Definition Rtypes.h:65
@ kBlack
Definition Rtypes.h:65
@ kGreen
Definition Rtypes.h:66
@ kBlue
Definition Rtypes.h:66
@ kDashed
Definition TAttLine.h:48
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t TPoint TPoint const char y2
Option_t Option_t TPoint TPoint const char y1
char name[80]
Definition TGX11.cxx:110
float xmin
float ymin
float xmax
float ymax
#define gROOT
Definition TROOT.h:405
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
Definition TString.cxx:2467
#define gPad
RooFit::OwningPtr< RooArgSet > getVariables(bool stripDisconnected=true) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
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 bool remove(const RooAbsArg &var, bool silent=false, bool matchByNameOnly=false)
Remove the specified argument from our list.
bool contains(const RooAbsArg &var) const
Check if collection contains an argument with the same name as var.
Int_t getSize() const
Return the number of elements in the collection.
const char * GetName() const override
Returns name of object.
virtual bool add(const RooAbsArg &var, bool silent=false)
Add the specified argument to list.
void assign(const RooAbsCollection &other) const
Sets the value, cache and constant attribute of any argument in our set that also appears in the othe...
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual Int_t getBins(const char *name=nullptr) const
Get number of bins of currently defined range.
virtual double getMax(const char *name=nullptr) const
Get maximum of currently defined range.
RooPlot * frame(const RooCmdArg &arg1, const RooCmdArg &arg2=RooCmdArg::none(), const RooCmdArg &arg3=RooCmdArg::none(), const RooCmdArg &arg4=RooCmdArg::none(), const RooCmdArg &arg5=RooCmdArg::none(), const RooCmdArg &arg6=RooCmdArg::none(), const RooCmdArg &arg7=RooCmdArg::none(), const RooCmdArg &arg8=RooCmdArg::none()) const
Create a new RooPlot on the heap with a drawing frame initialized for this object,...
virtual double getMin(const char *name=nullptr) const
Get minimum of currently defined range.
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
Definition RooAbsReal.h:62
double getVal(const RooArgSet *normalisationSet=nullptr) const
Evaluate object.
Definition RooAbsReal.h:91
virtual RooAbsReal * createProfile(const RooArgSet &paramsOfInterest)
Create a RooProfileLL object that eliminates all nuisance parameters in the present function.
TH1 * fillHistogram(TH1 *hist, const RooArgList &plotVars, double scaleFactor=1, const RooArgSet *projectedVars=nullptr, bool scaling=true, const RooArgSet *condObs=nullptr, bool setError=true) const
Fill the ROOT histogram 'hist' with values sampled from this function at the bin centers.
TF1 * asTF(const RooArgList &obs, const RooArgList &pars=RooArgList(), const RooArgSet &nset=RooArgSet()) const
Return a ROOT TF1,2,3 object bound to this RooAbsReal with given definition of observables and parame...
virtual RooPlot * plotOn(RooPlot *frame, const RooCmdArg &arg1=RooCmdArg(), const RooCmdArg &arg2=RooCmdArg(), const RooCmdArg &arg3=RooCmdArg(), const RooCmdArg &arg4=RooCmdArg(), const RooCmdArg &arg5=RooCmdArg(), const RooCmdArg &arg6=RooCmdArg(), const RooCmdArg &arg7=RooCmdArg(), const RooCmdArg &arg8=RooCmdArg(), const RooCmdArg &arg9=RooCmdArg(), const RooCmdArg &arg10=RooCmdArg()) const
Plot (project) PDF on specified frame.
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:55
TObject * clone(const char *newname) const override
Definition RooArgSet.h:148
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Definition RooCmdArg.h:26
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition RooPlot.h:43
void SetTitle(const char *name) override
Set the title of the RooPlot to 'title'.
Definition RooPlot.cxx:1255
void addObject(TObject *obj, Option_t *drawOptions="", bool invisible=false)
Add a generic object to this plot.
Definition RooPlot.cxx:380
virtual void SetMinimum(double minimum=-1111)
Set minimum value of Y axis.
Definition RooPlot.cxx:1059
virtual void SetMaximum(double maximum=-1111)
Set maximum value of Y axis.
Definition RooPlot.cxx:1049
TAxis * GetYaxis() const
Definition RooPlot.cxx:1276
void Draw(Option_t *options=nullptr) override
Draw this plot and all of the elements it contains.
Definition RooPlot.cxx:649
Class RooProfileLL implements the profile likelihood estimator for a given likelihood and set of para...
RooAbsReal & nll()
RooRealVar represents a variable that can be changed from the outside.
Definition RooRealVar.h:40
void setVal(double value) override
Set value of variable to 'value'.
void setBins(Int_t nBins, const char *name=nullptr)
Create a uniform binning under name 'name' for this variable.
This class provides simple and straightforward utilities to plot a LikelihoodInterval object.
Color_t fColor
color for the contour (for 2D) or function (in 1D)
void SetPlotParameters(const RooArgSet *params)
Int_t fNPoints
number of points used to scan the PL
Style_t fFillStyle
fill style for contours
void Draw(const Option_t *options=nullptr) override
draw the likelihood interval or contour for the 1D case a RooPlot is drawn by default of the profiled...
LikelihoodIntervalPlot()
LikelihoodIntervalPlot default constructor with default parameters.
void SetLikelihoodInterval(LikelihoodInterval *theInterval)
Color_t fLineColor
line color for the interval (1D) or for other contours (2D)
~LikelihoodIntervalPlot() override
Destructor of SamplingDistribution.
LikelihoodInterval is a concrete implementation of the RooStats::ConfInterval interface.
double ConfidenceLevel() const override
return confidence level
double UpperLimit(const RooRealVar &param)
return the upper bound of the interval on a given parameter
Int_t GetContourPoints(const RooRealVar &paramX, const RooRealVar &paramY, double *x, double *y, Int_t npoints=30)
return the 2D-contour points for the given subset of parameters by default make the contour using 30 ...
RooArgSet * GetParameters() const override
return a cloned list of parameters of interest. User manages the return object
double LowerLimit(const RooRealVar &param)
return the lower bound of the interval on a given parameter
RooAbsReal * GetLikelihoodRatio()
return the profile log-likelihood ratio function
const RooArgSet * GetBestFitParameters() const
return a pointer to a snapshot with best fit parameter of interest
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
Definition TAttFill.h:37
virtual void SetFillStyle(Style_t fstyle)
Set the fill area style.
Definition TAttFill.h:39
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
Definition TAttLine.h:42
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
Definition TAttLine.h:43
virtual void SetLineColor(Color_t lcolor)
Set the line color.
Definition TAttLine.h:40
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Definition TAttMarker.h:38
virtual void SetMarkerStyle(Style_t mstyle=1)
Set the marker style.
Definition TAttMarker.h:40
Float_t GetBottomMargin() const
Definition TAttPad.h:43
Double_t GetXmax() const
Definition TAxis.h:135
Double_t GetXmin() const
Definition TAxis.h:134
The Canvas class.
Definition TCanvas.h:23
TObject * Clone(const char *newname="") const override
Make a clone of an collection using the Streamer facility.
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
1-Dim function class
Definition TF1.h:213
virtual TH1 * GetHistogram() const
Return a pointer to the histogram used to visualise the function Note that this histogram is managed ...
Definition TF1.cxx:1585
TAxis * GetYaxis() const
Get y axis of the function.
Definition TF1.cxx:2410
virtual void SetMaximum(Double_t maximum=-1111)
Set the maximum value along Y for this function In case the function is already drawn,...
Definition TF1.cxx:3392
virtual void SetRange(Double_t xmin, Double_t xmax)
Initialize the upper and lower bounds to draw the function.
Definition TF1.cxx:3520
void SetTitle(const char *title="") override
Set function title if title has the form "fffffff;xxxx;yyyy", it is assumed that the function title i...
Definition TF1.cxx:3550
virtual void SetNpx(Int_t npx=100)
Set the number of points used to draw the function.
Definition TF1.cxx:3431
void Draw(Option_t *option="") override
Draw this function with its current attributes.
Definition TF1.cxx:1334
virtual Double_t GetX(Double_t y, Double_t xmin=0, Double_t xmax=0, Double_t epsilon=1.E-10, Int_t maxiter=100, Bool_t logx=false) const
Returns the X value corresponding to the function value fy for (xmin<x<xmax).
Definition TF1.cxx:1864
TObject * Clone(const char *newname=nullptr) const override
Make a complete copy of the underlying object.
Definition TF1.cxx:1065
TAxis * GetXaxis() const
Get x axis of the function.
Definition TF1.cxx:2399
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Set x and y values for point number i.
Definition TGraph.cxx:2325
Double_t * GetY() const
Definition TGraph.h:137
Double_t * GetX() const
Definition TGraph.h:136
virtual Int_t RemovePoint()
Delete point close to the mouse position Returns index of removed point (or -1 if nothing was changed...
Definition TGraph.cxx:2021
void SetName(const char *name="") override
Set graph name.
Definition TGraph.cxx:2364
void Draw(Option_t *chopt="") override
Draw this graph with its current attributes.
Definition TGraph.cxx:808
void SetTitle(const char *title) override
Change (i.e.
Definition TH1.cxx:6700
@ kNoStats
Don't draw stats box.
Definition TH1.h:163
TAxis * GetXaxis()
Definition TH1.h:322
virtual Double_t GetMaximum(Double_t maxval=FLT_MAX) const
Return maximum value smaller than maxval of bins in the range, unless the value has been overridden b...
Definition TH1.cxx:8411
virtual void SetMaximum(Double_t maximum=-1111)
Definition TH1.h:400
TAxis * GetYaxis()
Definition TH1.h:323
void Draw(Option_t *option="") override
Draw this histogram with options.
Definition TH1.cxx:3060
virtual void SetContour(Int_t nlevels, const Double_t *levels=nullptr)
Set the number and values of contour levels.
Definition TH1.cxx:8349
TObject * Clone(const char *newname="") const override
Make a complete copy of the underlying object.
Definition TH1.cxx:2727
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
Definition TH1.cxx:8856
2-D histogram with a double per channel (see TH1 documentation)}
Definition TH2.h:300
static TClass * Class()
2-D histogram with a float per channel (see TH1 documentation)}
Definition TH2.h:257
Service class for 2-D histogram classes.
Definition TH2.h:30
Use the TLine constructor to create a simple line.
Definition TLine.h:22
A doubly linked list.
Definition TList.h:38
virtual void SetTitle(const char *title="")
Set the title of the TNamed.
Definition TNamed.cxx:164
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
const char * GetTitle() const override
Returns title of object.
Definition TNamed.h:48
virtual void SetName(const char *name)
Set the name of the TNamed.
Definition TNamed.cxx:140
An array of TObjects.
Definition TObjArray.h:31
TObject * At(Int_t idx) const override
Definition TObjArray.h:164
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current selected pad with: gROOT->SetSelectedPad(c1).
Definition TObject.cxx:299
void SetBit(UInt_t f, Bool_t set)
Set or unset the user status bits as specified in f.
Definition TObject.cxx:774
virtual TClass * IsA() const
Definition TObject.h:245
virtual void Draw(Option_t *option="")
Default Draw method for all objects.
Definition TObject.cxx:274
The most important graphics class in the ROOT system.
Definition TPad.h:28
Basic string class.
Definition TString.h:139
Ssiz_t Length() const
Definition TString.h:421
void ToLower()
Change string to lower-case.
Definition TString.cxx:1170
const char * Data() const
Definition TString.h:380
TString & ReplaceAll(const TString &s1, const TString &s2)
Definition TString.h:704
TString & Append(const char *cs)
Definition TString.h:576
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
Definition TString.cxx:2356
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
Definition TString.h:636
TVirtualPad is an abstract base class for the Pad and Canvas classes.
Definition TVirtualPad.h:51
RooCmdArg Precision(double prec)
RooCmdArg LineColor(Color_t color)
double chisquared_quantile(double z, double r)
Inverse ( ) of the cumulative distribution function of the lower tail of the distribution with degr...
TGraphErrors * gr
Definition legend1.C:25
TF1 * f1
Definition legend1.C:11
Namespace for the RooStats classes.
Definition Asimov.h:19