62 _refFile(refFile), _debug(false), _write(writeRef), _verb(verbose)
80 string refNameStr(refName) ;
100 string refNameStr(refName) ;
101 _regResults.push_back(make_pair(
r.release(),refNameStr)) ;
111 string refNameStr(refName) ;
122 string refNameStr(refName) ;
123 _regTables.push_back(make_pair(t,refNameStr)) ;
135 string refNameStr(refName) ;
136 _regWS.push_back(make_pair(ws,refNameStr)) ;
148 string refNameStr(refName) ;
149 _regTH.push_back(make_pair(th,refNameStr)) ;
162 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: cannot retrieve RooWorkspace " << refName
163 <<
" from reference file, skipping " << endl ;
186 if(
_verb >= 0) std::cout <<
"KS distances = " << kmax << std::endl;
203 for (
Int_t i=0 ; i<ntest ; i++) {
223 list<pair<RooPlot*, string> >::iterator iter =
_regPlots.begin() ;
233 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: cannot retrieve RooPlot " << iter->second
234 <<
" from reference file, skipping " << std::endl;
241 cout <<
"comparing RooPlot " << iter->first <<
" to benchmark " << iter->second <<
" = " << bmark << endl ;
242 cout <<
"reference: " ; iter->first->
Print() ;
243 cout <<
"benchmark: " ; bmark->
Print() ;
246 RooPlot* compPlot =
_debug ? iter->first->emptyClone(
Form(
"%s_comparison",iter->first->GetName())) : 0 ;
249 Stat_t nItems = iter->first->numItems() ;
250 for (
Stat_t i=0 ; i<nItems ; i++) {
258 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: cannot retrieve reference object " << obj->
GetName()
259 <<
" from benchmark RooPlot " << iter->second <<
", skipping" << std::endl;
269 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: comparison of object " << obj->
ClassName() <<
"::" << obj->
GetName()
270 <<
" fails comparison with counterpart in reference RooPlot " << bmark->
GetName() << std::endl;
291 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: comparison of object " << obj->
ClassName() <<
"::" << obj->
GetName()
292 <<
" fails comparison with counterpart in reference RooPlot " << bmark->
GetName() << std::endl;
314 if (anyFail && compPlot) {
315 cout <<
"RooUnitTest INFO: writing comparison plot " << compPlot->
GetName() <<
" of failed test to RooUnitTest_DEBUG.root" << endl ;
316 TFile fdbg(
"RooUnitTest_DEBUG.root",
"UPDATE") ;
330 std::cout <<
"RooUnitTest: Writing reference RooPlot " << iter->first <<
" as benchmark " << iter->second << endl ;
332 iter->first->Write(iter->second.c_str()) ;
340 list<pair<RooFitResult*, string> >::iterator iter2 =
_regResults.begin() ;
350 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: cannot retrieve RooFitResult "
351 << iter2->second <<
" from reference file, skipping " << std::endl ;
358 cout <<
"comparing RooFitResult " << iter2->first <<
" to benchmark " << iter2->second <<
" = " << bmark << endl ;
362 if(
_verb >= 0) cout <<
"RooUnitTest ERROR: comparison of object " << iter2->first->
ClassName() <<
"::" << iter2->first->GetName()
363 <<
" from result " << iter2->second
364 <<
" fails comparison with counterpart in reference RooFitResult " << bmark->
GetName() << std::endl;
369 delete iter2->first ;
376 std::cout <<
"RooUnitTest: Writing reference RooFitResult " << iter2->first <<
" as benchmark " << iter2->second << endl ;
378 iter2->first->Write(iter2->second.c_str()) ;
385 list<pair<double, string> >::iterator iter3 =
_regValues.begin() ;
395 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: cannot retrieve RooDouble " << iter3->second <<
" from reference file, skipping " << std::endl;
402 cout <<
"comparing value " << iter3->first <<
" to benchmark " << iter3->second <<
" = " << (
double)(*ref) << endl ;
405 if (std::abs(iter3->first - (
double)(*ref))>
vtol() ) {
406 if(
_verb >= 0) cout <<
"RooUnitTest ERROR: comparison of value " << iter3->first <<
" fails comparison with reference " << ref->
GetName() << endl ;
415 std::cout <<
"RooUnitTest: Writing reference double " << iter3->first <<
" as benchmark " << iter3->second << endl ;
418 rd->
Write(iter3->second.c_str()) ;
426 list<pair<RooTable*, string> >::iterator iter4 =
_regTables.begin() ;
436 if(
_verb >= 0) cout <<
"RooUnitTest ERROR: cannot retrieve RooTable " << iter4->second <<
" from reference file, skipping " << endl ;
443 cout <<
"comparing RooTable " << iter4->first <<
" to benchmark " << iter4->second <<
" = " << bmark << endl ;
446 if (!iter4->first->isIdentical(*bmark,
_verb >= 0)) {
447 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: comparison of object " << iter4->first->
ClassName() <<
"::" << iter4->first->GetName()
448 <<
" fails comparison with counterpart in reference RooTable " << bmark->
GetName() << endl ;
450 iter4->first->Print(
"V");
457 delete iter4->first ;
464 std::cout <<
"RooUnitTest: Writing reference RooTable " << iter4->first <<
" as benchmark " << iter4->second << endl ;
466 iter4->first->Write(iter4->second.c_str()) ;
474 list<pair<RooWorkspace*, string> >::iterator iter5 =
_regWS.begin() ;
475 while (iter5!=
_regWS.end()) {
481 std::cout <<
"RooUnitTest: Writing reference RooWorkspace " << iter5->first <<
" as benchmark " << iter5->second << endl ;
483 iter5->first->Write(iter5->second.c_str()) ;
491 list<pair<TH1*, string> >::iterator iter6 =
_regTH.begin() ;
492 while (iter6!=
_regTH.end()) {
501 if(
_verb >= 0) cout <<
"RooUnitTest ERROR: cannot retrieve TH1 " << iter6->second <<
" from reference file, skipping " << endl ;
508 cout <<
"comparing TH1 " << iter6->first <<
" to benchmark " << iter6->second <<
" = " << bmark << endl ;
513 if(
_verb >= 0) cout <<
"RooUnitTest ERROR: comparison of object " << iter6->first->
ClassName() <<
"::" << iter6->first->GetName()
514 <<
" fails comparison with counterpart in reference TH1 " << bmark->
GetName() << endl ;
518 cout <<
"RooUnitTest INFO: writing THx " << iter6->first->GetName() <<
" and " << bmark->
GetName()
519 <<
" of failed test to RooUnitTest_DEBUG.root" << endl ;
520 TFile fdbg(
"RooUnitTest_DEBUG.root",
"UPDATE") ;
521 iter6->first->SetName(
Form(
"%s_test",iter6->first->GetName())) ;
522 iter6->first->Write() ;
532 delete iter6->first ;
539 std::cout <<
"RooUnitTest: Writing reference TH1 " << iter6->first <<
" as benchmark " << iter6->second << endl ;
541 iter6->first->Write(iter6->second.c_str()) ;
589 std::cout <<
"*** Begin of output of Unit Test at normal verbosity *************" << endl ;
605 std::cout <<
"*** End of output of Unit Test at normal verbosity ***************" << endl ;
609 if(
_verb >= 0) std::cout <<
"RooUnitTest: ERROR messages were logged, failing test" << endl ;
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
R__EXTERN TRandom * gRandom
char * Form(const char *fmt,...)
Formats a string in a circular formatting buffer.
A RooCurve is a one-dimensional graphical representation of a real-valued function.
bool isIdentical(const RooCurve &other, double tol=1e-6, bool verbose=true) 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 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 isIdentical(const RooHist &other, double tol=1e-6, bool verbose=true) const
Return true if contents of this RooHist is identical within given relative tolerance to that of 'othe...
static RooMsgService & instance()
Return reference to singleton instance.
StreamConfig & getStream(Int_t id)
void setStreamStatus(Int_t id, bool active)
(De)Activate stream with given unique ID
void setSilentMode(bool flag)
A RooPlot is a plot frame and a container for graphics objects within that frame.
void SetName(const char *name) override
Set the name of the RooPlot to 'name'.
TObject * findObject(const char *name, const TClass *clas=nullptr) const
Find the named object in our list of items and return a pointer to it.
void Print(Option_t *options=nullptr) const override
This method must be overridden when a class wants to print itself.
TAttLine * getAttLine(const char *name=nullptr) const
Return a pointer to the line attributes of the named object in this plot, or zero if the named object...
TAttMarker * getAttMarker(const char *name=nullptr) const
Return a pointer to the marker attributes of the named object in this plot, or zero if the named obje...
void createInternalPlotVarClone()
Replaces the pointer to the plot variable with a pointer to a clone of the plot variable that is owne...
void addPlotable(RooPlotable *plotable, Option_t *drawOptions="", bool invisible=false, bool refreshNorm=false)
Add the specified plotable object to our plot.
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
virtual double htol()
histogram test tolerance (KS dist != prob)
void regWS(RooWorkspace *ws, const char *refName)
void regTH(TH1 *h, const char *refName)
virtual double fptol()
fit parameter test tolerance
std::list< std::pair< RooWorkspace *, std::string > > _regWS
static void setMemDir(TDirectory *memDir)
Set gMemDir to memDir.
RooWorkspace * getWS(const char *refName)
void regResult(std::unique_ptr< RooFitResult > r, const char *refName)
std::list< std::pair< RooPlot *, std::string > > _regPlots
void regPlot(RooPlot *frame, const char *refName)
void regValue(double value, const char *refName)
void regTable(RooTable *t, const char *refName)
RooUnitTest(const char *name, TFile *refFile, bool writeRef, Int_t verbose)
std::list< std::pair< RooFitResult *, std::string > > _regResults
virtual double ctol()
curve test tolerance
std::list< std::pair< double, std::string > > _regValues
virtual bool testCode()=0
bool areTHidentical(TH1 *htest, TH1 *href)
virtual double fctol()
fit correlation test tolerance
std::list< std::pair< RooTable *, std::string > > _regTables
virtual double vtol()
value test tolerance
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() 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()
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
void SetName(const char *name) override
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.
TObject * Clone(const char *newname="") const override
Make a clone of an object using the Streamer facility.
const char * GetName() const override
Returns name of object.
void Print(Option_t *option="") const override
Print TNamed name and title.
Mother of all ROOT objects.
virtual const char * GetName() const
Returns name of object.
virtual const char * ClassName() const
Returns name of class to which the object belongs.
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
Write this object to the current directory.
virtual TClass * IsA() const
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
RooFit::MsgLevel minLevel