Logo ROOT   6.30.04
Reference Guide
 All Namespaces Files Pages
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 "Rtypes.h"
19 #include "TNamed.h"
20 #include "RooTable.h"
21 #include "RooWorkspace.h"
22 #include "RooFitResult.h"
23 #include "RooPlot.h"
24 #include "TFile.h"
25 #include "TH1.h"
26 #include <list>
27 #include <string>
28 #include <map>
29 
30 /*
31  * The tolerance for the curve test is put to 0.4 instead of 0.2 to take into
32  * account the small variations in the values of the likelihood which can occur
33  * in presence of a different treatment of floating point numbers.
34  */
35 
36 class RooUnitTest : public TNamed {
37 public:
38  RooUnitTest(const char* name, TFile* refFile, Bool_t writeRef, Int_t verbose) ;
39  ~RooUnitTest() ;
40 
41  void setDebug(Bool_t flag) { _debug = flag ; }
42  void setSilentMode() ;
43  void clearSilentMode() ;
44  void regPlot(RooPlot* frame, const char* refName) ;
45  void regResult(RooFitResult* r, const char* refName) ;
46  void regValue(Double_t value, const char* refName) ;
47  void regTable(RooTable* t, const char* refName) ;
48  void regWS(RooWorkspace* ws, const char* refName) ;
49  void regTH(TH1* h, const char* refName) ;
50  RooWorkspace* getWS(const char* refName) ;
51  Bool_t runTest() ;
52  Bool_t runCompTests() ;
53  Bool_t areTHidentical(TH1* htest, TH1* href) ;
54 
55  virtual Bool_t isTestAvailable() { return kTRUE ; }
56  virtual Bool_t testCode() = 0 ;
57 
58  virtual Double_t htol() { return 5e-4 ; } // histogram test tolerance (KS dist != prob)
59 #ifdef R__FAST_MATH
60  virtual Double_t ctol() { return 2e-3 ; } // curve test tolerance
61 #else
62  virtual Double_t ctol() { return 4e-3 ; } // curve test tolerance
63 #endif
64  virtual Double_t fptol() { return 1e-5 ; } // fit parameter test tolerance
65  virtual Double_t fctol() { return 1e-4 ; } // fit correlation test tolerance
66  virtual Double_t vtol() { return 1e-3 ; } // value test tolerance
67 
68  static void setMemDir(TDirectory* memDir);
69 
70 protected:
71 
72  static TDirectory* gMemDir ;
73 
74  TFile* _refFile ;
75  Bool_t _debug ;
76  Bool_t _write ;
77  Int_t _verb ;
78  std::list<std::pair<RooPlot*, std::string> > _regPlots ;
79  std::list<std::pair<RooFitResult*, std::string> > _regResults ;
80  std::list<std::pair<Double_t, std::string> > _regValues ;
81  std::list<std::pair<RooTable*,std::string> > _regTables ;
82  std::list<std::pair<RooWorkspace*,std::string> > _regWS ;
83  std::list<std::pair<TH1*,std::string> > _regTH ;
84 
85  ClassDef(RooUnitTest,0) ; // Abstract base class for RooFit/RooStats unit regression tests
86 } ;
87 #endif