ndmspc 0.20250304.0
Loading...
Searching...
No Matches
ndh-stress.cxx
1#include <TFile.h>
2#include <TH2.h>
3#include "HnSparse.h"
4#include "HnSparseStress.h"
5#include "ndmspc.h"
6
7int main(int argc, char ** argv)
8{
9 Printf("%s v%s-%s", NDMSPC_NAME, NDMSPC_VERSION, NDMSPC_VERSION_RELEASE);
10
11 Long64_t size = 1e5;
12 bool bytes = false;
13 std::string filename = "/tmp/HnSparse.root";
14 bool projections = false;
15
16 int nDim = 10;
17 int nBins = 1000;
18 double min = -(double)nBins / 2;
19 double max = (double)nBins / 2;
20 Long64_t chunkSize = 1024 * 1024;
21
22 Int_t bins[nDim];
23 Double_t mins[nDim];
24 Double_t maxs[nDim];
25 for (Int_t i = 0; i < nDim; i++) {
26 bins[i] = nBins;
27 mins[i] = min;
28 maxs[i] = max;
29 }
30
31 Ndmspc::Ndh::HnSparseD * h = new Ndmspc::Ndh::HnSparseD("hNStress", "hNStress", nDim, bins, mins, maxs, chunkSize);
32
34
35 TStopwatch timeStress;
36 timeStress.Start();
37 stress.Stress(h, size, bytes);
38 timeStress.Stop();
39 timeStress.Print("m");
40 h->Print();
41 Long64_t nBinsSizeBytes = sizeof(Double_t) * h->GetNbins();
42 Printf("size : %03.2f MB (%lld B)", (double)nBinsSizeBytes / (1024 * 1024), nBinsSizeBytes);
43
44 TStopwatch timeWrite;
45 timeWrite.Start();
46 TFile * f = TFile::Open(filename.data(), "RECREATE");
47 f->SetCompressionSettings(ROOT::RCompressionSetting::EDefaults::kUseAnalysis);
48 Printf("Writing histogram ...");
49 h->Write();
50 if (projections) {
51 Printf("Creating and writing projections ...");
52 for (Int_t i = 0; i < nDim; i++) {
53 ((TH1 *)h->Projection(i))->Write();
54 for (Int_t j = 0; j < nDim; j++) {
55 if (i == j) continue;
56 ((TH2 *)h->Projection(j, i))->Write();
57 }
58 }
59 }
60 f->Close();
61 timeWrite.Stop();
62 timeWrite.Print("m");
63 Printf("Output was saved in '%s' size : %.2f MB (%lld B)", filename.data(),
64 (double)f->GetBytesWritten() / (1024 * 1024), f->GetBytesWritten());
65
66 return 0;
67}
HnSparseStress object.
virtual Bool_t Stress(HnSparse *h, Long64_t size=1e3, bool bytes=false)