ATLAS Offline Software
Macros | Functions
main_validation.cxx File Reference
#include "HistValBase.h"
#include "validatefunctions.h"
#include "HistVal1D.h"
#include "HistVal2D.h"
#include "HistValProfile.h"
#include "HistValProfile2D.h"
#include "LWHists/LWHistControls.h"
#include "TH1F.h"
#include "LWHists/TH1F_LW.h"
#include "TH1D.h"
#include "LWHists/TH1D_LW.h"
#include "TH1I.h"
#include "LWHists/TH1I_LW.h"
#include "TH2F.h"
#include "LWHists/TH2F_LW.h"
#include "TH2D.h"
#include "LWHists/TH2D_LW.h"
#include "TH2I.h"
#include "LWHists/TH2I_LW.h"
#include "TProfile.h"
#include "LWHists/TProfile_LW.h"
#include "TProfile2D.h"
#include "LWHists/TProfile2D_LW.h"
#include "CxxUtils/ubsan_suppress.h"
#include "CxxUtils/checker_macros.h"
#include "TInterpreter.h"
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <vector>
#include <climits>
#include <limits>
#include <type_traits>

Go to the source code of this file.

Macros

#define LW_OLD_WEIGHTED_PROFILE_ERRORS   1
 
#define SYSTEST(x)   { if (verbose) { std::cout<<"Systematic filling: "<<x<<std::endl;} }
 

Functions

std::vector< double > getXValues ()
 
std::vector< double > getWeights (bool is_int)
 
template<class HistVal >
void setNamesAndTitles (int &icount, HistVal &hist)
 
template<class T1 , class T2 >
void fillInVariousWays (bool trigger_conversion_all, int nbinsx, double xmin, double xmax, int nbinsy, double ymin, double ymax)
 
template<class T1 , class T2 >
void fillInVariousWays (bool trigger_conversion_all, int nbins, double xmin, double xmax)
 
template<class HistVal >
void fillInVariousWays_int (HistVal &h, bool doUnitWeight, bool doFloatWeight)
 
template<class HistVal >
void fillInVariousWays_int2d (HistVal &h, bool doUnitWeight, bool doFloatWeight)
 
template<class T1 , class T2 >
void basicValidation (bool trigger_conversion_all, int &icount, bool verbose, bool do_systematic_tests=true)
 
template<class T1 , class T2 >
void basicValidation2D (bool trigger_conversion_all, int &icount, bool verbose)
 
template<class T1 , class T2 >
void stressTestValidation (bool trigger_conversion_all)
 
void basicValidation_Profile (bool trigger_conversion_all, int &icount, bool verbose, bool do_systematic_tests=true)
 
void basicValidation_Profile2D (bool trigger_conversion_all, int &icount, bool verbose, bool do_systematic_tests=true)
 
void usage ATLAS_NOT_THREAD_SAFE (char **argv, int exitcode)
 
int main ATLAS_NOT_THREAD_SAFE (int argc, char **argv)
 

Macro Definition Documentation

◆ LW_OLD_WEIGHTED_PROFILE_ERRORS

#define LW_OLD_WEIGHTED_PROFILE_ERRORS   1

Definition at line 46 of file main_validation.cxx.

◆ SYSTEST

#define SYSTEST (   x)    { if (verbose) { std::cout<<"Systematic filling: "<<x<<std::endl;} }

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE() [1/2]

void usage ATLAS_NOT_THREAD_SAFE ( char **  argv,
int  exitcode 
)

Definition at line 1047 of file main_validation.cxx.

1047  {
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;
1052  exit(exitcode);
1053 }

◆ ATLAS_NOT_THREAD_SAFE() [2/2]

int main ATLAS_NOT_THREAD_SAFE ( int  argc,
char **  argv 
)

Definition at line 1054 of file main_validation.cxx.

1054  {
1055 
1056  // Suppress ubsan warnings from cling.
1057  CxxUtils::ubsan_suppress ([]() { TInterpreter::Instance(); });
1058 
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);
1066 #ifndef NDEBUG
1067  //Debug builds have quick by default, to even out run times a bit.
1068  cfg_quick = true;
1069 #endif
1070  bool sawquickopt(false);
1071  bool cfg_verbose(false);
1072  for (int i=1; i<argc;++i) {
1073  std::string arg(argv[i]);
1074  if (arg=="-h"||arg=="--help")
1075  usage(argv,0);
1076  if (arg=="-v"||arg=="--verbose") {
1077  if (cfg_verbose)
1078  usage(argv,1);
1079  cfg_verbose = true;
1080  continue;
1081  }
1082  if (arg=="--no1d") {
1083  if (!cfg_do1d)
1084  usage(argv,1);
1085  cfg_do1d = false;
1086  continue;
1087  }
1088  if (arg=="--no2d") {
1089  if (!cfg_do2d)
1090  usage(argv,1);
1091  cfg_do2d = false;
1092  continue;
1093  }
1094  if (arg=="--noprofile") {
1095  if (!cfg_doprofile)
1096  usage(argv,1);
1097  cfg_doprofile = false;
1098  continue;
1099  }
1100  if (arg=="--quick") {
1101  if (sawquickopt)
1102  usage(argv,1);
1103  sawquickopt = true;
1104  cfg_quick = true;
1105  continue;
1106  }
1107  if (arg=="--noquick") {
1108  if (sawquickopt)
1109  usage(argv,1);
1110  sawquickopt = true;
1111  cfg_quick = false;
1112  continue;
1113  }
1114  if (arg=="--rootbackend") {
1115  if (cfg_rootbackend)
1116  usage(argv,1);
1117  cfg_rootbackend = true;
1118  continue;
1119  }
1120  if (arg=="--triggerconv") {
1121  if (cfg_triggerrootconversion)
1122  usage(argv,1);
1123  cfg_triggerrootconversion = true;
1124  continue;
1125  }
1126  if (arg.rfind("--seed=")==0&&arg.size()>=8) {
1127  if (cfg_seed!=UINT_MAX)
1128  usage(argv,1);
1129  unsigned iseed = atoi(&(arg.c_str()[7]));
1130  std::ostringstream ss; ss<<iseed;
1131  if (arg!="--seed="+ss.str())
1132  usage(argv,1);
1133  cfg_seed = iseed;
1134  continue;
1135  }
1136  usage(argv,1);
1137  }
1138 
1139  LWHistControls::setROOTBackend(cfg_rootbackend);
1140 
1141  if (cfg_rootbackend)
1142  TH1::AddDirectory (false);//get rid of "possible memory leak" warnings
1143 
1144  std::cout<<"Starting tests"<<std::endl;
1145 
1146  std::cout<<"Testing types..."<<std::endl;
1148 
1149  //seed random numbers;
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;
1152  srand(actual_seed);
1153  int icount = 0;
1154 
1155  if (cfg_do1d) {
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);
1162 
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);
1169  }
1170 
1171  if (cfg_do2d) {
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);
1178  }
1179 
1180  if (cfg_doprofile) {
1181  std::cout<<"Performing basic validation of TProfile vs. TProfile_LW..."<<std::endl;
1182  basicValidation_Profile(cfg_triggerrootconversion, icount, cfg_verbose, !cfg_quick);
1183  std::cout<<"Performing basic validation of TProfile2D vs. TProfile2D_LW..."<<std::endl;
1184  basicValidation_Profile2D(cfg_triggerrootconversion, icount, cfg_verbose);
1185  }
1186 
1187 
1188 
1190 
1191  std::cout <<"All enabled tests succesfully completed"<<std::endl;
1192 
1193  //Magic report triggering lines in case librootspy.so is preloaded:
1194  TH1F * hreport = new TH1F("rootspy","",1,0,1);
1195  hreport->Fill("rootspy_producereport",0.123456);
1196  delete hreport;
1197 }

◆ basicValidation()

template<class T1 , class T2 >
void basicValidation ( bool  trigger_conversion_all,
int &  icount,
bool  verbose,
bool  do_systematic_tests = true 
)

Definition at line 280 of file main_validation.cxx.

280  {
281  //Test name/title:
282  HistVal1D<T1,T2> h(trigger_conversion_all,
283  "name1","title1",150,-10.0,80.0);
284  setNamesAndTitles(icount, h);
285  HistVal1D<T1,T2> h2(trigger_conversion_all,
286  "name1","",150,0.0,17.0);
287  setNamesAndTitles(icount, h2);
288  HistVal1D<T1,T2> h3(trigger_conversion_all,
289  "","title3",150,0.0,17.0);
290  setNamesAndTitles(icount, h3);
291  HistVal1D<T1,T2> h4(trigger_conversion_all,
292  "","",150,0.0,17.0);
293  setNamesAndTitles(icount, h4);
294  //Special basic test:
295  HistVal1D<T1,T2> h5(trigger_conversion_all,
296  "name1test","title1test",2,0.0,100.0);
297  h5.fill(80);
298  h5.compareAll();
299  // std::cout<<"basic validation of h1="<<typeid(T1).name()<<" vs. h2="<<typeid(T2).name()<<std::endl;
300  h5.fill(30,4.545);
301  h5.compareAll();
302  h5.fill(-1,4.545);
303  h5.compareAll();
304  h5.fill(101,4.545);
305  h5.compareAll();
306 
307  //Another special test for savanna bug #73561
308  HistVal1D<T1,T2> h_errbug(trigger_conversion_all,
309  "nameerrtest","title1test",2,0.0,100.0);
310  h_errbug.setBinContentAndError(1,10.0,10.0);//err is now 10
311  h_errbug.setBinContentAndError(1,4.0,2.0);//err is now sqrt(content)
312  h_errbug.compareAll();
313 
314  std::cout << " ---> Quick basic test completed"<<std::endl;
315 
316  //Very simple test of our scaleContentsAndErrors:
317  unsigned nbinsscaled(100);
318  T2 * hscale = T2::create("namescale","titlescale",nbinsscaled,0.0,100.0);
319  hscale->Fill(0.5);//ibin = 1
320  hscale->Fill(50.5,17.0);//ibin = 51
321  double scalefact=15.0;//We choose integer values 17.0 and 15.0 here to let the test pass for TH1I also.
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) {
327  double c,e;
328  hscale->GetBinContentAndError(ibin,c,e);
329  HistValFunctions::test("Scaled bin content",c,unscaled_cont.at(ibin)*scalefact);
330  HistValFunctions::test("Scaled bin error",e,unscaled_err.at(ibin)*scalefact);
331  }
332  LWHist::safeDelete(hscale);
333 
334  std::cout << " ---> Basic scaling test completed"<<std::endl;
335 
336  if (do_systematic_tests) {
337  //Systematic validation of special cases:
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);//underflow bin
344  sys_ibin.push_back(1);sys_x.push_back(0.5);//internal bin 1
345  sys_ibin.push_back(6);sys_x.push_back(5.5);//internal bin 2 (<16 bins from bin1)
346  sys_ibin.push_back(36);sys_x.push_back(35.5);//internal bin 3 (>16 bins from bin1 and bin2)
347 #ifdef LW_STRICT_ROOT_BEHAVIOUR
348  sys_ibin.push_back(nbins+1);sys_x.push_back(xmax+10.0);//overflow bin
349  sys_ibin.push_back(nbins+USHRT_MAX+100);sys_x.push_back(std::numeric_limits<float>::quiet_NaN());//bin out of range and x NaN
350 #endif
351  unsigned npoints=sys_ibin.size();
352  assert(npoints==sys_x.size());
353  std::vector<double> sys_args;
354  sys_args.push_back(0.0);
355  //FIXME: sys_args.push_back(std::numeric_limits<float>::quiet_NaN());
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);
361 
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)
378  {
379  ++itest;
380  SYSTEST("------------> 1D Test number "<<itest);
381  HistVal1D<T1,T2> h(trigger_conversion_all,
382  "systname","systtitle",nbins,xmin,xmax);
383  h.setCompareBinContentsOnEachFill(expecterror);
384 
385  i=sys_ibin.at(ipoint1);x=sys_x.at(ipoint1); a=sys_args.at(iarg1);
386 
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
391  //only compatible when SetBinError is last when not in strict mode
392  if (doSetBinError_1) { SYSTEST("setBinError("<<i<<", "<<a<<")"); h.setBinError(i,a); }
393 #endif
394 
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
400  //only compatible when SetBinError is last when not in strict mode
401  if (doSetBinError_1) { SYSTEST("setBinError("<<i<<", "<<a<<")"); h.setBinError(i,a); }
402 #endif
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); }
406  }
407  std::cout << " ---> Systematic tests ("<<itest<<") completed"<<std::endl;
408  }
409 
410  float * xbins = new float[5];
411  xbins[0] = 0.0;
412  xbins[1] = 1.0;
413  xbins[2] = 2.7;
414  xbins[3] = 2.701;
415  xbins[4] = 10.0;
416  HistVal1D<T1,T2> h6(trigger_conversion_all,
417  "name6","title6",4,xbins);
418  delete[] xbins;
419  h6.fill(2.6);h6.compareAll();
420  h6.fill(2.7);h6.compareAll();
421  h6.fill(0.0);h6.compareAll();
422  h6.fill(10.0,1.2);h6.compareAll();
423  h6.fill(-20.0);h6.compareAll();
424  h6.fill(12.0);h6.compareAll();
425  h6.fill(5.0);h6.compareAll();
426  h6.fill(1.2);h6.compareAll();
427  std::cout << " ---> Variable binning tests completed"<<std::endl;
428 
429  fillInVariousWays_int(h,true,true);
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);//not small()!
433  std::cout << " ---> Various filling tests completed"<<std::endl;
434 
435 }

◆ basicValidation2D()

template<class T1 , class T2 >
void basicValidation2D ( bool  trigger_conversion_all,
int &  icount,
bool  verbose 
)

Definition at line 438 of file main_validation.cxx.

438  {
439  //Test name/title:
440  HistVal2D<T1,T2> h(trigger_conversion_all,
441  "name1","title1",100,-10.0,80.0,50,10.0,1230.0);
442  setNamesAndTitles(icount, h);
443  HistVal2D<T1,T2> h2(trigger_conversion_all,
444  "name1","",100,0.0,17.0,50,10.0,1230.0);
445  setNamesAndTitles(icount, h2);
446  HistVal2D<T1,T2> h3(trigger_conversion_all,
447  "","title3",100,0.0,17.0,50,10.0,1230.0);
448  setNamesAndTitles(icount, h3);
449  HistVal2D<T1,T2> h4(trigger_conversion_all,
450  "","",100,0.0,17.0,50,10.0,1230.0);
451  setNamesAndTitles(icount, h4);
452  std::cout << " ---> Quick basic test completed"<<std::endl;
453  fillInVariousWays_int2d(h,true,true);
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;
456 
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);//underflow bin
465  sys_ibin.push_back(2);sys_x.push_back(1.5);//internal bin
466 #ifdef LW_STRICT_ROOT_BEHAVIOUR
467  sys_ibin.push_back(nbins+1);sys_x.push_back(xmax+10.0);//overflow bin
468  sys_ibin.push_back(nbins+USHRT_MAX+100);sys_x.push_back(std::numeric_limits<float>::quiet_NaN());//bin out of range and x NaN
469 #endif
470  unsigned npoints=sys_ibin.size();
471  assert(npoints==sys_x.size());
472  std::vector<double> sys_args;
473  sys_args.push_back(0.0);
474  //FIXMEsys_args.push_back(std::numeric_limits<float>::quiet_NaN());
475  sys_args.push_back(-17.0);
476  sys_args.push_back(17.0);
477 
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)
487  {
488  ++itest;
489  SYSTEST("------------> 2D Test number "<<itest)
490  HistVal2D<T1,T2> h(trigger_conversion_all,
491  "systname","systtitle",nbins,xmin,xmax,nbins,xmin,xmax);
492  h.setCompareBinContentsOnEachFill(expecterror);
493 
494  ibinx=sys_ibin.at(ix);x=sys_x.at(ix);
495  ibiny=sys_ibin.at(ix);y=sys_x.at(ix);
496  a=sys_args.at(iarg);
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); }
501  }
502  std::cout << " ---> Systematic tests ("<<itest<<") completed"<<std::endl;
503  }
504  float * xbins = new float[5];
505  xbins[0] = 0.0;
506  xbins[1] = 1.0;
507  xbins[2] = 2.7;
508  xbins[3] = 2.701;
509  xbins[4] = 10.0;
510  double * xbinsd = new double[5];
511  xbinsd[0] = 0.0;
512  xbinsd[1] = 1.0;
513  xbinsd[2] = 2.7;
514  xbinsd[3] = 2.701;
515  xbinsd[4] = 10.0;
516  float * ybins = new float[3];
517  ybins[0] = -20.0;
518  ybins[1] = 0.0;
519  ybins[2] = 100.0;
520  double * ybinsd = new double[3];
521  ybinsd[0] = -20.0;
522  ybinsd[1] = 0.0;
523  ybinsd[2] = 100.0;
524  HistVal2D<T1,T2> h6(trigger_conversion_all,
525  "name6","title6",4,xbins,2,ybins);
526  HistVal2D<T1,T2> h7(trigger_conversion_all,
527  "name7","title7",4,xbinsd,2,ybinsd);
528  HistVal2D<T1,T2> h8(trigger_conversion_all,
529  "name8","title8",4,xbinsd,2,-20.0,100.0);
530  HistVal2D<T1,T2> h9(trigger_conversion_all,
531  "name9","title9",4,0.0,10.0,2,ybinsd);
532  delete[] xbins;
533  delete[] ybins;
534  delete[] xbinsd;
535  delete[] ybinsd;
536 
537  const double eps=1e-5;
538 
539  h6.fill(2.6,1.0);h6.compareAll();
540  h6.fill(2.7,1.0);h6.compareAll();
541  h6.fill(0.0,1.0);h6.compareAll();
542  h6.fill(10.0,1.2,1.0);h6.compareAll();
543  h6.fill(-20.0,1.0);h6.compareAll();
544  h6.fill(12.0,1.0);h6.compareAll();
545  h6.fill(5.0,1.0);h6.compareAll();
546  h6.fill(1.2,1.0);h6.compareAll();
547 
548  h7.fill(2.6,1.0);h7.compareAll();
549  h7.fill(2.7+eps,1.0);h7.compareAll();
550  h7.fill(0.0,1.0);h7.compareAll();
551  h7.fill(10.0,1.2,1.0);h7.compareAll();
552  h7.fill(-20.0,1.0);h7.compareAll();
553  h7.fill(12.0,1.0);h7.compareAll();
554  h7.fill(5.0,1.0);h7.compareAll();
555  h7.fill(1.2,1.0);h7.compareAll();
556 
557  h8.fill(2.6,1.0);h8.compareAll();
558  h8.fill(2.7+eps,1.0);h8.compareAll();
559  h8.fill(0.0,1.0);h8.compareAll();
560  h8.fill(10.0,1.2,1.0);h8.compareAll();
561  h8.fill(-20.0,1.0);h8.compareAll();
562  h8.fill(12.0,1.0);h8.compareAll();
563  h8.fill(5.0,1.0);h8.compareAll();
564  h8.fill(1.2,1.0);h8.compareAll();
565 
566  h9.fill(2.6,1.0);h9.compareAll();
567  h9.fill(2.7,1.0);h9.compareAll();
568  h9.fill(0.0,1.0);h9.compareAll();
569  h9.fill(10.0,1.2,1.0);h9.compareAll();
570  h9.fill(-20.0,1.0);h9.compareAll();
571  h9.fill(12.0,1.0);h9.compareAll();
572  h9.fill(5.0,1.0);h9.compareAll();
573  h9.fill(1.2,1.0);h9.compareAll();
574 
575  std::cout << " ---> Variable binning tests completed"<<std::endl;
576 }

◆ basicValidation_Profile()

void basicValidation_Profile ( bool  trigger_conversion_all,
int &  icount,
bool  verbose,
bool  do_systematic_tests = true 
)

Definition at line 639 of file main_validation.cxx.

643 {
644  //Basic usage of methods:
645  HistValProfile a(trigger_conversion_all,
646  "aprofilehist","a title for my profile hist",100, 0.0, 100.0 );
647  setNamesAndTitles(icount, a);
648 
649  a.compareAll();
650  a.fill(7.0, 10.0);
651  a.compareAll();
652  a.fill(91.5,20.0,5.0);
653  a.compareAll();
654  a.fill(81.5,-20.0,-5.0);
655  a.compareAll();
656  a.setBinEntries(20, 5.5);
657  a.compareAll();
658  a.setBinContent(30, 20.2);
659  a.compareAll();
660  a.setBinError(40, 23.4);
661  a.compareAll();
662  a.setBinInfo(50, 1.0,2.0,3.0);
663  a.compareAll();
664 
665 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
666  double weight = 1;
667 #else
668  double weight = 3;
669 #endif
670 
671  //test ranges on the profile par
672  HistValProfile b(trigger_conversion_all,
673  "anotherprofilehist","another title for my profile hist",100, 0.0, 100.0 );
674  b.fill(30.0,-1.0);
675  b.fill(30.0,0.0);
676  b.fill(30.0,0.5);
677  b.fill(30.0,1.0);
678  b.fill(30.0,2.0);
679  b.fill(30.0,-1.0,weight);
680  b.fill(30.0,0.0,weight);
681  b.fill(30.0,0.5,weight);
682  b.fill(30.0,1.0,weight);
683  b.fill(30.0,2.0,weight);
684  b.compareAll();
685 
686  HistValProfile b2(trigger_conversion_all,
687  "yetanotherprofilehist","bla",100, 0.0, 100.0, -1.0,2.0 );
688  b2.fill(30.0,-1.0);
689  b2.fill(30.0,0.0);
690  b2.fill(30.0,0.5);
691  b2.fill(30.0,1.0);
692  b2.fill(30.0,2.0);
693  b2.fill(30.0,-1.0,weight);
694  b2.fill(30.0,0.0,weight);
695  b2.fill(30.0,0.5,weight);
696  b2.fill(30.0,1.0,weight);
697  b2.fill(30.0,2.0,weight);
698  b2.compareAll();
699 
700  std::cout << " ---> Quick basic test completed"<<std::endl;
701  //Systematic:
702  if (do_systematic_tests) {
703  //Systematic validation of special cases:
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);
709  //NB: Important that these match up (x vs. ibin)!:
710  sys_ibin.push_back(0);sys_x.push_back(xmin-10.0);//underflow bin
711  sys_ibin.push_back(1);sys_x.push_back(0.5);//internal bin 1
712  sys_ibin.push_back(6);sys_x.push_back(5.5);//internal bin 2 (<16 bins from bin1)
713  sys_ibin.push_back(36);sys_x.push_back(35.5);//internal bin 3 (>16 bins from bin1 and bin2)
714 #ifdef LW_STRICT_ROOT_BEHAVIOUR
715  sys_ibin.push_back(nbins+1);sys_x.push_back(xmax+10.0);//overflow bin
716  //sys_ibin.push_back(nbins+USHRT_MAX+100);sys_x.push_back(std::numeric_limits<float>::quiet_NaN());//bin out of range and x NaN
717 #endif
718  unsigned npoints=sys_ibin.size();
719  assert(npoints==sys_x.size());
720  std::vector<double> sys_args;
721  sys_args.push_back(0.0);
722  //FIXME: sys_args.push_back(std::numeric_limits<float>::quiet_NaN());
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);
728 
729  const bool expecterror(false);
730  //#define SYSTEST(x) { if (verbose) { std::cout<<"Systematic filling: "<<x<<std::endl;} }
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)
737 #ifdef LW_EXTRATESTS
738  for (unsigned doFillXW_1 = 0;doFillXW_1<=1;++doFillXW_1)
739 #endif
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)
743 #ifdef LW_EXTRATESTS
744  for (unsigned doFillX_2 = 0;doFillX_2<=1;++doFillX_2)
745 #endif
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)
751  {
752  ++itest;
753  SYSTEST("------------> 1D-profile Test number "<<itest);
754  HistValProfile h(trigger_conversion_all,
755  "systname","systtitle",nbins,xmin,xmax);
756  h.setCompareBinContentsOnEachFill(expecterror);
757 
758  i=sys_ibin.at(ipoint1);x=sys_x.at(ipoint1); a=sys_args.at(iarg1),a2=sys_args.at(iarg2);
759 
760  bool cansetdirectly_1(false);
761  if (doFillX_1) { SYSTEST("Fill("<<x<<","<<a<<")"); h.fill(x,a); cansetdirectly_1=true;}
762 #ifdef LW_EXTRATESTS
763  if (doFillXW_1) { SYSTEST("Fill("<<x<<", "<<a<<", "<<a2<<")"); h.fill(x,a,a2); cansetdirectly_1=true;}
764 #endif
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); }
768 
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
772  a2 = 1;
773 #endif
774 #ifdef LW_EXTRATESTS
775  if (doFillX_2) { SYSTEST("Fill("<<x<<", "<<a<<")"); h.fill(x,a); cansetdirectly_2 = true; }
776 #endif
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); }
780  if (doSetBinInfo_2)
781  { SYSTEST("setBinInfo("<<i<<", "<<a<<", "<<a2<<", 17.0)"); h.setBinInfo(i,a,a2,17.0); }
782  }
783  std::cout << " ---> Systematic tests ("<<itest<<") completed"<<std::endl;
784  }
785 
786  //Floating point precision tests (since we use floats internally
787  //rather than doubles):
788 
789  //First a quickie with many fills in one bin (well, we keep it at O(10^6) due to floats).
790  unsigned ifptests(1);
791  HistValProfile h_fp(trigger_conversion_all,
792  "profhist_fptest0","sometitle",1, 0.0, 1.0 );
793  h_fp.setCompareBinContentsOnEachFill(false);
794  for (long long unsigned i=0;i<1000000;++i)
795  //h_fp.fill(0.5,1.0);
797  h_fp.fill(0.5,1.2*(i%10));
798 #else
799  h_fp.fill(0.5,1.2*(i%10),0.5+i%3);
800 #endif
801  h_fp.compareAll();
802  //Then a bit more systematic:
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);
809  // fptest_profpar.push_back(2.5);
810  fptest_profpar.push_back(5.0);
811  // fptest_profpar.push_back(100.0);
812  fptest_profpar.push_back(10000.0);
813 
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);//== use unweighted fill.
818  fptest_weight.push_back(1.2);
819  fptest_weight.push_back(100.0);
820  fptest_weight.push_back(1000.0);
821 
822  //fptest_profpar.size()*fptest_weight.size() combinations (~40-50)
823  //Use 50**3 times, i.e. fill three times.
824 
825  const bool expecterror(false);
826  double pp, w;
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)
833  {
834  ++ifptests;
835  HistValProfile h(trigger_conversion_all,
836  "profhist_fptest","sometitle",1, 0.0, 1.0 );
837  h.setCompareBinContentsOnEachFill(expecterror);
838 
839  if (verbose)
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
843  w = 1;
844 #endif
845  if (verbose)
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);
848 
849  pp = fptest_profpar.at(ipp2); w = fptest_weight.at(iw2);
850 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
851  w = 1;
852 #endif
853  if (verbose)
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);
856 
857  pp = fptest_profpar.at(ipp3); w = fptest_weight.at(iw3);
858 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
859  w = 1;
860 #endif
861  if (verbose)
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);
864 
865  }
866  std::cout << " ---> Floating point precision tests ("<<ifptests<<") completed"<<std::endl;
867 
868  float * xbins = new float[5];
869  xbins[0] = 0.0;
870  xbins[1] = 1.0;
871  xbins[2] = 2.7;
872  xbins[3] = 2.701;
873  xbins[4] = 10.0;
874  HistValProfile c(trigger_conversion_all,
875  "profvarbins","profile with varbins",4, xbins );
876  delete[] xbins;
877  c.fill(0.1,1.20);//,2.0);
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
882  double weight2 = 1;
883 #else
884  double weight2 = 2;
885 #endif
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;
893 }

◆ basicValidation_Profile2D()

void basicValidation_Profile2D ( bool  trigger_conversion_all,
int &  icount,
bool  verbose,
bool  do_systematic_tests = true 
)

Definition at line 895 of file main_validation.cxx.

899 {
900  //Basic usage of methods:
901  HistValProfile2D a(trigger_conversion_all,
902  "a2dprofilehist","a title for my 2d profile hist",100, 0.0, 100.0,100, 0.0, 100.0 );
903  setNamesAndTitles(icount, a);
904 
905 
906  a.compareAll();
907  a.fill(7.0, 17.0,10.0);
908  a.compareAll();
909 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
910  a.fill(91.5,17.0, 20.0);
911 #else
912  a.fill(91.5,17.0, 20.0,5.0);
913 #endif
914  a.compareAll();
915 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
916  a.fill(81.5,17.0,-20.0);
917 #else
918  a.fill(81.5,17.0,-20.0,-5.0);
919 #endif
920  a.compareAll();
921  a.setBinEntries(20, 17,5.5);
922  a.compareAll();
923  a.setBinContent(30, 17, 20.2);
924  a.compareAll();
925  a.setBinError(40, 17, 23.4);
926  a.compareAll();
927  a.setBinInfo(50, 17, 1.0,2.0,3.0);
928  a.compareAll();
929 
930 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
931  double weight = 1;
932 #else
933  double weight = 3;
934 #endif
935 
936  //test ranges on the profile par
937  HistValProfile2D b(trigger_conversion_all,
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);
945  b.fill(30.0,10.0,-1.0,weight);
946  b.fill(30.0,10.0,0.0,weight);
947  b.fill(30.0,10.0,0.5,weight);
948  b.fill(30.0,10.0,1.0,weight);
949  b.fill(30.0,10.0,2.0,weight);
950 
951  std::cout << " ---> Quick basic test completed"<<std::endl;
952  //Systematic:
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);//underflow bin
960  sys_ibin.push_back(2);sys_x.push_back(1.5);//internal bin
961 #ifdef LW_STRICT_ROOT_BEHAVIOUR
962  sys_ibin.push_back(nbins+1);sys_x.push_back(xmax+10.0);//overflow bin
963  //sys_ibin.push_back(nbins+USHRT_MAX+100);sys_x.push_back(std::numeric_limits<float>::quiet_NaN());//bin out of range and x NaN
964 #endif
965  unsigned npoints=sys_ibin.size();
966  assert(npoints==sys_x.size());
967  std::vector<double> sys_args;
968  sys_args.push_back(0.0);
969  //FIXMEsys_args.push_back(std::numeric_limits<float>::quiet_NaN());
970  sys_args.push_back(-17.0);
971  sys_args.push_back(17.0);
972 
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)
985  {
986  if (doSetBinError_1&&!doSetBinEntries_1)
987  continue;//We can't call setBinError unless we are sure there are some entries.
988  ++itest;
989  SYSTEST("------------> 2D-profile Test number "<<itest)
990  HistValProfile2D h(trigger_conversion_all,
991  "systname","systtitle",nbins,xmin,xmax,nbins,xmin,xmax);
992  h.setCompareBinContentsOnEachFill(expecterror);
993 
994  ibinx=sys_ibin.at(ix);x=sys_x.at(ix);
995  ibiny=sys_ibin.at(ix);y=sys_x.at(ix);
996  a=sys_args.at(iarg);
997  a2=sys_args.at(iarg2);
998 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
999  a = 1;
1000  a2 = 1;
1001 #endif
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); }
1004  //Fixme: setbinentries? setbininfo
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); }
1008  if (doSetBinInfo_1)
1009  { SYSTEST("setBinInfo("<<ibinx<<", "<<ibiny<<", "<<a<<", "<<a2<<", 17.0)"); h.setBinInfo(ibinx,ibiny,a,a2,17.0); }
1010 
1011  }
1012  std::cout << " ---> Systematic tests ("<<itest<<") completed"<<std::endl;
1013  }
1014 
1015  double * xbins = new double[5];
1016  xbins[0] = 0.0;
1017  xbins[1] = 1.0;
1018  xbins[2] = 2.7;
1019  xbins[3] = 2.701;
1020  xbins[4] = 10.0;
1021  double * ybins = new double[3];
1022  ybins[0] = -20.0;
1023  ybins[1] = 0.0;
1024  ybins[2] = 100.0;
1025  HistValProfile2D hvb(trigger_conversion_all,
1026  "hvb","sometitle",4,xbins,2,ybins);
1027  delete[] xbins;
1028  delete[] ybins;
1029  const double eps(1.0e-4);//we use epsilon to avoid edges due to
1030  //double vs. float used for binning in root
1031  //vs. lwhists.
1032  hvb.compareAll();
1033  hvb.fill(2.6,1.0,2.0,2.0); hvb.compareAll();
1034  hvb.fill(2.7+eps,1.0, 2.0);hvb.compareAll();
1035  hvb.fill(0.0+eps,1.0, 2.0);hvb.compareAll();
1036 #ifdef LW_OLD_WEIGHTED_PROFILE_ERRORS
1037  hvb.fill(10.0-eps,1.0, 1.0);hvb.compareAll();
1038 #else
1039  hvb.fill(10.0-eps,1.0, 1.0,2.0);hvb.compareAll();
1040 #endif
1041  hvb.fill(-20.0,1.0, 2.0);hvb.compareAll();
1042  hvb.fill(12.0,1.0, 2.0);hvb.compareAll();
1043  hvb.fill(5.0,1.0, 2.0);hvb.compareAll();
1044  hvb.fill(1.2,1.0, 2.0);hvb.compareAll();
1045 }

◆ fillInVariousWays() [1/2]

template<class T1 , class T2 >
void fillInVariousWays ( bool  trigger_conversion_all,
int  nbins,
double  xmin,
double  xmax 
)

Definition at line 179 of file main_validation.cxx.

181 {
182  //Either Fill(x) or Fill(x,w):
183  HistVal1D<T1,T2> h1(trigger_conversion_all,
184  "name1a","title1",nbins,xmin,xmax);
185  fillInVariousWays_int(h1,true,false);
186  HistVal1D<T1,T2> h2(trigger_conversion_all,
187  "name1b","title1",nbins,xmin,xmax);
188  fillInVariousWays_int(h2,false,true);
189 
190  //First Fill(x), then Fill(x,w):
191  HistVal1D<T1,T2> h3(trigger_conversion_all,
192  "name1c","title1",nbins,xmin,xmax);
193  fillInVariousWays_int(h3,true,false);
194  fillInVariousWays_int(h3,false,true);
195 
196  //First Fill(x,w), then Fill(x):
197  HistVal1D<T1,T2> h4(trigger_conversion_all,
198  "name1d","title1",nbins,xmin,xmax);
199  fillInVariousWays_int(h4,false,true);
200  fillInVariousWays_int(h4,true,false);
201 
202  //Fill slowly to pass through char, short and full stages:
203  HistVal1D<T1,T2> h5(trigger_conversion_all,
204  "name1e","title1",nbins,xmin,xmax);
205  for (unsigned i=0; i<UCHAR_MAX+10;++i)
206  h5.fill(17);
207  h5.setCompareBinContentsOnEachFill(false);//Disable since we will have maaany calls.
208  for (unsigned i=0; i<USHRT_MAX;++i)
209  h5.fill(17);
210  h5.compareAll();
211 
212  //Fill - with weights - in a way which allows us pass through char,
213  //short and full stages:
214 
215  //Char->Short->Full:
216  HistVal1D<T1,T2> h6(trigger_conversion_all,
217  "name1f","title1",nbins,xmin,xmax);
218  h6.fill(17,1.0);
219  h6.fill(17,UCHAR_MAX+1.0);
220  h6.fill(17,USHRT_MAX+1.0);
221  //Char->Full:
222  HistVal1D<T1,T2> h7(trigger_conversion_all,
223  "name1g","title1",nbins,xmin,xmax);
224  h6.fill(17,1.0);
225  h6.fill(17,UCHAR_MAX+USHRT_MAX+1.0);
226 }

◆ fillInVariousWays() [2/2]

template<class T1 , class T2 >
void fillInVariousWays ( bool  trigger_conversion_all,
int  nbinsx,
double  xmin,
double  xmax,
int  nbinsy,
double  ymin,
double  ymax 
)

Definition at line 142 of file main_validation.cxx.

145 {
146  //Either Fill(x) or Fill(x,w):
147  HistVal2D<T1,T2> h1(trigger_conversion_all,
148  "name1a","title1",nbinsx,xmin,xmax,nbinsy,ymin,ymax);
149  fillInVariousWays_int2d(h1,true,false);
150  HistVal2D<T1,T2> h2(trigger_conversion_all,
151  "name1b","title1",nbinsx,xmin,xmax,nbinsy,ymin,ymax);
152  fillInVariousWays_int2d(h2,false,true);
153 
154  //First Fill(x), then Fill(x,w):
155  HistVal2D<T1,T2> h3(trigger_conversion_all,
156  "name1c","title1",nbinsx,xmin,xmax,nbinsy,ymin,ymax);
157  fillInVariousWays_int2d(h3,true,false);
158  fillInVariousWays_int2d(h3,false,true);
159 
160  //First Fill(x,w), then Fill(x):
161  HistVal2D<T1,T2> h4(trigger_conversion_all,
162  "name1d","title1",nbinsx,xmin,xmax,nbinsy,ymin,ymax);
163  fillInVariousWays_int2d(h4,false,true);
164  fillInVariousWays_int2d(h4,true,false);
165 
166  //Fill slowly to pass through char, short and full stages:
167  HistVal2D<T1,T2> h5(trigger_conversion_all,
168  "name1e","title1",nbinsx,xmin,xmax,nbinsy,ymin,ymax);
169  for (unsigned i=0; i<UCHAR_MAX+10;++i)
170  h5.fill(17,18);
171  h5.setCompareBinContentsOnEachFill(false);//Disable since we will have maaany calls.
172  for (unsigned i=0; i<USHRT_MAX;++i)
173  h5.fill(17,18);
174  h5.compareAll();
175 
176 }

◆ fillInVariousWays_int()

template<class HistVal >
void fillInVariousWays_int ( HistVal &  h,
bool  doUnitWeight,
bool  doFloatWeight 
)

Definition at line 229 of file main_validation.cxx.

230 {
232  std::vector<double> x(getXValues());
233 
234  //Fill(x):
235  if (doUnitWeight)
236  for (unsigned ix=0; ix<x.size();++ix)
237  h.fill(x.at(ix));
238 
239  h.compareAll();
240  //Fill(x,w):
241  if (doFloatWeight)
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));
245 
246  h.compareAll();
247 }

◆ fillInVariousWays_int2d()

template<class HistVal >
void fillInVariousWays_int2d ( HistVal &  h,
bool  doUnitWeight,
bool  doFloatWeight 
)

Definition at line 250 of file main_validation.cxx.

251 {
253  std::vector<double> x(getXValues());
254 
255  //Fill(x):
256  if (doUnitWeight) {
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));
261  }
262  h.setCompareBinContentsOnEachFill(true);
263  }
264  h.compareAll();
265  //Fill(x,w):
266  if (doFloatWeight) {
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));
273  }
274  h.setCompareBinContentsOnEachFill(true);
275  }
276  h.compareAll();
277 }

◆ getWeights()

std::vector<double> getWeights ( bool  is_int)

Definition at line 59 of file main_validation.cxx.

60 {
61  std::vector<double> w;
62  w.push_back(1.0);//unit
63  w.push_back(0.0);//zero
64  w.push_back(8.0);//positive integer
65  w.push_back(-1.0);//negative unit
66  w.push_back(-7.0);//negative integer
67  w.push_back(4.655);//positive
68  w.push_back(-4.252);//negative
69  w.push_back(2.655);//positive
70  w.push_back(4.251);//positive (different trunc vs. round from above)
71  w.push_back(-4.257);//negativ (different trunc vs. round from above)
72  w.push_back(2.251);//positive (different trunc vs. round from above)
73  if (!is_int) {
74  w.push_back(5.0e9);//Out of int range
75  w.push_back(-8.0e9);//Out of int range
76  }
77  return w;
78 }

◆ getXValues()

std::vector<double> getXValues ( )

Definition at line 47 of file main_validation.cxx.

48 {
49  std::vector<double> x;
50  x.push_back(5.4);//inside
51  x.push_back(0.0);//= hist edge
52  x.push_back(100.0);//= hist edge
53  x.push_back(-20.0);//underflow
54  x.push_back(10.0);//inside
55  x.push_back(1123.0);//overflow
56  return x;
57 }

◆ setNamesAndTitles()

template<class HistVal >
void setNamesAndTitles ( int &  icount,
HistVal &  hist 
)

Definition at line 81 of file main_validation.cxx.

81  {
82  hist.setName("name1");
83  hist.setName("name2");
84  hist.setName("title1");//not typo
85  hist.setTitle("");
86  hist.setTitle("title2");
87  hist.setName("name3");
88  hist.setNameTitle("someothername","someothertitle");
89 
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");
98 
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");
113 
114  hist.compareAll();
115  hist.SetMarkerStyle( 3 );
116  hist.compareAll();
117  hist.SetMarkerColor( 4 );
118  hist.compareAll();
119  hist.SetMarkerSize( 1.02 );
120  hist.compareAll();
121  switch (icount%5) {
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;
128  };
129  hist.compareAll();
130  switch (icount%5) {
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;
137  };
138  ++icount;
139 }

◆ stressTestValidation()

template<class T1 , class T2 >
void stressTestValidation ( bool  trigger_conversion_all)

Definition at line 579 of file main_validation.cxx.

579  {
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);
585  assert(u>l);
586  std::ostringstream s;
587  s<<"n"<<ih;
588  HistVal1D<T1,T2> htest1(trigger_conversion_all,
589  s.str(),"t"+s.str(),rand()%maxbins+1,l,u);
590  s<<"b";
591  HistVal1D<T1,T2> htest2(trigger_conversion_all,
592  s.str(),"t"+s.str(),rand()%maxbins+1,l,u);
593  s<<"c";
594  double v = l;
595  unsigned ibin=0;
596  double avstep((u-l)/(rand()%maxbins+1));
597  while(true) {
598  xbins[ibin++] = v;
599  v+=avstep*((rand()*1.0*(1./RAND_MAX))+0.001)*2;
600  if (v>=u||ibin==maxbins) {
601  xbins[ibin++] = u;
602  break;
603  }
604  }
605  assert(ibin>0);
606  unsigned nvarbins = ibin-1;
607  if (nvarbins==0) {
608  nvarbins = 1;
609  xbins[0] = l;
610  xbins[1] = u;
611  }
612  assert(xbins[0]==l);
613  assert(xbins[nvarbins]==u);
614  assert(nvarbins>=1);
615  HistVal1D<T1,T2> htest3(trigger_conversion_all,
616  s.str(),"t"+s.str(),nvarbins,xbins);
617  htest1.setCompareBinContentsOnEachFill(false);
618  htest2.setCompareBinContentsOnEachFill(false);
619  htest3.setCompareBinContentsOnEachFill(false);
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.0e-6-0.1)));
623  htest1.fill(x);
624  htest2.fill(x,double(rand()%10-5+0.345));
625  htest3.fill(x);
626  if (!(i%1000)) {
627  htest1.compareBinContents();
628  htest2.compareBinContents();
629  htest3.compareBinContents();
630  }
631  }
632  htest1.compareAll();
633  htest2.compareAll();
634  htest3.compareAll();
635  }
636  delete[] xbins;
637 }
LW_OLD_WEIGHTED_PROFILE_ERRORS
#define LW_OLD_WEIGHTED_PROFILE_ERRORS
Definition: main_validation.cxx:45
AtlCoolConsole.usage
tuple usage
Definition: AtlCoolConsole.py:443
HistVal1D
Definition: HistVal1D.h:21
ymin
double ymin
Definition: listroot.cxx:63
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
basicValidation_Profile2D
void basicValidation_Profile2D(bool trigger_conversion_all, int &icount, bool verbose, bool do_systematic_tests=true)
Definition: main_validation.cxx:895
PowhegControl_ttHplus_NLO.ss
ss
Definition: PowhegControl_ttHplus_NLO.py:83
plotmaker.hist
hist
Definition: plotmaker.py:148
PixelAthClusterMonAlgCfg.ybins
ybins
Definition: PixelAthClusterMonAlgCfg.py:163
yodamerge_tmp.npoints
npoints
Definition: yodamerge_tmp.py:250
athena.value
value
Definition: athena.py:122
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
athena.exitcode
int exitcode
Definition: athena.py:159
SYSTEST
#define SYSTEST(x)
LArCellConditions.argv
argv
Definition: LArCellConditions.py:112
read_hist_ntuple.h1
h1
Definition: read_hist_ntuple.py:21
x
#define x
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:83
HistValFunctions::testTypes
void testTypes()
Definition: validatefunctions.cxx:16
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
HistVal2D
Definition: HistVal2D.h:21
HistValFunctions::test
void test(const std::string &testname, double val1, double val2)
Definition: validatefunctions.cxx:27
SCT_CalibAlgs::nbins
@ nbins
Definition: SCT_CalibNumbers.h:10
fillInVariousWays_int2d
void fillInVariousWays_int2d(HistVal &h, bool doUnitWeight, bool doFloatWeight)
Definition: main_validation.cxx:250
LArG4FSStartPointFilter.rand
rand
Definition: LArG4FSStartPointFilter.py:80
lumiFormat.i
int i
Definition: lumiFormat.py:92
xmin
double xmin
Definition: listroot.cxx:60
setNamesAndTitles
void setNamesAndTitles(int &icount, HistVal &hist)
Definition: main_validation.cxx:81
beamspotman.n
n
Definition: beamspotman.py:731
extractSporadic.h
list h
Definition: extractSporadic.py:97
LWHistControls::setROOTBackend
static void setROOTBackend(bool)
Definition: LWHistControls.cxx:53
DQHistogramMergeRegExp.argc
argc
Definition: DQHistogramMergeRegExp.py:20
WriteCalibToCool.swap
swap
Definition: WriteCalibToCool.py:94
calibdata.exit
exit
Definition: calibdata.py:236
HistValProfile2D
Definition: HistValProfile2D.h:22
create_dcsc_inputs_sqlite.arg
list arg
Definition: create_dcsc_inputs_sqlite.py:48
getXValues
std::vector< double > getXValues()
Definition: main_validation.cxx:47
LWHistControls::releaseAllHeldMemory
static void releaseAllHeldMemory()
Definition: LWHistControls.cxx:41
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
fillInVariousWays_int
void fillInVariousWays_int(HistVal &h, bool doUnitWeight, bool doFloatWeight)
Definition: main_validation.cxx:229
LArCellBinning.xbins
int xbins
Definition: LArCellBinning.py:163
python.PyAthena.v
v
Definition: PyAthena.py:157
LWHist::safeDelete
static void safeDelete(LWHist *)
Definition: LWHist.cxx:30
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
a
TList * a
Definition: liststreamerinfos.cxx:10
y
#define y
h
TH1F
Definition: rootspy.cxx:320
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
basicValidation_Profile
void basicValidation_Profile(bool trigger_conversion_all, int &icount, bool verbose, bool do_systematic_tests=true)
Definition: main_validation.cxx:639
python.TriggerHandler.verbose
verbose
Definition: TriggerHandler.py:297
xmax
double xmax
Definition: listroot.cxx:61
getWeights
std::vector< double > getWeights(bool is_int)
Definition: main_validation.cxx:59
CxxUtils::atoi
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...
Definition: Control/CxxUtils/Root/StringUtils.cxx:85
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
python.IoTestsLib.w
def w
Definition: IoTestsLib.py:200
CxxUtils::ubsan_suppress
void ubsan_suppress(void(*func)())
Helper for suppressing ubsan warnings.
Definition: ubsan_suppress.cxx:69
python.compressB64.c
def c
Definition: compressB64.py:93
HistValProfile
Definition: HistValProfile.h:22
ymax
double ymax
Definition: listroot.cxx:64