53#define INT_MAX std::numeric_limits<int>::max() 
   69      : fValue(nullptr), fDim(dim), fBins(bins), fNum(num), 
fSparse(nullptr), fHist(nullptr), 
fHn(nullptr)
 
   77         return fTime[hist][0];
 
   78      return fTime[hist][1];
 
   84   void Fill(
EHist hist);
 
  102Int_t TTimeHists::fgDebug = 0;
 
  104TTimeHists::~TTimeHists()
 
  112bool TTimeHists::Run()
 
  118   for (
int h = 0; 
h < 2; ++
h) {
 
  132         } 
while ((!
h && 
w.RealTime() < 0.1) || (
h && 
rep[0] > 0 && 
rep[1] < 
rep[0]));
 
  134         fTime[
h][0] = (1. * fNum * 
rep[
h]) / 
w.RealTime() / 1
E6;
 
  135         fTime[
h][1] = (1. * fNum * 
rep[
h]) / 
w.CpuTime() / 1
E6;
 
  137         if (
h == 1 && (fTime[
h][0] > 1
E20 || fTime[
h][1] > 1
E20)) {
 
  145            } 
while (
w.RealTime() < 0.1);
 
  147            fTime[
h][0] = (1. * fNum * 
rep[
h]) / 
w.RealTime() / 1
E6;
 
  148            fTime[
h][1] = (1. * fNum * 
rep[
h]) / 
w.CpuTime() / 1
E6;
 
  151         if (fTime[
h][0] > 1
E20)
 
  153         if (fTime[
h][1] > 1
E20)
 
  155      } 
catch (std::exception &) {
 
  156         fTime[
h][0] = fTime[
h][1] = -1.;
 
  163         printf(
"ERROR: mismatch of histogram (%g) and sparse histogram (%g) for dim=%d, bins=%d!\n", 
check[0],
 
  164                check[1], fDim, fBins);
 
  171void TTimeHists::NextValues()
 
  177void TTimeHists::SetupValues()
 
  185void TTimeHists::Fill(
EHist hist)
 
  190         printf(
"%ld: fill %s", 
n, hist == 
kHist ? (fDim < 4 ? 
"hist" : 
"arr") : 
"sparse");
 
  197         case 1: fHist->Fill(fValue[0]); 
break;
 
  198         case 2: ((
TH2F *)fHist)->Fill(fValue[0], fValue[1]); 
break;
 
  199         case 3: ((
TH3F *)fHist)->Fill(fValue[0], fValue[1], fValue[2]); 
break;
 
  200         default: 
fHn->Fill(fValue); 
break;
 
  208void TTimeHists::SetupHist(
EHist hist)
 
  212      case 1: fHist = 
new TH1F(
"h1", 
"h1", fBins, -1., 1.); 
break;
 
  213      case 2: fHist = 
new TH2F(
"h2", 
"h2", fBins, -1., 1., fBins, -1., 1.); 
break;
 
  214      case 3: fHist = 
new TH3F(
"h3", 
"h3", fBins, -1., 1., fBins, -1., 1., fBins, -1., 1.); 
break;
 
  222               throw std::bad_alloc();
 
  226            throw std::bad_alloc();
 
  263      while (
x[0] <= fBins + 1) {
 
  273            v = 
fHn->GetBinContent(
x);
 
  280         if (fgDebug > 2 || (fgDebug > 1 && 
v)) {
 
  281            printf(
"%s%d", fDim < 4 ? 
"hist" : 
"arr", fDim);
 
  290         for (
Int_t d = fDim - 1; 
d > 0; --
d) {
 
  291            if (
x[
d] > fBins + 1) {
 
  316      printf(
"check %s%d = %g\n", hist == 
kHist ? (fDim < 4 ? 
"hist" : 
"arr") : 
"sparse", fDim, 
check);
 
  324#if defined(__CLING__) 
  325   printf(
"Please run this script in compiled mode by running \".x hist103_THnSparse_hist.C+\"\n");
 
  329   TH2F *
htime[TTimeHists::kNumHist][TTimeHists::kNumTime];
 
  330   for (
int h = 0; 
h < TTimeHists::kNumHist; ++
h)
 
  331      for (
int t = 0; t < TTimeHists::kNumTime; ++t) {
 
  341         title.
Form(
"Throughput (fill,get) %s (%s, 1M entries/sec);dim;bins;1M entries/sec",
 
  342                    h == 0 ? 
"TH1/2/3/nF" : 
"THnSparseF", t == 0 ? 
"real" : 
"CPU");
 
  347      new TH2F(
"hsparse_mem", 
"Fractional memory usage;dim;bins;fraction of memory used", 6, 0.5, 6.5, 10, 5, 105);
 
  348   TH2F *
hsparse_bins = 
new TH2F(
"hsparse_bins", 
"Fractional number of used bins;dim;bins;fraction of filled bins", 6,
 
  349                                 0.5, 6.5, 10, 5, 105);
 
  353   for (
Int_t dim = 1; dim < 7; ++dim) {
 
  354      printf(
"Processing dimension %d", dim);
 
  355      for (
Int_t bins = 10; bins <= 100; bins += 10) {
 
  358         for (
int h = 0; 
h < TTimeHists::kNumHist; ++
h) {
 
  359            for (
int t = 0; t < TTimeHists::kNumTime; ++t) {
 
  360               Double_t time = 
timer.GetTime((TTimeHists::EHist)
h, (TTimeHists::ETime)t);
 
  362                  htime[
h][t]->Fill(dim, bins, time);
 
  368         if (max < 
timer.GetTime(TTimeHists::kSparse, TTimeHists::kReal))
 
  369            max = 
timer.GetTime(TTimeHists::kSparse, TTimeHists::kReal);
 
  381   for (
int t = 0; t < TTimeHists::kNumTime; ++t) {
 
  382      const char *
name = t ? 
"htime_ratio" : 
"htime_ratio_r";
 
  385      title.
Form(
"Relative speed improvement (%s, 1M entries/sec): sparse/hist;dim;bins;#Delta 1M entries/sec",
 
  386                 t == 0 ? 
"real" : 
"CPU");
 
  393   TFile *
f = 
new TFile(
"sparsehist.root", 
"RECREATE");
 
  401   const char *opt = 
"TEXT COL";
 
  403   for (
int t = 0; t < TTimeHists::kNumTime; ++t) {
 
  404      for (
int h = 0; 
h < TTimeHists::kNumHist; ++
h) {
 
  405         htime[
h][t]->SetMaximum(max);
 
  407         canv->cd(1 + 
h + 3 * t);
 
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
 
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
 
THnSparseT< TArrayF > THnSparseF
 
R__EXTERN TRandom * gRandom
 
R__EXTERN TStyle * gStyle
 
R__EXTERN TSystem * gSystem
 
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
 
1-D histogram with a float per channel (see TH1 documentation)
 
TH1 is the base class of all histogram classes in ROOT.
 
2-D histogram with a float per channel (see TH1 documentation)
 
3-D histogram with a float per channel (see TH1 documentation)
 
Efficient multidimensional histogram.
 
Multidimensional histogram.
 
virtual Double_t Gaus(Double_t mean=0, Double_t sigma=1)
Samples a random number from the standard Normal (Gaussian) Distribution with the given mean and sigm...
 
virtual void SetSeed(ULong_t seed=0)
Set the random generator seed.
 
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
 
void SetOptStat(Int_t stat=1)
The type of information printed in the histogram statistics box can be selected via the parameter mod...
 
void SetPaintTextFormat(const char *format="g")
 
void SetPalette(Int_t ncolors=kBird, Int_t *colors=nullptr, Float_t alpha=1.)
See TColor::SetPalette.
 
virtual int GetMemInfo(MemInfo_t *info) const
Returns ram and swap memory usage info into the MemInfo_t structure.