ndmspc 0.20250304.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:
85 HnSparseT(const char * name, const char * title, Int_t dim, const Int_t * nbins, const Double_t * xmin = nullptr,
86 const Double_t * xmax = nullptr, Int_t chunksize = 1024 * 16)
87 : HnSparse(name, title, dim, nbins, xmin, xmax, chunksize)
88 {
89 }
90
92 TArray * GenerateArray() const override { return new CONT(GetChunkSize()); }
93
94 private:
96 ClassDefOverride(HnSparseT, 1); // Sparse n-dimensional histogram with templated content
98};
99
100typedef HnSparseT<TArrayD> HnSparseD;
101typedef HnSparseT<TArrayF> HnSparseF;
102#if ROOT_VERSION_CODE >= ROOT_VERSION(6, 32, 0)
103typedef HnSparseT<TArrayL64> HnSparseL;
104#else
105typedef HnSparseT<TArrayL> HnSparseL;
106#endif
107typedef HnSparseT<TArrayI> HnSparseI;
108typedef HnSparseT<TArrayS> HnSparseS;
109typedef HnSparseT<TArrayC> HnSparseC;
110
111} // namespace Ndh
112} // namespace Ndmspc
113
114#endif /* HNSPARSE_H */
HnSparseT(const char *name, const char *title, Int_t dim, const Int_t *nbins, const Double_t *xmin=nullptr, const Double_t *xmax=nullptr, Int_t chunksize=1024 *16)
Constructor.
Definition HnSparse.h:85
HnSparseT()
Default constructor.
Definition HnSparse.h:83
TArray * GenerateArray() const override
Returns content array.
Definition HnSparse.h:92
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