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