ndmspc 0.20250128.0
Loading...
Searching...
No Matches
HnSparse.h
1#ifndef HnSparse_H
2#define HnSparse_H
3
4#include <TObject.h>
5#include <TSystem.h>
6#include <TTree.h>
7#include <THnSparse.h>
8
9namespace Ndmspc {
10namespace Ndh {
11
18
19class HnSparse : public THnSparse {
20
21 protected:
22 HnSparse();
23 HnSparse(const char * name, const char * title, Int_t dim, const Int_t * nbins, const Double_t * xmin = 0,
24 const Double_t * xmax = 0, Int_t chunksize = 1024 * 16);
25
26 public:
27 Bool_t Import(std::vector<Int_t> r, TString filename, TString objname, TString cacheDir = gSystem->HomeDirectory());
28
30 void SetOutputFileName(const char * fn) { fOutputFileName = fn; }
32 TString GetOutputFileName() const { return fOutputFileName; }
33
34 void ReserveBins(Long64_t nBins);
35
36 protected:
37 bool RecursiveLoop(THnSparse * s, Int_t level, Int_t * coord, Int_t * dims, std::vector<Int_t> & r);
38
39 private:
40 TTree * fTree{nullptr};
41 TString fOutputFileName{"ndh.root"};
42
44 ClassDef(HnSparse, 1);
46};
47
48//______________________________________________________________________________
79template <class CONT>
80class HnSparseT : public HnSparse {
81 public:
82 HnSparseT() {}
83 HnSparseT(const char * name, const char * title, Int_t dim, const Int_t * nbins, const Double_t * xmin = nullptr,
84 const Double_t * xmax = nullptr, Int_t chunksize = 1024 * 16)
85 : HnSparse(name, title, dim, nbins, xmin, xmax, chunksize)
86 {
87 }
88
89 TArray * GenerateArray() const override { return new CONT(GetChunkSize()); }
90
91 private:
92 ClassDefOverride(HnSparseT, 1); // Sparse n-dimensional histogram with templated content
93};
94
97#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 32, 0)
99#else
101#endif
105
106} // namespace Ndh
107} // namespace Ndmspc
108
109#endif /* HNSPARSE_H */
HnSparse object.
Definition HnSparse.h:19
TTree * fTree
Container.
Definition HnSparse.h:40
void ReserveBins(Long64_t nBins)
Definition HnSparse.cxx:145
void SetOutputFileName(const char *fn)
Setting output file name.
Definition HnSparse.h:30
Bool_t Import(std::vector< Int_t > r, TString filename, TString objname, TString cacheDir=gSystem->HomeDirectory())
Definition HnSparse.cxx:32
TString GetOutputFileName() const
Returns output filename.
Definition HnSparse.h:32
bool RecursiveLoop(THnSparse *s, Int_t level, Int_t *coord, Int_t *dims, std::vector< Int_t > &r)
Definition HnSparse.cxx:105
TString fOutputFileName
Output filename.
Definition HnSparse.h:41