-
Notifications
You must be signed in to change notification settings - Fork 1
/
TH2Dlog.hh
65 lines (46 loc) · 2.05 KB
/
TH2Dlog.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include "TH2D.h"
#include "TMath.h"
TH2D *TH2Dlogx(const char *name, const char *title, const int nbinsx, const double xmin, const double xmax, const int nbinsy, const double ymin, const double ymax)
{
const double log_xmin = TMath::Log10(xmin);
const double log_xmax = TMath::Log10(xmax);
const double binx_width = (log_xmax-log_xmin)/nbinsx;
const double biny_width = (ymax-ymin)/nbinsy;
double xbins[nbinsx+1];
double ybins[nbinsy+1];
for (int i=0; i<=nbinsx; ++i)
xbins[i] = TMath::Power(10, log_xmin + i*binx_width);
for (int i=0; i<=nbinsy; ++i)
ybins[i] = ymin + i*biny_width;
return new TH2D(name, title, nbinsx, xbins, nbinsy, ybins);
}
TH2D *TH2Dlogy(const char *name, const char *title, const int nbinsx, const double xmin, const double xmax, const int nbinsy, const double ymin, const double ymax)
{
const double log_ymin = TMath::Log10(ymin);
const double log_ymax = TMath::Log10(ymax);
const double binx_width = (xmax-xmin)/nbinsx;
const double biny_width = (log_ymax-log_ymin)/nbinsy;
double xbins[nbinsx+1];
double ybins[nbinsy+1];
for (int i=0; i<=nbinsx; ++i)
xbins[i] = xmin + i*binx_width;
for (int i=0; i<=nbinsy; ++i)
ybins[i] = TMath::Power(10, log_ymin + i*biny_width);
return new TH2D(name, title, nbinsx, xbins, nbinsy, ybins);
}
TH2D *TH2Dlogxy(const char *name, const char *title, const int nbinsx, const double xmin, const double xmax, const int nbinsy, const double ymin, const double ymax)
{
const double log_xmin = TMath::Log10(xmin);
const double log_xmax = TMath::Log10(xmax);
const double log_ymin = TMath::Log10(ymin);
const double log_ymax = TMath::Log10(ymax);
const double binx_width = (log_xmax-log_xmin)/nbinsx;
const double biny_width = (log_ymax-log_ymin)/nbinsy;
double xbins[nbinsx+1];
double ybins[nbinsy+1];
for (int i=0; i<=nbinsx; ++i)
xbins[i] = TMath::Power(10, log_xmin + i*binx_width);
for (int i=0; i<=nbinsy; ++i)
ybins[i] = TMath::Power(10, log_ymin + i*biny_width);
return new TH2D(name, title, nbinsx, xbins, nbinsy, ybins);
}