]>
Commit | Line | Data |
---|---|---|
621688e4 | 1 | #ifndef AliUnicorHN_H |
2 | #define AliUnicorHN_H | |
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: | |
22 | AliUnicorHN() : TH1D(), fNdim(0) {printf("default AliUnicorHN object created\n");} | |
23 | AliUnicorHN(Char_t *nam, Int_t ndim, TAxis **ax); // constructor from scratch | |
24 | AliUnicorHN(Char_t *filename, Char_t *name); // constructor from file | |
25 | virtual ~AliUnicorHN() {printf("AliUnicorHN object %s deleted\n",GetName());} | |
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 | |
43 | TH1D *ProjectOn(char *nam, Int_t dim, Int_t *first=0, Int_t *last=0) const; | |
44 | // project on 1-dim histogram | |
45 | TH1D *ProjectOn(char *nam, Int_t dim, Double_t *first, Double_t *last); | |
46 | // project on 2-dim histogram | |
47 | TH2D *ProjectOn(char *nam, Int_t dim0, Int_t dim1, Int_t *first=0, Int_t *last=0) const; | |
48 | ||
49 | protected: | |
50 | ||
51 | static const Int_t fgkMaxNdim=10; // maximum number of dimensions | |
52 | Int_t fNdim; // number of dimensions | |
53 | TAxis fAxis[fgkMaxNdim]; // axes | |
54 | Int_t fNbins[fgkMaxNdim]; // {fAxis[0]->GetNbins(),fAxis[1]->... | |
55 | Int_t fMbins[fgkMaxNdim]; // {...[fNdim-2]*fNbins[fNdim-1],fNbins[fNdim-1],1} | |
56 | static Int_t Albins(Int_t n, TAxis **ax); // product of nbins of ax[0]...ax[n-1] | |
57 | Int_t MulToOne(Int_t *k) const; // calc 1-dim index from n-dim indices | |
58 | Int_t MulToOne(Double_t *x); // calc 1-dim index from n-dim vector | |
59 | void OneToMul(Int_t n, Int_t *k) const; // calc n-dim indices from 1-dim index | |
60 | ||
61 | ClassDef(AliUnicorHN,1) | |
62 | }; | |
63 | //============================================================================= | |
64 | #endif |