22 <input>../mixed.cdst.root</input>
23 <output>MCvalidationMixed.root</output>
24 <description>Determining multiplicities of different particles on generator level</description>
29import modularAnalysis as ma
30from variables import variables as v
31from variables import collections as vc
32from SplitMultiplicities import SplitMultiplicities
35path = b2.create_path()
38def get_argument_parser():
40 Parses the command line options and returns the corresponding arguments.
43 parser = argparse.ArgumentParser(
44 description=__doc__.split("--examples--")[0],
46 formatter_class=argparse.RawDescriptionHelpFormatter,
50 parser.add_argument(
'--input', type=str, default=
'../mixed.cdst.root', help=
'The name of the input root file')
51 parser.add_argument(
'--output', type=str, default=
'MCvalidationMixed.root', help=
'The name of the output root file')
56def define_ups_aliases():
57 '''Define aliases to write out multiplicities'''
59 alias_dict[
'nPIp'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(211))'
60 alias_dict[
'nPI0'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(111))'
61 alias_dict[
'nETA'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(221))'
62 alias_dict[
'nETAprim'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(331))'
63 alias_dict[
'nPHI'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(333))'
64 alias_dict[
'nRHOp'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(213))'
65 alias_dict[
'nRHO0'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(113))'
66 alias_dict[
'nKp'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(321))'
67 alias_dict[
'nKL0'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(130))'
68 alias_dict[
'nKS0'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(310))'
69 alias_dict[
'nKstar0'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(313))'
70 alias_dict[
'nKstarp'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(323))'
71 alias_dict[
'nDp'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(411))'
72 alias_dict[
'nD0'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(421))'
73 alias_dict[
'nBp'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(521))'
74 alias_dict[
'nB0'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(511))'
75 alias_dict[
'nJPSI'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(443))'
76 alias_dict[
'nELECTRON'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(11))'
77 alias_dict[
'nENEUTRINO'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(12))'
78 alias_dict[
'nMUON'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(13))'
79 alias_dict[
'nMNEUTRINO'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(14))'
80 alias_dict[
'nTAUON'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(15))'
81 alias_dict[
'nTNEUTRINO'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(16))'
82 alias_dict[
'nPHOTON'] =
'genUpsilon4S(NumberOfMCParticlesInEvent(22))'
83 alias_dict[
'GenUp4S_nTracks'] =
'genUpsilon4S(nTracks)'
87def define_split_aliases():
88 '''Define aliases for extraInfo resulting from SplitMultiplicities module'''
90 alias_dict[
'gen_Kp'] =
'eventExtraInfo(nGen_321)'
91 alias_dict[
'gen_Kp_Bp'] =
'eventExtraInfo(nGen_321_Bp)'
92 alias_dict[
'gen_Kp_Bm'] =
'eventExtraInfo(nGen_321_Bm)'
93 alias_dict[
'gen_Kp_B0'] =
'eventExtraInfo(nGen_321_B0)'
94 alias_dict[
'gen_Kp_antiB0'] =
'eventExtraInfo(nGen_321_antiB0)'
95 alias_dict[
'gen_Km'] =
'eventExtraInfo(nGen_-321)'
96 alias_dict[
'gen_Km_Bp'] =
'eventExtraInfo(nGen_-321_Bp)'
97 alias_dict[
'gen_Km_Bm'] =
'eventExtraInfo(nGen_-321_Bm)'
98 alias_dict[
'gen_Km_B0'] =
'eventExtraInfo(nGen_-321_B0)'
99 alias_dict[
'gen_Km_antiB0'] =
'eventExtraInfo(nGen_-321_antiB0)'
100 alias_dict[
'gen_K0'] =
'eventExtraInfo(nGen_311)'
101 alias_dict[
'gen_K0_Bp'] =
'eventExtraInfo(nGen_311_Bp)'
102 alias_dict[
'gen_K0_Bm'] =
'eventExtraInfo(nGen_311_Bm)'
103 alias_dict[
'gen_K0_B0'] =
'eventExtraInfo(nGen_311_B0)'
104 alias_dict[
'gen_K0_antiB0'] =
'eventExtraInfo(nGen_311_antiB0)'
105 alias_dict[
'gen_antiK0'] =
'eventExtraInfo(nGen_-311)'
106 alias_dict[
'gen_antiK0_Bp'] =
'eventExtraInfo(nGen_-311_Bp)'
107 alias_dict[
'gen_antiK0_Bm'] =
'eventExtraInfo(nGen_-311_Bm)'
108 alias_dict[
'gen_antiK0_B0'] =
'eventExtraInfo(nGen_-311_B0)'
109 alias_dict[
'gen_antiK0_antiB0'] =
'eventExtraInfo(nGen_-311_antiB0)'
113def add_aliases(alias_dict={}):
114 '''Here we add the aliases defined in define_{split/ups}_aliases'''
115 for key, value
in alias_dict.items():
116 v.addAlias(key, value)
119parser = get_argument_parser()
120args = parser.parse_args()
123ma.inputMdstList(args.input, path)
131pions = (
"pi+:MC",
'')
133muons = (
"mu+:MC",
'')
134electrons = (
"e+:MC",
'')
135protons = (
"p+:MC",
'')
136photons = (
"gamma:MC",
'')
137klongs = (
"K_L0:MC",
'')
138ma.fillParticleListsFromMC([pions, kaons, muons, electrons, protons, klongs, photons], path=path)
141ma.buildEventShape([
'pi+:MC',
"K+:MC",
"mu+:MC",
"e+:MC",
"p+:MC",
"K_L0:MC",
"gamma:MC"], path=path)
144Multi_aliasDict = define_ups_aliases()
145Split_aliasDict = define_split_aliases()
148add_aliases(Multi_aliasDict)
149add_aliases(Split_aliasDict)
150multi_variables = list(Multi_aliasDict.keys())
151split_variables = list(Split_aliasDict.keys())
154eventshape_variables = vc.event_shape
159 treename=
"Multiplicities",
160 variables=multi_variables,
161 filename=args.output,
163ma.variablesToNtuple(
'', treename=
"Split", variables=split_variables, filename=args.output, path=path)
166 treename=
"EventShape",
167 variables=eventshape_variables,
168 filename=args.output,
171progress = ma.register_module(
'Progress')
172path.add_module(progress)