Belle II Software development
SplitMultiplicityPlotsMixed.py
1#!/usr/bin/env python
2
3
10
11"""
12<header>
13 <input>MCvalidationMixed.root</input>
14 <output>SplitMultiplicityPlotsMixed.root</output>
15 <contact>Swagato Banerjee; swagato.banerjee@gmail.com</contact>
16 <description>Comparing generated kaon multiplicities, optionally split by charge and originating B meson flavor</description>
17</header>
18"""
19
20import ROOT
21import argparse
22
23
24def get_argument_parser():
25 """
26 Parses the command line options and returns the corresponding arguments.
27 """
28
29 parser = argparse.ArgumentParser(
30 description=__doc__.split("--examples--")[0],
31 # epilog=__doc__.split("--examples--")[1],
32 formatter_class=argparse.RawDescriptionHelpFormatter,
33 # usage="%(prog)s [optional arguments] [--] program [program arguments]"
34 )
35
36 parser.add_argument('--input', type=str, default='MCvalidationMixed.root', help='The name of the input root file')
37 parser.add_argument('--output', type=str, default='SplitMultiplicityPlotsMixed.root', help='The name of the output root file')
38
39 return parser
40
41
42def PlottingHistos(particle, pos, neg):
43 ''' Plotting function'''
44
45 nbins = int(2*range_dic[particle])
46
47 hist = rdf_fix.Histo1D((particle, particle, nbins, -range_dic[particle], range_dic[particle]), pos)
48 hist_neg = rdf_fix.Histo1D((f"{particle}_neg", f"{particle}_neg", nbins, -range_dic[particle], range_dic[particle]), neg)
49 hist.Add(hist_neg.GetPtr())
50 hist.SetTitle(f";{axis_dic[particle]}; Events")
51 hist.GetListOfFunctions().Add(ROOT.TNamed('Description', f'{axis_dic[particle]} multiplicity'))
52 hist.GetListOfFunctions().Add(ROOT.TNamed('Check', 'Shape should not change drastically.'))
53 hist.GetListOfFunctions().Add(ROOT.TNamed('Contact', 'swagato.banerjee@gmail.com'))
54 hist.GetListOfFunctions().Add(ROOT.TNamed('MetaOptions', 'nostats'))
55 hist.Write()
56 # c1.Clear()
57
58
59if __name__ == '__main__':
60
61 parser = get_argument_parser()
62 args = parser.parse_args()
63
64 # load in the root files
65 rdf = ROOT.RDataFrame("Split", args.input)
66 rdf_fix = rdf.Define("gen_Kn", "-gen_Km").Define("gen_K0bar", "-gen_antiK0")
67
68 axis_dic = {'Kpm': 'K^{+} / K^{#minus} from both B',
69 'K0': 'K^{0} / #bar{K}^{0} from both B'
70 }
71
72 range_dic = {'Kpm': 4.5,
73 'K0': 3.5,
74 'Kpm_same': 4.5,
75 'Kpm_diff': 4.5,
76 'K0_same': 3.5,
77 'K0_diff': 3.5
78 }
79
80 outputFile = ROOT.TFile(args.output, "RECREATE")
81 ROOT.gROOT.SetBatch(True)
82
83 PlottingHistos("Kpm", "gen_Kp", "gen_Kn")
84 PlottingHistos("K0", "gen_K0", "gen_K0bar")
85 axis_dic['Kpm_same'] = 'K^{+} from B^{0} / K^{#minus} from #bar{B}^{0}'
86 axis_dic['Kpm_diff'] = 'K^{+} from #bar{B}^{0} / K^{#minus} from B^{0}'
87 axis_dic['K0_same'] = 'K^{0} from B^{0} / #bar{K}^{0} from #bar{B}^{0}'
88 axis_dic['K0_diff'] = 'K^{0} from #bar{B}^{0} / #bar{K}^{0} from B^{0}'
89 rdf_fix = rdf.Define("gen_Kp_B0bar", "-gen_Kp_antiB0")\
90 .Define("gen_Km_B0bar", "-gen_Km_antiB0")\
91 .Define("gen_K0_B0bar", "-gen_K0_antiB0")\
92 .Define("gen_antiK0_B0bar", "-gen_antiK0_antiB0")
93 PlottingHistos("Kpm_same", "gen_Kp_B0", "gen_Km_B0bar")
94 PlottingHistos("Kpm_diff", "gen_Kp_B0bar", "gen_Km_B0")
95 PlottingHistos("K0_same", "gen_K0_B0", "gen_antiK0_B0bar")
96 PlottingHistos("K0_diff", "gen_K0_B0bar", "gen_antiK0_B0")
97
98 outputFile.Close()