58 _refFile(refFile), _debug(
kFALSE), _write(writeRef), _verb(verbose), _batchMode(batchMode)
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 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: cannot retrieve RooWorkspace " << refName
155 <<
" from reference file, skipping " << endl ;
178 if(
_verb >= 0) std::cout <<
"KS distances = " << kmax << std::endl;
195 for (
Int_t i=0 ; i<ntest ; i++) {
215 list<pair<RooPlot*, string> >::iterator iter =
_regPlots.begin() ;
225 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: cannot retrieve RooPlot " << iter->second
226 <<
" from reference file, skipping " << std::endl;
233 cout <<
"comparing RooPlot " << iter->first <<
" to benchmark " << iter->second <<
" = " << bmark << endl ;
234 cout <<
"reference: " ; iter->first->
Print() ;
235 cout <<
"benchmark: " ; bmark->
Print() ;
238 RooPlot* compPlot =
_debug ? iter->first->emptyClone(
Form(
"%s_comparison",iter->first->GetName())) : 0 ;
241 Stat_t nItems = iter->first->numItems() ;
242 for (
Stat_t i=0 ; i<nItems ; i++) {
250 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: cannot retrieve reference object " << obj->
GetName()
251 <<
" from benchmark RooPlot " << iter->second <<
", skipping" << std::endl;
257 if (obj->IsA()==RooHist::Class()) {
261 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: comparison of object " << obj->IsA()->
GetName() <<
"::" << obj->
GetName()
262 <<
" fails comparison with counterpart in reference RooPlot " << bmark->
GetName() << std::endl;
279 }
else if (obj->IsA()==RooCurve::Class()) {
283 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: comparison of object " << obj->IsA()->
GetName() <<
"::" << obj->
GetName()
284 <<
" fails comparison with counterpart in reference RooPlot " << bmark->
GetName() << std::endl;
306 if (anyFail && compPlot) {
307 cout <<
"RooUnitTest INFO: writing comparison plot " << compPlot->
GetName() <<
" of failed test to RooUnitTest_DEBUG.root" << endl ;
308 TFile fdbg(
"RooUnitTest_DEBUG.root",
"UPDATE") ;
322 std::cout <<
"RooUnitTest: Writing reference RooPlot " << iter->first <<
" as benchmark " << iter->second << endl ;
324 iter->first->Write(iter->second.c_str()) ;
332 list<pair<RooFitResult*, string> >::iterator iter2 =
_regResults.begin() ;
342 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: cannot retrieve RooFitResult "
343 << iter2->second <<
" from reference file, skipping " << std::endl ;
350 cout <<
"comparing RooFitResult " << iter2->first <<
" to benchmark " << iter2->second <<
" = " << bmark << endl ;
354 if(
_verb >= 0) cout <<
"RooUnitTest ERROR: comparison of object " << iter2->first->IsA()->
GetName() <<
"::" << iter2->first->GetName()
355 <<
" from result " << iter2->second
356 <<
" fails comparison with counterpart in reference RooFitResult " << bmark->
GetName() << std::endl;
361 delete iter2->first ;
368 std::cout <<
"RooUnitTest: Writing reference RooFitResult " << iter2->first <<
" as benchmark " << iter2->second << endl ;
370 iter2->first->Write(iter2->second.c_str()) ;
377 list<pair<Double_t, string> >::iterator iter3 =
_regValues.begin() ;
387 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: cannot retrieve RooDouble " << iter3->second <<
" from reference file, skipping " << std::endl;
394 cout <<
"comparing value " << iter3->first <<
" to benchmark " << iter3->second <<
" = " << (
Double_t)(*ref) << endl ;
398 if(
_verb >= 0) cout <<
"RooUnitTest ERROR: comparison of value " << iter3->first <<
" fails comparison with reference " << ref->
GetName() << endl ;
407 std::cout <<
"RooUnitTest: Writing reference Double_t " << iter3->first <<
" as benchmark " << iter3->second << endl ;
410 rd->
Write(iter3->second.c_str()) ;
418 list<pair<RooTable*, string> >::iterator iter4 =
_regTables.begin() ;
428 if(
_verb >= 0) cout <<
"RooUnitTest ERROR: cannot retrieve RooTable " << iter4->second <<
" from reference file, skipping " << endl ;
435 cout <<
"comparing RooTable " << iter4->first <<
" to benchmark " << iter4->second <<
" = " << bmark << endl ;
438 if (!iter4->first->isIdentical(*bmark,
_verb >= 0)) {
439 if(
_verb >= 0) std::cout <<
"RooUnitTest ERROR: comparison of object " << iter4->first->IsA()->
GetName() <<
"::" << iter4->first->GetName()
440 <<
" fails comparison with counterpart in reference RooTable " << bmark->
GetName() << endl ;
442 iter4->first->Print(
"V");
449 delete iter4->first ;
456 std::cout <<
"RooUnitTest: Writing reference RooTable " << iter4->first <<
" as benchmark " << iter4->second << endl ;
458 iter4->first->Write(iter4->second.c_str()) ;
466 list<pair<RooWorkspace*, string> >::iterator iter5 =
_regWS.begin() ;
467 while (iter5!=
_regWS.end()) {
473 std::cout <<
"RooUnitTest: Writing reference RooWorkspace " << iter5->first <<
" as benchmark " << iter5->second << endl ;
475 iter5->first->Write(iter5->second.c_str()) ;
483 list<pair<TH1*, string> >::iterator iter6 =
_regTH.begin() ;
484 while (iter6!=
_regTH.end()) {
493 if(
_verb >= 0) cout <<
"RooUnitTest ERROR: cannot retrieve TH1 " << iter6->second <<
" from reference file, skipping " << endl ;
500 cout <<
"comparing TH1 " << iter6->first <<
" to benchmark " << iter6->second <<
" = " << bmark << endl ;
505 if(
_verb >= 0) cout <<
"RooUnitTest ERROR: comparison of object " << iter6->first->IsA()->
GetName() <<
"::" << iter6->first->GetName()
506 <<
" fails comparison with counterpart in reference TH1 " << bmark->
GetName() << endl ;
510 cout <<
"RooUnitTest INFO: writing THx " << iter6->first->GetName() <<
" and " << bmark->
GetName()
511 <<
" of failed test to RooUnitTest_DEBUG.root" << endl ;
512 TFile fdbg(
"RooUnitTest_DEBUG.root",
"UPDATE") ;
513 iter6->first->SetName(
Form(
"%s_test",iter6->first->GetName())) ;
514 iter6->first->Write() ;
524 delete iter6->first ;
531 std::cout <<
"RooUnitTest: Writing reference TH1 " << iter6->first <<
" as benchmark " << iter6->second << endl ;
533 iter6->first->Write(iter6->second.c_str()) ;
581 std::cout <<
"*** Begin of output of Unit Test at normal verbosity *************" << endl ;
597 std::cout <<
"*** End of output of Unit Test at normal verbosity ***************" << endl ;
601 if(
_verb >= 0) std::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, 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_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, bool verbose=true) 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, std::string const &batchMode="off")
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() 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
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