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