]>
Commit | Line | Data |
---|---|---|
7148817a | 1 | // Author: Dariusz Miskowiec <mailto:d.miskowiec@gsi.de> 2007 |
2 | ||
5a6d201c | 3 | //============================================================================= |
4 | // multidimensional histogram | |
5 | //============================================================================= | |
6 | ||
7148817a | 7 | #ifndef AliDHN_H |
8 | #define AliDHN_H | |
9 | ||
10 | #include <TH1.h> | |
11 | class TH2D; | |
12 | class TAxis; | |
13 | ||
14 | const Int_t fMaxNdim=10; // maximum number of dimensions | |
15 | ||
16 | //============================================================================= | |
17 | class AliDHN : public TH1D { | |
18 | ||
19 | public: | |
20 | AliDHN() : TH1D(), fNdim(0) {printf("AliDHN object created\n");} | |
21 | AliDHN(Char_t *nam, Int_t ndim, TAxis **ax); // constructor from scratch | |
22 | AliDHN(Char_t *filename, Char_t *name); // constructor from file | |
23 | virtual ~AliDHN() {printf("AliDHN object %s deleted\n",GetName());} | |
24 | Int_t GetNdim() const {return fNdim;} | |
5a6d201c | 25 | TAxis *GetAxis(Int_t i) const {return (TAxis*) &fAxis[i];} |
26 | ||
27 | Int_t Fill(Double_t *xx, Double_t y=1); // fill histo | |
28 | Int_t Fill(Double_t) {return -1;} // insufficient number of arguments | |
29 | Int_t Fill(Double_t x0, Double_t w) {return Fill(&x0,w);} // 1-dim histo fill | |
30 | Int_t Fill(Double_t x0, Double_t x1, ...);// 2 or more dim histo fill | |
31 | Int_t Fill(const char*, Double_t) {return -1;} // overload TH1 | |
32 | ||
33 | Int_t Write() const; // save histo and axis on file | |
34 | Int_t Write() {return ((const AliDHN*)this)->Write();} | |
35 | Int_t Write(const char *, Int_t, Int_t) {return Write();} // overload TObject | |
36 | Int_t Write(const char *, Int_t, Int_t) const {return Write();} | |
37 | ||
7148817a | 38 | // project along (integrate over) one axis |
5a6d201c | 39 | AliDHN *ProjectAlong(char *nam, Int_t dim, Int_t first=-1, Int_t last=-1); |
7148817a | 40 | // project on 1-dim histogram |
5a6d201c | 41 | TH1D *ProjectOn(char *nam, Int_t dim, Int_t *first=0, Int_t *last=0) const; |
7148817a | 42 | // project on 1-dim histogram |
43 | TH1D *ProjectOn(char *nam, Int_t dim, Double_t *first, Double_t *last); | |
44 | // project on 2-dim histogram | |
5a6d201c | 45 | TH2D *ProjectOn(char *nam, Int_t dim0, Int_t dim1, Int_t *first=0, Int_t *last=0) const; |
7148817a | 46 | |
47 | protected: | |
48 | ||
49 | Int_t fNdim; // number of dimensions | |
50 | TAxis fAxis[fMaxNdim]; // axes | |
51 | Int_t fNbins[fMaxNdim]; // {fAxis[0]->GetNbins(),fAxis[1]->... | |
52 | Int_t fMbins[fMaxNdim]; // {...[fNdim-2]*fNbins[fNdim-1],fNbins[fNdim-1],1} | |
53 | ||
54 | static Int_t Albins(Int_t n, TAxis **ax); // product of nbins of ax[0]...ax[n-1] | |
55 | Int_t MulToOne(Int_t *k) const; // calc 1-dim index from n-dim indices | |
56 | Int_t MulToOne(Double_t *x); // calc 1-dim index from n-dim vector | |
5a6d201c | 57 | void OneToMul(Int_t n, Int_t *k) const; // calc n-dim indices from 1-dim index |
7148817a | 58 | |
59 | ClassDef(AliDHN,1) | |
60 | }; | |
61 | //============================================================================= | |
62 | #endif |