Beispiel #1
0
recoWithoutFakes = mig.project("y")

eff_noerr = H1D(eff)
for k in range(0, len(eff_noerr.err)):
    eff_noerr.err[k] = 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)
Beispiel #2
0
  plotH1D(bkg[i], "Reconstructed "+varname, "Events", "Background", "bkg_%s.%s" % (i, extension))

  plotH1D({"Original truth": truth[i], "Projected": mig[i].project("x")/eff[i]}, "Particle-level "+varname, "Events", "Particle-level distribution", "truth_project.%s" % extension)
  plotH1D({"Original truth - projected": truth[i] - mig[i].project("x")/eff[i]}, "Particle-level "+varname, "Events", "Particle-level distribution", "truth_project_diff.%s" % extension)

  plotH1D(truth[i], "Particle-level "+varname, "Events", "Particle-level distribution", "truth_%s.%s" % (i, extension))
  plotH1D(nrt[i], "Particle-level "+varname, "Events", "Events in particle-level selection but not reconstructed", "nrt_%s.%s" % (i,extension))
  plotH1D(recoWithFakes[i], "Reconstructed "+varname, "Events", "Reconstructed-level distribution with fakes", "recoWithFakes_%s.%s" % (i,extension))
  plotH1D(recoWithoutFakes[i], "Reconstructed "+varname, "Events", "Reconstructed-level distribution without fakes", "recoWithoutFakes_%s.%s" % (i,extension))
  plotH1D(eff[i], "Particle-level "+varname, "Efficiency", "Efficiency of particle-level selection", "eff_%s.%s" % (i,extension))

  plotH1D({"Reco with fakes from projection": recoWithoutFakes[i]+bkg[i], "From getHistograms": recoWithFakes[i]}, "Reconstructed "+varname, "Events", "Reconstructed-level distribution without fakes", "reco_project.%s" % extension)
  plotH1D({"Reco with fakes from projection - getHistograms": recoWithoutFakes[i]+bkg[i] - recoWithFakes[i]}, "Reconstructed "+varname, "Events", "Reconstructed-level distribution without fakes", "reco_project_diff.%s" % extension)

  # Create unfolding class
  m = Unfolder(bkg[i], mig[i], eff[i], truth[i])

  # plot response matrix P(r|t)*eff(r)
  plotH2D(m.response, "Reconstructed-level bin", "Particle-level bin", "Transpose of response matrix P(r|t)*eff(t)", "responseMatrix_%s.%s" % (i, extension), 0, np.amax(eff[i].val)*1.2)
# and also the migration probabilities matrix
  plotH2D(m.response_noeff, "Reconstructed-level bin", "Particle-level bin", "Transpose of migration probabilities P(r|t)", "migrationMatrix_%s.%s" % (i, extension), 0, 1)

comparePlot([bkg[""], bkg["me"], bkg["ps"]],
            ["Background nominal", "Background ME", "Background PS"],
            1.0, False, "", "compare_bkg.%s" % extension)

comparePlot([eff[""], eff["me"], eff["ps"]],
            ["Efficiency nominal", "Efficiency ME", "Efficiency PS"],
            1.0, False, "", "compare_eff.%s" % extension)

comparePlot([recoWithoutFakes[""], recoWithoutFakes["me"], recoWithoutFakes["ps"]],
Beispiel #3
0
# generate perfect fake data
data = recoWithFakes[""]

# generate fake data from model
pseudo_data = getDataFromModel(bkg[""], mig[""], eff[""])

comparePlot([data, pseudo_data, data - bkg[""], pseudo_data - bkg[""]], [
    "Reco. projected from unfolding factors",
    "Reco. simulated with toy experiments",
    "Reco. projected from unfolding factors - bkg",
    "Reco. simulated with toy experiments - bkg"
], luminosity * 1e-3, True, "fb/GeV", "pseudoData.%s" % extension)

# Create unfolding class
m = Unfolder(bkg[""], mig[""], eff[""], truth[""])
m.setUniformPrior()
#m.setGaussianPrior()
#m.setCurvaturePrior()
#m.setEntropyPrior()
#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']
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'))