18from ROOT
import Belle2
19from ROOT.Belle2
import EvtGenDatabasePDG
20from terminal_utils
import ANSIColors
as ac
22database = EvtGenDatabasePDG.Instance()
24f = open(basf2.find_file(
'decfiles/dec/DECAY_BELLE2.DEC'))
25decfile_lines = f.readlines()
28re_decay = re.compile(
'Decay *([^ ]+).*\n')
29re_enddecay = re.compile(
'Enddecay *')
36for i
in range(len(decfile_lines)):
38 match = re_enddecay.match(decfile_lines[i])
42 if (decfile_lines[i] !=
'\n'):
43 if (decfile_lines[i].lstrip()[0] !=
'#'):
44 decays[particle].append(decfile_lines[i])
46 match = re_decay.match(decfile_lines[i])
48 particle = match.group(1)
56def get_decay_length(particle_name):
57 if particle_name
in decays:
58 return len(decays[particle_name])
62for particle
in database.ParticleList():
63 code = particle.PdgCode()
64 name = particle.GetName()
66 antiparticle = database.GetParticle(-code)
68 antiname = antiparticle.GetName()
69 length = get_decay_length(name)
70 antilength = get_decay_length(antiname)
71 if (length > 0
and antilength > 0
and length != antilength):
72 print(
'Inconsistent length of decay description '
73 f
'for {name} ({length}) and {antiname} ({antilength}).')
78def get_branching_fraction(particle_name):
79 if particle_name
in decays:
81 for decmode
in decays[particle_name]:
82 bfsum += float(decmode.split()[0])
87for particle
in database.ParticleList():
88 code = particle.PdgCode()
89 name = particle.GetName()
91 antiparticle = database.GetParticle(-code)
93 antiname = antiparticle.GetName()
94 bfsum = get_branching_fraction(name)
95 antibfsum = get_branching_fraction(antiname)
96 if (bfsum > 0
and antibfsum > 0
and bfsum != antibfsum):
97 print(
'Inconsistent sum of decay branching fractions '
98 f
'for {name} ({bfsum}) and {antiname} ({antibfsum}).\n'
99 f
'Did you remember to modify both {name} and {antiname} branching fractions? '
100 f
'Check it also by running "{ac.color("red")}b2dec-compare-BFs{ac.reset()}".')
104 if ((abs(code) == 511
or abs(code) == 521)
and bfsum > 0
and abs(1.0 - bfsum) > 1e-7):
105 print(
'Sum of decay mode branching fractions '
106 f
'for {name} is not compatible with 1 ({bfsum}).\n'
107 f
'Did you remember to run "{ac.color("red")}b2dec-correct-pythiaBFs{ac.reset()}"?')
111 if ((abs(code) == 511
or abs(code) == 521)
and antibfsum > 0
and abs(1.0 - antibfsum) > 1e-7):
112 print(
'Sum of decay mode branching fractions '
113 f
'for {antiname} is not compatible with 1 ({antibfsum}).\n'
114 f
'Did you remember to run "{ac.color("red")}b2dec-correct-pythiaBFs{ac.reset()}"?')