]>
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: | |
28eee19b | 22 | AliUnicorHN(const char *nam="muhi", Int_t ndim=0, TAxis **ax=0); // constructor |
fa0cb889 | 23 | AliUnicorHN(TRootIOCtor *) : TH1D(), fNdim(0) {for (int i=0; i<fgkMaxNdim; i++) fNbins[i]=fMbins[i]=0;} // default constructor |
28eee19b | 24 | virtual ~AliUnicorHN() {} // destructor |
25 | static AliUnicorHN* Retrieve(const char *filnam, const char *nam); // read from file | |
26 | ||
621688e4 | 27 | Int_t GetNdim() const {return fNdim;} |
28 | TAxis *GetAxis(Int_t i) const {return (TAxis*) &fAxis[i];} | |
29 | ||
30 | Int_t Fill(Double_t *xx, Double_t y=1); // fill histo | |
31 | Int_t Fill(Double_t) {return -1;} // insufficient number of arguments | |
61e4657c | 32 | Int_t Fill(Double_t x0, Double_t w) {Double_t x[1]={x0}; return Fill(x,w);} // 1-dim histo fill |
621688e4 | 33 | Int_t Fill(Double_t x0, Double_t x1, ...);// 2 or more dim histo fill |
34 | Int_t Fill(const char*, Double_t) {return -1;} // overload TH1 | |
35 | ||
28eee19b | 36 | Int_t Save() const; // save histo and axis on file |
621688e4 | 37 | |
38 | // project along (integrate over) one axis | |
61e4657c | 39 | AliUnicorHN *ProjectAlong(const char *nam, Int_t dim, Int_t first=0, Int_t last=0); |
621688e4 | 40 | // project on 1-dim histogram |
61e4657c | 41 | TH1D *ProjectOn(const char *nam, Int_t dim, const Int_t * const first=0, const Int_t * const last=0) const; |
28eee19b | 42 | TH1D *ProjectOn(const char *nam, Int_t dim, const Double_t * const first, const Double_t * const last) const; |
621688e4 | 43 | // project on 2-dim histogram |
61e4657c | 44 | TH2D *ProjectOn(const char *nam, Int_t dim0, Int_t dim1, const Int_t * const first=0, const Int_t * const last=0) const; |
28eee19b | 45 | TH2D *ProjectOn(const char *nam, Int_t dim0, Int_t dim1, const Double_t * const first, const Double_t * const last) const; |
46 | void OneToMul(Int_t n, Int_t *k) const; // calc n-dim indices from 1-dim index | |
621688e4 | 47 | |
48 | protected: | |
49 | ||
c6fc7f72 | 50 | static const Int_t fgkMaxNdim=10; // maximum number of dimensions |
51 | Int_t fNdim; // number of dimensions | |
52 | TAxis fAxis[fgkMaxNdim]; // axes | |
53 | Int_t fNbins[fgkMaxNdim]; // {fAxis[0]->GetNbins(),fAxis[1]->... | |
54 | Int_t fMbins[fgkMaxNdim]; // {...[fNdim-2]*fNbins[fNdim-1],fNbins[fNdim-1],1} | |
55 | static Int_t Albins(Int_t n, TAxis **ax); // product of nbins of ax[0]...ax[n-1] | |
56 | Int_t MulToOne(const Int_t * const k) const; // calc 1-dim index from n-dim indices | |
57 | Int_t MulToOne(Double_t *x); // calc 1-dim index from n-dim vector | |
621688e4 | 58 | |
59 | ClassDef(AliUnicorHN,1) | |
60 | }; | |
61 | //============================================================================= | |
62 | #endif |