Пример #1
0
bkg_noerr = H1D(bkg)
for k in range(0, len(bkg_noerr.err)):
    bkg_noerr.err[k] = 0

# generate fake data
data = recoWithFakes

# Create unfolding class
m = Unfolder(bkg, mig, eff, truth)
m.setUniformPrior()
#m.setGaussianPrior()
#m.setCurvaturePrior()
#m.setFirstDerivativePrior()

m.run(data)
m.setAlpha(1.0)
m.sample(50000)

# plot marginal distributions
m.plotMarginal("plotMarginal.%s" % extension)

# plot correlations
#m.plotPairs("pairPlot.%s" % extension) # takes forever
m.plotCov("covPlot.%s" % extension)
m.plotCorr("corrPlot.%s" % extension)
m.plotCorrWithNP("corrPlotWithNP.%s" % extension)
m.plotSkewness("skewPlot.%s" % extension)
m.plotKurtosis("kurtosisPlot.%s" % extension)

m.plotNP("plotNP.%s" % extension)
Пример #2
0
m.setUniformPrior()
#m.setGaussianPrior()
#m.setCurvaturePrior()
#m.setFirstDerivativePrior()

# add uncertainties
#uncList = ['sjcalib1030', 'eup', 'ecup'] + ['lup'+str(x) for x in range(0, 10+1)] + ['cup'+str(x) for x in range(0, 3+1)] + ['bup'+str(x) for x in range(0, 3+1)] + ['ewkup']
uncList = []
for k in uncList:
    print "Getting histograms for syst. ", k
    struth, srecoWithFakes, sbkg, smig, seff, snrt = getHistograms(
        "out_ttallhad_psrw_Syst.root", k, "mttAsymm")
    m.addUncertainty(k, sbkg, smig.project('y'))

m.run(data)
m.setAlpha(0.0)
m.sample(100000)

unf_orig = m.hunf

uncUnfList = ["me", "ps"]
for k in uncUnfList:
    m.addUnfoldingUncertainty(k, bkg[k], mig[k], eff[k])
    #m.addUncertainty(k, bkg[k], np.dot(truth[k].val, response[k].val))

m.run(data)
m.setAlpha(0.0)
m.sample(100000)

# plot marginal distributions
m.plotMarginal("plotMarginal.%s" % extension)
Пример #3
0
    alpha[i], alphaChi2[i], bestAlphaBias[i], bestAlphaBiasStd[
        i], bestAlphaNormBias[i], bestAlphaNormBiasStd[i] = m.scanAlpha(
            t_bkg, t_mig, t_eff, 1000, np.arange(0.0, 5.0, 0.250),
            "scanAlpha_%s.%s" % (i, extension),
            "scanAlpha_%s_chi2.%s" % (i, extension),
            "scanAlpha_%s_norm.%s" % (i, extension))
    # for curvature
    #alpha[i], alphaChi2[i], bestAlphaBias[i], bestAlphaBiasStd[i], bestAlphaNormBias[i], bestAlphaNormBiasStd[i] = m.scanAlpha(t_bkg, t_mig, t_eff, 1000, np.arange(0.0, 4e-8, 2e-9), "scanAlpha_%s.%s" % (i, extension), "scanAlpha_%s_chi2.%s" % (i, extension), "scanAlpha_%s_norm.%s" % (i, extension))
    # for entropy
    #alpha[i], alphaChi2[i], bestAlphaBias[i], bestAlphaBiasStd[i], bestAlphaNormBias[i], bestAlphaNormBiasStd[i] = m.scanAlpha(t_bkg, t_mig, t_eff, 1000, np.arange(0.0, 100.0, 4.0), "scanAlpha_%s.%s" % (i, extension), "scanAlpha_%s_chi2.%s" % (i, extension), "scanAlpha_%s_norm.%s" % (i, extension))
    print "For configuration '%s': Found alpha = %f with bias chi2 = %f, bias mean = %f, bias std = %f, norm bias = %f, norm bias std = %f" % (
        i, alpha[i], alphaChi2[i], bestAlphaBias[i], bestAlphaBiasStd[i],
        bestAlphaNormBias[i], bestAlphaNormBiasStd[i])

# do the rest with the best alpha from stat. test only
m.setAlpha(alpha[""])

m.run(pseudo_data)
m.setData(pseudo_data)
m.sample(100000)

# plot marginal distributions
m.plotMarginal("plotMarginal_pseudo.%s" % extension)
for i in uncList:
    m.plotNPMarginal(i, "plotNPMarginal_pseudo_%s.%s" % (i, extension))

# plot unfolded spectrum
m.plotUnfolded("plotUnfolded_pseudo.%s" % extension)
m.plotOnlyUnfolded(luminosity * 1e-3, True, "fb/GeV",
                   "plotOnlyUnfolded_pseudo.%s" % extension)
Пример #4
0
    alpha[i], alphaChi2[i], bestAlphaBias[i], bestAlphaBiasStd[
        i], bestAlphaNormBias[i], bestAlphaNormBiasStd[i] = m.scanAlpha(
            t_bkg, t_mig, t_eff, 1000, np.arange(0.0, 10, 0.5),
            "scanAlpha_%s.%s" % (i, extension),
            "scanAlpha_%s_chi2.%s" % (i, extension),
            "scanAlpha_%s_norm.%s" % (i, extension))
    # for curvature
    #alpha[i], alphaChi2[i], bestAlphaBias[i], bestAlphaBiasStd[i], bestAlphaNormBias[i], bestAlphaNormBiasStd[i] = m.scanAlpha(t_bkg, t_mig, t_eff, 1000, np.arange(0.0, 4e-8, 2e-9), "scanAlpha_%s.%s" % (i, extension), "scanAlpha_%s_chi2.%s" % (i, extension), "scanAlpha_%s_norm.%s" % (i, extension))
    # for entropy
    #alpha[i], alphaChi2[i], bestAlphaBias[i], bestAlphaBiasStd[i], bestAlphaNormBias[i], bestAlphaNormBiasStd[i] = m.scanAlpha(t_bkg, t_mig, t_eff, 1000, np.arange(0.0, 100.0, 4.0), "scanAlpha_%s.%s" % (i, extension), "scanAlpha_%s_chi2.%s" % (i, extension), "scanAlpha_%s_norm.%s" % (i, extension))
    print "For configuration '%s': Found alpha = %f with bias chi2 = %f, bias mean = %f, bias std = %f, norm bias = %f, norm bias std = %f" % (
        i, alpha[i], alphaChi2[i], bestAlphaBias[i], bestAlphaBiasStd[i],
        bestAlphaNormBias[i], bestAlphaNormBiasStd[i])

# do the rest with the best alpha from stat. test only
m.setAlpha(alpha["A"])

m.run(pseudo_data)
m.setData(pseudo_data)
m.sample(100000)

# plot marginal distributions
m.plotMarginal("plotMarginal_pseudo.%s" % extension)
for i in uncUnfList:
    m.plotNPUMarginal(i, "plotNPUMarginal_pseudo_%s.%s" % (i, extension))

# plot unfolded spectrum
m.plotUnfolded("plotUnfolded_pseudo.%s" % extension)
m.plotOnlyUnfolded(1.0, False, "", "plotOnlyUnfolded_pseudo.%s" % extension)

# plot correlations graphically