1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 """Definitions of the objects needed both for MadFKS from real
17 and MadFKS from born"""
18
19 import madgraph.core.base_objects as MG
20 import madgraph.core.helas_objects as helas_objects
21 import madgraph.core.diagram_generation as diagram_generation
22 import madgraph.core.color_amp as color_amp
23 import madgraph.core.color_algebra as color_algebra
24 from operator import itemgetter
25 import copy
26 import logging
27 import array
28 import fractions
33 """Exception for MadFKS"""
34 pass
35
38 """Modified diagram tags to be used to link born and real configurations.
39 """
40
41 @staticmethod
43 """Returns the default end link for a leg: ((id, number), number).
44 Note that the number is not taken into account if tag comparison,
45 but is used only to extract leg permutations.
46 """
47 return [((leg.get('id'), leg.get('number')), leg.get('number'))]
48
51 """finds the real configurations that match the born ones, i.e. for
52 each born configuration, the real configuration that has the ij ->
53 i j splitting. i, j and ij are integers, and refer to the leg
54 position in the real process (i, j) and in the born process (ij).
55 """
56
57 id_ij = born_amp['process']['legs'][ij - 1]['id']
58 nlegs_b = len(born_amp['process']['legs'])
59 nlegs_r = len(real_amp['process']['legs'])
60 if nlegs_r - nlegs_b != 1:
61 raise FKSProcessError('Inconsistent number of born and real legs: %d %d' % (nlegs_b, nlegs_r))
62
63
64 shift_dict = {}
65 for ir in range(1, nlegs_r + 1):
66 shift = 0
67 if ir > j:
68 shift += 1
69 if ir > i:
70 shift += 1
71 if ir > ij and ij <= max(i,j):
72 shift -= 1
73 shift_dict[ir] = ir - shift
74
75
76 minvert = min([max([len(vert.get('legs')) \
77 for vert in diag.get('vertices')]) \
78 for diag in born_amp.get('diagrams')])
79
80 born_confs = []
81 real_confs = []
82
83 k=0
84 for diag in born_amp.get('diagrams'):
85 if any([len(vert.get('legs')) > minvert for vert in
86 diag.get('vertices')]):
87 continue
88 else:
89 born_confs.append({'number' : k, 'diagram' : diag})
90 k=k+1
91
92 k=0
93 for diag in real_amp.get('diagrams'):
94 if any([len(vert.get('legs')) > minvert \
95 for vert in diag.get('vertices')]):
96 continue
97 else:
98 real_confs.append({'number': k, 'diagram': diag})
99 k=k+1
100
101 good_diags = []
102
103
104
105
106 real_confs_new = copy.deepcopy(real_confs)
107 for diag in real_confs_new:
108 for vert in diag['diagram'].get('vertices'):
109 vert_legs = [l.get('number') for l in vert.get('legs')]
110 vert_ids = [l.get('id') for l in vert.get('legs')]
111 if (i in vert_legs and not j in vert_legs) or \
112 (j in vert_legs and not i in vert_legs):
113 break
114
115 if i in vert_legs and j in vert_legs:
116 vert_ids.remove(vert_ids[vert_legs.index(i)])
117 vert_legs.remove(i)
118 vert_ids.remove(vert_ids[vert_legs.index(j)])
119 vert_legs.remove(j)
120 last_leg = vert_legs[0]
121
122
123 if abs(vert_ids[0]) == abs(id_ij):
124 diag['diagram']['vertices'].remove(vert)
125 good_diags.append({'diagram': diag['diagram'],
126 'leg_ij': last_leg,
127 'number': diag['number']})
128 break
129
130
131
132
133
134
135
136
137
138
139
140 for ir in range(1, nlegs_r + 1):
141 for good_diag in good_diags:
142 for vert in good_diag['diagram'].get('vertices'):
143 for l in vert.get('legs'):
144 if l.get('number') == ir:
145 l.set('number', shift_dict[l.get('number')])
146
147
148 if len(good_diags) == 1 and len(born_confs) == 1:
149 return [{'real_conf': good_diags[0]['number'],
150 'born_conf': born_confs[0]['number']}]
151
152
153
154 if nlegs_b ==3:
155 for diag in good_diags:
156 counts = []
157 for il in range(nlegs_b):
158 counts.append([l['number'] for v in diag['diagram']['vertices'] for l in v['legs']].count(il+1))
159
160
161 even_list = [c / 2 * 2 == c for c in counts]
162 if any(even_list):
163 if not even_list.count(True) == 2:
164 raise FKSProcessError('Linking: Don\'t know what to do in this case')
165
166 ilmax = counts.index(max([c for c in counts if even_list[counts.index(c)]]))
167 ilmin = counts.index(min([c for c in counts if even_list[counts.index(c)]]))
168
169
170 replaced = False
171 for vert in diag['diagram']['vertices']:
172 for leg in vert['legs']:
173 if leg['number'] == ilmax + 1 and not replaced:
174 leg['number'] = ilmin + 1
175 replaced = True
176
177
178 born_tags = [FKSDiagramTag(d['diagram'],
179 born_amp.get('process').get('model')) \
180 for d in born_confs]
181
182
183 real_tags = [FKSDiagramTag(d['diagram'],
184 real_amp.get('process').get('model')) \
185 for d in good_diags ]
186 real_tags = []
187 for d in good_diags:
188 tag = FKSDiagramTag(d['diagram'], real_amp.get('process').get('model'))
189 if not tag in real_tags:
190 real_tags.append(tag)
191
192
193 if len(born_tags) != len(real_tags):
194 print '\n'.join([str(r) for r in real_tags]) + '\n'
195 raise FKSProcessError('Cannot map born/real configurations between \
196 %s and %s (i,j=%d,%d): not same number of configurations: %d %d' % \
197 (born_amp.get('process').nice_string().replace('Process:',''),
198 real_amp.get('process').nice_string().replace('Process:',''),
199 i,j,
200 len(born_tags),
201 len(real_tags)))
202
203 links = []
204 for ib, btag in enumerate(born_tags):
205 try:
206 ir = real_tags.index(btag)
207 links.append({'real_conf': good_diags[ir]['number'],
208 'born_conf': born_confs[ib]['number']})
209 real_tags.remove(btag)
210 good_diags.pop(ir)
211 except ValueError:
212 print real_tags, i, j, ij
213 print '\n'.join( d['diagram'].nice_string() for d in good_diags)
214 raise FKSProcessError('Linking %s to %s: could not link born diagram %s' % \
215 (born_amp.get('process').nice_string().replace('Process:',''),
216 real_amp.get('process').nice_string().replace('Process:',''),
217 born_confs[ib]['diagram'].nice_string()) )
218
219 return links
220
224 """Takes an amplitude as input, and returns a dictionary with the
225 orders of the couplings.
226 """
227 assert isinstance(amp, diagram_generation.Amplitude)
228 orders = {}
229 for diag in amp.get('diagrams'):
230 for order, value in diag.get('orders').items():
231 if value != 0 or order in amp['process']['orders'].keys():
232 try:
233 orders[order] = max(orders[order], value)
234 except KeyError:
235 orders[order] = value
236 return orders
237
240 """Finds the possible splittings corresponding to leg
241 """
242 if dict == {}:
243 dict = find_pert_particles_interactions(model, pert)
244 splittings = []
245
246
247 if leg.get('id') in dict['pert_particles']:
248 part = model.get('particle_dict')[leg.get('id')]
249 antipart = model.get('particle_dict')[part.get_anti_pdg_code()]
250 for ii in dict['interactions']:
251
252 parts = copy.deepcopy(ii['particles'])
253 nsoft = 0
254 if part in parts:
255
256 parts.pop(parts.index(antipart))
257 for p in parts:
258 if p.get_pdg_code() in dict['soft_particles']:
259 nsoft += 1
260 if nsoft >= 1:
261 splittings.extend(split_leg(leg, parts, model))
262 return splittings
263
266 """Splits the leg into parts, and returns the two new legs.
267 """
268
269 split = []
270
271 if leg['state'] :
272 split.append([])
273 for part in parts:
274 split[-1].append(to_fks_leg({'state': True, \
275 'id': part.get_pdg_code()},model))
276 ij_final(split[-1])
277
278
279 else:
280 if parts[0] != parts[1]:
281 for part in parts:
282 cparts = copy.deepcopy(parts)
283 split.append([\
284 to_fks_leg({'state': False,
285 'id': cparts.pop(cparts.index(part)).get_pdg_code(),
286 'fks': 'j'}, model),
287 to_fks_leg({'state': True,
288 'id': cparts[0].get_anti_pdg_code(),
289 'fks': 'i'}, model)\
290 ])
291 else:
292 split.append([\
293 to_fks_leg({'state': False,
294 'id': parts[0].get_pdg_code(),
295 'fks': 'j'}, model),
296 to_fks_leg({'state': True,
297 'id': parts[1].get_anti_pdg_code(),
298 'fks': 'i'}, model)])
299 return split
300
303 """given a pair of legs in the final state, assigns the i/j fks id
304 NOTE: the j partons is always put before the i one
305 """
306
307
308
309 if len(pair) == 2:
310 for i in range(len(pair)):
311 set = 0
312 if (pair[i]['massless'] and pair[i]['self_antipart']) or \
313 (not pair[i]['is_part'] and pair[1-i]['is_part'] and\
314 (pair[i]['spin']+pair[1-i]['spin'])%2==0) and not set:
315 pair[i]['fks'] = 'i'
316 pair[1-i]['fks'] = 'j'
317
318 if i < 1 - i:
319 pair.reverse()
320 set = 1
321
323 """Returns a new leglist with leg splitted into split.
324 The convention is to remove leg ij, replace it with leg j, and put
325 i at the end of the group of legs with the same color(charge) representation
326 """
327 if pert =='QCD':
328 color = 'color'
329 elif pert == 'QED':
330 color = 'charge'
331 else:
332 raise FKSProcessError, "Only QCD or QED is allowed not %s" % pert
333
334 leglist = FKSLegList(copy.deepcopy(leglist_orig))
335
336 for i in range(len(leglist)):
337 if leglist[-i - 1].get('state'):
338 firstfinal = len(leglist) - i - 1
339
340 leglist[leglist.index(leg)] = split[0]
341
342 col_maxindex = {}
343 mass_col_maxindex = {}
344 for col in set([l[color] for l in leglist[firstfinal:] if l['massless']]):
345 col_maxindex[col] = max([0] + [leglist.index(l) for l in leglist[firstfinal:]\
346 if l[color] == col and l['massless']])
347 for col in set([abs(l[color]) for l in leglist[firstfinal:] if not l['massless']]):
348 mass_col_maxindex[col] = max([0] + [leglist.index(l) for l in leglist[firstfinal:]\
349 if abs(l[color]) == col and not l['massless']])
350
351 if pert == 'QCD':
352 for col in copy.copy(col_maxindex.keys()):
353 if abs(col) > abs(split[1][color]):
354 del col_maxindex[col]
355
356
357
358
359 if split[1]['is_part'] and not split[1]['self_antipart']:
360
361
362
363
364 try:
365 del col_maxindex[-split[1][color]]
366 except KeyError:
367 pass
368
369 leglist.insert(max(col_maxindex.values() + mass_col_maxindex.values() + [firstfinal - 1] ) + 1, split[1])
370
371
372
373
374
375
376
377
378
379
380
381 for i, leg in enumerate(leglist):
382 leg['number'] = i + 1
383 return leglist
384
385
386 -def combine_ij( i, j, model, dict, pert='QCD'):
387 """checks whether FKSlegs i and j can be combined together in the given model
388 and with given perturbation order and if so combines them into ij.
389 If dict is empty it is initialized with find_pert_particles_interactions
390 """
391 if dict == {}:
392 dict = find_pert_particles_interactions(model, pert)
393 ij = []
394 num = copy.copy(min(i.get('number'), j.get('number')))
395
396
397 not_double_counting = (j.get('spin') == 3 and j.get('massless') and
398 i.get('spin') == 3 and i.get('massless')) or \
399 j.get('spin') != 3 or not j.get('massless') or \
400 not j.get('state')
401
402
403
404 if j.get('state') and j.get('id') == - i.get('id'):
405 not_double_counting = not_double_counting and j.get('id') >0
406
407 if i.get('id') in dict['soft_particles'] and \
408 j.get('id') in dict['pert_particles'] and \
409 i.get('state') and not_double_counting:
410 for int in dict['interactions']:
411 parts= copy.copy(int['particles'])
412
413 try:
414 parts.remove(model.get('particle_dict')[i.get('id')])
415 except ValueError:
416 continue
417
418
419 if j.get('state'):
420 j_id = j.get('id')
421 else:
422 j_id = model.get('particle_dict')[j.get('id')].get_anti_pdg_code()
423 try:
424 parts.remove(model.get('particle_dict')[j_id])
425 except ValueError:
426 continue
427
428
429 if j.get('state'):
430 ij.append(MG.Leg({
431 'id': parts[0].get_anti_pdg_code(),
432 'state': True,
433 'number': num}))
434 else:
435 ij.append(MG.Leg({
436 'id': parts[0].get_pdg_code(),
437 'state': False,
438 'number': num}))
439 return to_fks_legs(ij, model)
440
441
442 -def find_pert_particles_interactions(model, pert_order = 'QCD'):
443 """given a model and pert_order, returns a dictionary with as entries:
444 --interactions : the interactions of order pert_order
445 --pert_particles : pdgs of particles taking part to interactions
446 --soft_particles : pdgs of massless particles in pert_particles
447 """
448
449 ghost_list = []
450 ghost_list += [ p.get_pdg_code() for p in model.get('particles') if p.get('ghost')]
451 qcd_inter = MG.InteractionList()
452 pert_parts = []
453 soft_parts = []
454 for i, ii in model.get('interaction_dict').items():
455
456
457 if ii.get('orders') == {pert_order:1} and len(ii['particles']) == 3 :
458 masslist = [p.get('mass').lower() for p in ii['particles']]
459
460
461
462
463 try:
464 masslist.remove('zero')
465 except ValueError:
466 continue
467 if len(set(masslist)) == 1 and not \
468 any( [ p.get_pdg_code() in ghost_list for p in ii['particles']]) :
469 qcd_inter.append(ii)
470 for pp in ii['particles']:
471 pert_parts.append(pp.get_pdg_code())
472 if pp['mass'].lower() == 'zero':
473 soft_parts.append(pp.get_pdg_code())
474
475 return {'interactions': sorted(qcd_inter),
476 'pert_particles': sorted(set(pert_parts)),
477 'soft_particles': sorted(set(soft_parts))}
478
481 """insert the color links in col_obj: returns a list of dictionaries
482 (one for each link) with the following entries:
483 --link: the numbers of the linked legs
484 --link_basis: the linked color basis
485 --link_matrix: the color matrix created from the original basis and the linked one
486 """
487 assert isinstance(col_basis, color_amp.ColorBasis)
488 assert isinstance(col_obj, list)
489 result =[]
490 for link in links:
491 this = {}
492
493 l =[]
494 for leg in link['legs']:
495 l.append(leg.get('number'))
496 this['link'] = l
497
498
499
500
501
502 this_col_obj = []
503 for old_dict in col_obj:
504 new_dict = dict(old_dict)
505 for k, string in new_dict.items():
506 new_dict[k] = string.create_copy()
507 for col in new_dict[k]:
508 for ind in col:
509 for pair in link['replacements']:
510 if ind == pair[0]:
511 col[col.index(ind)] = pair[1]
512 new_dict[k].product(link['string'])
513 this_col_obj.append(new_dict)
514 basis_link = color_amp.ColorBasis()
515 for ind, new_dict in enumerate(this_col_obj):
516 basis_link.update_color_basis(new_dict, ind)
517
518 this['link_basis'] = basis_link
519 this['link_matrix'] = color_amp.ColorMatrix(col_basis,basis_link)
520 result.append(this)
521 basis_orig = color_amp.ColorBasis()
522 for ind, new_dict in enumerate(col_obj):
523 basis_orig.update_color_basis(new_dict, ind)
524
525 for link in result:
526 link['orig_basis'] = basis_orig
527 return result
528
532 """Finds all the possible color(charge) links between any
533 two legs of the born.
534 If symm is true, only half of the color links are generated, those
535 for which leg1['number'] <= leg2['number']
536 """
537 if pert == 'QCD':
538 color = 'color'
539 zero = 1
540 elif pert == 'QED':
541 color = 'charge'
542 zero = 0.
543 else:
544 raise FKSProcessError,"Only QCD or QED is allowed not %s" % pert
545 color_links = []
546 for leg1 in leglist:
547 for leg2 in leglist:
548
549 if (leg1.get(color) != zero and leg2.get(color) != zero) \
550 and (leg1 != leg2 or not leg1.get('massless')):
551 if not symm or leg1['number'] <= leg2['number']:
552 col_dict = legs_to_color_link_string(leg1,leg2,pert = pert)
553 color_links.append({
554 'legs': [leg1, leg2],
555 'string': col_dict['string'],
556 'replacements': col_dict['replacements']})
557
558 return color_links
559
562 """given two FKSlegs, returns a dictionary containing:
563 --string: the color link between the two particles, to be appended to
564 the old color string
565 extra minus or 1/2 factor are included as it was done in MadDipole
566 --replacements: a pair of lists containing the replacements of the color
567 indices in the old string to match the link
568 """
569
570
571
572 legs = FKSLegList([leg1, leg2])
573 dict = {}
574 min_index = -3000
575 iglu = min_index*2
576 string = color_algebra.ColorString()
577 replacements = []
578 if pert == 'QCD':
579 if leg1 != leg2:
580 for leg in legs:
581 min_index -= 1
582 num = leg.get('number')
583 replacements.append([num, min_index])
584 icol = 1
585 if not leg.get('state'):
586 icol = - 1
587 if leg.get('color') * icol == 3:
588 string.product(color_algebra.ColorString([
589 color_algebra.T(iglu, num, min_index)]))
590 string.coeff = string.coeff * (-1)
591 elif leg.get('color') * icol == - 3:
592 string.product(color_algebra.ColorString([
593 color_algebra.T(iglu, min_index, num)]))
594 elif leg.get('color') == 8:
595 string.product(color_algebra.ColorString(init_list = [
596 color_algebra.f(min_index,iglu,num)],
597 is_imaginary =True))
598
599 else:
600 icol = 1
601 if not leg1.get('state'):
602 icol = - 1
603 num = leg1.get('number')
604 replacements.append([num, min_index -1])
605 if leg1.get('color') * icol == 3:
606 string = color_algebra.ColorString(
607 [color_algebra.T(iglu, iglu, num, min_index -1)])
608 elif leg1.get('color') * icol == - 3:
609 string = color_algebra.ColorString(
610 [color_algebra.T(iglu, iglu, min_index-1, num)])
611 elif leg1.get('color') == 8:
612 string = color_algebra.ColorString(init_list = [
613 color_algebra.f(min_index-1,iglu,min_index)],
614 is_imaginary =True)
615 string.product(color_algebra.ColorString(init_list = [
616 color_algebra.f(min_index,iglu,num)],
617 is_imaginary =True))
618 string.coeff = string.coeff * fractions.Fraction(1, 2)
619
620 elif pert == 'QED':
621 for leg in legs:
622
623 string.coeff = string.coeff * fractions.Fraction(leg['charge']*3.)*\
624 fractions.Fraction(1,3)
625 else:
626 raise FKSProcessError,"Only QCD or QED is allowed not %s"% pert
627
628 dict['replacements'] = replacements
629 dict['string'] = string
630 return dict
631
634 """Given a process, this function returns the same process
635 but with sorted FKSLegs.
636 """
637 leglist = to_fks_legs(process.get('legs'), process.get('model'))
638 leglist.sort(pert = pert)
639 for n, leg in enumerate(leglist):
640 leg['number'] = n + 1
641 process['legs'] = leglist
642
643 process['legs_with_decays']=MG.LegList()
644
645 return process
646
649 """Given a FKSLeg, returns the original Leg.
650 """
651 leg = MG.Leg( \
652 {'id': fksleg.get('id'),
653 'number': fksleg.get('number'),
654 'state': fksleg.get('state'),
655 'from_group': fksleg.get('from_group'),
656 })
657 return leg
658
661 """Given a FKSLegList, returns the corresponding LegList.
662 """
663 leglist = MG.LegList()
664 for leg in fkslegs:
665 leglist.append(to_leg(leg))
666 return leglist
667
670 """Given a leg or a dict with Leg entries,
671 adds color, spin and massless entries, according to model"""
672 fksleg = FKSLeg(leg)
673 part = model.get('particle_dict')[leg['id']]
674 fksleg['color'] = part.get_color()
675 fksleg['charge'] = part.get_charge()
676 fksleg['massless'] = part['mass'].lower() == 'zero'
677 fksleg['spin'] = part.get('spin')
678 fksleg['is_part'] = part.get('is_part')
679 fksleg['self_antipart'] = part.get('self_antipart')
680 return fksleg
681
684 """given leglist, sets color and massless entries according to the model
685 variable.
686 return a FKSLeglist"""
687 fkslegs = FKSLegList()
688 for leg in leglist:
689 fkslegs.append(to_fks_leg(leg, model))
690 return fkslegs
691
694 """list of FKSLegs"""
695
697 """Test if object obj is a valid FKSLeg for the list."""
698 return isinstance(obj, FKSLeg)
699
700 - def sort(self,pert='QCD'):
701 """Sorting routine, sorting chosen to be optimal for madfks"""
702 sorted_leglist = FKSLegList()
703
704 initial_legs = FKSLegList([l for l in copy.copy(self) if not l['state']])
705
706 final_legs = FKSLegList([l for l in copy.copy(self) if l['state']])
707 if len(initial_legs) == 1:
708 sorted_leglist.extend(initial_legs)
709 elif len(initial_legs) == 2:
710 if initial_legs[0]['number'] > initial_legs[1]['number']:
711 initial_legs.reverse()
712 sorted_leglist.extend(initial_legs)
713 else:
714 raise FKSProcessError('Too many initial legs')
715
716 if pert == 'QCD':
717 color = 'color'
718 zero = 1
719 elif pert == 'QED':
720 color = 'charge'
721 zero = 0.
722 else:
723 raise FKSProcessError,"Only QCD and QED is allowed not %s"% pert
724 colors = sorted(set([abs(l[color]) for l in final_legs]))
725
726 if zero in colors:
727 sorted_leglist.extend(sorted(\
728 [l for l in final_legs if l[color] == zero], key = itemgetter('number')))
729 colors.remove(zero)
730
731
732 massless_dict = {}
733 massive_dict = {}
734 for col in colors:
735 col_legs = FKSLegList([l for l in final_legs if abs(l[color]) == col])
736
737 massive_dict[col] = [l for l in col_legs if not l['massless']]
738 massless_dict[col] = [l for l in col_legs if l['massless']]
739
740 for i_m, dict in enumerate([massive_dict, massless_dict]):
741 for col in colors:
742
743
744 if col == zero:
745 keys = [itemgetter('number'), itemgetter('number')]
746 reversing = False
747 else:
748 keys = [itemgetter('id'), itemgetter('id')]
749 reversing = True
750
751 init_pdg_legs = []
752 list = dict[col]
753 if len(initial_legs) == 2:
754
755 for i in range(len(set([ abs(l['id']) for l in initial_legs]))):
756 pdg = abs(initial_legs[i]['id'])
757 init_pdg_legs = [l for l in list if abs(l['id']) == pdg]
758 if init_pdg_legs:
759
760
761 init_pdg_legs.sort(key = keys[i_m], reverse=reversing)
762 sorted_leglist.extend(FKSLegList(init_pdg_legs))
763
764 init_pdgs = [ abs(l['id']) for l in initial_legs]
765 other_legs = [l for l in list if not abs(l['id']) in init_pdgs]
766 other_legs.sort(key = keys[i_m], reverse=reversing)
767 sorted_leglist.extend(FKSLegList(other_legs))
768 else:
769 list.sort(key = keys[i_m], reverse=reversing)
770 sorted_leglist.extend(FKSLegList(list))
771
772 for i, l in enumerate(sorted_leglist):
773 self[i] = l
774
778 """a class for FKS legs: it inherits from the ususal leg class, with two
779 extra keys in the dictionary:
780 -'fks', whose value can be 'i', 'j' or 'n' (for "normal" particles)
781 -'color', which gives the color of the leg
782 -'charge', which gives the charge of the leg
783 -'massless', boolean, true if leg is massless
784 -'spin' which gives the spin of leg
785 -'is_part', boolean, true if leg is an particle
786 -'self_antipart', boolean, true if leg is an self-conjugated particle
787 """
788
790 """Default values for all properties"""
791 super(FKSLeg, self).default_setup()
792
793 self['fks'] = 'n'
794 self['color'] = 0
795 self['charge'] = 0.
796 self['massless'] = True
797 self['spin'] = 0
798 self['is_part'] = True
799 self['self_antipart'] = False
800
802 """Return particle property names as a nicely sorted list."""
803 keys = super(FKSLeg, self).get_sorted_keys()
804 keys += ['fks', 'color','charge', 'massless', 'spin','is_part','self_antipart']
805 return keys
806
807
808 - def filter(self, name, value):
809 """Filter for valid leg property values."""
810
811 if name == 'fks':
812 if not isinstance(value, str):
813 raise self.PhysicsObjectError, \
814 "%s is not a valid string for leg fks flag" \
815 % str(value)
816 if name in ['color', 'spin']:
817 if not isinstance(value, int):
818 raise self.PhysicsObjectError, \
819 "%s is not a valid leg %s flag" % \
820 str(value),name
821
822 if name in ['massless','self_antipart','is_part']:
823 if not isinstance(value, bool):
824 raise self.PhysicsObjectError, \
825 "%s is not a valid boolean for leg flag %s" % \
826 str(value),name
827 if name is 'charge':
828 if not isinstance(value, float):
829 raise self.PhysicsObjectError, \
830 "%s is not a valid float for leg flag charge" \
831 % str(value)
832 return super(FKSLeg,self).filter(name, value)
833