46 using namespace RooStats;
52 LikelihoodIntervalPlot::LikelihoodIntervalPlot()
76 fInterval = theInterval;
78 fNdimPlot = fParamsPlot->
getSize();
96 LikelihoodIntervalPlot::~LikelihoodIntervalPlot()
104 fInterval = theInterval;
106 fNdimPlot = fParamsPlot->
getSize();
113 void LikelihoodIntervalPlot::SetPlotParameters(
const RooArgSet *params)
161 TIter it = fParamsPlot->createIterator();
163 RooArgSet* intervalParams = fInterval->GetParameters();
167 if (!intervalParams->
contains(*arg) ) {
169 <<
" - do not use for plotting " << std::endl;
171 extraParams.
add(*arg);
175 fParamsPlot->remove(extraParams,
true,
true);
179 <<
") ERROR: contours for more than 2 dimensions not implemented!" << std::endl;
187 RooAbsReal* oldProfile = fInterval->GetLikelihoodRatio();
188 if (fNdimPlot != intervalParams->
getSize() ) {
190 if (!profilell)
return;
195 newProfile = oldProfile;
202 if (fInterval->GetBestFitParameters() ) {
203 *fParamsPlot = *fInterval->GetBestFitParameters();
212 int nPoints = fNPoints;
227 if (nPoints <=0) nPoints = 100;
229 const Double_t xcont_min = fInterval->LowerLimit(*myparam);
230 const Double_t xcont_max = fInterval->UpperLimit(*myparam);
237 if (fColor == 0) fColor =
kBlue;
238 if (fLineColor == 0) fLineColor =
kGreen;
248 if (fXmin < fXmax) { xmin = fXmin; xmax = fXmax; }
250 TF1 * tmp = newProfile->
asTF(*myarg);
252 tmp->SetRange(xmin, xmax);
253 tmp->SetNpx(nPoints);
256 TF1 *
f1 = (TF1*) tmp->Clone();
267 if (fMaximum > 0 && fXmin >= fXmax ) {
268 double x0 = f1->GetX(0, xmin, xmax);
270 if ( x0 > x1 && x0 < x2) {
271 x1 = f1->GetX(fMaximum, xmin, x0);
272 x2 = f1->GetX(fMaximum, x0, xmax);
273 f1->SetMaximum(fMaximum);
281 f1->SetLineColor(
kBlue);
282 f1->GetXaxis()->SetTitle(myarg->
GetName());
283 f1->GetYaxis()->SetTitle(
Form(
"- log #lambda(%s)",myparam->
GetName()));
285 fPlotObject = f1->GetHistogram();
291 if (fXmin < fXmax) { xmin = fXmin; xmax = fXmax; }
295 int prevBins = myarg->
getBins();
299 frame = myarg->
frame(xmin,xmax,nPoints);
325 TLine *Yline_cutoff =
new TLine(x1,Yat_Xmax,x2,Yat_Xmax);
326 TLine *Yline_min =
new TLine(xcont_min,0.,xcont_min,Yat_Xmax);
327 TLine *Yline_max =
new TLine(xcont_max,0.,xcont_max,Yat_Xmax);
329 Yline_cutoff->SetLineColor(fLineColor);
330 Yline_min->SetLineColor(fLineColor);
331 Yline_max->SetLineColor(fLineColor);
335 Yline_cutoff->Draw();
353 else if(fNdimPlot == 2){
358 bool useMinuit = !opt.
Contains(
"nominuit");
360 bool plotHist = !opt.
Contains(
"nohist");
363 if (opt.
Contains(
"minuit") ) useMinuit=
true;
364 if (useMinuit) plotHist =
false;
365 if (opt.
Contains(
"hist") ) plotHist=
true;
372 cont_level = cont_level/2;
376 for (
int i = 0; i < params.getSize(); ++i) {
391 if (nPoints <=0) nPoints = 40;
395 if (fXmin < fXmax) { xmin = fXmin; xmax = fXmax; }
396 if (fYmin < fYmax) { ymin = fYmin; ymax = fYmax; }
399 if (!useMinuit || plotHist) {
405 int nBins = int(
std::sqrt(
double(nPoints)) + 0.5 );
406 TH2* hist2D =
new TH2D(histName, title, nBins, xmin, xmax, nBins, ymin, ymax );
415 const int nLevels = 51;
416 double contLevels[nLevels];
417 contLevels[0] = 0.01;
418 double maxVal = (fMaximum > 0) ? fMaximum : hist2D->
GetMaximum();
419 for (
int k = 1; k < nLevels; ++k) {
420 contLevels[k] = k*maxVal/
double(nLevels-1);
432 const int nLevels = 8;
433 double contLevels[nLevels];
435 double confLevels[nLevels] = { 0.1,0.3,0.5,0.683,0.95,0.9973,0.9999366575,0.9999994267};
436 for (
int k = 0; k < nLevels; ++k) {
446 if (tmpOpt.
Length() < 3) opt +=
"cont3";
448 if (plotHist) opt +=
TString(
" same");
461 TCanvas * tmpCanvas =
new TCanvas(
"tmpCanvas",
"tmpCanvas");
462 h->
Draw(
"CONT LIST");
487 TPad *
null=
new TPad(
"null",
"null",0,0,1,1);
488 null->SetFillStyle(0);
489 null->SetFrameFillStyle(0);
492 null->Range(x1-(x2-x1)*(lm/(1-rm-lm)),
493 y1-(y2-y1)*(bm/(1-tm-lm)),
494 x2+(x2-x1)*(rm/(1-rm-lm)),
495 y2+(y2-y1)*(tm/(1-tm-lm)));
502 int ncontours = contours->
GetSize();
503 for (
int icont = 0; icont < ncontours; ++icont) {
505 if (contourList && contourList->
GetSize() > 0) {
508 while( (gr = dynamic_cast<TGraph*>(itgr->
Next()) ) ){
509 if (fLineColor) gr->SetLineColor(fLineColor);
513 gr->SetFillColor(fColor);
525 <<
") ERROR: no contours found in ListOfSpecial" << std::endl;
528 fPlotObject = hist2D;
535 TGraph *
gr =
new TGraph(nPoints+1);
537 int ncp = fInterval->GetContourPoints(*myparam, *myparamY, gr->GetX(), gr->GetY(),nPoints);
539 if (
int(ncp) < nPoints) {
540 std::cout <<
"Warning - Less points calculated in contours np = " << ncp <<
" / " << nPoints << std::endl;
541 for (
int i = ncp; i < nPoints; ++i) gr->RemovePoint(i);
544 gr->SetPoint(ncp, gr->GetX()[0], gr->GetY()[0] );
547 if (!opt.
Contains(
"same") && !plotHist) {
549 TH2F* hist2D =
new TH2F(
"_hist2D",title, nPoints, xmin, xmax, nPoints, ymin, ymax );
550 hist2D->GetXaxis()->SetTitle(myparam->
GetName());
551 hist2D->GetYaxis()->SetTitle(myparamY->
GetName());
553 hist2D->SetFillStyle(fFillStyle);
554 hist2D->SetMaximum(1);
555 hist2D->Draw(
"AXIS");
557 if (fLineColor) gr->SetLineColor(fLineColor);
560 gr->SetFillColor(fColor);
564 if (opt.
Contains(
"same")) gr->SetFillStyle(fFillStyle);
569 if (!fPlotObject) fPlotObject =
gr;
570 else if (fPlotObject->IsA() !=
TH2D::Class() ) fPlotObject = gr;
575 const RooArgSet * bestFitParams = fInterval->GetBestFitParameters();
577 TGraph * gr0 =
new TGraph(1);
580 gr0->SetPoint(0,x0,y0);
581 gr0->SetMarkerStyle(33);
583 if (fColor !=
kBlack) gr0->SetMarkerColor(fColor+4);
584 else gr0->SetMarkerColor(
kGray);
587 delete bestFitParams;
595 if (newProfile != oldProfile)
delete newProfile;
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.
ClassImp(RooStats::LikelihoodIntervalPlot)
static Vc_ALWAYS_INLINE int_v min(const int_v &x, const int_v &y)
virtual void SetMaximum(Double_t maximum=-1111)
Class RooProfileLL implements the profile likelihood estimator for a given likelihood and set of para...
RooCmdArg LineColor(Color_t color)
LikelihoodInterval is a concrete implementation of the RooStats::ConfInterval interface.
void addObject(TObject *obj, Option_t *drawOptions="", Bool_t invisible=kFALSE)
Add a generic object to this plot.
TString & ReplaceAll(const TString &s1, const TString &s2)
virtual void SetContour(Int_t nlevels, const Double_t *levels=0)
Set the number and values of contour levels.
virtual RooArgSet * GetParameters() const
return a cloned list of parameters of interest. User manages the return object
Bool_t contains(const RooAbsArg &var) const
This class provides simple and straightforward utilities to plot a LikelihoodInterval object...
virtual Double_t getMin(const char *name=0) const
void ToLower()
Change string to lower-case.
void SetTitle(const char *name)
Set the title of the RooPlot to 'title'.
virtual TObject * DrawClone(Option_t *option="") const
Draw a clone of this object in the current pad.
Iterator abstract base class.
TObject * Clone(const char *newname=0) const
Make a complete copy of the underlying object.
virtual TObject * Clone(const char *newname="") const
Make a clone of an collection using the Streamer facility.
const char * Data() const
virtual void SetMinimum(Double_t minimum=-1111)
Set minimum value of Y axis.
static const double x2[5]
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString...
RooArgSet * getVariables(Bool_t stripDisconnected=kTRUE) const
Return RooArgSet with all variables (tree leaf nodes of expresssion tree)
virtual Int_t getBins(const char *name=0) const
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...
TString & Append(const char *cs)
Double_t getVal(const RooArgSet *set=0) const
void setBins(Int_t nBins, const char *name=0)
TVirtualPad is an abstract base class for the Pad and Canvas classes.
RooRealVar represents a fundamental (non-derived) real valued object.
virtual void setVal(Double_t value)
Set value of variable to 'value'.
virtual void SetLineColor(Color_t lcolor)
Service class for 2-Dim histogram classes.
RooAbsArg * find(const char *name) const
Find object with given name in list.
virtual void Draw(Option_t *option="")
Draw this histogram with options.
TPaveLabel title(3, 27.1, 15, 28.7,"ROOT Environment and Tools")
virtual void SetMaximum(Double_t maximum=-1111)
Set maximum value of Y axis.
char * Form(const char *fmt,...)
virtual const char * GetName() const
Returns name of object.
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
TH1 * fillHistogram(TH1 *hist, const RooArgList &plotVars, Double_t scaleFactor=1, const RooArgSet *projectedVars=0, Bool_t scaling=kTRUE, const RooArgSet *condObs=0, Bool_t setError=kTRUE) const
Fill the ROOT histogram 'hist' with values sampled from this function at the bin centers.
A RooPlot is a plot frame and a container for graphics objects within that frame. ...
virtual TObject * clone(const char *newname) const
virtual Int_t GetSize() const
static const double x1[5]
RooCmdArg Precision(Double_t prec)
RooAbsReal is the common abstract base class for objects that represent a real value and implements f...
static Vc_ALWAYS_INLINE int_v max(const int_v &x, const int_v &y)
virtual Double_t getMax(const char *name=0) const
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual RooAbsReal * createProfile(const RooArgSet ¶msOfInterest)
Create a RooProfileLL object that eliminates all nuisance parameters in the present function...
virtual TObject * Next()=0
virtual TIterator * MakeIterator(Bool_t dir=kIterForward) const
Return a list iterator.
virtual void SetTitle(const char *title)
Change (i.e.
TObject * At(Int_t idx) const
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
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...
virtual void SetTitle(const char *title="")
Change (i.e. set) the title of the TNamed.
virtual void SetStats(Bool_t stats=kTRUE)
Set statistics option on/off.
double chisquared_quantile(double z, double r)
Inverse ( ) of the cumulative distribution function of the lower tail of the distribution with degr...
virtual Bool_t add(const RooAbsArg &var, Bool_t silent=kFALSE)
Add element to non-owning set.
const char * GetName() const
Returns name of object.
virtual void Draw(Option_t *options=0)
Draw this plot and all of the elements it contains.
RooCmdArg is a named container for two doubles, two integers two object points and three string point...
Double_t getRealValue(const char *name, Double_t defVal=0, Bool_t verbose=kFALSE) const
Get value of a RooAbsReal stored in set with given name.
2-D histogram with a double per channel (see TH1 documentation)}