00001
00002
00003
00004 #include "TWebFile.h"
00005 #include "TSystem.h"
00006 #include "TString.h"
00007 #include "TStopwatch.h"
00008 #include "TROOT.h"
00009 #include "TLine.h"
00010 #include "TFile.h"
00011 #include "TClass.h"
00012 #include "TCanvas.h"
00013 #include "TH1.h"
00014 #include "TBenchmark.h"
00015 #include "RooGlobalFunc.h"
00016 #include "RooMsgService.h"
00017 #include "RooPlot.h"
00018 #include "RooFitResult.h"
00019 #include "RooDouble.h"
00020 #include "RooWorkspace.h"
00021 #include "Roo1DTable.h"
00022 #include "RooCurve.h"
00023 #include "RooHist.h"
00024 #include "RooRandom.h"
00025 #include "RooTrace.h"
00026 #include "RooMath.h"
00027 #include <string>
00028 #include <list>
00029 #include <iostream>
00030 #include <math.h>
00031
00032 using namespace std ;
00033 using namespace RooFit ;
00034
00035
00036
00037
00038
00039
00040
00041
00042 Int_t stressRooFit(const char* refFile, Bool_t writeRef, Int_t doVerbose, Int_t oneTest, Bool_t dryRun) ;
00043
00044 static TDirectory* gMemDir = 0 ;
00045
00046
00047 void StatusPrint(Int_t id,const TString &title,Int_t status)
00048 {
00049
00050 const Int_t kMAX = 65;
00051 Char_t number[4];
00052 sprintf(number,"%2d",id);
00053 TString header = TString("Test ")+number+" : "+title;
00054 const Int_t nch = header.Length();
00055 for (Int_t i = nch; i < kMAX; i++) header += '.';
00056 cout << header << (status>0 ? "OK" : (status<0 ? "SKIPPED" : "FAILED")) << endl;
00057 }
00058
00059
00060
00061 class RooFitTestUnit : public TNamed {
00062 public:
00063 RooFitTestUnit(const char* name, TFile* refFile, Bool_t writeRef, Int_t verbose) ;
00064 ~RooFitTestUnit() ;
00065
00066 void setDebug(Bool_t flag) { _debug = flag ; }
00067 void setSilentMode() ;
00068 void clearSilentMode() ;
00069 void regPlot(RooPlot* frame, const char* refName) ;
00070 void regResult(RooFitResult* r, const char* refName) ;
00071 void regValue(Double_t value, const char* refName) ;
00072 void regTable(RooTable* t, const char* refName) ;
00073 void regWS(RooWorkspace* ws, const char* refName) ;
00074 void regTH(TH1* h, const char* refName) ;
00075 RooWorkspace* getWS(const char* refName) ;
00076 Bool_t runTest() ;
00077 Bool_t runCompTests() ;
00078 Bool_t areTHidentical(TH1* htest, TH1* href) ;
00079
00080 virtual Bool_t isTestAvailable() { return kTRUE ; }
00081 virtual Bool_t testCode() = 0 ;
00082
00083 virtual Double_t htol() { return 5e-4 ; }
00084 virtual Double_t ctol() { return 2e-3 ; }
00085 virtual Double_t fptol() { return 1e-3 ; }
00086 virtual Double_t fctol() { return 1e-3 ; }
00087 virtual Double_t vtol() { return 1e-3 ; }
00088
00089 protected:
00090 TFile* _refFile ;
00091 Bool_t _debug ;
00092 Bool_t _write ;
00093 Int_t _verb ;
00094 list<pair<RooPlot*, string> > _regPlots ;
00095 list<pair<RooFitResult*, string> > _regResults ;
00096 list<pair<Double_t, string> > _regValues ;
00097 list<pair<RooTable*,string> > _regTables ;
00098 list<pair<RooWorkspace*,string> > _regWS ;
00099 list<pair<TH1*,string> > _regTH ;
00100 } ;
00101
00102
00103 RooFitTestUnit::RooFitTestUnit(const char* name, TFile* refFile, Bool_t writeRef, Int_t verbose) : TNamed(name,name),
00104 _refFile(refFile), _debug(kFALSE), _write(writeRef), _verb(verbose)
00105 {
00106 }
00107
00108
00109 RooFitTestUnit::~RooFitTestUnit()
00110 {
00111 }
00112
00113 void RooFitTestUnit::regPlot(RooPlot* frame, const char* refName)
00114 {
00115 if (_refFile) {
00116 string refNameStr(refName) ;
00117 frame->SetName(refName) ;
00118 _regPlots.push_back(make_pair(frame,refNameStr)) ;
00119 } else {
00120 delete frame ;
00121 }
00122 }
00123
00124 void RooFitTestUnit::regResult(RooFitResult* r, const char* refName)
00125 {
00126 if (_refFile) {
00127 string refNameStr(refName) ;
00128 _regResults.push_back(make_pair(r,refNameStr)) ;
00129 } else {
00130 delete r ;
00131 }
00132 }
00133
00134 void RooFitTestUnit::regValue(Double_t d, const char* refName)
00135 {
00136 if (_refFile) {
00137 string refNameStr(refName) ;
00138 _regValues.push_back(make_pair(d,refNameStr)) ;
00139 }
00140 }
00141
00142 void RooFitTestUnit::regTable(RooTable* t, const char* refName)
00143 {
00144 if (_refFile) {
00145 string refNameStr(refName) ;
00146 _regTables.push_back(make_pair(t,refNameStr)) ;
00147 } else {
00148 delete t ;
00149 }
00150 }
00151
00152
00153 void RooFitTestUnit::regWS(RooWorkspace* ws, const char* refName)
00154 {
00155 if (_refFile) {
00156 string refNameStr(refName) ;
00157 _regWS.push_back(make_pair(ws,refNameStr)) ;
00158 } else {
00159 delete ws ;
00160 }
00161 }
00162
00163
00164 void RooFitTestUnit::regTH(TH1* th, const char* refName)
00165 {
00166 if (_refFile) {
00167 string refNameStr(refName) ;
00168 _regTH.push_back(make_pair(th,refNameStr)) ;
00169 } else {
00170 delete th ;
00171 }
00172 }
00173
00174
00175 RooWorkspace* RooFitTestUnit::getWS(const char* refName)
00176 {
00177 RooWorkspace* ws = dynamic_cast<RooWorkspace*>(_refFile->Get(refName)) ;
00178 if (!ws) {
00179 cout << "stressRooFit ERROR: cannot retrieve RooWorkspace " << refName
00180 << " from reference file, skipping " << endl ;
00181 return 0 ;
00182 }
00183
00184 return ws ;
00185 }
00186
00187
00188 Bool_t RooFitTestUnit::areTHidentical(TH1* htest, TH1* href)
00189 {
00190 if (htest->GetDimension() != href->GetDimension()) {
00191 return kFALSE ;
00192 }
00193
00194
00195
00196
00197 Double_t kmax = htest->KolmogorovTest(href,"M") ;
00198
00199 if (kmax>htol()) {
00200
00201 cout << "KS distances = " << kmax << endl ;
00202
00203 Int_t ntest = htest->GetNbinsX() +2 ;
00204 Int_t nref = href->GetNbinsX() +2 ;
00205 if (htest->GetDimension()>1) {
00206 ntest *= htest->GetNbinsY() + 2 ;
00207 nref *= href->GetNbinsY() + 2 ;
00208 }
00209 if (htest->GetDimension()>2) {
00210 ntest *= htest->GetNbinsZ() + 2 ;
00211 nref *= href->GetNbinsZ() + 2 ;
00212 }
00213
00214 if (ntest != nref) {
00215 return kFALSE ;
00216 }
00217
00218 for (Int_t i=0 ; i<ntest ; i++) {
00219 if (fabs(htest->GetBinContent(i)-href->GetBinContent(i))>htol()) {
00220 cout << "htest[" << i << "] = " << htest->GetBinContent(i) << " href[" << i << "] = " << href->GetBinContent(i) << endl;
00221 }
00222 }
00223
00224 return kFALSE ;
00225 }
00226
00227 return kTRUE ;
00228 }
00229
00230
00231 Bool_t RooFitTestUnit::runCompTests()
00232 {
00233 Bool_t ret = kTRUE ;
00234
00235 list<pair<RooPlot*, string> >::iterator iter = _regPlots.begin() ;
00236 while (iter!=_regPlots.end()) {
00237
00238 if (!_write) {
00239
00240
00241
00242
00243 RooPlot* bmark = dynamic_cast<RooPlot*>(_refFile->Get(iter->second.c_str())) ;
00244 if (!bmark) {
00245 cout << "stressRooFit ERROR: cannot retrieve RooPlot " << iter->second << " from reference file, skipping " << endl ;
00246 ret = kFALSE ;
00247 ++iter ;
00248 continue ;
00249 }
00250
00251 if (_verb) {
00252 cout << "comparing RooPlot " << iter->first << " to benchmark " << iter->second << " = " << bmark << endl ;
00253 cout << "reference: " ; iter->first->Print() ;
00254 cout << "benchmark: " ; bmark->Print() ;
00255 }
00256
00257 RooPlot* compPlot = _debug ? iter->first->emptyClone(Form("%s_comparison",iter->first->GetName())) : 0 ;
00258 Bool_t anyFail=kFALSE ;
00259
00260 Stat_t nItems = iter->first->numItems() ;
00261 for (Stat_t i=0 ; i<nItems ; i++) {
00262 TObject* obj = iter->first->getObject((Int_t)i) ;
00263
00264
00265 TObject* objRef = bmark->findObject(obj->GetName()) ;
00266
00267 if (!objRef) {
00268 cout << "stressRooFit ERROR: cannot retrieve object " << obj->GetName() << " from reference RooPlot " << iter->second << ", skipping" << endl ;
00269 ret = kFALSE ;
00270 break ;
00271 }
00272
00273
00274 if (obj->IsA()==RooHist::Class()) {
00275 RooHist* testHist = static_cast<RooHist*>(obj) ;
00276 RooHist* refHist = static_cast<RooHist*>(objRef) ;
00277 if (!testHist->isIdentical(*refHist,htol())) {
00278 cout << "stressRooFit ERROR: comparison of object " << obj->IsA()->GetName() << "::" << obj->GetName()
00279 << " fails comparison with counterpart in reference RooPlot " << bmark->GetName() << endl ;
00280
00281 if (compPlot) {
00282 compPlot->addPlotable((RooHist*)testHist->Clone(),"P") ;
00283 compPlot->getAttLine()->SetLineColor(kRed) ;
00284 compPlot->getAttMarker()->SetMarkerColor(kRed) ;
00285 compPlot->getAttLine()->SetLineWidth(1) ;
00286
00287 compPlot->addPlotable((RooHist*)refHist->Clone(),"P") ;
00288 compPlot->getAttLine()->SetLineColor(kBlue) ;
00289 compPlot->getAttMarker()->SetMarkerColor(kBlue) ;
00290 compPlot->getAttLine()->SetLineWidth(1) ;
00291 }
00292
00293 anyFail=kTRUE ;
00294 ret = kFALSE ;
00295 }
00296 } else if (obj->IsA()==RooCurve::Class()) {
00297 RooCurve* testCurve = static_cast<RooCurve*>(obj) ;
00298 RooCurve* refCurve = static_cast<RooCurve*>(objRef) ;
00299 if (!testCurve->isIdentical(*refCurve,ctol())) {
00300 cout << "stressRooFit ERROR: comparison of object " << obj->IsA()->GetName() << "::" << obj->GetName()
00301 << " fails comparison with counterpart in reference RooPlot " << bmark->GetName() << endl ;
00302
00303 if (compPlot) {
00304 compPlot->addPlotable((RooCurve*)testCurve->Clone()) ;
00305 compPlot->getAttLine()->SetLineColor(kRed) ;
00306 compPlot->getAttLine()->SetLineWidth(1) ;
00307 compPlot->getAttLine()->SetLineStyle(kSolid) ;
00308
00309 compPlot->addPlotable((RooCurve*)refCurve->Clone()) ;
00310 compPlot->getAttLine()->SetLineColor(kBlue) ;
00311 compPlot->getAttLine()->SetLineWidth(1) ;
00312 compPlot->getAttLine()->SetLineStyle(kDashed) ;
00313 }
00314
00315 anyFail=kTRUE ;
00316 ret = kFALSE ;
00317 }
00318
00319 }
00320
00321 }
00322
00323 if (anyFail && compPlot) {
00324 cout << "stressRooFit INFO: writing comparison plot " << compPlot->GetName() << " of failed test to stressRooFit_DEBUG.root" << endl ;
00325 TFile fdbg("stressRooFit_DEBUG.root","UPDATE") ;
00326 compPlot->Write() ;
00327 fdbg.Close() ;
00328 } else {
00329 delete compPlot ;
00330 }
00331
00332
00333 delete iter->first ;
00334
00335 } else {
00336
00337
00338
00339 cout <<"stressRooFit: Writing reference RooPlot " << iter->first << " as benchmark " << iter->second << endl ;
00340 _refFile->cd() ;
00341 iter->first->Write(iter->second.c_str()) ;
00342 gMemDir->cd() ;
00343 }
00344
00345 ++iter ;
00346 }
00347
00348
00349 list<pair<RooFitResult*, string> >::iterator iter2 = _regResults.begin() ;
00350 while (iter2!=_regResults.end()) {
00351
00352 if (!_write) {
00353
00354
00355
00356
00357 RooFitResult* bmark = dynamic_cast<RooFitResult*>(_refFile->Get(iter2->second.c_str())) ;
00358 if (!bmark) {
00359 cout << "stressRooFit ERROR: cannot retrieve RooFitResult " << iter2->second << " from reference file, skipping " << endl ;
00360 ++iter2 ;
00361 ret = kFALSE ;
00362 continue ;
00363 }
00364
00365 if (_verb) {
00366 cout << "comparing RooFitResult " << iter2->first << " to benchmark " << iter2->second << " = " << bmark << endl ;
00367 }
00368
00369 if (!iter2->first->isIdentical(*bmark,fptol(),fctol())) {
00370 cout << "stressRooFit ERROR: comparison of object " << iter2->first->IsA()->GetName() << "::" << iter2->first->GetName()
00371 << " fails comparison with counterpart in reference RooFitResult " << bmark->GetName() << endl ;
00372 ret = kFALSE ;
00373 }
00374
00375
00376 delete iter2->first ;
00377
00378
00379 } else {
00380
00381
00382
00383 cout <<"stressRooFit: Writing reference RooFitResult " << iter2->first << " as benchmark " << iter2->second << endl ;
00384 _refFile->cd() ;
00385 iter2->first->Write(iter2->second.c_str()) ;
00386 gMemDir->cd() ;
00387 }
00388
00389 ++iter2 ;
00390 }
00391
00392 list<pair<Double_t, string> >::iterator iter3 = _regValues.begin() ;
00393 while (iter3!=_regValues.end()) {
00394
00395 if (!_write) {
00396
00397
00398
00399
00400 RooDouble* ref = dynamic_cast<RooDouble*>(_refFile->Get(iter3->second.c_str())) ;
00401 if (!ref) {
00402 cout << "stressRooFit ERROR: cannot retrieve RooDouble " << iter3->second << " from reference file, skipping " << endl ;
00403 ++iter3 ;
00404 ret = kFALSE ;
00405 continue ;
00406 }
00407
00408 if (_verb) {
00409 cout << "comparing value " << iter3->first << " to benchmark " << iter3->second << " = " << (Double_t)(*ref) << endl ;
00410 }
00411
00412 if (fabs(iter3->first - (Double_t)(*ref))>vtol() ) {
00413 cout << "stressRooFit ERROR: comparison of value " << iter3->first << " fails comparison with reference " << ref->GetName() << endl ;
00414 ret = kFALSE ;
00415 }
00416
00417
00418 } else {
00419
00420
00421
00422 cout <<"stressRooFit: Writing reference Double_t " << iter3->first << " as benchmark " << iter3->second << endl ;
00423 _refFile->cd() ;
00424 RooDouble* rd = new RooDouble(iter3->first) ;
00425 rd->Write(iter3->second.c_str()) ;
00426 gMemDir->cd() ;
00427 }
00428
00429 ++iter3 ;
00430 }
00431
00432
00433 list<pair<RooTable*, string> >::iterator iter4 = _regTables.begin() ;
00434 while (iter4!=_regTables.end()) {
00435
00436 if (!_write) {
00437
00438
00439
00440
00441 RooTable* bmark = dynamic_cast<RooTable*>(_refFile->Get(iter4->second.c_str())) ;
00442 if (!bmark) {
00443 cout << "stressRooFit ERROR: cannot retrieve RooTable " << iter4->second << " from reference file, skipping " << endl ;
00444 ++iter4 ;
00445 ret = kFALSE ;
00446 continue ;
00447 }
00448
00449 if (_verb) {
00450 cout << "comparing RooTable " << iter4->first << " to benchmark " << iter4->second << " = " << bmark << endl ;
00451 }
00452
00453 if (!iter4->first->isIdentical(*bmark)) {
00454 cout << "stressRooFit ERROR: comparison of object " << iter4->first->IsA()->GetName() << "::" << iter4->first->GetName()
00455 << " fails comparison with counterpart in reference RooTable " << bmark->GetName() << endl ;
00456 ret = kFALSE ;
00457 }
00458
00459
00460 delete iter4->first ;
00461
00462
00463 } else {
00464
00465
00466
00467 cout <<"stressRooFit: Writing reference RooTable " << iter4->first << " as benchmark " << iter4->second << endl ;
00468 _refFile->cd() ;
00469 iter4->first->Write(iter4->second.c_str()) ;
00470 gMemDir->cd() ;
00471 }
00472
00473 ++iter4 ;
00474 }
00475
00476
00477 list<pair<RooWorkspace*, string> >::iterator iter5 = _regWS.begin() ;
00478 while (iter5!=_regWS.end()) {
00479
00480 if (_write) {
00481
00482
00483
00484 cout <<"stressRooFit: Writing reference RooWorkspace " << iter5->first << " as benchmark " << iter5->second << endl ;
00485 _refFile->cd() ;
00486 iter5->first->Write(iter5->second.c_str()) ;
00487 gMemDir->cd() ;
00488 }
00489
00490 ++iter5 ;
00491 }
00492
00493
00494 list<pair<TH1*, string> >::iterator iter6 = _regTH.begin() ;
00495 while (iter6!=_regTH.end()) {
00496
00497 if (!_write) {
00498
00499
00500
00501
00502 TH1* bmark = dynamic_cast<TH1*>(_refFile->Get(iter6->second.c_str())) ;
00503 if (!bmark) {
00504 cout << "stressRooFit ERROR: cannot retrieve TH1 " << iter6->second << " from reference file, skipping " << endl ;
00505 ++iter6 ;
00506 ret = kFALSE ;
00507 continue ;
00508 }
00509
00510 if (_verb) {
00511 cout << "comparing TH1 " << iter6->first << " to benchmark " << iter6->second << " = " << bmark << endl ;
00512 }
00513
00514 if (!areTHidentical(iter6->first,bmark)) {
00515 cout << "stressRooFit ERROR: comparison of object " << iter6->first->IsA()->GetName() << "::" << iter6->first->GetName()
00516 << " fails comparison with counterpart in reference TH1 " << bmark->GetName() << endl ;
00517
00518
00519 if (_debug) {
00520 cout << "stressRooFit INFO: writing THx " << iter6->first->GetName() << " and " << bmark->GetName()
00521 << " of failed test to stressRooFit_DEBUG.root" << endl ;
00522 TFile fdbg("stressRooFit_DEBUG.root","UPDATE") ;
00523 iter6->first->SetName(Form("%s_test",iter6->first->GetName())) ;
00524 iter6->first->Write() ;
00525 bmark->SetName(Form("%s_ref",bmark->GetName())) ;
00526 bmark->Write() ;
00527 fdbg.Close() ;
00528 }
00529
00530 ret = kFALSE ;
00531 }
00532
00533
00534 delete iter6->first ;
00535
00536
00537 } else {
00538
00539
00540
00541 cout <<"stressRooFit: Writing reference TH1 " << iter6->first << " as benchmark " << iter6->second << endl ;
00542 _refFile->cd() ;
00543 iter6->first->Write(iter6->second.c_str()) ;
00544 gMemDir->cd() ;
00545 }
00546
00547 ++iter6 ;
00548 }
00549
00550
00551
00552
00553 return ret ;
00554 }
00555
00556 void RooFitTestUnit::setSilentMode()
00557 {
00558 RooMsgService::instance().setSilentMode(kTRUE) ;
00559 for (Int_t i=0 ; i<RooMsgService::instance().numStreams() ; i++) {
00560 if (RooMsgService::instance().getStream(i).minLevel<RooFit::ERROR) {
00561 RooMsgService::instance().setStreamStatus(i,kFALSE) ;
00562 }
00563 }
00564 }
00565
00566 void RooFitTestUnit::clearSilentMode()
00567 {
00568 RooMsgService::instance().setSilentMode(kFALSE) ;
00569 for (Int_t i=0 ; i<RooMsgService::instance().numStreams() ; i++) {
00570 RooMsgService::instance().setStreamStatus(i,kTRUE) ;
00571 }
00572 }
00573
00574
00575 Bool_t RooFitTestUnit::runTest()
00576 {
00577 gMemDir->cd() ;
00578
00579 if (_verb<2) {
00580 setSilentMode() ;
00581 } else {
00582 cout << "*** Begin of output of Unit Test at normal verbosity *************" << endl ;
00583 }
00584
00585 RooMsgService::instance().clearErrorCount() ;
00586
00587
00588 gRandom->SetSeed(12345) ;
00589 RooRandom::randomGenerator()->SetSeed(12345) ;
00590
00591 if (!testCode()) return kFALSE ;
00592
00593 if (_verb<2) {
00594 clearSilentMode() ;
00595 } else {
00596 cout << "*** End of output of Unit Test at normal verbosity ***************" << endl ;
00597 }
00598
00599 if (RooMsgService::instance().errorCount()>0) {
00600 cout << "RooFitUnitTest: ERROR messages were logged, failing test" << endl ;
00601 return kFALSE ;
00602 }
00603
00604 return runCompTests() ;
00605 }
00606
00607
00608
00609 #include "stressRooFit_tests.cxx"
00610
00611
00612 Int_t stressRooFit(const char* refFile, Bool_t writeRef, Int_t doVerbose, Int_t oneTest, Bool_t dryRun, Bool_t doDump)
00613 {
00614
00615 gMemDir = gDirectory ;
00616
00617 TFile* fref = 0 ;
00618 if (!dryRun) {
00619 if (TString(refFile).Contains("http:")) {
00620 if (writeRef) {
00621 cout << "stressRooFit ERROR: reference file must be local file in writing mode" << endl ;
00622 return kFALSE ;
00623 }
00624 fref = new TWebFile(refFile) ;
00625 } else {
00626 fref = new TFile(refFile,writeRef?"RECREATE":"") ;
00627 }
00628 if (fref->IsZombie()) {
00629 cout << "stressRooFit ERROR: cannot open reference file " << refFile << endl ;
00630 return kFALSE ;
00631 }
00632 }
00633
00634 if (dryRun) {
00635
00636 RooNumIntConfig::defaultConfig() ;
00637 RooResolutionModel::identity() ;
00638
00639 RooTrace::active(1) ;
00640 }
00641
00642
00643 RooMsgService::instance().addStream(RooFit::ERROR) ;
00644
00645 cout << "******************************************************************" <<endl;
00646 cout << "* RooFit - S T R E S S suite *" <<endl;
00647 cout << "******************************************************************" <<endl;
00648 cout << "******************************************************************" <<endl;
00649
00650 TStopwatch timer;
00651 timer.Start();
00652
00653 list<RooFitTestUnit*> testList ;
00654 testList.push_back(new TestBasic101(fref,writeRef,doVerbose)) ;
00655 testList.push_back(new TestBasic102(fref,writeRef,doVerbose)) ;
00656 testList.push_back(new TestBasic103(fref,writeRef,doVerbose)) ;
00657 testList.push_back(new TestBasic105(fref,writeRef,doVerbose)) ;
00658 testList.push_back(new TestBasic108(fref,writeRef,doVerbose)) ;
00659 testList.push_back(new TestBasic109(fref,writeRef,doVerbose)) ;
00660 testList.push_back(new TestBasic110(fref,writeRef,doVerbose)) ;
00661 testList.push_back(new TestBasic111(fref,writeRef,doVerbose)) ;
00662 testList.push_back(new TestBasic201(fref,writeRef,doVerbose)) ;
00663 testList.push_back(new TestBasic202(fref,writeRef,doVerbose)) ;
00664 testList.push_back(new TestBasic203(fref,writeRef,doVerbose)) ;
00665 testList.push_back(new TestBasic204(fref,writeRef,doVerbose)) ;
00666 testList.push_back(new TestBasic205(fref,writeRef,doVerbose)) ;
00667 testList.push_back(new TestBasic208(fref,writeRef,doVerbose)) ;
00668 testList.push_back(new TestBasic209(fref,writeRef,doVerbose)) ;
00669 testList.push_back(new TestBasic301(fref,writeRef,doVerbose)) ;
00670 testList.push_back(new TestBasic302(fref,writeRef,doVerbose)) ;
00671 testList.push_back(new TestBasic303(fref,writeRef,doVerbose)) ;
00672 testList.push_back(new TestBasic304(fref,writeRef,doVerbose)) ;
00673 testList.push_back(new TestBasic305(fref,writeRef,doVerbose)) ;
00674 testList.push_back(new TestBasic306(fref,writeRef,doVerbose)) ;
00675 testList.push_back(new TestBasic307(fref,writeRef,doVerbose)) ;
00676 testList.push_back(new TestBasic308(fref,writeRef,doVerbose)) ;
00677 testList.push_back(new TestBasic310(fref,writeRef,doVerbose)) ;
00678 testList.push_back(new TestBasic311(fref,writeRef,doVerbose)) ;
00679 testList.push_back(new TestBasic312(fref,writeRef,doVerbose)) ;
00680 testList.push_back(new TestBasic313(fref,writeRef,doVerbose)) ;
00681 testList.push_back(new TestBasic315(fref,writeRef,doVerbose)) ;
00682 testList.push_back(new TestBasic314(fref,writeRef,doVerbose)) ;
00683 testList.push_back(new TestBasic316(fref,writeRef,doVerbose)) ;
00684 testList.push_back(new TestBasic402(fref,writeRef,doVerbose)) ;
00685 testList.push_back(new TestBasic403(fref,writeRef,doVerbose)) ;
00686 testList.push_back(new TestBasic404(fref,writeRef,doVerbose)) ;
00687 testList.push_back(new TestBasic405(fref,writeRef,doVerbose)) ;
00688 testList.push_back(new TestBasic406(fref,writeRef,doVerbose)) ;
00689 testList.push_back(new TestBasic501(fref,writeRef,doVerbose)) ;
00690 testList.push_back(new TestBasic599(fref,writeRef,doVerbose)) ;
00691 testList.push_back(new TestBasic601(fref,writeRef,doVerbose)) ;
00692 testList.push_back(new TestBasic602(fref,writeRef,doVerbose)) ;
00693 testList.push_back(new TestBasic604(fref,writeRef,doVerbose)) ;
00694 testList.push_back(new TestBasic605(fref,writeRef,doVerbose)) ;
00695 testList.push_back(new TestBasic606(fref,writeRef,doVerbose)) ;
00696 testList.push_back(new TestBasic607(fref,writeRef,doVerbose)) ;
00697 testList.push_back(new TestBasic609(fref,writeRef,doVerbose)) ;
00698 testList.push_back(new TestBasic701(fref,writeRef,doVerbose)) ;
00699 testList.push_back(new TestBasic702(fref,writeRef,doVerbose)) ;
00700 testList.push_back(new TestBasic703(fref,writeRef,doVerbose)) ;
00701 testList.push_back(new TestBasic704(fref,writeRef,doVerbose)) ;
00702 testList.push_back(new TestBasic705(fref,writeRef,doVerbose)) ;
00703 testList.push_back(new TestBasic706(fref,writeRef,doVerbose)) ;
00704 testList.push_back(new TestBasic707(fref,writeRef,doVerbose)) ;
00705 testList.push_back(new TestBasic708(fref,writeRef,doVerbose)) ;
00706 testList.push_back(new TestBasic801(fref,writeRef,doVerbose)) ;
00707 testList.push_back(new TestBasic802(fref,writeRef,doVerbose)) ;
00708 testList.push_back(new TestBasic803(fref,writeRef,doVerbose)) ;
00709 testList.push_back(new TestBasic804(fref,writeRef,doVerbose)) ;
00710
00711 cout << "* Starting S T R E S S basic suite *" <<endl;
00712 cout << "******************************************************************" <<endl;
00713
00714 if (doDump) {
00715 TFile fdbg("stressRooFit_DEBUG.root","RECREATE") ;
00716 }
00717
00718 gBenchmark->Start("StressRooFit");
00719
00720 Int_t i(1) ;
00721 for (list<RooFitTestUnit*>::iterator iter = testList.begin () ; iter != testList.end() ; ++iter) {
00722 if (oneTest<0 || oneTest==i) {
00723 if (doDump) {
00724 (*iter)->setDebug(kTRUE) ;
00725 }
00726 StatusPrint( i,(*iter)->GetName(),(*iter)->isTestAvailable()?(*iter)->runTest():-1);
00727 }
00728 delete (*iter) ;
00729 i++ ;
00730 }
00731
00732 if (dryRun) {
00733 RooTrace::dump() ;
00734 }
00735
00736 gBenchmark->Stop("StressRooFit");
00737
00738
00739
00740 Bool_t UNIX = strcmp(gSystem->GetName(), "Unix") == 0;
00741 printf("******************************************************************\n");
00742 if (UNIX) {
00743 TString sp = gSystem->GetFromPipe("uname -a");
00744 sp.Resize(60);
00745 printf("* SYS: %s\n",sp.Data());
00746 if (strstr(gSystem->GetBuildNode(),"Linux")) {
00747 sp = gSystem->GetFromPipe("lsb_release -d -s");
00748 printf("* SYS: %s\n",sp.Data());
00749 }
00750 if (strstr(gSystem->GetBuildNode(),"Darwin")) {
00751 sp = gSystem->GetFromPipe("sw_vers -productVersion");
00752 sp += " Mac OS X ";
00753 printf("* SYS: %s\n",sp.Data());
00754 }
00755 } else {
00756 const Char_t *os = gSystem->Getenv("OS");
00757 if (!os) printf("* SYS: Windows 95\n");
00758 else printf("* SYS: %s %s \n",os,gSystem->Getenv("PROCESSOR_IDENTIFIER"));
00759 }
00760
00761 printf("******************************************************************\n");
00762 gBenchmark->Print("StressFit");
00763 #ifdef __CINT__
00764 Double_t reftime = 186.34;
00765 #else
00766 Double_t reftime = 93.59;
00767 #endif
00768 const Double_t rootmarks = 860*reftime/gBenchmark->GetCpuTime("StressRooFit");
00769
00770 printf("******************************************************************\n");
00771 printf("* ROOTMARKS =%6.1f * Root%-8s %d/%d\n",rootmarks,gROOT->GetVersion(),
00772 gROOT->GetVersionDate(),gROOT->GetVersionTime());
00773 printf("******************************************************************\n");
00774
00775 printf("Time at the end of job = %f seconds\n",timer.CpuTime());
00776
00777 if (fref) {
00778 fref->Close() ;
00779 delete fref ;
00780 }
00781
00782 delete gBenchmark ;
00783 gBenchmark = 0 ;
00784
00785 return 0;
00786 }
00787
00788
00789 #ifndef __CINT__
00790
00791 int main(int argc,const char *argv[])
00792 {
00793 Bool_t doWrite = kFALSE ;
00794 Int_t doVerbose = 0 ;
00795 Int_t oneTest = -1 ;
00796 Int_t dryRun = kFALSE ;
00797 Bool_t doDump = kFALSE ;
00798
00799 string refFileName = "http://root.cern.ch/files/stressRooFit_v528_ref.root" ;
00800
00801
00802 for (Int_t i=1 ; i<argc ; i++) {
00803 string arg = argv[i] ;
00804
00805 if (arg=="-f") {
00806 cout << "stressRooFit: using reference file " << argv[i+1] << endl ;
00807 refFileName = argv[++i] ;
00808 }
00809
00810 if (arg=="-w") {
00811 cout << "stressRooFit: running in writing mode to updating reference file" << endl ;
00812 doWrite = kTRUE ;
00813 }
00814
00815 if (arg=="-mc") {
00816 cout << "stressRooFit: running in memcheck mode, no regression tests are performed" << endl ;
00817 dryRun=kTRUE ;
00818 }
00819
00820 if (arg=="-v") {
00821 cout << "stressRooFit: running in verbose mode" << endl ;
00822 doVerbose = 1 ;
00823 }
00824
00825 if (arg=="-vv") {
00826 cout << "stressRooFit: running in very verbose mode" << endl ;
00827 doVerbose = 2 ;
00828 }
00829
00830 if (arg=="-n") {
00831 cout << "stressRooFit: running single test " << argv[i+1] << endl ;
00832 oneTest = atoi(argv[++i]) ;
00833 }
00834
00835 if (arg=="-d") {
00836 cout << "stressRooFit: setting gDebug to " << argv[i+1] << endl ;
00837 gDebug = atoi(argv[++i]) ;
00838 }
00839
00840 if (arg=="-c") {
00841 cout << "stressRooFit: dumping comparison file for failed tests " << endl ;
00842 doDump=kTRUE ;
00843 }
00844
00845 if (arg=="-h") {
00846 cout << "usage: stressRooFit [ options ] " << endl ;
00847 cout << "" << endl ;
00848 cout << " -f <file> : use given reference file instead of default (" << refFileName << ")" << endl ;
00849 cout << " -w : write reference file, instead of reading file and running comparison tests" << endl ;
00850 cout << " " << endl ;
00851 cout << " -n N : Only run test with sequential number N instead of full suite of tests" << endl ;
00852 cout << " -c : dump file stressRooFit_DEBUG.root to which results of both current result and reference for each failed test are written" << endl ;
00853 cout << " -mc : memory check mode, no regression test are performed. Set this flag when running with valgrind" << endl ;
00854 cout << " -v/-vv : set verbose mode (show result of each regression test) or very verbose mode (show all roofit output as well)" << endl ;
00855 cout << " -d N : set ROOT gDebug flag to N" << endl ;
00856 cout << " " << endl ;
00857 return 0 ;
00858 }
00859
00860 }
00861
00862 if (doWrite && refFileName.find("http:")==0) {
00863
00864
00865 char* buf = new char[refFileName.size()+1] ;
00866 strcpy(buf,refFileName.c_str()) ;
00867 char *ptr = strrchr(buf,'/') ;
00868 if (!ptr) {
00869 ptr = strrchr(buf,':') ;
00870 }
00871 refFileName = ptr+1 ;
00872 delete[] buf ;
00873
00874 cout << "stressRooFit: WARNING running in write mode, but reference file is web file, writing local file instead: " << refFileName << endl ;
00875 }
00876
00877
00878
00879 RooMath::cacheCERF(kFALSE) ;
00880
00881 gBenchmark = new TBenchmark();
00882 stressRooFit(refFileName.c_str(),doWrite,doVerbose,oneTest,dryRun,doDump);
00883 return 0;
00884 }
00885
00886 #endif