Logo ROOT   6.08/07
Reference Guide
MinNLLTestStat.h
Go to the documentation of this file.
1 // @(#)root/roostats:$Id: MinNLLTestStat.h 43035 2012-02-16 16:48:57Z sven $
2 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
3 // Additional Contributions: Giovanni Petrucciani
4 /*************************************************************************
5  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOSTATS_MinNLLTestStat
13 #define ROOSTATS_MinNLLTestStat
14 
15 
16 
17 
18 #ifndef ROOT_Rtypes
19 #include "Rtypes.h"
20 #endif
21 
22 #include <vector>
23 
24 #include "RooStats/RooStatsUtils.h"
25 
26 //#include "RooStats/DistributionCreator.h"
28 #include "RooStats/TestStatistic.h"
29 
30 #include "RooStats/RooStatsUtils.h"
31 
32 #include "RooRealVar.h"
33 #include "RooProfileLL.h"
34 #include "RooNLLVar.h"
35 #include "RooMsgService.h"
36 
37 #include "RooMinuit.h"
38 #include "RooMinimizer.h"
39 #include "Math/MinimizerOptions.h"
40 #include "TStopwatch.h"
42 
43 namespace RooStats {
44 
45  /**
46 
47  MinNLLTestStat is an implementation of the TestStatistic interface that calculates the minimum value of the negative log likelihood
48  function and returns it as a test statistic.
49  Internaly it operates by delegating to a MinNLLTestStat object.
50 
51  \ingroup Roostats
52  */
53 
54  class MinNLLTestStat : public TestStatistic{
55 
56  public:
58  // Proof constructor. Do not use.
59  fProflts = 0;
60  }
63  }
64 
66  RooAbsPdf * pdf = rhs.fProflts->GetPdf();
67  if (pdf) fProflts = new ProfileLikelihoodTestStat(*pdf);
68  }
69 
71  if (this == &rhs) return *this;
72  RooAbsPdf * pdf = rhs.fProflts->GetPdf();
73  if (fProflts) delete fProflts;
74  fProflts = NULL;
75  if (pdf) fProflts = new ProfileLikelihoodTestStat(*pdf);
76  return *this;
77  }
78 
79  virtual ~MinNLLTestStat() {
80  delete fProflts;
81  }
82 
83  void SetOneSided(Bool_t flag=true) {fProflts->SetOneSided(flag);}
85  void SetReuseNLL(Bool_t flag) { fProflts->SetReuseNLL(flag); }
86  void SetMinimizer(const char* minimizer){ fProflts->SetMinimizer(minimizer); }
88  void SetTolerance(double tol){ fProflts->SetTolerance(tol); }
90  void SetLOffset(Bool_t flag=kTRUE) { fProflts->SetLOffset(flag) ; }
91 
92  // Main interface to evaluate the test statistic on a dataset
93  virtual Double_t Evaluate(RooAbsData& data, RooArgSet& paramsOfInterest) {
94  return fProflts->EvaluateProfileLikelihood(1, data, paramsOfInterest); //find unconditional NLL minimum
95  }
96 
97  virtual void EnableDetailedOutput( bool e=true ) { fProflts->EnableDetailedOutput(e); }
98 
99  virtual const RooArgSet* GetDetailedOutput(void) const {
100  // Returns detailed output. The value returned by this function is updated after each call to Evaluate().
101  // The returned RooArgSet contains the following:
102  // <ul>
103  // <li> the minimum nll, fitstatus and convergence quality for each fit </li>
104  // <li> for all non-constant parameters their value, error and pull </li>
105  // </ul>
106  return fProflts->GetDetailedOutput();
107  }
108 
109  virtual void SetVarName(const char* name) { fProflts->SetVarName(name); }
110 
111  virtual const TString GetVarName() const { return fProflts->GetVarName(); }
112 
113  private:
115 
116  protected:
117  ClassDef(MinNLLTestStat,1) // implements the minimum NLL as a test statistic to be used with several tools
118  };
119 }
120 
121 
122 #endif
MinNLLTestStat(RooAbsPdf &pdf)
virtual const RooArgSet * GetDetailedOutput(void) const
return detailed output: for fits this can be pulls, processing time, ... The returned pointer will no...
MinNLLTestStat is an implementation of the TestStatistic interface that calculates the minimum value ...
void SetStrategy(Int_t strategy)
void SetReuseNLL(Bool_t flag)
Basic string class.
Definition: TString.h:137
void SetOneSided(Bool_t flag=true)
virtual void EnableDetailedOutput(bool e=true, bool withErrorsAndPulls=false)
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
virtual const TString GetVarName() const
virtual Double_t EvaluateProfileLikelihood(int type, RooAbsData &data, RooArgSet &paramsOfInterest)
void SetTolerance(double tol)
#define ClassDef(name, id)
Definition: Rtypes.h:254
void SetPrintLevel(Int_t printlevel)
int printlevel
virtual const TString GetVarName() const
void SetMinimizer(const char *minimizer)
void SetOneSidedDiscovery(Bool_t flag=true)
void SetLOffset(Bool_t flag=kTRUE)
const double tol
virtual void SetVarName(const char *name)
MinNLLTestStat & operator=(const MinNLLTestStat &rhs)
virtual const RooArgSet * GetDetailedOutput(void) const
return detailed output: for fits this can be pulls, processing time, ... The returned pointer will no...
RooAbsData is the common abstract base class for binned and unbinned datasets.
Definition: RooAbsData.h:37
ProfileLikelihoodTestStat is an implementation of the TestStatistic interface that calculates the pro...
virtual Double_t Evaluate(RooAbsData &data, RooArgSet &paramsOfInterest)
Main interface to evaluate the test statistic on a dataset given the values for the Null Parameters O...
virtual void EnableDetailedOutput(bool e=true)
Namespace for the RooStats classes.
Definition: Asimov.h:20
double Double_t
Definition: RtypesCore.h:55
you should not use this method at all Int_t Int_t Double_t Double_t Double_t e
Definition: TRolke.cxx:630
RooAbsPdf is the abstract interface for all probability density functions The class provides hybrid a...
Definition: RooAbsPdf.h:41
ProfileLikelihoodTestStat * fProflts
#define NULL
Definition: Rtypes.h:82
const int strategy
Definition: testNdimFit.cxx:46
MinNLLTestStat(const MinNLLTestStat &rhs)
const Bool_t kTRUE
Definition: Rtypes.h:91
virtual void SetVarName(const char *name)
TestStatistic is an interface class to provide a facility for construction test statistics distributi...
Definition: TestStatistic.h:33
char name[80]
Definition: TGX11.cxx:109