11 from ROOT
import Belle2
12 from ROOT.Belle2
import EvtGenDatabasePDG
14 database = EvtGenDatabasePDG.Instance()
17 decfile_lines = f.readlines()
20 re_decay = re.compile(
'Decay *([^ ]+).*\n')
21 re_enddecay = re.compile(
'Enddecay *')
25 for i
in range(len(decfile_lines)):
27 match = re_enddecay.match(decfile_lines[i])
31 if(decfile_lines[i] !=
'\n'):
32 if(decfile_lines[i].lstrip()[0] !=
'#'):
33 decays[particle].append(decfile_lines[i])
35 match = re_decay.match(decfile_lines[i])
37 particle = match.group(1)
44 def get_decay_length(particle_name):
45 if particle_name
in decays:
46 return len(decays[particle_name])
49 for particle
in database.ParticleList():
50 code = particle.PdgCode()
51 name = particle.GetName()
53 antiparticle = database.GetParticle(-code)
55 antiname = antiparticle.GetName()
56 length = get_decay_length(name)
57 antilength = get_decay_length(antiname)
58 if (length > 0
and antilength > 0
and length != antilength):
59 print(f
'Inconsistent length of decay description '
60 f
'for {name} ({length}) and {antiname} ({antilength}).')
65 def get_branching_fraction(particle_name):
66 if particle_name
in decays:
68 for decmode
in decays[particle_name]:
69 bfsum += float(decmode.split()[0])
73 for particle
in database.ParticleList():
74 code = particle.PdgCode()
75 name = particle.GetName()
77 antiparticle = database.GetParticle(-code)
79 antiname = antiparticle.GetName()
80 bfsum = get_branching_fraction(name)
81 antibfsum = get_branching_fraction(antiname)
82 if (bfsum > 0
and antibfsum > 0
and bfsum != antibfsum):
83 print(f
'Inconsistent sum of decay branching fractions '
84 f
'for {name} ({bfsum}) and {antiname} ({antibfsum}).')
87 if((abs(code) == 511
or abs(code) == 521)
and bfsum > 0
and abs(1.0-bfsum) > 1e-7):
88 print(f
'Sum of decay mode branching fractions '
89 f
'for {name} is not compatible with 1 ({bfsum}).')
92 if((abs(code) == 511
or abs(code) == 521)
and antibfsum > 0
and abs(1.0-antibfsum) > 1e-7):
93 print(f
'Sum of decay mode branching fractions '
94 f
'for {antiname} is not compatible with 1 ({antibfsum}).')