ndmspc  0.20240624.0
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 
9 
10 namespace NDH {
11 
18 
19 class 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 //______________________________________________________________________________
79 template <class CONT>
80 class 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 
108 #endif /* HNSPARSE_H */
HnSparse object.
Definition: HnSparse.h:19
void SetOutputFileName(const char *fn)
Setting output file name.
Definition: HnSparse.h:30
bool RecursiveLoop(THnSparse *s, Int_t level, Int_t *coord, Int_t *dims, std::vector< Int_t > &r)
Definition: HnSparse.cxx:105
TString GetOutputFileName() const
Returns output filename.
Definition: HnSparse.h:32
void ReserveBins(Long64_t nBins)
Definition: HnSparse.cxx:145
TString fOutputFileName
Output filename.
Definition: HnSparse.h:41
TTree * fTree
Container.
Definition: HnSparse.h:40
Bool_t Import(std::vector< Int_t > r, TString filename, TString objname, TString cacheDir=gSystem->HomeDirectory())
Definition: HnSparse.cxx:32