58 _refFile(refFile), _debug(
kFALSE), _write(writeRef), _verb(verbose)
76 string refNameStr(refName) ;
78 _regPlots.push_back(make_pair(frame,refNameStr)) ;
90 string refNameStr(refName) ;
103 string refNameStr(refName) ;
114 string refNameStr(refName) ;
115 _regTables.push_back(make_pair(t,refNameStr)) ;
127 string refNameStr(refName) ;
128 _regWS.push_back(make_pair(
ws,refNameStr)) ;
140 string refNameStr(refName) ;
141 _regTH.push_back(make_pair(th,refNameStr)) ;
154 cout <<
"RooUnitTest ERROR: cannot retrieve RooWorkspace " << refName
155 <<
" from reference file, skipping " << endl ;
178 cout <<
"KS distances = " << kmax << endl ;
195 for (
Int_t i=0 ; i<ntest ; i++) {
215 list<pair<RooPlot*, string> >::iterator iter =
_regPlots.begin() ;
225 cout <<
"RooUnitTest ERROR: cannot retrieve RooPlot " << iter->second <<
" from reference file, skipping " << endl ;
232 cout <<
"comparing RooPlot " << iter->first <<
" to benchmark " << iter->second <<
" = " << bmark << endl ;
233 cout <<
"reference: " ; iter->first->
Print() ;
234 cout <<
"benchmark: " ; bmark->
Print() ;
237 RooPlot* compPlot =
_debug ? iter->first->emptyClone(
Form(
"%s_comparison",iter->first->GetName())) : 0 ;
240 Stat_t nItems = iter->first->numItems() ;
241 for (
Stat_t i=0 ; i<nItems ; i++) {
249 cout <<
"RooUnitTest ERROR: cannot retrieve object " << obj->
GetName() <<
" from reference RooPlot " << iter->second <<
", skipping" << endl ;
255 if (obj->IsA()==RooHist::Class()) {
259 cout <<
"RooUnitTest ERROR: comparison of object " << obj->IsA()->
GetName() <<
"::" << obj->
GetName()
260 <<
" fails comparison with counterpart in reference RooPlot " << bmark->
GetName() << endl ;
277 }
else if (obj->IsA()==RooCurve::Class()) {
281 cout <<
"RooUnitTest ERROR: comparison of object " << obj->IsA()->
GetName() <<
"::" << obj->
GetName()
282 <<
" fails comparison with counterpart in reference RooPlot " << bmark->
GetName() << endl ;
304 if (anyFail && compPlot) {
305 cout <<
"RooUnitTest INFO: writing comparison plot " << compPlot->
GetName() <<
" of failed test to RooUnitTest_DEBUG.root" << endl ;
306 TFile fdbg(
"RooUnitTest_DEBUG.root",
"UPDATE") ;
320 cout <<
"RooUnitTest: Writing reference RooPlot " << iter->first <<
" as benchmark " << iter->second << endl ;
322 iter->first->Write(iter->second.c_str()) ;
330 list<pair<RooFitResult*, string> >::iterator iter2 =
_regResults.begin() ;
340 cout <<
"RooUnitTest ERROR: cannot retrieve RooFitResult " << iter2->second <<
" from reference file, skipping " << endl ;
347 cout <<
"comparing RooFitResult " << iter2->first <<
" to benchmark " << iter2->second <<
" = " << bmark << endl ;
350 if (!iter2->first->isIdentical(*bmark,
fptol(),
fctol())) {
351 cout <<
"RooUnitTest ERROR: comparison of object " << iter2->first->IsA()->
GetName() <<
"::" << iter2->first->GetName()
352 <<
" from result " << iter2->second
353 <<
" fails comparison with counterpart in reference RooFitResult " << bmark->
GetName() << endl ;
358 delete iter2->first ;
365 cout <<
"RooUnitTest: Writing reference RooFitResult " << iter2->first <<
" as benchmark " << iter2->second << endl ;
367 iter2->first->Write(iter2->second.c_str()) ;
374 list<pair<Double_t, string> >::iterator iter3 =
_regValues.begin() ;
384 cout <<
"RooUnitTest ERROR: cannot retrieve RooDouble " << iter3->second <<
" from reference file, skipping " << endl ;
391 cout <<
"comparing value " << iter3->first <<
" to benchmark " << iter3->second <<
" = " << (
Double_t)(*ref) << endl ;
395 cout <<
"RooUnitTest ERROR: comparison of value " << iter3->first <<
" fails comparison with reference " << ref->
GetName() << endl ;
404 cout <<
"RooUnitTest: Writing reference Double_t " << iter3->first <<
" as benchmark " << iter3->second << endl ;
407 rd->
Write(iter3->second.c_str()) ;
415 list<pair<RooTable*, string> >::iterator iter4 =
_regTables.begin() ;
425 cout <<
"RooUnitTest ERROR: cannot retrieve RooTable " << iter4->second <<
" from reference file, skipping " << endl ;
432 cout <<
"comparing RooTable " << iter4->first <<
" to benchmark " << iter4->second <<
" = " << bmark << endl ;
435 if (!iter4->first->isIdentical(*bmark)) {
436 cout <<
"RooUnitTest ERROR: comparison of object " << iter4->first->IsA()->
GetName() <<
"::" << iter4->first->GetName()
437 <<
" fails comparison with counterpart in reference RooTable " << bmark->
GetName() << endl ;
439 iter4->first->Print(
"V");
446 delete iter4->first ;
453 cout <<
"RooUnitTest: Writing reference RooTable " << iter4->first <<
" as benchmark " << iter4->second << endl ;
455 iter4->first->Write(iter4->second.c_str()) ;
463 list<pair<RooWorkspace*, string> >::iterator iter5 =
_regWS.begin() ;
464 while (iter5!=
_regWS.end()) {
470 cout <<
"RooUnitTest: Writing reference RooWorkspace " << iter5->first <<
" as benchmark " << iter5->second << endl ;
472 iter5->first->Write(iter5->second.c_str()) ;
480 list<pair<TH1*, string> >::iterator iter6 =
_regTH.begin() ;
481 while (iter6!=
_regTH.end()) {
490 cout <<
"RooUnitTest ERROR: cannot retrieve TH1 " << iter6->second <<
" from reference file, skipping " << endl ;
497 cout <<
"comparing TH1 " << iter6->first <<
" to benchmark " << iter6->second <<
" = " << bmark << endl ;
502 cout <<
"RooUnitTest ERROR: comparison of object " << iter6->first->IsA()->
GetName() <<
"::" << iter6->first->GetName()
503 <<
" fails comparison with counterpart in reference TH1 " << bmark->
GetName() << endl ;
507 cout <<
"RooUnitTest INFO: writing THx " << iter6->first->GetName() <<
" and " << bmark->
GetName()
508 <<
" of failed test to RooUnitTest_DEBUG.root" << endl ;
509 TFile fdbg(
"RooUnitTest_DEBUG.root",
"UPDATE") ;
510 iter6->first->SetName(
Form(
"%s_test",iter6->first->GetName())) ;
511 iter6->first->Write() ;
521 delete iter6->first ;
528 cout <<
"RooUnitTest: Writing reference TH1 " << iter6->first <<
" as benchmark " << iter6->second << endl ;
530 iter6->first->Write(iter6->second.c_str()) ;
578 cout <<
"*** Begin of output of Unit Test at normal verbosity *************" << endl ;
594 cout <<
"*** End of output of Unit Test at normal verbosity ***************" << endl ;
598 cout <<
"RooUnitTest: ERROR messages were logged, failing test" << endl ;
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
A RooCurve is a one-dimensional graphical representation of a real-valued function.
Bool_t isIdentical(const RooCurve &other, Double_t tol=1e-6) const
Return true if curve is identical to other curve allowing for given absolute tolerance on each point ...
RooDouble is a minimal implementation of a TObject holding a Double_t value.
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
A RooHist is a graphical representation of binned data based on the TGraphAsymmErrors class.
Bool_t isIdentical(const RooHist &other, Double_t tol=1e-6) const
Return kTRUE if contents of this RooHist is identical within given relative tolerance to that of 'oth...
void setStreamStatus(Int_t id, Bool_t active)
(De)Activate stream with given unique ID
static RooMsgService & instance()
Return reference to singleton instance.
StreamConfig & getStream(Int_t id)
void setSilentMode(Bool_t flag)
A RooPlot is a plot frame and a container for graphics objects within that frame.
TAttMarker * getAttMarker(const char *name=0) const
Return a pointer to the marker attributes of the named object in this plot, or zero if the named obje...
void SetName(const char *name)
Set the name of the RooPlot to 'name'.
TAttLine * getAttLine(const char *name=0) const
Return a pointer to the line attributes of the named object in this plot, or zero if the named object...
void addPlotable(RooPlotable *plotable, Option_t *drawOptions="", Bool_t invisible=kFALSE, Bool_t refreshNorm=kFALSE)
Add the specified plotable object to our plot.
TObject * findObject(const char *name, const TClass *clas=0) const
Find the named object in our list of items and return a pointer to it.
virtual void Print(Option_t *options=0) const
Print TNamed name and title.
static TRandom * randomGenerator()
Return a pointer to a singleton random-number generator implementation.
RooTable is the abstract interface for table objects.
static void callgrind_zero()
Utility function to trigger zeroing of callgrind counters.
static void callgrind_dump()
Utility function to trigger dumping of callgrind counters.
RooUnit test is an abstract base class for unit regression tests for RooFit and RooStats tests perfor...
std::list< std::pair< TH1 *, std::string > > _regTH
void regValue(Double_t value, const char *refName)
Bool_t areTHidentical(TH1 *htest, TH1 *href)
void regWS(RooWorkspace *ws, const char *refName)
void regTH(TH1 *h, const char *refName)
RooUnitTest(const char *name, TFile *refFile, Bool_t writeRef, Int_t verbose)
void regResult(RooFitResult *r, const char *refName)
virtual Bool_t testCode()=0
std::list< std::pair< RooWorkspace *, std::string > > _regWS
static void setMemDir(TDirectory *memDir)
Set gMemDir to memDir.
RooWorkspace * getWS(const char *refName)
std::list< std::pair< Double_t, std::string > > _regValues
std::list< std::pair< RooPlot *, std::string > > _regPlots
void regPlot(RooPlot *frame, const char *refName)
void regTable(RooTable *t, const char *refName)
std::list< std::pair< RooFitResult *, std::string > > _regResults
std::list< std::pair< RooTable *, std::string > > _regTables
static TDirectory * gMemDir
The RooWorkspace is a persistable container for RooFit projects.
virtual void SetLineStyle(Style_t lstyle)
Set the line style.
virtual void SetLineWidth(Width_t lwidth)
Set the line width.
virtual void SetLineColor(Color_t lcolor)
Set the line color.
virtual void SetMarkerColor(Color_t mcolor=1)
Set the marker color.
Bool_t cd(const char *path=nullptr) override
Change current directory to "this" directory.
TObject * Get(const char *namecycle) override
Return pointer to object identified by namecycle.
Describe directory structure in memory.
virtual Bool_t cd(const char *path=nullptr)
Change current directory to "this" directory.
A ROOT file is a suite of consecutive data records (TKey instances) with a well defined format.
void Close(Option_t *option="") override
Close a file.
TH1 is the base class of all histogram classes in ROOT.
virtual Int_t GetNbinsY() const
virtual Int_t GetNbinsZ() const
virtual Int_t GetDimension() const
virtual Int_t GetNbinsX() const
virtual void SetName(const char *name)
Change the name of this histogram.
virtual Double_t GetBinContent(Int_t bin) const
Return content of bin number bin.
virtual Double_t KolmogorovTest(const TH1 *h2, Option_t *option="") const
Statistical test of compatibility in shape between this histogram and h2, using Kolmogorov test.
The TNamed class is the base class for all named ROOT classes.
virtual void Print(Option_t *option="") const
Print TNamed name and title.
virtual TObject * Clone(const char *newname="") const
Make a clone of an object using the Streamer facility.
virtual const char * GetName() const
Returns name of object.
Mother of all ROOT objects.
virtual Int_t Write(const char *name=0, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual const char * GetName() const
Returns name of object.
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
RooFit::MsgLevel minLevel