30 #include "TProfile2D.h"
35 #include "TInterpreter.h"
43 #include <type_traits>
45 #define LW_OLD_WEIGHTED_PROFILE_ERRORS 1
49 std::vector<double>
x;
61 std::vector<double>
w;
80 template <
class HistVal>
82 hist.setName(
"name1");
83 hist.setName(
"name2");
84 hist.setName(
"title1");
86 hist.setTitle(
"title2");
87 hist.setName(
"name3");
88 hist.setNameTitle(
"someothername",
"someothertitle");
90 hist.setXAxis_LabelSize(0.04);
91 hist.setXAxis_LabelSize(2.0);
92 hist.setYAxis_LabelSize(0.04);
93 hist.setYAxis_LabelSize(0.01);
94 hist.setXAxis_Title(
"");
95 hist.setXAxis_Title(
"some-x-title");
96 hist.setYAxis_Title(
"some-y-title");
97 hist.setZAxis_Title(
"some-z-title");
99 unsigned nx(
hist.getXAxis_NBins());
100 hist.setXAxis_BinLabel(1,
"hejsa");
101 hist.setXAxis_BinLabel(17%nx+1,
"hejsa");
102 hist.setXAxis_BinLabel(19%nx+1,
"hejsa");
103 hist.setXAxis_BinLabel(74%nx+1,
"hejsa");
104 hist.setXAxis_BinLabel(nx,
"hejsa");
105 hist.setXAxis_BinLabel(19%nx+1,
"hejsa");
106 hist.setXAxis_BinLabel(1%nx+1,
"hejsa");
107 hist.setXAxis_BinLabel(1%nx+1,
"hejsa");
108 hist.setXAxis_BinLabel(100%nx+1,
"hejsa");
109 unsigned ny(
hist.getYAxis_NBins());
110 hist.setYAxis_BinLabel(2%ny+1,
"hejsa");
111 hist.setYAxis_BinLabel(1%ny+1,
"hejsa");
112 hist.setYAxis_BinLabel(ny,
"hejsa");
115 hist.SetMarkerStyle( 3 );
117 hist.SetMarkerColor( 4 );
119 hist.SetMarkerSize( 1.02 );
122 case 0:
hist.setMinimum(12312.0);
break;
123 case 1:
hist.setMinimum();
break;
124 case 2:
hist.setMinimum(0);
break;
125 case 3:
hist.setMinimum(-123.0);
break;
126 case 4:
hist.setMinimum(-123.0);
hist.setMinimum();
break;
127 default: assert(
false);
break;
131 case 0:
hist.setMaximum(12312.0);
break;
132 case 1:
hist.setMaximum();
break;
133 case 2:
hist.setMaximum(0);
break;
134 case 3:
hist.setMaximum(-123.0);
break;
135 case 4:
hist.setMaximum(-123.0);
hist.setMaximum();
break;
136 default: assert(
false);
break;
141 template <
class T1,
class T2>
143 int nbinsx,
double xmin,
double xmax,
144 int nbinsy,
double ymin,
double ymax)
169 for (
unsigned i=0;
i<UCHAR_MAX+10;++
i)
172 for (
unsigned i=0;
i<USHRT_MAX;++
i)
178 template <
class T1,
class T2>
205 for (
unsigned i=0;
i<UCHAR_MAX+10;++
i)
208 for (
unsigned i=0;
i<USHRT_MAX;++
i)
219 h6.
fill(17,UCHAR_MAX+1.0);
220 h6.
fill(17,USHRT_MAX+1.0);
225 h6.
fill(17,UCHAR_MAX+USHRT_MAX+1.0);
228 template <
class HistVal>
236 for (
unsigned ix=0; ix<
x.size();++ix)
242 for (
unsigned ix=0; ix<
x.size();++ix)
243 for (
unsigned iw=0; iw<
w.size();++iw)
244 h.fill(
x.at(ix),
w.at(iw));
249 template <
class HistVal>
257 h.setCompareBinContentsOnEachFill(
false);
258 for (
unsigned ix=0; ix<
x.size();++ix) {
259 for (
unsigned iy=0; iy<
x.size();++iy)
260 h.fill(
x.at(ix),
x.at(iy));
262 h.setCompareBinContentsOnEachFill(
true);
267 h.setCompareBinContentsOnEachFill(
false);
268 for (
unsigned ix=0; ix<
x.size();++ix) {
269 h.setCompareBinContentsOnEachFill(
false);
270 for (
unsigned iy=0; iy<
x.size();++iy)
271 for (
unsigned iw=0; iw<
w.size();++iw)
272 h.fill(
x.at(ix),
x.at(iy),
w.at(iw));
274 h.setCompareBinContentsOnEachFill(
true);
279 template <
class T1,
class T2>
283 "name1",
"title1",150,-10.0,80.0);
286 "name1",
"",150,0.0,17.0);
289 "",
"title3",150,0.0,17.0);
296 "name1test",
"title1test",2,0.0,100.0);
309 "nameerrtest",
"title1test",2,0.0,100.0);
314 std::cout <<
" ---> Quick basic test completed"<<std::endl;
317 unsigned nbinsscaled(100);
318 T2 * hscale = T2::create(
"namescale",
"titlescale",nbinsscaled,0.0,100.0);
320 hscale->Fill(50.5,17.0);
321 double scalefact=15.0;
322 std::vector<double> unscaled_cont(nbinsscaled+2),unscaled_err(nbinsscaled+2);
323 for (
unsigned ibin=0;ibin<nbinsscaled;++ibin)
324 hscale->GetBinContentAndError(ibin,unscaled_cont.at(ibin),unscaled_err.at(ibin));
325 hscale->scaleContentsAndErrors(scalefact);
326 for (
unsigned ibin=0;ibin<nbinsscaled;++ibin) {
328 hscale->GetBinContentAndError(ibin,
c,
e);
334 std::cout <<
" ---> Basic scaling test completed"<<std::endl;
336 if (do_systematic_tests) {
338 std::vector<unsigned> sys_ibin;
339 std::vector<double> sys_x;
340 const unsigned nbins=40;
341 const double xmin(0.0);
342 const double xmax(40.0);
343 sys_ibin.push_back(0);sys_x.push_back(
xmin-10.0);
344 sys_ibin.push_back(1);sys_x.push_back(0.5);
345 sys_ibin.push_back(6);sys_x.push_back(5.5);
346 sys_ibin.push_back(36);sys_x.push_back(35.5);
347 #ifdef LW_STRICT_ROOT_BEHAVIOUR
348 sys_ibin.push_back(
nbins+1);sys_x.push_back(
xmax+10.0);
349 sys_ibin.push_back(
nbins+USHRT_MAX+100);sys_x.push_back(std::numeric_limits<float>::quiet_NaN());
351 unsigned npoints=sys_ibin.size();
353 std::vector<double> sys_args;
354 sys_args.push_back(0.0);
356 sys_args.push_back(-4.0);
357 sys_args.push_back(-2.0);
358 sys_args.push_back(2.0);
359 sys_args.push_back(4.0);
360 sys_args.push_back(20.0);
362 const bool expecterror(
false);
363 #define SYSTEST(x) { if (verbose) { std::cout<<"Systematic filling: "<<x<<std::endl;} }
364 double x,
a;
unsigned i, itest(0);
365 for (
unsigned ipoint1 = 0;ipoint1<
npoints;++ipoint1)
366 for (
unsigned ipoint2 = 0;ipoint2<
npoints;++ipoint2)
367 for (
unsigned iarg1 = 0;iarg1<sys_args.size();++iarg1)
368 for (
unsigned iarg2 = 0;iarg2<sys_args.size();++iarg2)
369 for (
unsigned doFillX_1 = 0;doFillX_1<=1;++doFillX_1)
370 for (
unsigned doFillXW_1 = 0;doFillXW_1<=1;++doFillXW_1)
371 for (
unsigned doSetBinContent_1 = 0;doSetBinContent_1<=1;++doSetBinContent_1)
372 for (
unsigned doSetBinError_1 = 0;doSetBinError_1<=1;++doSetBinError_1)
373 for (
unsigned doFillX_2 = 0;doFillX_2<=1;++doFillX_2)
374 for (
unsigned doFillXW_2 = 0;doFillXW_2<=1;++doFillXW_2)
375 for (
unsigned doSetBinContent_2 = 0;doSetBinContent_2<=1;++doSetBinContent_2)
376 for (
unsigned doSetBinError_2 = 0;doSetBinError_2<=1;++doSetBinError_2)
377 for (
unsigned doSetBinContentAndError_2 = 0;doSetBinContentAndError_2<=1;++doSetBinContentAndError_2)
380 SYSTEST(
"------------> 1D Test number "<<itest);
383 h.setCompareBinContentsOnEachFill(expecterror);
385 i=sys_ibin.at(ipoint1);
x=sys_x.at(ipoint1);
a=sys_args.at(iarg1);
387 if (doFillX_1) {
SYSTEST(
"Fill("<<
x<<
")");
h.fill(
x); }
388 if (doFillXW_1) {
SYSTEST(
"Fill("<<
x<<
", "<<
a<<
")");
h.fill(
x,
a); }
389 if (doSetBinContent_1) {
SYSTEST(
"setBinContent("<<
i<<
", "<<
a<<
")");
h.setBinContent(
i,
a); }
390 #ifdef LW_STRICT_ROOT_BEHAVIOUR
392 if (doSetBinError_1) {
SYSTEST(
"setBinError("<<
i<<
", "<<
a<<
")");
h.setBinError(
i,
a); }
395 i=sys_ibin.at(ipoint2);
x=sys_x.at(ipoint2);
a=sys_args.at(iarg2);
396 if (doFillX_2) {
SYSTEST(
"Fill("<<
x<<
")");
h.fill(
x); }
397 if (doFillXW_2) {
SYSTEST(
"Fill("<<
x<<
", "<<
a<<
")");
h.fill(
x,
a); }
398 if (doSetBinContent_2) {
SYSTEST(
"setBinContent("<<
i<<
", "<<
a<<
")");
h.setBinContent(
i,
a); }
399 #ifndef LW_STRICT_ROOT_BEHAVIOUR
401 if (doSetBinError_1) {
SYSTEST(
"setBinError("<<
i<<
", "<<
a<<
")");
h.setBinError(
i,
a); }
403 if (doSetBinError_2) {
SYSTEST(
"setBinError("<<
i<<
", "<<
a<<
")");
h.setBinError(
i,
a); }
404 if (doSetBinContentAndError_2)
405 {
SYSTEST(
"setBinContentAndError("<<
i<<
", "<<
a<<
", 17.0)");
h.setBinContentAndError(
i,
a,17.0); }
407 std::cout <<
" ---> Systematic tests ("<<itest<<
") completed"<<std::endl;
410 float *
xbins =
new float[5];
417 "name6",
"title6",4,
xbins);
427 std::cout <<
" ---> Variable binning tests completed"<<std::endl;
430 fillInVariousWays<T1,T2>(trigger_conversion_all, 100,0.0,100.0);
431 fillInVariousWays<T1,T2>(trigger_conversion_all, 150,0.0,100.0);
432 fillInVariousWays<T1,T2>(trigger_conversion_all, 15000,0.0,100.0);
433 std::cout <<
" ---> Various filling tests completed"<<std::endl;
437 template <
class T1,
class T2>
441 "name1",
"title1",100,-10.0,80.0,50,10.0,1230.0);
444 "name1",
"",100,0.0,17.0,50,10.0,1230.0);
447 "",
"title3",100,0.0,17.0,50,10.0,1230.0);
450 "",
"",100,0.0,17.0,50,10.0,1230.0);
452 std::cout <<
" ---> Quick basic test completed"<<std::endl;
454 fillInVariousWays<T1,T2>(trigger_conversion_all, 100,0.0,100.0,100,0.0,100.0);
455 std::cout <<
" ---> Various filling tests completed"<<std::endl;
457 const bool do_systematic_tests =
true;
458 if (do_systematic_tests) {
459 std::vector<unsigned> sys_ibin;
460 std::vector<double> sys_x;
461 const unsigned nbins=3;
462 const double xmin(0.0);
463 const double xmax(3.0);
464 sys_ibin.push_back(0);sys_x.push_back(
xmin-10.0);
465 sys_ibin.push_back(2);sys_x.push_back(1.5);
466 #ifdef LW_STRICT_ROOT_BEHAVIOUR
467 sys_ibin.push_back(
nbins+1);sys_x.push_back(
xmax+10.0);
468 sys_ibin.push_back(
nbins+USHRT_MAX+100);sys_x.push_back(std::numeric_limits<float>::quiet_NaN());
470 unsigned npoints=sys_ibin.size();
472 std::vector<double> sys_args;
473 sys_args.push_back(0.0);
475 sys_args.push_back(-17.0);
476 sys_args.push_back(17.0);
478 const bool expecterror(
false);
479 double x,
y,
a;
unsigned ibinx, ibiny, itest(0);
480 for (
unsigned ix = 0;ix<
npoints;++ix)
481 for (
unsigned iy = 0;iy<
npoints;++iy)
482 for (
unsigned iarg = 0;iarg<sys_args.size();++iarg)
483 for (
unsigned doFillX_1 = 0;doFillX_1<=1;++doFillX_1)
484 for (
unsigned doFillXW_1 = 0;doFillXW_1<=1;++doFillXW_1)
485 for (
unsigned doSetBinContent_1 = 0;doSetBinContent_1<=1;++doSetBinContent_1)
486 for (
unsigned doSetBinError_1 = 0;doSetBinError_1<=1;++doSetBinError_1)
489 SYSTEST(
"------------> 2D Test number "<<itest)
492 h.setCompareBinContentsOnEachFill(expecterror);
494 ibinx=sys_ibin.at(ix);
x=sys_x.at(ix);
495 ibiny=sys_ibin.at(ix);
y=sys_x.at(ix);
497 if (doFillX_1) {
SYSTEST(
"Fill("<<
x<<
", "<<
y<<
")");
h.fill(
x,
y); }
498 if (doFillXW_1) {
SYSTEST(
"Fill("<<
x<<
", "<<
y<<
", "<<
a<<
")");
h.fill(
x,
y,
a); }
499 if (doSetBinContent_1) {
SYSTEST(
"setBinContent("<<ibinx<<
", "<<ibiny<<
", "<<
a<<
")");
h.setBinContent(ibinx,ibiny,
a); }
500 if (doSetBinError_1) {
SYSTEST(
"setBinError("<<ibinx<<
", "<<ibiny<<
", "<<
a<<
")");
h.setBinError(ibinx,ibiny,
a); }
502 std::cout <<
" ---> Systematic tests ("<<itest<<
") completed"<<std::endl;
504 float *
xbins =
new float[5];
510 double * xbinsd =
new double[5];
516 float *
ybins =
new float[3];
520 double * ybinsd =
new double[3];
527 "name7",
"title7",4,xbinsd,2,ybinsd);
529 "name8",
"title8",4,xbinsd,2,-20.0,100.0);
531 "name9",
"title9",4,0.0,10.0,2,ybinsd);
537 const double eps=1
e-5;
575 std::cout <<
" ---> Variable binning tests completed"<<std::endl;
578 template <
class T1,
class T2>
580 const unsigned maxbins(300);
581 double *
xbins =
new double[maxbins+1];
582 for (
int ih = 1; ih <= 15; ++ih) {
583 double l(
rand()%300000+50.232-150000);
584 double u(
l+
rand()%1000+0.1);
586 std::ostringstream
s;
589 s.str(),
"t"+
s.str(),
rand()%maxbins+1,
l,
u);
592 s.str(),
"t"+
s.str(),
rand()%maxbins+1,
l,
u);
596 double avstep((
u-
l)/(
rand()%maxbins+1));
599 v+=avstep*((
rand()*1.0*(1./RAND_MAX))+0.001)*2;
600 if (
v>=
u||ibin==maxbins) {
606 unsigned nvarbins = ibin-1;
613 assert(
xbins[nvarbins]==
u);
616 s.str(),
"t"+
s.str(),nvarbins,
xbins);
620 const int n(ih*ih*ih*ih);
621 for (
int i = 0;
i <
n; ++
i) {
622 double x(((
u-
l)*1.2*(
rand()%1000000*1.0
e-6-0.1)));
624 htest2.
fill(
x,
double(
rand()%10-5+0.345));
642 bool do_systematic_tests =
true)
646 "aprofilehist",
"a title for my profile hist",100, 0.0, 100.0 );
652 a.fill(91.5,20.0,5.0);
654 a.fill(81.5,-20.0,-5.0);
656 a.setBinEntries(20, 5.5);
658 a.setBinContent(30, 20.2);
660 a.setBinError(40, 23.4);
662 a.setBinInfo(50, 1.0,2.0,3.0);
665 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
673 "anotherprofilehist",
"another title for my profile hist",100, 0.0, 100.0 );
687 "yetanotherprofilehist",
"bla",100, 0.0, 100.0, -1.0,2.0 );
700 std::cout <<
" ---> Quick basic test completed"<<std::endl;
702 if (do_systematic_tests) {
704 std::vector<unsigned> sys_ibin;
705 std::vector<double> sys_x;
706 const unsigned nbins=40;
707 const double xmin(0.0);
708 const double xmax(40.0);
710 sys_ibin.push_back(0);sys_x.push_back(
xmin-10.0);
711 sys_ibin.push_back(1);sys_x.push_back(0.5);
712 sys_ibin.push_back(6);sys_x.push_back(5.5);
713 sys_ibin.push_back(36);sys_x.push_back(35.5);
714 #ifdef LW_STRICT_ROOT_BEHAVIOUR
715 sys_ibin.push_back(
nbins+1);sys_x.push_back(
xmax+10.0);
718 unsigned npoints=sys_ibin.size();
720 std::vector<double> sys_args;
721 sys_args.push_back(0.0);
723 sys_args.push_back(-4.0);
724 sys_args.push_back(-2.0);
725 sys_args.push_back(2.0);
726 sys_args.push_back(4.0);
727 sys_args.push_back(20.0);
729 const bool expecterror(
false);
731 double x,
a,a2;
unsigned i, itest(0);
732 for (
unsigned ipoint1 = 0;ipoint1<
npoints;++ipoint1)
733 for (
unsigned ipoint2 = 0;ipoint2<
npoints;++ipoint2)
734 for (
unsigned iarg1 = 0;iarg1<sys_args.size();++iarg1)
735 for (
unsigned iarg2 = 0;iarg2<sys_args.size();++iarg2)
736 for (
unsigned doFillX_1 = 0;doFillX_1<=1;++doFillX_1)
738 for (
unsigned doFillXW_1 = 0;doFillXW_1<=1;++doFillXW_1)
740 for (
unsigned doSetBinEntries_1 = 0;doSetBinEntries_1<=1;++doSetBinEntries_1)
741 for (
unsigned doSetBinContent_1 = 0;doSetBinContent_1<=1;++doSetBinContent_1)
742 for (
unsigned doSetBinError_1 = 0;doSetBinError_1<=1;++doSetBinError_1)
744 for (
unsigned doFillX_2 = 0;doFillX_2<=1;++doFillX_2)
746 for (
unsigned doFillXW_2 = 0;doFillXW_2<=1;++doFillXW_2)
747 for (
unsigned doSetBinEntries_2 = 0;doSetBinEntries_2<=1;++doSetBinEntries_2)
748 for (
unsigned doSetBinContent_2 = 0;doSetBinContent_2<=1;++doSetBinContent_2)
749 for (
unsigned doSetBinError_2 = 0;doSetBinError_2<=1;++doSetBinError_2)
750 for (
unsigned doSetBinInfo_2 = 0;doSetBinInfo_2<=1;++doSetBinInfo_2)
753 SYSTEST(
"------------> 1D-profile Test number "<<itest);
756 h.setCompareBinContentsOnEachFill(expecterror);
758 i=sys_ibin.at(ipoint1);
x=sys_x.at(ipoint1);
a=sys_args.at(iarg1),a2=sys_args.at(iarg2);
760 bool cansetdirectly_1(
false);
761 if (doFillX_1) {
SYSTEST(
"Fill("<<
x<<
","<<
a<<
")");
h.fill(
x,
a); cansetdirectly_1=
true;}
763 if (doFillXW_1) {
SYSTEST(
"Fill("<<
x<<
", "<<
a<<
", "<<a2<<
")");
h.fill(
x,
a,a2); cansetdirectly_1=
true;}
765 if (doSetBinEntries_1&&cansetdirectly_1) {
SYSTEST(
"setBinEntries("<<
i<<
", "<<
a<<
")");
h.setBinEntries(
i,
a); }
766 if (doSetBinContent_1&&cansetdirectly_1) {
SYSTEST(
"setBinContent("<<
i<<
", "<<
a<<
")");
h.setBinContent(
i,
a); }
767 if (doSetBinError_1&&cansetdirectly_1) {
SYSTEST(
"setBinError("<<
i<<
", "<<
a<<
")");
h.setBinError(
i,
a); }
769 bool cansetdirectly_2 =
false;
770 i=sys_ibin.at(ipoint2);
x=sys_x.at(ipoint2);
std::swap(
a,a2);
771 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
775 if (doFillX_2) {
SYSTEST(
"Fill("<<
x<<
", "<<
a<<
")");
h.fill(
x,
a); cansetdirectly_2 =
true; }
777 if (doFillXW_2) {
SYSTEST(
"Fill("<<
x<<
", "<<
a<<
", "<<a2<<
")");
h.fill(
x,
a,a2); cansetdirectly_2 =
true; }
778 if (doSetBinContent_2&&cansetdirectly_2) {
SYSTEST(
"setBinContent("<<
i<<
", "<<
a<<
")");
h.setBinContent(
i,
a); }
779 if (doSetBinError_2&&cansetdirectly_2) {
SYSTEST(
"setBinError("<<
i<<
", "<<
a<<
")");
h.setBinError(
i,
a); }
781 {
SYSTEST(
"setBinInfo("<<
i<<
", "<<
a<<
", "<<a2<<
", 17.0)");
h.setBinInfo(
i,
a,a2,17.0); }
783 std::cout <<
" ---> Systematic tests ("<<itest<<
") completed"<<std::endl;
790 unsigned ifptests(1);
792 "profhist_fptest0",
"sometitle",1, 0.0, 1.0 );
794 for (
long long unsigned i=0;
i<1000000;++
i)
797 h_fp.
fill(0.5,1.2*(
i%10));
799 h_fp.
fill(0.5,1.2*(
i%10),0.5+
i%3);
803 std::vector<double> fptest_profpar, fptest_weight;
804 fptest_profpar.push_back(-5.0);
805 fptest_profpar.push_back(0.0);
806 fptest_profpar.push_back(0.001);
807 fptest_profpar.push_back(1.0);
808 fptest_profpar.push_back(1.2);
810 fptest_profpar.push_back(5.0);
812 fptest_profpar.push_back(10000.0);
814 fptest_weight.push_back(0.0);
815 fptest_weight.push_back(-2.0);
816 fptest_weight.push_back(0.1);
817 fptest_weight.push_back(1.0);
818 fptest_weight.push_back(1.2);
819 fptest_weight.push_back(100.0);
820 fptest_weight.push_back(1000.0);
825 const bool expecterror(
false);
827 for (
unsigned ipp1 = 0; ipp1<fptest_profpar.size();++ipp1)
828 for (
unsigned iw1 = 0; iw1<fptest_weight.size();++iw1)
829 for (
unsigned ipp2 = 0; ipp2<fptest_profpar.size();++ipp2)
830 for (
unsigned iw2 = 0; iw2<fptest_weight.size();++iw2)
831 for (
unsigned ipp3 = 0; ipp3<fptest_profpar.size();++ipp3)
832 for (
unsigned iw3 = 0; iw3<fptest_weight.size();++iw3)
836 "profhist_fptest",
"sometitle",1, 0.0, 1.0 );
837 h.setCompareBinContentsOnEachFill(expecterror);
840 std::cout<<
"-----> FP Test #"<<ifptests<<std::endl;
841 pp = fptest_profpar.at(ipp1);
w = fptest_weight.at(iw1);
842 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
846 std::cout<<
" --> Fill profpar = "<<pp<<
", weight = "<<
w<<std::endl;
847 if (
w!=1.0)
h.fill(0.5,pp,
w);
else h.fill(0.5,pp);
849 pp = fptest_profpar.at(ipp2);
w = fptest_weight.at(iw2);
850 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
854 std::cout<<
" --> Fill profpar = "<<pp<<
", weight = "<<
w<<std::endl;
855 if (
w!=1.0)
h.fill(0.5,pp,
w);
else h.fill(0.5,pp);
857 pp = fptest_profpar.at(ipp3);
w = fptest_weight.at(iw3);
858 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
862 std::cout<<
" --> Fill profpar = "<<pp<<
", weight = "<<
w<<std::endl;
863 if (
w!=1.0)
h.fill(0.5,pp,
w);
else h.fill(0.5,pp);
866 std::cout <<
" ---> Floating point precision tests ("<<ifptests<<
") completed"<<std::endl;
868 float *
xbins =
new float[5];
875 "profvarbins",
"profile with varbins",4,
xbins );
878 c.fill(2.6,2.0);
c.compareAll();
879 c.fill(2.7,2.0);
c.compareAll();
880 c.fill(0.0,2.0);
c.compareAll();
881 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
886 c.fill(0.0,2.0,weight2);
c.compareAll();
887 c.fill(10.0,1.2,weight2);
c.compareAll();
888 c.fill(-20.0,2.0);
c.compareAll();
889 c.fill(12.0,2.0);
c.compareAll();
890 c.fill(5.0,2.0);
c.compareAll();
891 c.fill(1.2,2.0);
c.compareAll();
892 std::cout <<
" ---> Variable binning tests completed"<<std::endl;
898 bool do_systematic_tests =
true)
902 "a2dprofilehist",
"a title for my 2d profile hist",100, 0.0, 100.0,100, 0.0, 100.0 );
907 a.fill(7.0, 17.0,10.0);
909 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
910 a.fill(91.5,17.0, 20.0);
912 a.fill(91.5,17.0, 20.0,5.0);
915 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
916 a.fill(81.5,17.0,-20.0);
918 a.fill(81.5,17.0,-20.0,-5.0);
921 a.setBinEntries(20, 17,5.5);
923 a.setBinContent(30, 17, 20.2);
925 a.setBinError(40, 17, 23.4);
927 a.setBinInfo(50, 17, 1.0,2.0,3.0);
930 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
938 "another2dprofilehist",
"another title for my 2dprofile hist",
939 100, 0.0, 100.0, 100, 0.0, 100.0, 0.0,1.0 );
940 b.fill(30.0,10.0,-1.0);
941 b.fill(30.0,10.0,0.0);
942 b.fill(30.0,10.0,0.5);
943 b.fill(30.0,10.0,1.0);
944 b.fill(30.0,10.0,2.0);
951 std::cout <<
" ---> Quick basic test completed"<<std::endl;
953 if (do_systematic_tests) {
954 std::vector<unsigned> sys_ibin;
955 std::vector<double> sys_x;
956 const unsigned nbins=3;
957 const double xmin(0.0);
958 const double xmax(3.0);
959 sys_ibin.push_back(0);sys_x.push_back(
xmin-10.0);
960 sys_ibin.push_back(2);sys_x.push_back(1.5);
961 #ifdef LW_STRICT_ROOT_BEHAVIOUR
962 sys_ibin.push_back(
nbins+1);sys_x.push_back(
xmax+10.0);
965 unsigned npoints=sys_ibin.size();
967 std::vector<double> sys_args;
968 sys_args.push_back(0.0);
970 sys_args.push_back(-17.0);
971 sys_args.push_back(17.0);
973 const bool expecterror(
false);
974 double x,
y,
a,a2;
unsigned ibinx, ibiny, itest(0);
975 for (
unsigned ix = 0;ix<
npoints;++ix)
976 for (
unsigned iy = 0;iy<
npoints;++iy)
977 for (
unsigned iarg = 0;iarg<sys_args.size();++iarg)
978 for (
unsigned iarg2 = 0;iarg2<sys_args.size();++iarg2)
979 for (
unsigned doFillX_1 = 0;doFillX_1<=1;++doFillX_1)
980 for (
unsigned doFillXW_1 = 0;doFillXW_1<=1;++doFillXW_1)
981 for (
unsigned doSetBinEntries_1 = 0;doSetBinEntries_1<=1;++doSetBinEntries_1)
982 for (
unsigned doSetBinContent_1 = 0;doSetBinContent_1<=1;++doSetBinContent_1)
983 for (
unsigned doSetBinError_1 = 0;doSetBinError_1<=1;++doSetBinError_1)
984 for (
unsigned doSetBinInfo_1 = 0;doSetBinInfo_1<=1;++doSetBinInfo_1)
986 if (doSetBinError_1&&!doSetBinEntries_1)
989 SYSTEST(
"------------> 2D-profile Test number "<<itest)
992 h.setCompareBinContentsOnEachFill(expecterror);
994 ibinx=sys_ibin.at(ix);
x=sys_x.at(ix);
995 ibiny=sys_ibin.at(ix);
y=sys_x.at(ix);
997 a2=sys_args.at(iarg2);
998 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
1002 if (doFillX_1) {
SYSTEST(
"Fill("<<
x<<
", "<<
y<<
", "<<a2<<
")");
h.fill(
x,
y,a2); }
1003 if (doFillXW_1) {
SYSTEST(
"Fill("<<
x<<
", "<<
y<<
", "<<a2<<
", "<<
a<<
")");
h.fill(
x,
y,a2,
a); }
1005 if (doSetBinEntries_1) {
SYSTEST(
"setBinEntries("<<ibinx<<
", "<<ibiny<<
", "<<
a<<
")");
h.setBinEntries(ibinx,ibiny,
a); }
1006 if (doSetBinContent_1) {
SYSTEST(
"setBinContent("<<ibinx<<
", "<<ibiny<<
", "<<
a<<
")");
h.setBinContent(ibinx,ibiny,
a); }
1007 if (doSetBinError_1) {
SYSTEST(
"setBinError("<<ibinx<<
", "<<ibiny<<
", "<<
a<<
")");
h.setBinError(ibinx,ibiny,
a); }
1009 {
SYSTEST(
"setBinInfo("<<ibinx<<
", "<<ibiny<<
", "<<
a<<
", "<<a2<<
", 17.0)");
h.setBinInfo(ibinx,ibiny,
a,a2,17.0); }
1012 std::cout <<
" ---> Systematic tests ("<<itest<<
") completed"<<std::endl;
1015 double *
xbins =
new double[5];
1021 double *
ybins =
new double[3];
1029 const double eps(1.0
e-4);
1036 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
1048 std::cout <<
"Usage:"<<std::endl;
1049 std::cout <<
""<<std::endl;
1050 std::cout <<
argv[0]<<
" [-h|--help] [-v|--verbose] [--no1d] [--no2d] [--noprofile] [--quick|--noquick] [--rootbackend] [--triggerconv] [--seed=XXX]"<<std::endl;
1051 std::cout <<
""<<std::endl;
1059 bool cfg_rootbackend(
false);
1060 bool cfg_triggerrootconversion(
false);
1061 unsigned cfg_seed(UINT_MAX);
1062 bool cfg_do1d(
true);
1063 bool cfg_do2d(
true);
1064 bool cfg_doprofile(
true);
1065 bool cfg_quick(
false);
1070 bool sawquickopt(
false);
1071 bool cfg_verbose(
false);
1074 if (
arg==
"-h"||
arg==
"--help")
1076 if (
arg==
"-v"||
arg==
"--verbose") {
1082 if (
arg==
"--no1d") {
1088 if (
arg==
"--no2d") {
1094 if (
arg==
"--noprofile") {
1097 cfg_doprofile =
false;
1100 if (
arg==
"--quick") {
1107 if (
arg==
"--noquick") {
1114 if (
arg==
"--rootbackend") {
1115 if (cfg_rootbackend)
1117 cfg_rootbackend =
true;
1120 if (
arg==
"--triggerconv") {
1121 if (cfg_triggerrootconversion)
1123 cfg_triggerrootconversion =
true;
1126 if (
arg.rfind(
"--seed=")==0&&
arg.size()>=8) {
1127 if (cfg_seed!=UINT_MAX)
1129 unsigned iseed =
atoi(&(
arg.c_str()[7]));
1130 std::ostringstream
ss;
ss<<iseed;
1131 if (
arg!=
"--seed="+
ss.str())
1141 if (cfg_rootbackend)
1142 TH1::AddDirectory (
false);
1144 std::cout<<
"Starting tests"<<std::endl;
1146 std::cout<<
"Testing types..."<<std::endl;
1150 unsigned actual_seed = (cfg_seed==0||cfg_seed==UINT_MAX) ? (
unsigned)
time(0) : cfg_seed;
1151 std::cout<<
"NB: Stress-tests will use random seed = "<<actual_seed<<std::endl;
1156 std::cout<<
"Performing basic validation of TH1F vs. TH1F_LW..."<<std::endl;
1157 basicValidation<TH1F,TH1F_LW>(cfg_triggerrootconversion, icount, cfg_verbose);
1158 std::cout<<
"Performing basic validation of TH1D vs. TH1D_LW..."<<std::endl;
1159 basicValidation<TH1D,TH1D_LW>(cfg_triggerrootconversion, icount, cfg_verbose, !cfg_quick);
1160 std::cout<<
"Performing basic validation of TH1I vs. TH1I_LW..."<<std::endl;
1161 basicValidation<TH1I,TH1I_LW>(cfg_triggerrootconversion, icount, cfg_verbose, !cfg_quick);
1163 std::cout<<
"Performing stress-test level validations of TH1F vs. TH1F_LW..."<<std::endl;
1164 stressTestValidation<TH1F,TH1F_LW>(cfg_triggerrootconversion);
1165 std::cout<<
"Performing stress-test level validations of TH1D vs. TH1D_LW..."<<std::endl;
1166 stressTestValidation<TH1D,TH1D_LW>(cfg_triggerrootconversion);
1167 std::cout<<
"Performing stress-test level validations of TH1I vs. TH1I_LW..."<<std::endl;
1168 stressTestValidation<TH1I,TH1I_LW>(cfg_triggerrootconversion);
1172 std::cout<<
"Performing basic validation of TH2F vs. TH2F_LW..."<<std::endl;
1173 basicValidation2D<TH2F,TH2F_LW>(cfg_triggerrootconversion, icount, cfg_verbose);
1174 std::cout<<
"Performing basic validation of TH2D vs. TH2D_LW..."<<std::endl;
1175 basicValidation2D<TH2D,TH2D_LW>(cfg_triggerrootconversion, icount, cfg_verbose);
1176 std::cout<<
"Performing basic validation of TH2I vs. TH2I_LW..."<<std::endl;
1177 basicValidation2D<TH2I,TH2I_LW>(cfg_triggerrootconversion, icount, cfg_verbose);
1180 if (cfg_doprofile) {
1181 std::cout<<
"Performing basic validation of TProfile vs. TProfile_LW..."<<std::endl;
1183 std::cout<<
"Performing basic validation of TProfile2D vs. TProfile2D_LW..."<<std::endl;
1191 std::cout <<
"All enabled tests succesfully completed"<<std::endl;
1194 TH1F * hreport =
new TH1F(
"rootspy",
"",1,0,1);
1195 hreport->Fill(
"rootspy_producereport",0.123456);