Logo ROOT  
Reference Guide
RooUnitTest.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Project: RooFit *
3  * Package: RooFitCore *
4  * File: $Id$
5  * Authors: *
6  * WV, Wouter Verkerke, NIKHEF, verkerke@nikhef.nl *
7  * *
8  * Copyright (c) 2000-2011, Regents of the University of California *
9  * and Stanford University. All rights reserved. *
10  * *
11  * Redistribution and use in source and binary forms, *
12  * with or without modification, are permitted according to the terms *
13  * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
14  *****************************************************************************/
15 #ifndef ROO_UNIT_TEST
16 #define ROO_UNIT_TEST
17 
18 #include "TNamed.h"
19 #include "RooTable.h"
20 #include "RooWorkspace.h"
21 #include "RooFitResult.h"
22 #include "RooPlot.h"
23 #include "TFile.h"
24 #include "TH1.h"
25 #include <list>
26 #include <string>
27 #include <utility>
28 
29 /*
30  * The tolerance for the curve test is put to 0.4 instead of 0.2 to take into
31  * account the small variations in the values of the likelihood which can occur
32  * in presence of a different treatment of floating point numbers.
33  */
34 
35 class RooUnitTest : public TNamed {
36 public:
37  RooUnitTest(const char* name, TFile* refFile, Bool_t writeRef, Int_t verbose) ;
38  ~RooUnitTest() ;
39 
40  void setDebug(Bool_t flag) { _debug = flag ; }
41  void setSilentMode() ;
42  void clearSilentMode() ;
43  void regPlot(RooPlot* frame, const char* refName) ;
44  void regResult(RooFitResult* r, const char* refName) ;
45  void regValue(Double_t value, const char* refName) ;
46  void regTable(RooTable* t, const char* refName) ;
47  void regWS(RooWorkspace* ws, const char* refName) ;
48  void regTH(TH1* h, const char* refName) ;
49  RooWorkspace* getWS(const char* refName) ;
50  Bool_t runTest() ;
52  Bool_t areTHidentical(TH1* htest, TH1* href) ;
53 
54  virtual Bool_t isTestAvailable() { return kTRUE ; }
55  virtual Bool_t testCode() = 0 ;
56 
57  virtual Double_t htol() { return 5e-4 ; } // histogram test tolerance (KS dist != prob)
58 #ifdef R__FAST_MATH
59  virtual Double_t ctol() { return 2e-3 ; } // curve test tolerance
60 #else
61  virtual Double_t ctol() { return 4e-3 ; } // curve test tolerance
62 #endif
63  virtual Double_t fptol() { return 1e-5 ; } // fit parameter test tolerance
64  virtual Double_t fctol() { return 1e-4 ; } // fit correlation test tolerance
65  virtual Double_t vtol() { return 1e-3 ; } // value test tolerance
66 
67  static void setMemDir(TDirectory* memDir);
68 
69 protected:
70 
71  static TDirectory* gMemDir ;
72 
77  std::list<std::pair<RooPlot*, std::string> > _regPlots ;
78  std::list<std::pair<RooFitResult*, std::string> > _regResults ;
79  std::list<std::pair<Double_t, std::string> > _regValues ;
80  std::list<std::pair<RooTable*,std::string> > _regTables ;
81  std::list<std::pair<RooWorkspace*,std::string> > _regWS ;
82  std::list<std::pair<TH1*,std::string> > _regTH ;
83 
84  ClassDef(RooUnitTest,0) ; // Abstract base class for RooFit/RooStats unit regression tests
85 } ;
86 #endif
RooWorkspace.h
kTRUE
const Bool_t kTRUE
Definition: RtypesCore.h:91
RooUnitTest::_refFile
TFile * _refFile
Definition: RooUnitTest.h:73
e
#define e(i)
Definition: RSha256.hxx:103
RooUnitTest::areTHidentical
Bool_t areTHidentical(TH1 *htest, TH1 *href)
Definition: RooUnitTest.cxx:165
RooUnitTest::_verb
Int_t _verb
Definition: RooUnitTest.h:76
RooUnitTest::vtol
virtual Double_t vtol()
Definition: RooUnitTest.h:65
r
ROOT::R::TRInterface & r
Definition: Object.C:4
TNamed.h
RooUnitTest::_regWS
std::list< std::pair< RooWorkspace *, std::string > > _regWS
Definition: RooUnitTest.h:81
RooUnitTest::setDebug
void setDebug(Bool_t flag)
Definition: RooUnitTest.h:40
RooUnitTest::getWS
RooWorkspace * getWS(const char *refName)
Definition: RooUnitTest.cxx:150
RooUnitTest::_regResults
std::list< std::pair< RooFitResult *, std::string > > _regResults
Definition: RooUnitTest.h:78
RooUnitTest::setMemDir
static void setMemDir(TDirectory *memDir)
Set gMemDir to memDir.
Definition: RooUnitTest.cxx:609
TFile.h
RooUnitTest::_write
Bool_t _write
Definition: RooUnitTest.h:75
RooUnitTest::RooUnitTest
RooUnitTest(const char *name, TFile *refFile, Bool_t writeRef, Int_t verbose)
Definition: RooUnitTest.cxx:57
bool
RooFitResult
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
RooUnitTest::isTestAvailable
virtual Bool_t isTestAvailable()
Definition: RooUnitTest.h:54
RooUnitTest::htol
virtual Double_t htol()
Definition: RooUnitTest.h:57
RooUnitTest::_debug
Bool_t _debug
Definition: RooUnitTest.h:74
RooTable
RooTable is the abstract interface for table objects.
Definition: RooTable.h:23
RooUnitTest::clearSilentMode
void clearSilentMode()
Definition: RooUnitTest.cxx:559
ws
void ws()
Definition: ws.C:66
RooUnitTest::_regTH
std::list< std::pair< TH1 *, std::string > > _regTH
Definition: RooUnitTest.h:82
h
#define h(i)
Definition: RSha256.hxx:106
TNamed
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
RooUnitTest
RooUnit test is an abstract base class for unit regression tests for RooFit and RooStats tests perfor...
Definition: RooUnitTest.h:35
RooPlot.h
RooPlot
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:44
RooUnitTest::gMemDir
static TDirectory * gMemDir
Definition: RooUnitTest.h:71
RooUnitTest::testCode
virtual Bool_t testCode()=0
RooUnitTest::_regValues
std::list< std::pair< Double_t, std::string > > _regValues
Definition: RooUnitTest.h:79
RooUnitTest::regValue
void regValue(Double_t value, const char *refName)
Definition: RooUnitTest.cxx:100
RooUnitTest::setSilentMode
void setSilentMode()
Definition: RooUnitTest.cxx:546
RooUnitTest::ctol
virtual Double_t ctol()
Definition: RooUnitTest.h:61
TFile
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
RooFitResult.h
RooUnitTest::runTest
Bool_t runTest()
Definition: RooUnitTest.cxx:571
RooWorkspace
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
RooTable.h
Double_t
double Double_t
Definition: RtypesCore.h:59
ClassDef
#define ClassDef(name, id)
Definition: Rtypes.h:325
TH1
TH1 is the base class of all histogramm classes in ROOT.
Definition: TH1.h:58
name
char name[80]
Definition: TGX11.cxx:110
RooUnitTest::regPlot
void regPlot(RooPlot *frame, const char *refName)
Definition: RooUnitTest.cxx:73
RooUnitTest::_regTables
std::list< std::pair< RooTable *, std::string > > _regTables
Definition: RooUnitTest.h:80
RooUnitTest::runCompTests
Bool_t runCompTests()
Definition: RooUnitTest.cxx:211
TDirectory
Describe directory structure in memory.
Definition: TDirectory.h:45
RooUnitTest::regTable
void regTable(RooTable *t, const char *refName)
Definition: RooUnitTest.cxx:111
genreflex::verbose
bool verbose
Definition: rootcling_impl.cxx:133
RooUnitTest::regResult
void regResult(RooFitResult *r, const char *refName)
Definition: RooUnitTest.cxx:87
TH1.h
RooUnitTest::~RooUnitTest
~RooUnitTest()
Definition: RooUnitTest.cxx:66
RooUnitTest::fctol
virtual Double_t fctol()
Definition: RooUnitTest.h:64
RooUnitTest::regWS
void regWS(RooWorkspace *ws, const char *refName)
Definition: RooUnitTest.cxx:124
RooUnitTest::_regPlots
std::list< std::pair< RooPlot *, std::string > > _regPlots
Definition: RooUnitTest.h:77
int
RooUnitTest::regTH
void regTH(TH1 *h, const char *refName)
Definition: RooUnitTest.cxx:137
RooUnitTest::fptol
virtual Double_t fptol()
Definition: RooUnitTest.h:63