Skip to content

Commit 2ea6412

Browse files
committed
Better histogram binning in TOF example macro
1 parent c0220c4 commit 2ea6412

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

examples/smearing/tof.C

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,26 @@ tof(const char *inputFile = "delphes.root",
3636
smearer.loadTable(321, "lutCovm.ka.dat");
3737
smearer.loadTable(2212, "lutCovm.pr.dat");
3838

39+
// logx binning
40+
const Int_t nbins = 80;
41+
double xmin = 1.e-2;
42+
double xmax = 1.e2;
43+
double logxmin = std::log10(xmin);
44+
double logxmax = std::log10(xmax);
45+
double binwidth = (logxmax - logxmin) / nbins;
46+
double xbins[nbins + 1];
47+
xbins[0] = xmin;
48+
for (Int_t i = 1; i <= nbins; ++i)
49+
xbins[i] = xmin + std::pow(10., logxmin + i * binwidth);
50+
3951
// histograms
4052
auto hTime0 = new TH1F("hTime0", ";t_{0} (ns)", 1000, -1., 1.);
41-
auto hBetaP = new TH2F("hBetaP", ";log_{10}(#it{p}/GeV);#beta", 400, -2., 2., 1000, 0.1, 1.1);
53+
auto hBetaP = new TH2F("hBetaP", ";#it{p} (GeV/#it{c});#beta", nbins, xbins, 1000, 0.1, 1.1);
4254
TH2 *hNsigmaP[5];
4355
const char *pname[5] = {"el", "mu", "pi", "ka", "pr"};
4456
const char *plabel[5] = {"e", "#mu", "#pi", "K", "p"};
4557
for (int i = 0; i < 5; ++i)
46-
hNsigmaP[i] = new TH2F(Form("hNsigmaP_%s", pname[i]), Form(";log_{10}(#it{p}/GeV);n#sigma_{%s}", plabel[i]), 40, -2., 2., 200, -10., 10.);
58+
hNsigmaP[i] = new TH2F(Form("hNsigmaP_%s", pname[i]), Form("#it{p} (GeV/#it{c});n#sigma_{%s}", plabel[i]), nbins, xbins, 200, -10., 10.);
4759

4860
for (Int_t ientry = 0; ientry < numberOfEntries; ++ientry) {
4961

@@ -84,13 +96,13 @@ tof(const char *inputFile = "delphes.root",
8496
// fill beta-p
8597
auto p = track->P;
8698
auto beta = toflayer.getBeta(*track);
87-
hBetaP->Fill(log10(p), beta);
99+
hBetaP->Fill(p, beta);
88100

89101
// fill nsigma
90102
std::array<float, 5> deltat, nsigma;
91103
toflayer.makePID(*track, deltat, nsigma);
92104
for (int i = 0; i < 5; ++i)
93-
hNsigmaP[i]->Fill(log10(p), nsigma[i]);
105+
hNsigmaP[i]->Fill(p, nsigma[i]);
94106

95107
}
96108
}

0 commit comments

Comments
 (0)