]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FEMTOSCOPY/UNICOR/AliUnicorHN.h
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / FEMTOSCOPY / UNICOR / AliUnicorHN.h
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(const char *nam="muhi", Int_t ndim=0, TAxis **ax=0);     // constructor
23   AliUnicorHN(TRootIOCtor *) : TH1D(), fNdim(0) {for (int i=0; i<fgkMaxNdim; i++) fNbins[i]=fMbins[i]=0;}  // default constructor
24   virtual ~AliUnicorHN() {}                                            // destructor
25   static AliUnicorHN* Retrieve(const char *filnam, const char *nam);   // read from file
26
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
32   Int_t Fill(Double_t x0, Double_t w)       {Double_t x[1]={x0}; return Fill(x,w);} // 1-dim histo fill
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
36   Int_t Save() const;                      // save histo and axis on file 
37
38   // project along (integrate over) one axis
39   AliUnicorHN  *ProjectAlong(const char *nam, Int_t dim, Int_t first=0, Int_t last=0);
40   // project on 1-dim histogram
41   TH1D *ProjectOn(const char *nam, Int_t dim, const Int_t * const first=0, const Int_t * const last=0) const;
42   TH1D *ProjectOn(const char *nam, Int_t dim, const Double_t * const first, const Double_t * const last) const;
43   // project on 2-dim histogram
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;
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
47
48  protected:
49
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
58
59   ClassDef(AliUnicorHN,1)
60 };
61 //=============================================================================
62 #endif