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 "RooTable.h"
19#include "RooWorkspace.h"
20#include "RooFitResult.h"
21#include "RooPlot.h"
22
23#include "TNamed.h"
24#include "TFile.h"
25#include "TH1.h"
26
27#include <list>
28#include <string>
29#include <utility>
30
31/*
32 * The tolerance for the curve test is put to 0.4 instead of 0.2 to take into
33 * account the small variations in the values of the likelihood which can occur
34 * in presence of a different treatment of floating point numbers.
35 */
36
37class RooUnitTest : public TNamed {
38public:
39 RooUnitTest(const char* name, TFile* refFile, bool writeRef, Int_t verbose, std::string const& batchMode="off") ;
40 ~RooUnitTest() override ;
41
42 void setDebug(bool flag) { _debug = flag ; }
43 void setSilentMode() ;
44 void clearSilentMode() ;
45 void regPlot(RooPlot* frame, const char* refName) ;
46 void regResult(RooFitResult* r, const char* refName) ;
47 void regValue(double value, const char* refName) ;
48 void regTable(RooTable* t, const char* refName) ;
49 void regWS(RooWorkspace* ws, const char* refName) ;
50 void regTH(TH1* h, const char* refName) ;
51 RooWorkspace* getWS(const char* refName) ;
52 bool runTest() ;
53 bool runCompTests() ;
54 bool areTHidentical(TH1* htest, TH1* href) ;
55
56 virtual bool isTestAvailable() { return true ; }
57 virtual bool testCode() = 0 ;
58
59 virtual double htol() { return 5e-4 ; } ///< histogram test tolerance (KS dist != prob)
60#ifdef R__FAST_MATH
61 virtual double ctol() { return 2e-3 ; } ///< curve test tolerance
62#else
63 virtual double ctol() { return 4e-3 ; } ///< curve test tolerance
64#endif
65 virtual double fptol() { return 1e-5 ; } ///< fit parameter test tolerance
66 virtual double fctol() { return 1e-4 ; } ///< fit correlation test tolerance
67 virtual double vtol() { return 1e-3 ; } ///< value test tolerance
68
69 static void setMemDir(TDirectory* memDir);
70
71protected:
72
74
76 bool _debug ;
77 bool _write ;
79 std::string _batchMode="off";
80 std::list<std::pair<RooPlot*, std::string> > _regPlots ;
81 std::list<std::pair<RooFitResult*, std::string> > _regResults ;
82 std::list<std::pair<double, std::string> > _regValues ;
83 std::list<std::pair<RooTable*,std::string> > _regTables ;
84 std::list<std::pair<RooWorkspace*,std::string> > _regWS ;
85 std::list<std::pair<TH1*,std::string> > _regTH ;
86
87 ClassDefOverride(RooUnitTest,0) ; // Abstract base class for RooFit/RooStats unit regression tests
88} ;
89#endif
#define h(i)
Definition: RSha256.hxx:106
#define e(i)
Definition: RSha256.hxx:103
#define ClassDefOverride(name, id)
Definition: Rtypes.h:339
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
char name[80]
Definition: TGX11.cxx:110
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Definition: RooFitResult.h:40
A RooPlot is a plot frame and a container for graphics objects within that frame.
Definition: RooPlot.h:43
RooTable is the abstract interface for table objects.
Definition: RooTable.h:23
RooUnit test is an abstract base class for unit regression tests for RooFit and RooStats tests perfor...
Definition: RooUnitTest.h:37
std::list< std::pair< TH1 *, std::string > > _regTH
Definition: RooUnitTest.h:85
bool runCompTests()
virtual double htol()
histogram test tolerance (KS dist != prob)
Definition: RooUnitTest.h:59
~RooUnitTest() override
Definition: RooUnitTest.cxx:65
RooUnitTest(const char *name, TFile *refFile, bool writeRef, Int_t verbose, std::string const &batchMode="off")
Definition: RooUnitTest.cxx:56
void regWS(RooWorkspace *ws, const char *refName)
void regTH(TH1 *h, const char *refName)
void regResult(RooFitResult *r, const char *refName)
Definition: RooUnitTest.cxx:86
virtual double fptol()
fit parameter test tolerance
Definition: RooUnitTest.h:65
std::string _batchMode
Definition: RooUnitTest.h:79
std::list< std::pair< RooWorkspace *, std::string > > _regWS
Definition: RooUnitTest.h:84
static void setMemDir(TDirectory *memDir)
Set gMemDir to memDir.
bool runTest()
RooWorkspace * getWS(const char *refName)
std::list< std::pair< RooPlot *, std::string > > _regPlots
Definition: RooUnitTest.h:80
void regPlot(RooPlot *frame, const char *refName)
Definition: RooUnitTest.cxx:72
void setDebug(bool flag)
Definition: RooUnitTest.h:42
Int_t _verb
Definition: RooUnitTest.h:78
void regValue(double value, const char *refName)
Definition: RooUnitTest.cxx:99
void regTable(RooTable *t, const char *refName)
std::list< std::pair< RooFitResult *, std::string > > _regResults
Definition: RooUnitTest.h:81
virtual double ctol()
curve test tolerance
Definition: RooUnitTest.h:63
std::list< std::pair< double, std::string > > _regValues
Definition: RooUnitTest.h:82
virtual bool testCode()=0
bool areTHidentical(TH1 *htest, TH1 *href)
virtual double fctol()
fit correlation test tolerance
Definition: RooUnitTest.h:66
std::list< std::pair< RooTable *, std::string > > _regTables
Definition: RooUnitTest.h:83
virtual double vtol()
value test tolerance
Definition: RooUnitTest.h:67
TFile * _refFile
Definition: RooUnitTest.h:75
virtual bool isTestAvailable()
Definition: RooUnitTest.h:56
void setSilentMode()
static TDirectory * gMemDir
Definition: RooUnitTest.h:73
void clearSilentMode()
The RooWorkspace is a persistable container for RooFit projects.
Definition: RooWorkspace.h:43
Describe directory structure in memory.
Definition: TDirectory.h:45
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
Definition: TFile.h:54
TH1 is the base class of all histogram classes in ROOT.
Definition: TH1.h:58
The TNamed class is the base class for all named ROOT classes.
Definition: TNamed.h:29
void ws()
Definition: ws.C:66