Belle II Software  release-05-02-19
decparser.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 
4 """
5 Decay File Parser to check whether a decay file is correctly defined before committing to svn
6 P. Urquijo
7 """
8 
9 import sys
10 import settings
11 import os
12 import time
13 from colours import *
14 import descriptcheck
15 
16 mesg('Starting the decfile check')
17 query('Opening decfile')
18 if len(sys.argv) < 2:
19  fail(['Please pass the decfile as the first argument.'])
20  sys.exit()
21 
22 filename = sys.argv[1]
23 dkfilespath = os.path.dirname(os.path.abspath(sys.argv[0])) + '/' \
24  + settings.dkfilespath
25 
26 if not os.path.exists(filename):
27  fail(['The file does not exist'])
28  sys.exit()
29 elif not os.path.isfile(filename):
30 
31  fail(['The path does not point to a regular file.'])
32  sys.exit()
33 
34 file = open(filename)
35 if not file:
36  fail(['Unknown error opening file.'])
37  sys.exit()
38 
39 done()
40 
41 documentation_inprocess = False
42 date = ''
43 responsible = ''
44 eventtype = 0
45 descriptor = ''
46 nickname = ''
47 cuts = ''
48 fulleventcuts = ''
49 documentation = []
50 physicswg = ''
51 tested = ''
52 email = ''
53 extraopts = ''
54 particledefs = []
55 decay = {}
56 current_decay = []
57 order = []
58 
59 decay_started = False
60 decay_inprocess = False
61 
62 alias = {}
63 chargeconj = {}
64 cdecay = []
65 mother = ''
66 
67 Ended = False
68 endcheck = False
69 
70 linecount = 0
71 
72 
73 def getfield(line, string):
74  tmp = ''
75  if string + ':' in line:
76  query('Now parsing: ' + string)
77  tmp = line.partition(string + ':')[2]
78  done()
79  if tmp.startswith(' '):
80  tmp = tmp.strip()
81 # warning("Please leave a single space after the : sign. on line:"+str(linecount))
82  if tmp == '':
83  warning('Field empty on line ' + str(linecount))
84  return tmp
85 
86 
87 for line in file:
88  linecount += 1
89 
90  if line.strip() == '':
91  continue
92 
93  if line.startswith('#') and not decay_started:
94 
95  if documentation_inprocess:
96  if 'EndDocumentation' in line:
97  documentation_inprocess = False
98  documentation = ' '.join(documentation)
99  continue
100  documentation += [line.strip('#')]
101  continue
102 
103  tmp = getfield(line, 'Documentation')
104  if tmp:
105  file2 = open(filename)
106  for line2 in file2:
107  if 'EndDocumentation' in line2:
108  documentation_inprocess = True
109  break
110  file2.close()
111  documentation += [tmp]
112 
113  tmp = getfield(line, 'EventType')
114  if tmp:
115  try:
116  eventtype = int(tmp)
117  except:
118  fail(['Failed parsing eventtype on line ' + str(linecount),
119  'Not a number.'])
120  order += ['EventType']
121  mesg('Eventtype found: ' + str(eventtype))
122 
123  tmp = getfield(line, 'Descriptor')
124  if tmp:
125  descriptor = tmp
126  order += ['descriptor']
127  if '{,gamma}' in tmp:
128  warning('Please do not include radiative photons in the descriptor.'
129  )
130 
131  tmp = getfield(line, 'NickName')
132  if tmp:
133  if tmp == '':
134  fail(['NickName empty on line ' + str(linecount)])
135  elif not tmp == os.path.basename(filename).partition('.dec')[0]:
136  fail(['NickName not the same as filename!'])
137  else:
138  nickname = tmp
139  order += ['nickname']
140 
141  tmp = getfield(line, 'Cuts')
142  if tmp:
143  cuts = tmp
144  order += ['cuts']
145  test_cuts = ['None', 'DaughtersInBelleII']
146  if cuts not in test_cuts:
147  warning('Unknown cuts <' + cuts + '> on line ' + str(linecount) + '. Please check.')
148 
149  tmp = getfield(line, 'FullEventCuts')
150  if tmp:
151  fulleventcuts = tmp
152  order += ['fulleventcuts']
153 
154  tmp = getfield(line, 'ExtraOptions')
155  if tmp:
156  extraopts = tmp
157  order += ['extraopts']
158 
159  tmp = getfield(line, 'PhysicsWG')
160  if tmp:
161  physicswg = tmp
162  order += ['physicswg']
163 
164  tmp = getfield(line, 'Tested')
165  if tmp:
166  if tmp == 'No':
167  warning('File not tested! Please test the file!')
168  elif not tmp == 'Yes':
169  warning('Unkown Tested state. Please use Yes or No.')
170  else:
171  tested = tmp
172  order += ['tested']
173 
174  tmp = getfield(line, 'Responsible')
175  if tmp:
176  responsible = tmp
177  order += ['responsible']
178 
179  tmp = getfield(line, 'Email')
180  if tmp:
181  if '@' not in tmp:
182  warning('Please use a correct email format.')
183  else:
184  email = tmp
185  order += ['email']
186 
187  tmp = getfield(line, 'ParticleValue')
188  if tmp:
189  tmp = tmp.split(',')
190  tmp2 = {}
191  for part in tmp:
192  part = part.strip('"')
193  part = part.split()
194  tmp2[part[6]] = part[1]
195  particledefs = tmp2
196 
197  tmp = getfield(line, 'Date')
198  if tmp:
199  try:
200  date = int(tmp)
201  if not date / 10000 == time.gmtime().tm_year:
202  warning('Date is not from this year. Please use YYYYMMDD for date field. YYYY parsed:' +
203  str(date / 10000) + ' vs. current year: ' + str(time.gmtime().tm_year))
204  if date - 10000 * (date / 10000) > 1231:
205  warning('Cannot parse date. Please use YYYYMMDD for date field. MMDD parsed:' +
206  str(date - 10000 * (date / 10000)))
207  if date - 100 * (date / 100) > 31:
208  warning('Cannot parse date. Please use YYYYMMDD for date field. DD parsed:' +
209  str(date - 100 * (date / 100)))
210  except:
211  warning('Cannot parse date. Please use YYYYMMDD for date field.'
212  )
213  elif not line == '' and not decay_started and not Ended:
214 
215  mesg('End of header.')
216  decay_started = True
217 
218  if Ended:
219  endcheck = True
220 
221  if decay_started:
222  if not line.startswith('#'):
223  if 'Alias' in line:
224  elements = line.partition('Alias')[2].strip().split()
225  alias[elements[0].strip()] = elements[1].strip()
226  if 'ChargeConj' in line:
227  elements = line.partition('ChargeConj')[2].strip().split()
228  chargeconj[elements[0].strip()] = elements[1].strip()
229 
230  if 'CDecay' in line:
231  elements = line.partition('CDecay')[2].strip()
232  cdecay += [elements]
233  elif 'Decay' in line:
234 
235  mother = line.partition('Decay ')[2].strip()
236  mesg('Found decay: ' + mother)
237  decay_inprocess = True
238  continue
239 
240  if 'End' in line and 'Enddecay' not in line:
241  Ended = True
242  decay_started = False
243 
244  if decay_inprocess:
245  if 'Enddecay' in line:
246  decay[mother] = current_decay
247  decay_inprocess = False
248  # mesg("Found decay end of: "+mother)
249  current_decay = []
250  else:
251 
252  line = line.strip().split()
253  bf = line[0]
254  dec = []
255  try:
256  bf = float(bf)
257  except:
258  warning('Branching fraction not a number on line: ' +
259  str(linecount) + '. Skipping.')
260  continue
261  for daug in line[1:-1]:
262  if daug.strip(';') in settings.terminators:
263  # mesg("Terminator found, ending decay line.")
264  break
265  elif daug.endswith(';'):
266  warning('A new terminator found: ' + daug.strip(';') + '. Adding to list')
267  settings.terminators += [daug.strip(';')]
268  break
269  if daug in alias:
270  # daug = alias[daug]
271  pass
272  elif daug in chargeconj:
273  # daug = chargeconj[daug]
274  if daug in alias:
275  daug = alias[daug]
276  else:
277  warning("You defined a charge conjugation without either particle being an alias. "
278  "Are you sure you know what you're doing on line " + str(linecount) + '?')
279  else:
280  for k in alias:
281  if daug == alias[k]:
282  warning('You defined an alias to particle ' + daug + ' called ' + k + ' but on line ' +
283  str(linecount) + ' you use the original particle. Is this what you want?')
284  dec += [daug]
285  if not line[-1].endswith(';'):
286  warning('Line ' + str(linecount) + ' does not end with a ;')
287  current_decay += [(bf, dec)]
288 
289 mesg('File parsed successfully.')
290 file.close()
291 
292 if not eventtype:
293  warning("Cannot proceed without eventtype. Please fix the eventtype so it's recognisable."
294  )
295  sys.exit()
296 
297 newevtype = ''
298 parttype = eventtype
299 query('Checking general flag')
300 general = parttype / 10000000
301 flag = 0
302 parttype -= general * 10000000
303 mother = ''
304 for daug in decay:
305  if 'sig' in daug:
306  mother = daug.partition('sig')[0]
307  # mesg("Found mother: "+mother)
308  break
309 else:
310  if nickname.startswith('uubar'):
311  flag = 3
312  elif nickname.startswith('ddbar'):
313  flag = 3
314  elif nickname.startswith('ssbar'):
315  flag = 3
316  elif nickname.startswith('mixed'):
317  flag = 1
318  elif nickname.startswith('charged'):
319  flag = 1
320  elif nickname.startswith('charm'):
321  flag = 2
322  else:
323  fail(['Cannot find the signal particle and cannot determine the inclusive mode.'])
324  sys.exit()
325  done()
326 if mother:
327  if 'B' in mother or 'b0' in mother or 'Upsilon' in mother or 'chi_b' in mother:
328  flag = 1
329  elif 'D' in mother or 'psi' in mother or 'chi_c' in mother or 'c+' in mother:
330  flag = 2
331  elif 'K_S0' in mother or 'Lambda' in mother or 'Sigma' in mother or 'tau' in mother:
332  flag = 3
333  else:
334  warning("Didn't recognise the mother particle. Check general flag manually.")
335  flag = general
336  if not flag == general:
337  fail(['General flag not compliant. Should be ' + str(flag) + '.Please check.'])
338  else:
339  done()
340 newevtype += str(flag)
341 
342 query('Checking selection flag')
343 selection = parttype / 1000000
344 parttype -= selection * 1000000
345 flag = selection
346 if not mother:
347  flag = 0
348 elif mother == 'D-' or mother == 'B0' or mother == 'D+' or mother == 'anti-B0':
349  flag = 1
350 elif mother == 'D0' or mother == 'anti-D0' or mother == 'B+' or mother == 'B-':
351  flag = 2
352 elif mother == 'B_s0' or mother == 'D_s-' or mother == 'D_s+':
353  flag = 3
354 elif mother == 'J/psi':
355  flag = 4
356 elif mother == 'Lambda_b0' or mother == 'Lambda_c+':
357  flag = 5
358 elif ('Sigma_b' in mother or 'chi_b' in mother or 'Omega_b' in mother) and general == 1:
359  flag = 6
360 elif ('Upsilon' in mother or 'chi_b' in mother) and general == 1:
361  flag = 8
362 elif ('D' in mother and '*' in mother or 'D_s1' in mother) and general == 2:
363  flag = 7
364 elif ('psi(2S)' in mother or 'X_1(3872)' in mother or 'h_c' in mother or
365  'chi_c' in mother or mother == 'eta_c') and general == 2:
366 
367  flag = 8
368 elif general == 3:
369 
370  if mother == 'tau+' or mother == 'tau-':
371  flag = 1
372  elif 'Lambda' in mother:
373  flag = 3
374  elif 'Sigma' in mother:
375  flag = 2
376  elif mother == 'K_S0':
377  flag = 4
378  else:
379  warning('General flag is 3 but mother particle is not recogniced - assuming minbias.'
380  )
381  flag = 0
382 else:
383  warning('Cannot determine selection flag. Please check manually.')
384  flag = selection
385 if not flag == selection:
386  warning('Selection flag is not compliant, should be ' + str(flag) + '. Please check.')
387 else:
388  done()
389 newevtype += str(flag)
390 
391 query('Unfolding decay.')
392 
393 current_decay = []
394 if mother:
395  current_decay = (decay[mother + 'sig'])[:]
396 
397 for (bf2, dec2) in current_decay:
398  for daug in dec2:
399  if daug in decay:
400  newdecay = dec2[:]
401  newdecay.remove(daug)
402  for (bf2, dau2) in decay[daug]:
403  norm = 0.0
404  for (bf3, dau3) in decay[daug]:
405  norm += float(bf3)
406  newbf = bf * bf2 / norm
407  newdecay2 = newdecay[:] + dau2[:]
408  newdecay2.sort()
409  current_decay += [(newbf, newdecay2)]
410  break
411 
412 
413 def getmax(dec):
414  maximumbf = 0
415  toret = []
416  for (bf, dec2) in dec:
417  if bf > maximumbf:
418  maximumbf = bf
419  toret = dec2[:]
420  return toret
421 
422 
423 main_decay = []
424 if mother:
425  main_decay = [getmax(decay[mother + 'sig'])]
426 
427 clean = False
428 while not clean and mother:
429  clean = True
430  olddec = (main_decay[-1])[:]
431  for daug in main_decay[-1]:
432  if daug in alias:
433  olddec.remove(daug)
434  if daug not in decay:
435  for k in chargeconj:
436  if k == daug:
437  daug = chargeconj[k]
438  elif chargeconj[k] == daug:
439  daug = k
440  if daug not in decay:
441  warning('Aliased particle but cannot find its decay!: ' + daug)
442  newdec = [alias[daug]]
443  else:
444  newdec = getmax(decay[daug])
445  olddec += newdec
446  clean = False
447  if not clean:
448  main_decay += [olddec]
449 done()
450 
451 query('Checking the decay flag')
452 
453 decayflag = parttype / 100000
454 parttype -= decayflag * 100000
455 neutrinos = False
456 nFinal = 0
457 nCommon = 0
458 
459 final = []
460 
461 for (bf, dec) in current_decay:
462  common = 0
463  for (bf2, dec2) in current_decay:
464  test_dec1 = dec
465  test_dec2 = dec2
466  test_dec1.sort()
467  test_dec2.sort()
468  if test_dec2 == test_dec1:
469  common += 1
470  for daug in dec:
471  if 'nu_' in daug:
472  neutrinos = True
473  if common >= 2:
474  nCommon += 1
475  for daug in dec:
476  if daug in alias:
477  break
478  else:
479  if not final:
480  final = dec
481  final.sort()
482  else:
483  dec.sort()
484  if final == dec:
485  continue
486  nFinal += 1
487 
488 flag = 0
489 if mother:
490  flag += 1
491 if nFinal > 1:
492  flag += 2
493 if nCommon > 0:
494  flag += 1
495 if neutrinos:
496  flag += 4
497 
498 if not decayflag == flag:
499  fail(['Decay flag is not compliant. Should be ' + str(flag) + '. Please check'])
500 else:
501  done()
502 newevtype += str(flag)
503 
504 query('Checking charm and lepton flag')
505 electron = False
506 muon = False
507 opencharm = False
508 closedcharm = False
509 doubleopen = False
510 
511 charmflag = parttype / 10000
512 parttype -= charmflag * 10000
513 
514 caughtopen = False
515 if not mother:
516  for field in [extraopts, cuts, fulleventcuts]:
517  if 'Electron' in field or 'electron' in field:
518  electron = True
519  if 'mu' in field or 'Mu' in field:
520  muon = True
521  if 'D0' in field or 'Dmu' in field or 'Ds' in field or 'DS' in field or 'DMass' in field or 'DMu' in field:
522  opencharm = True
523  if 'Jpsi' in field:
524  closedcharm = True
525 
526 for dec in main_decay:
527  caughtopen = False
528  for daug in dec:
529  if daug in alias:
530  daug = alias[daug]
531  # if "D" in mother or "Lambda_c" in mother:
532  # opencharm=True
533  if daug == 'e-' or daug == 'e+':
534  electron = True
535  continue
536  if daug == 'mu-' or daug == 'mu+':
537  muon = True
538  continue
539  if ('D' in daug or '_c' in daug) and 'chi_c' not in daug:
540  if caughtopen:
541  doubleopen = True
542  caughtopen = False
543  continue
544  caughtopen = True
545  opencharm = True
546  continue
547  if 'psi' in daug or 'chi_c' in daug:
548  closedcharm = True
549  continue
550 flag = 0
551 if opencharm:
552  flag += 6
553 elif closedcharm:
554  flag += 3
555 if electron:
556  flag += 2
557 elif muon:
558  flag += 1
559 if doubleopen:
560  flag = 9
561 
562 if not flag == charmflag:
563  fail(['Charm flag is not compliant. Should be :' + str(flag) + '. Please check'])
564 else:
565  done()
566 newevtype += str(flag)
567 
568 query('Checking track flag.')
569 trackflag = parttype / 1000
570 parttype -= trackflag * 1000
571 
572 maxbf = 0
573 maxtracks = 0
574 if not mother:
575  warning('Inclusive decay: Problem with settings the track flag. Check manually.'
576  )
577  if 'DiLepton' in fulleventcuts or 'DiLepton' in cuts or 'DiLepton' in extraopts:
578  maxtracks = 2
579 for dec in main_decay:
580  for daug in dec:
581  if daug in decay:
582  break
583  else:
584  tracks = 0
585  for daug in dec:
586  if daug in settings.longlived:
587  if tracks <= 9:
588  tracks += 1
589  if tracks > maxtracks:
590  maxtracks = tracks
591 
592 if not trackflag == maxtracks:
593  fail(['Track flag not compliant. Should be: ' + str(maxtracks) + '. Please check.'])
594 else:
595  done()
596 newevtype += str(maxtracks)
597 
598 query('Checking neutrals flag.')
599 neutrals = parttype / 100
600 parttype -= neutrals * 100
601 
602 pi0eta = False
603 gamma = False
604 Kslambda = False
605 klong = False
606 
607 for dec in main_decay:
608  for daug in dec:
609  if daug in alias:
610  daug = alias[daug]
611  if daug == 'K_S0' or daug == 'Lambda0' or mother == 'K_S0' or mother == 'Lambda0':
612  Kslambda = True
613  elif daug == 'pi0' or daug == 'eta':
614  pi0eta = True
615  elif daug == 'K_L0':
616  Klong = True
617 
618 previous_pi = False
619 for i in range(len(main_decay)):
620  if 'gamma' in main_decay[i]:
621  toBreak = False
622  if i != 0:
623  for daug in main_decay[i - 1]:
624  daug2 = daug
625  if daug in alias:
626  daug2 = alias[daug]
627  if daug2 == 'pi0' or daug2 == 'eta':
628  if daug not in main_decay[i]:
629  toBreak = True
630  if toBreak:
631  continue
632  gamma = True
633 
634 flag = 0
635 if Kslambda:
636  flag += 1
637 if klong:
638  flag += 8
639 else:
640  if gamma:
641  flag += 2
642  if pi0eta:
643  flag += 4
644 
645 if not flag == neutrals:
646  fail(['Neutrals flag not compliant. Should be ' + str(flag) + '. Please check.'])
647 else:
648  done()
649 newevtype += str(flag)
650 
651 query('Checking the extra and user for duplicity .')
652 
653 if settings.use_url:
654  if not zippednos:
655  warning('Cannot parse decfiles webpage')
656  settings.use_url = False
657  else:
658  for (k, v) in zippednos:
659  if filename.partition('=')[0] == v.partition('=')[0] and not eventtype / 10 == k / 10:
660  warning('The decfile: ' + v + ':' + str(k) + ' should contain the same decay, therefore the first 7 '
661  'digits of the eventtype should match. Please check and use the same extra flag.')
662  failed = True
663  if k == eventtype:
664  warning('Error: ' + v + ' has this eventtype already.')
665  failed = True
666  if k / 10 == eventtype / 10 and not os.path.basename(filename).partition('=')[0] == v.partition('=')[0]:
667  warning('The decfile: ' + v + ':' + str(k) + ' uses this extra flag, but the decay seems different. '
668  'Please check and use a unique extra flag.')
669  failed = True
670 
671  if settings.obs_url:
672 
673  if not obsnos:
674  warning('Cannot parse obsoletes trac file.')
675  settings.use_url = False
676  else:
677  if str(eventtype) in obsnos:
678  warning('The eventtype is obsolete on the line ' +
679  str(obsnos.index(str(eventtype)) + 1) + ' in: ' +
680  settings.obs_url)
681  failed = True
682 
683 if not settings.use_url:
684  filelist = os.listdir(dkfilespath)
685  newtype = 0
686  failed = False
687  for filen in filelist:
688  if filen.endswith('.dec'):
689  file = open(dkfilespath + '/' + filen)
690  for line in file:
691  if 'EventType: ' in line:
692  try:
693  newtype = int(line.partition('EventType: ')[2].strip())
694  break
695  except:
696  break
697  if filen.partition('=')[0] == filename.partition('='):
698  if not newtype / 10 == eventtype / 10:
699  warning('The decfile: ' + filen + ':' + str(newtype) + ' should contain the same decay, therefore the first 7 '
700  'digits of the eventtype should match. Please check and use the same extra flag.')
701  failed = True
702 # if newtype == eventtype and not os.path.basename(filename) == v:
703  if newtype == eventtype:
704  warning('Error: ' + filen + ' has this eventtype already.')
705  failed = True
706 
707  if settings.obsoletepath:
708  obsfile = open(settings.obsoletepath + '/table_obsolete.sql')
709  if obsfile:
710  for line in obsfile:
711  if int(line.partition('EVTTYPEID = ')[2].partition(', DESCRIPTION')[0]) == eventtype:
712  warning('The eventtype is obsolete on the following line in: ' + settings.obsoletepath + '/table_obsolete.sql')
713  mesg(line)
714  failed = True
715 
716 extraflag = eventtype / 10
717 extraflag = eventtype - extraflag * 10
718 if 'DaughtersInBelleII' not in cuts and extraflag and cuts == 0:
719  warning('Your cuts are not empty, please set your userflag to greater or equal to 1.'
720  )
721  failed = True
722 if cuts == ['None'] and extraflag != 0:
723  warning("Your cuts are empty, your user flag should be 0 unless that's taken. Please check."
724  )
725 
726 if failed:
727  fail([])
728 else:
729  done()
730 mesg('Eventtype constructed: ' + newevtype + 'XX')
731 
732 query('Checking nickname.')
733 faillist = []
734 failed = False
735 if not nickname == os.path.basename(filename).partition('.dec')[0]:
736  faillist += ['Filename not the same as nickname! Fix.']
737  failed = True
738 nick = nickname.partition('=')
739 if not nick[1] == '=' and not cuts == []:
740  faillist += \
741  ['The = sign not found in the nickname while cuts are present. Check nickname conventions and fix.'
742  ]
743  warning('The = sign not found in the nickname while cuts are present. Check nickname conventions and fix.'
744  )
745  # failed = True
746 if 'DaughtersInBelleII' in cuts and 'DecProdCut' not in nick[2].split(','):
747  faillist += \
748  ['You have decay angular acceptance cut in Cuts but not in the nickname.'
749  ]
750  failed = True
751 
752 if failed:
753  fail(faillist)
754 else:
755  done()
756 
757 if not len(nick[0].split(',')) > 1 and mother:
758  warning('Found only one decay level in the nickname - highly unusual, you should probably use at least two.'
759  )
760 
761 if len(nick[2].split(',')) < len(cuts.split(',')):
762  warning('You have more cuts than declared in the nickname. Please check.')
763 
764 query('Checking the Physics WG.')
765 if physicswg not in settings.groups:
766  fail(['The group /' + physicswg + '/ is not known. Please use one of the following:',
767  settings.groups])
768 else:
769  done()
770 
771 if mother:
772  query('Building descriptor.')
773  max_bf = 0
774  curdec = []
775  for (bf, dec) in decay[mother + 'sig']:
776  if bf > max_bf:
777  max_bf = bf
778  for (bf, dec) in decay[mother + 'sig']:
779  if bf == max_bf:
780  curdec = dec[:]
781  descript = [mother] + ['->'] + curdec
782 
783  notclean = True
784  while notclean:
785  for daug in descript:
786  notclean = False
787  if daug in decay:
788  notclean = True
789  max_bf = 0
790  for (bf, dec) in decay[daug]:
791  if bf > max_bf:
792  max_bf = bf
793  for (bf, dec) in decay[daug]:
794  if bf == max_bf:
795  curdec = dec[:]
796  ind = descript.index(daug)
797  descript.remove(daug)
798  if daug not in alias:
799  warning('You decay a particle: [' + daug +
800  '] without aliasing it first. Step aborted.')
801  notclean = False
802  break
803  else:
804  daug = alias[daug]
805  toadd = ['(', daug, '->'] + curdec + [')']
806  toadd.reverse()
807  for el in toadd:
808  descript.insert(ind, el)
809 
810 # Obsolete piece of code
811 # for i in range(len(descript)):
812 # if descript[i] in settings.descripslation:
813 # descript[i] = settings.descripslation[descript[i]]
814 
815  descript = '[' + ' '.join(descript) + ']'
816  descript = descript.replace('( ', '(')
817  descript = descript.replace(' )', ')')
818  for daug in cdecay:
819  if 'sig' in daug:
820  descript += 'cc'
821  break
822 
823  done()
824 
825  query('Checking descriptor.')
826 
827  decr_old = descriptor.partition('[')[2].partition(']')[0].split()
828  decr_new = descript.partition('[')[2].partition(']')[0].split()
829 
830  listA = descriptcheck.convertToList(descript)
831  listB = descriptcheck.convertToList(descriptor)
832 
833  if descriptcheck.compareList(listB, listA):
834  done()
835  else:
836  fail(['Descriptor not matched. Please check the old one:', descriptor,
837  '\nAnd the one built by the parser: ', descript])
838  for mes in descriptcheck.mesgdict:
839  warning(mes)
840 
841  for daug in decay:
842  print(daug, decay[daug])
843 
844  print('Main decay chain:')
845  for dec in main_decay:
846  print(dec)
847 
848 sys.exit('Decfile check complete.')
descriptcheck.compareList
def compareList(listA, listB)
Definition: descriptcheck.py:120
descriptcheck.convertToList
def convertToList(stringA)
Definition: descriptcheck.py:42