Ejemplo n.º 1
0
phsp = DalitzPhaseSpace("PhspDalitz", md, ma, mb, mc)

# Create a true PDF over this phase space, polynomial of power 4 in x and y
truepdf = FormulaDensity("TruePDF", phsp, "sqrt(1.-0.1*(x-1.3)^4)*(1.+2.*exp(-y))")

outfile = TFile.Open("DalitzPdf.root", "RECREATE")
ntuple = TNtuple("ntuple", "2D NTuple", "x:y")

# Generate 50000 toys according to the "true" PDF
truepdf.generate(ntuple, 25000)

# Create an approximation PDF, polynomial of power 3
poly = PolynomialDensity("PolyPDF", 
                         phsp,    # Phase space
                         2,       # Power of the polynomial
                         ntuple,  # Input ntuple
                         "x","y", # Ntuple variables
                         50000    # Sample size for MC integration
                         )

# Create kernel PDF from the generated sample
kde = BinnedKernelDensity("KernelPDF", 
                          phsp,    # Phase space
                          ntuple,  # Input ntuple
                          "x","y", # Variables to use
                          200,200, # Numbers of bins
                          0.4, 0.4,# Kernel widths
                          poly,    # Approximation PDF (0 for flat approximation)
                          50000    # Sample size for MC convolution (0 for binned convolution)
                         )
Ejemplo n.º 2
0
# First create the 1D phase space for variable x
xphsp = OneDimPhaseSpace("PhspX", -1., 1.) 
  
# Now create the parametric phase space for (x,y) where limits on variable y are functions of x
phsp = ParametricPhaseSpace("PhspParam", xphsp, "-sqrt(1-x^2)", "sqrt(1-x^2)", -1., 1.)

outfile = TFile("TwoDimPolyPdf.root", "RECREATE")
ntuple = TNtuple("ntuple", "2D NTuple", "x:y") 

# True PDF
true_pdf = FormulaDensity("TruePDF", phsp, "1.+0.1*x-0.4*x^2-0.8*y^2") 

# Generate 10000 toys according to the true PDF
true_pdf.generate(ntuple, 50000) 

poly = PolynomialDensity("PolyPDF", phsp, 4, ntuple, "x", "y", 100000) 

poly_hist = TH2F("poly", "Polynomial PDF", 200, -1.1, 1.1, 200, -1.1, 1.1) 

poly.project(poly_hist) 
poly_hist.Write()

gStyle.SetOptStat(0)
  
canvas = TCanvas("canvas", "TwoDimPolyPdf", 400, 400) 
poly_hist.Draw("zcol") 

canvas.Print("TwoDimPolyPdf.png") 

#outfile.Close()