Exemple #1
0
true_kpi = TH1F("true_kpi", "M^{2}(K_{S}#pi) slice", 100, phsp.lowerLimit(0), phsp.upperLimit(0) )
poly_kpi = TH1F("poly_kpi", "M^{2}(K_{S}#pi) slice", 100, phsp.lowerLimit(0), phsp.upperLimit(0) )
kernel_kpi = TH1F("kernel_kpi", "M^{2}(K_{S}#pi) slice", 100, phsp.lowerLimit(0), phsp.upperLimit(0) )
true_pipi = TH1F("true_pipi", "M^{2}(#pi#pi) slice", 100, phsp.lowerLimit(1), phsp.upperLimit(1) )
poly_pipi = TH1F("poly_pipi", "M^{2}(#pi#pi) slice", 100, phsp.lowerLimit(1), phsp.upperLimit(1) )
kernel_pipi = TH1F("kernel_pipi", "M^{2}(#pi#pi) slice", 100, phsp.lowerLimit(1), phsp.upperLimit(1) )

# Coordinates in the phase space where we will create the 1D slices.
from ROOT import std, Double
v = std.vector(Double)(2)
v[0] = 1.0;
v[1] = 0.3;

# Fill histogram with the result of kernel density estimation
truepdf.project(true_hist)
true_hist.Write()
poly.project(poly_hist)
poly_hist.Write()
kde.project(kernel_hist)
kernel_hist.Write()

# Fill 1D slice in x projection, at the point y=v[1]
truepdf.slice(v, 0, true_kpi) 
true_kpi.Write() 
poly.slice(v, 0, poly_kpi)
poly_kpi.Write()
kde.slice(v, 0, kernel_kpi)
kernel_kpi.Write()

# Fill 1D slice in y projection, at the point x=v[0]
                          0,           # Approximation PDF (0 for flat approximation)
                          100000       # Sample size for MC convolution (0 for binned convolution)
                         )

# Write binned PDF into a file
kde_adaptive.writeToFile("OneDimAdaptiveKernel_bins.root")
  
true_hist = TH1F("true_pdf", "PDF", 200, -1.1, 1.1)
kernel_hist = TH1F("kernel_pdf", "Kernel PDF", 200, -1.1, 1.1)
adaptive_hist = TH1F("adaptive_pdf", "Adaptive kernel PDF", 200, -1.1, 1.1)

kernel_diff = TH1F("kernel_diff", "PDF bias", 200, -1.1, 1.1)
adaptive_diff = TH1F("adaptive_diff", "PDF bias", 200, -1.1, 1.1)

# Fill histogram with true PDF
formula.project(true_hist); 
true_hist.Write();

# Fill histogram with the result of kernel density estimation
kde.project(kernel_hist); 
kernel_hist.Write();

kde_adaptive.project(adaptive_hist)
adaptive_hist.Write()

gStyle.SetOptStat(0)

canvas = TCanvas("canvas", "OneDimAdaptiveKernel", 400, 600)
canvas.Divide(1, 2)
canvas.cd(1)
true_hist.SetLineColor(1)