source: trunk/MagicSoft/Mars/mhist/MBinning.h@ 1303

Last change on this file since 1303 was 1215, checked in by rkb, 23 years ago
*** empty log message ***
File size: 1.5 KB
Line 
1#ifndef MARS_MBinning
2#define MARS_MBinning
3
4#ifndef MARS_MParContainer
5#include "MParContainer.h"
6#endif
7
8#ifndef ROOT_TArrayD
9#include "TArrayD.h"
10#endif
11
12class MBinning : public MParContainer
13{
14private:
15 TArrayD fEdges;
16
17public:
18 MBinning(const char *name=NULL, const char *title=NULL);
19
20 void SetEdges(const TArrayD &arr)
21 {
22 fEdges = arr;/*
23 const Int_t nbins = arr.GetSize();
24 fEdges.Set(nbins);
25 for (int i=0; i<nbins; i++)
26 fEdges[i] = (*(TArrayD*)(&arr))[i];*/
27 }
28
29 void SetEdges(const Int_t nbins, const Axis_t lo, Axis_t up)
30 {
31 const Double_t binsize = (up-lo)/nbins;
32 fEdges.Set(nbins+1);
33 for (int i=0; i<=nbins; i++)
34 fEdges[i] = binsize*i + lo;
35 }
36
37 void SetEdgesLog(const Int_t nbins, const Axis_t lo, Axis_t up)
38 {
39 // if (lo==0) ...
40
41 const Double_t binsize = log10(up/lo)/nbins;
42 fEdges.Set(nbins+1);
43 for (int i=0; i<=nbins; i++)
44 fEdges[i] = pow(10, binsize*i) * lo;
45 }
46
47 // FIXME: ROOT workaround: "operator[] const" missing
48 Double_t GetEdgeLo() const { return (*(TArrayD*)(&fEdges))[0]; }
49 Double_t GetEdgeHi() const { return (*(TArrayD*)(&fEdges))[fEdges.GetSize()-1]; }
50
51 Int_t GetNumEdges() const { return fEdges.GetSize(); }
52 Int_t GetNumBins() const { return fEdges.GetSize()-1; }
53
54 Double_t *GetEdges() const { return fEdges.GetArray(); }
55
56 ClassDef(MBinning, 1) //Container to store the binning of a histogram
57};
58
59#endif
60
Note: See TracBrowser for help on using the repository browser.