]>
Commit | Line | Data |
---|---|---|
03d23846 | 1 | // |
2 | // All implementations related to definition of an axis | |
3 | // which is used in the output histogams. | |
4 | // Simpler than TAxis, it defines an array of edges | |
5 | // which is then ported to the output histogram definition. | |
6 | // currently ported only in mini-package, but it could | |
7 | // become a default also for general package. | |
8 | // | |
9 | ||
10 | #include "TMath.h" | |
11 | #include "AliRsnMiniAxis.h" | |
12 | ||
13 | ClassImp(AliRsnMiniAxis) | |
14 | ||
15 | //_____________________________________________________________________________ | |
16 | void AliRsnMiniAxis::Set(Int_t nbins, Double_t min, Double_t max) | |
17 | { | |
18 | // | |
19 | // Set binning for the axis in equally spaced bins | |
20 | // where the number of bins, minimum and maximum are given. | |
21 | // | |
22 | ||
23 | if (!nbins) { | |
24 | fBins.Set(0); | |
25 | return; | |
26 | } | |
27 | ||
28 | fBins.Set(nbins + 1); | |
29 | ||
30 | Double_t mymax = TMath::Max(min, max); | |
31 | Double_t mymin = TMath::Min(min, max); | |
32 | ||
33 | Int_t k = 0; | |
34 | Double_t binSize = (mymax - mymin) / ((Double_t)nbins); | |
35 | ||
36 | fBins[0] = mymin; | |
37 | for (k = 1; k <= nbins; k++) fBins[k] = fBins[k - 1] + binSize; | |
38 | } | |
39 | ||
40 | //_____________________________________________________________________________ | |
41 | void AliRsnMiniAxis::Set(Double_t min, Double_t max, Double_t step) | |
42 | { | |
43 | // | |
44 | // Set binning for the axis in equally spaced bins | |
45 | // where the bin size, minimum and maximum are given. | |
46 | // | |
47 | ||
48 | Double_t dblNbins = TMath::Abs(max - min) / step; | |
49 | Int_t intNbins = ((Int_t)dblNbins) + 1; | |
50 | ||
51 | Set(intNbins, min, max); | |
52 | } | |
53 | ||
54 | //_____________________________________________________________________________ | |
55 | void AliRsnMiniAxis::Set(Int_t nbins, Double_t *array) | |
56 | { | |
57 | // | |
58 | // Set binning for the axis in unequally spaced bins | |
59 | // using the same way it is done in TAxis | |
60 | // | |
61 | ||
62 | if (!nbins) { | |
63 | fBins.Set(0); | |
64 | return; | |
65 | } | |
66 | ||
67 | Int_t i; | |
68 | fBins.Set(nbins); | |
69 | for (i = 0; i < nbins; i++) fBins[i] = array[i]; | |
70 | } |