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 *')
34 for i
in range(len(decfile_lines)):
36 match = re_enddecay.match(decfile_lines[i])
40 if(decfile_lines[i] !=
'\n'):
41 if(decfile_lines[i].lstrip()[0] !=
'#'):
42 decays[particle].append(decfile_lines[i])
44 match = re_decay.match(decfile_lines[i])
46 particle = match.group(1)
54 def get_decay_length(particle_name):
55 if particle_name
in decays:
56 return len(decays[particle_name])
60 for particle
in database.ParticleList():
61 code = particle.PdgCode()
62 name = particle.GetName()
64 antiparticle = database.GetParticle(-code)
66 antiname = antiparticle.GetName()
67 length = get_decay_length(name)
68 antilength = get_decay_length(antiname)
69 if (length > 0
and antilength > 0
and length != antilength):
70 print(
'Inconsistent length of decay description '
71 f
'for {name} ({length}) and {antiname} ({antilength}).')
76 def get_branching_fraction(particle_name):
77 if particle_name
in decays:
79 for decmode
in decays[particle_name]:
80 bfsum += float(decmode.split()[0])
85 for particle
in database.ParticleList():
86 code = particle.PdgCode()
87 name = particle.GetName()
89 antiparticle = database.GetParticle(-code)
91 antiname = antiparticle.GetName()
92 bfsum = get_branching_fraction(name)
93 antibfsum = get_branching_fraction(antiname)
94 if (bfsum > 0
and antibfsum > 0
and bfsum != antibfsum):
95 print(
'Inconsistent sum of decay branching fractions '
96 f
'for {name} ({bfsum}) and {antiname} ({antibfsum}).\n'
97 f
'Did you remember to modify both {name} and {antiname} branching fractions? '
98 f
'Check it also by running "{ac.color("red")}b2dec-compare-BFs{ac.reset()}".')
102 if((abs(code) == 511
or abs(code) == 521)
and bfsum > 0
and abs(1.0 - bfsum) > 1e-7):
103 print(
'Sum of decay mode branching fractions '
104 f
'for {name} is not compatible with 1 ({bfsum}).\n'
105 f
'Did you remember to run "{ac.color("red")}b2dec-correct-pythiaBFs{ac.reset()}"?')
109 if((abs(code) == 511
or abs(code) == 521)
and antibfsum > 0
and abs(1.0 - antibfsum) > 1e-7):
110 print(
'Sum of decay mode branching fractions '
111 f
'for {antiname} is not compatible with 1 ({antibfsum}).\n'
112 f
'Did you remember to run "{ac.color("red")}b2dec-correct-pythiaBFs{ac.reset()}"?')