4 /* Copyright(c) 1998-2048, ALICE Experiment at CERN, All rights reserved. *
5 * See cxx source for full Copyright notice */
8 // Author: Dariusz Miskowiec <mailto:d.miskowiec@gsi.de> 2007
10 //=============================================================================
11 // multidimensional histogram
12 //=============================================================================
18 //=============================================================================
19 class AliUnicorHN : public TH1D {
22 AliUnicorHN() : TH1D(), fNdim(0) {} // default contructor
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() {} // destructor
26 Int_t GetNdim() const {return fNdim;}
27 TAxis *GetAxis(Int_t i) const {return (TAxis*) &fAxis[i];}
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
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();}
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, const Int_t * const first=0, const Int_t * const last=0) const;
44 // project on 1-dim histogram
45 TH1D *ProjectOn(char *nam, Int_t dim, const Double_t * const first, const Double_t * const last);
46 // project on 2-dim histogram
47 TH2D *ProjectOn(char *nam, Int_t dim0, Int_t dim1, const Int_t * const first=0, const Int_t * const last=0) const;
48 void OneToMul(Int_t n, Int_t *k) const; // calc n-dim indices from 1-dim index
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
61 ClassDef(AliUnicorHN,1)
63 //=============================================================================