]>
Commit | Line | Data |
---|---|---|
c6fc7f72 | 1 | #ifndef ALIUNICORHN_H |
2 | #define ALIUNICORHN_H | |
621688e4 | 3 | |
4 | /* Copyright(c) 1998-2048, ALICE Experiment at CERN, All rights reserved. * | |
5 | * See cxx source for full Copyright notice */ | |
6 | /* $Id$ */ | |
7 | ||
8 | // Author: Dariusz Miskowiec <mailto:d.miskowiec@gsi.de> 2007 | |
9 | ||
10 | //============================================================================= | |
11 | // multidimensional histogram | |
12 | //============================================================================= | |
13 | ||
14 | #include <TH1.h> | |
15 | class TH2D; | |
16 | class TAxis; | |
17 | ||
18 | //============================================================================= | |
19 | class AliUnicorHN : public TH1D { | |
20 | ||
21 | public: | |
c6fc7f72 | 22 | AliUnicorHN() : TH1D(), fNdim(0) {} // default contructor |
621688e4 | 23 | AliUnicorHN(Char_t *nam, Int_t ndim, TAxis **ax); // constructor from scratch |
24 | AliUnicorHN(Char_t *filename, Char_t *name); // constructor from file | |
c6fc7f72 | 25 | virtual ~AliUnicorHN() {} // destructor |
621688e4 | 26 | Int_t GetNdim() const {return fNdim;} |
27 | TAxis *GetAxis(Int_t i) const {return (TAxis*) &fAxis[i];} | |
28 | ||
29 | Int_t Fill(Double_t *xx, Double_t y=1); // fill histo | |
30 | Int_t Fill(Double_t) {return -1;} // insufficient number of arguments | |
31 | Int_t Fill(Double_t x0, Double_t w) {return Fill(&x0,w);} // 1-dim histo fill | |
32 | Int_t Fill(Double_t x0, Double_t x1, ...);// 2 or more dim histo fill | |
33 | Int_t Fill(const char*, Double_t) {return -1;} // overload TH1 | |
34 | ||
35 | Int_t Write() const; // save histo and axis on file | |
36 | Int_t Write() {return ((const AliUnicorHN*)this)->Write();} | |
37 | Int_t Write(const char *, Int_t, Int_t) {return Write();} // overload TObject | |
38 | Int_t Write(const char *, Int_t, Int_t) const {return Write();} | |
39 | ||
40 | // project along (integrate over) one axis | |
41 | AliUnicorHN *ProjectAlong(char *nam, Int_t dim, Int_t first=-1, Int_t last=-1); | |
42 | // project on 1-dim histogram | |
c6fc7f72 | 43 | TH1D *ProjectOn(char *nam, Int_t dim, const Int_t * const first=0, const Int_t * const last=0) const; |
621688e4 | 44 | // project on 1-dim histogram |
c6fc7f72 | 45 | TH1D *ProjectOn(char *nam, Int_t dim, const Double_t * const first, const Double_t * const last); |
621688e4 | 46 | // project on 2-dim histogram |
c6fc7f72 | 47 | TH2D *ProjectOn(char *nam, Int_t dim0, Int_t dim1, const Int_t * const first=0, const Int_t * const last=0) const; |
040da09c | 48 | void OneToMul(Int_t n, Int_t *k) const; // calc n-dim indices from 1-dim index |
621688e4 | 49 | |
50 | protected: | |
51 | ||
c6fc7f72 | 52 | static const Int_t fgkMaxNdim=10; // maximum number of dimensions |
53 | Int_t fNdim; // number of dimensions | |
54 | TAxis fAxis[fgkMaxNdim]; // axes | |
55 | Int_t fNbins[fgkMaxNdim]; // {fAxis[0]->GetNbins(),fAxis[1]->... | |
56 | Int_t fMbins[fgkMaxNdim]; // {...[fNdim-2]*fNbins[fNdim-1],fNbins[fNdim-1],1} | |
57 | static Int_t Albins(Int_t n, TAxis **ax); // product of nbins of ax[0]...ax[n-1] | |
58 | Int_t MulToOne(const Int_t * const k) const; // calc 1-dim index from n-dim indices | |
59 | Int_t MulToOne(Double_t *x); // calc 1-dim index from n-dim vector | |
621688e4 | 60 | |
61 | ClassDef(AliUnicorHN,1) | |
62 | }; | |
63 | //============================================================================= | |
64 | #endif |