Belle II Software light-2406-ragdoll
test7_treeFitterFitResolution_Plot.py
1#!/usr/bin/env python
2
3
10
11"""
12<header>
13 <input>../TreeFitted_B0ToJPsiKs.root</input>
14 <contact>Frank Meier; frank.meier@duke.edu</contact>
15 <interval>nightly</interval>
16</header>
17"""
18# Bto J/Psi Ks(Pi+Pi-) is fitted and the resolution of the vertex
19# positions/E/P/pVal is plotted.
20
21import glob
22
23import ROOT
24import sysconfig
25ROOT.gROOT.ProcessLine(".include " + sysconfig.get_path("include")) # noqa
26
27workingFiles = glob.glob("../TreeFitted_B0ToJPsiKs.root")
28
29chain = ROOT.TChain("B0TreeFit")
30for iFile in workingFiles:
31 chain.AddFile(iFile)
32
33outputFile = ROOT.TFile("test7_TreeFitterOutput.root", "RECREATE")
34
35RangeMicrons = 100
36RangePull = 5
37nBins = 50
38
39B0_E_pull_s = ROOT.TH1F("B0_E_pull_s", 'Pull of the B^{0} energy sig', nBins, -RangePull, RangePull)
40B0_p_pull_s = ROOT.TH1F("B0_p_pull_s", 'Pull of the B^{0} momentum sig', nBins, -RangePull, RangePull)
41
42B0_vertex_pullx_s = ROOT.TH1F("B0_vertex_pullx_s", 'Pull of The B^{0} x vertex position sig', nBins, -RangePull, RangePull)
43B0_vertex_pully_s = ROOT.TH1F("B0_vertex_pully_s", 'Pull of The B^{0} y vertex position sig', nBins, -RangePull, RangePull)
44B0_vertex_pullz_s = ROOT.TH1F("B0_vertex_pullz_s", 'Pull of The B^{0} z vertex position sig', nBins, -RangePull, RangePull)
45
46B0_vertex_resolutionx_s = ROOT.TH1F("B0_vertex_resolutionx_s",
47 'meas - mc of the B^{0} x vertex sig', nBins, -RangeMicrons, RangeMicrons)
48B0_vertex_resolutiony_s = ROOT.TH1F("B0_vertex_resolutiony_s",
49 'meas - mc of the B^{0} y vertex sig', nBins, -RangeMicrons, RangeMicrons)
50B0_vertex_resolutionz_s = ROOT.TH1F("B0_vertex_resolutionz_s",
51 'meas - mc of the B^{0} z vertex sig', nBins, -RangeMicrons, RangeMicrons)
52pVal_s = ROOT.TH1F("pVal_s", 'global pValue sig', nBins, -1, 1)
53pVal_b = ROOT.TH1F("pVal_b", 'global pValue bkg', nBins, -1, 1)
54
55signalCut = ROOT.TCut("(isSignal>0)")
56bkgCut = ROOT.TCut("(isSignal<1)")
57
58histOperationStrings = [
59 "(E - mcE) / E_uncertainty>>B0_E_pull_s",
60 "(p - mcP) / pErr>>B0_p_pull_s",
61 "(x - mcDecayVertexX) / x_uncertainty>>B0_vertex_pullx_s",
62 "(y - mcDecayVertexY) / y_uncertainty>>B0_vertex_pully_s",
63 "(z - mcDecayVertexZ) / z_uncertainty>>B0_vertex_pullz_s",
64 "(x - mcDecayVertexX)*10000>>B0_vertex_resolutionx_s",
65 "(y - mcDecayVertexY)*10000>>B0_vertex_resolutiony_s",
66 "(z - mcDecayVertexZ)*10000>>B0_vertex_resolutionz_s",
67 "chiProb>>pVal_s",
68 "chiProb>>pVal_b",
69]
70
71drawToNewHist = chain.Draw
72for histOperation in histOperationStrings:
73 if "_s" in histOperation:
74 drawToNewHist(histOperation, signalCut)
75 else:
76 drawToNewHist(histOperation, bkgCut)
77
78histsAndLabels = {
79 B0_E_pull_s: "B^{0} E pull",
80 B0_p_pull_s: "B^{0} momentum pull",
81 B0_vertex_pullx_s: "pull of B^{0} vertex X ",
82 B0_vertex_pully_s: "pull of B^{0} vertex Y ",
83 B0_vertex_pullz_s: "pull of B^{0} vertex Z ",
84 B0_vertex_resolutionx_s: "meas-mc of B^{0} vertex X [#mum]",
85 B0_vertex_resolutiony_s: "meas-mc of B^{0} vertex Y [#mum]",
86 B0_vertex_resolutionz_s: "meas-mc of B^{0} vertex Z [#mum]",
87 pVal_b: "pValue",
88 pVal_s: "pValue",
89}
90
91checkForGausian = "This should be a Gaussian on flat bkg and not changing."
92metaOptions = "pvalue-warn=0.1"
93for hist, xlabel in histsAndLabels.items():
94 hist.GetXaxis().SetTitle(xlabel)
95 hist.GetListOfFunctions().Add(ROOT.TNamed("Contact", "frank.meier@duke.edu"))
96 hist.GetListOfFunctions().Add(ROOT.TNamed("Description", xlabel))
97 hist.GetListOfFunctions().Add(ROOT.TNamed("MetaOptions", metaOptions))
98 if any(string in xlabel for string in ["pull", "meas-mc"]):
99 hist.GetListOfFunctions().Add(ROOT.TNamed("Check", checkForGausian))
100
101outputFile.Write()