Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ProfileInspector.cxx
Go to the documentation of this file.
1// @(#)root/roostats:$Id: ProfileInspector.cxx 34109 2010-06-24 15:00:16Z moneta $
2
3/*************************************************************************
4 * Project: RooStats *
5 * Package: RooFit/RooStats *
6 * Authors: *
7 * Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke *
8 * Akira Shibata
9 *************************************************************************
10 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
11 * All rights reserved. *
12 * *
13 * For the licensing terms see $ROOTSYS/LICENSE. *
14 * For the list of contributors see $ROOTSYS/README/CREDITS. *
15 *************************************************************************/
16
17
18/** \class RooStats::ProfileInspector
19 \ingroup Roostats
20
21Utility class to plot conditional MLE of nuisance parameters vs. Parameters of Interest
22
23*/
24
25
27#include "RooRealVar.h"
28#include "RooAbsReal.h"
29#include "RooArgSet.h"
30#include "RooAbsPdf.h"
31#include "RooCurve.h"
32#include "TAxis.h"
33
35
36using namespace RooStats;
37using std::cout, std::endl, std::string, std::map;
38
39////////////////////////////////////////////////////////////////////////////////
40
42{
43}
44
45////////////////////////////////////////////////////////////////////////////////
46/// ProfileInspector destructor
47
49{
50}
51
52////////////////////////////////////////////////////////////////////////////////
53///
54/// This tool makes a plot of the conditional maximum likelihood estimate of the nuisance parameter
55/// vs the parameter of interest
56///
57/// This enables you to discover if any of the nuisance parameters are behaving strangely
58/// curve is the optional parameters, when used you can specify the points previously scanned
59/// in the process of plotOn or createHistogram.
60/// To do this, you can do the following after the plot has been made:
61/// ~~~ {.cpp}
62/// profile, RooRealVar * poi, RooCurve * curve ){
63///RooCurve * curve = 0;
64/// ~~~
65
67{
68
69 const RooArgSet* poi_set = config->GetParametersOfInterest();
70 const RooArgSet* nuis_params=config->GetNuisanceParameters();
71 RooAbsPdf* pdf = config->GetPdf();
72
73
74 if(!poi_set){
75 cout << "no parameters of interest" << endl;
76 return nullptr;
77 }
78
79 if(poi_set->size()!=1){
80 cout << "only one parameter of interest is supported currently" << endl;
81 return nullptr;
82 }
83 RooRealVar* poi = static_cast<RooRealVar*>(poi_set->first());
84
85
86 if(!nuis_params){
87 cout << "no nuisance parameters" << endl;
88 return nullptr;
89 }
90
91 if(!pdf){
92 cout << "pdf not set" << endl;
93 return nullptr;
94 }
95
96 std::unique_ptr<RooAbsReal> nll{pdf->createNLL(data)};
97 std::unique_ptr<RooAbsReal> profile{nll->createProfile(*poi)};
98
99 TList * list = new TList;
100 Int_t curve_N=100;
101 double* curve_x=nullptr;
102// if(curve){
103// curve_N=curve->GetN();
104// curve_x=curve->GetX();
105// } else {
106 double max = dynamic_cast<RooAbsRealLValue*>(poi)->getMax();
107 double min = dynamic_cast<RooAbsRealLValue*>(poi)->getMin();
108 double step = (max-min)/(curve_N-1);
109 curve_x=new double[curve_N];
110 for(int i=0; i<curve_N; ++i){
111 curve_x[i]=min+step*i;
112 }
113// }
114
115 map<string, std::vector<double> > name_val;
116 for(int i=0; i<curve_N; i++){
117 poi->setVal(curve_x[i]);
118 profile->getVal();
119
120 for (auto const *nuis_param : dynamic_range_cast<RooRealVar *> (*nuis_params)){
121 if(nuis_param) {
122 string name = nuis_param->GetName();
123 if(nuis_params->empty()) continue;
124 if(nuis_param && (! nuis_param->isConstant())){
125 if(name_val.find(name)==name_val.end()) name_val[name]=std::vector<double>(curve_N);
126 name_val[name][i]=nuis_param->getVal();
127
128 if(i==curve_N-1){
129 TGraph* g = new TGraph(curve_N, curve_x, &(name_val[name].front()));
130 g->SetName((name+"_"+string(poi->GetName())+"_profile").c_str());
131 g->GetXaxis()->SetTitle(poi->GetName());
132 g->GetYaxis()->SetTitle(nuis_param->GetName());
133 g->SetTitle("");
134 list->Add(g);
135 }
136 }
137 }
138 }
139 }
140
141 delete [] curve_x;
142
143 return list;
144}
#define g(i)
Definition RSha256.hxx:105
#define ClassImp(name)
Definition Rtypes.h:382
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
char name[80]
Definition TGX11.cxx:110
Storage_t::size_type size() const
RooAbsArg * first() const
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:57
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:40
RooFit::OwningPtr< RooAbsReal > createNLL(RooAbsData &data, CmdArgs_t const &... cmdArgs)
Construct representation of -log(L) of PDF with given dataset.
Definition RooAbsPdf.h:163
Abstract base class for objects that represent a real value that may appear on the left hand side of ...
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Variable that can be changed from the outside.
Definition RooRealVar.h:37
void setVal(double value) override
Set value of variable to 'value'.
ModelConfig is a simple class that holds configuration information specifying how a model should be u...
Definition ModelConfig.h:35
const RooArgSet * GetParametersOfInterest() const
get RooArgSet containing the parameter of interest (return nullptr if not existing)
const RooArgSet * GetNuisanceParameters() const
get RooArgSet containing the nuisance parameters (return nullptr if not existing)
RooAbsPdf * GetPdf() const
get model PDF (return nullptr if pdf has not been specified or does not exist)
Utility class to plot conditional MLE of nuisance parameters vs.
TList * GetListOfProfilePlots(RooAbsData &data, RooStats::ModelConfig *config)
This tool makes a plot of the conditional maximum likelihood estimate of the nuisance parameter vs th...
virtual ~ProfileInspector()
ProfileInspector destructor.
A TGraph is an object made of two arrays X and Y with npoints each.
Definition TGraph.h:41
A doubly linked list.
Definition TList.h:38
void Add(TObject *obj) override
Definition TList.h:83
const char * GetName() const override
Returns name of object.
Definition TNamed.h:47
Namespace for the RooStats classes.
Definition Asimov.h:19