16
16
"""Definitions of the objects needed both for MadFKS from real
17
17
and MadFKS from born"""
19
from __future__ import absolute_import
20
from __future__ import print_function
19
21
import madgraph.core.base_objects as MG
20
22
import madgraph.core.helas_objects as helas_objects
21
23
import madgraph.core.diagram_generation as diagram_generation
22
24
import madgraph.core.color_amp as color_amp
23
25
import madgraph.core.color_algebra as color_algebra
26
import madgraph.various.misc as misc
24
27
from operator import itemgetter
33
from six.moves import range
192
197
# and compare them
193
198
if len(born_tags) != len(real_tags):
194
print '\n'.join([str(r) for r in real_tags]) + '\n'
199
print('\n'.join([str(r) for r in real_tags]) + '\n')
195
200
raise FKSProcessError('Cannot map born/real configurations between \
196
201
%s and %s (i,j=%d,%d): not same number of configurations: %d %d' % \
197
202
(born_amp.get('process').nice_string().replace('Process:',''),
209
214
real_tags.remove(btag)
210
215
good_diags.pop(ir)
211
216
except ValueError:
212
print real_tags, i, j, ij
213
print '\n'.join( d['diagram'].nice_string() for d in good_diags)
217
print(real_tags, i, j, ij)
218
print('\n'.join( d['diagram'].nice_string() for d in good_diags))
214
219
raise FKSProcessError('Linking %s to %s: could not link born diagram %s' % \
215
220
(born_amp.get('process').nice_string().replace('Process:',''),
216
221
real_amp.get('process').nice_string().replace('Process:',''),
229
234
for diag in amp.get('diagrams'):
230
235
for order, value in diag.get('orders').items():
231
if value != 0 or order in amp['process']['orders'].keys():
236
if value != 0 or order in list(amp['process']['orders'].keys()):
233
238
orders[order] = max(orders[order], value)
329
334
elif pert == 'QED':
332
raise FKSProcessError, "Only QCD or QED is allowed not %s" % pert
337
raise FKSProcessError("Only QCD or QED is allowed not %s" % pert)
333
338
# the deepcopy statement is crucial
334
339
leglist = FKSLegList(copy.deepcopy(leglist_orig))
335
340
#find the position of the first final state leg
349
354
if abs(l[color]) == col and not l['massless']])
350
355
#no need to keep info on particles with color > i
351
356
if pert == 'QCD':
352
for col in copy.copy(col_maxindex.keys()):
357
for col in copy.copy(list(col_maxindex.keys())):
353
358
if abs(col) > abs(split[1][color]):
354
359
del col_maxindex[col]
355
360
### for col in copy.copy(mass_col_maxindex.keys()):
368
373
#so now the maximum of the max_col entries should be the position to insert leg i
369
leglist.insert(max(col_maxindex.values() + mass_col_maxindex.values() + [firstfinal - 1] ) + 1, split[1])
374
leglist.insert(max(list(col_maxindex.values()) + list(mass_col_maxindex.values()) + [firstfinal - 1] ) + 1, split[1])
370
375
### leglist.insert(max(col_maxindex.values() + [firstfinal - 1] ) + 1, split[1])
371
376
# for sleg in split:
372
377
# leglist.insert(i, sleg)
486
491
if pp['mass'].lower() == 'zero':
487
492
soft_parts.append(pp.get_pdg_code())
489
return {'interactions': sorted(qcd_inter),
494
return {'interactions': sorted(qcd_inter, key=misc.cmp_to_key(misc.dict_cmp)),
490
495
'pert_particles': sorted(set(pert_parts)),
491
496
'soft_particles': sorted(set(soft_parts))}
637
642
string.coeff = string.coeff * fractions.Fraction(leg['charge']*3.)*\
638
643
fractions.Fraction(1,3)
640
raise FKSProcessError,"Only QCD or QED is allowed not %s"% pert
645
raise FKSProcessError("Only QCD or QED is allowed not %s"% pert)
642
647
dict['replacements'] = replacements
643
648
dict['string'] = string
738
raise FKSProcessError,"Only QCD and QED is allowed not %s"% pert
743
raise FKSProcessError("Only QCD and QED is allowed not %s"% pert)
739
744
colors = sorted(set([abs(l[color]) for l in final_legs]))
740
745
# first put massless particles, without any rearrangment
741
746
if zero in colors:
826
831
if name == 'fks':
827
832
if not isinstance(value, str):
828
raise self.PhysicsObjectError, \
829
"%s is not a valid string for leg fks flag" \
833
raise self.PhysicsObjectError("%s is not a valid string for leg fks flag" \
831
835
if name in ['color', 'spin']:
832
836
if not isinstance(value, int):
833
raise self.PhysicsObjectError, \
834
"%s is not a valid leg %s flag" % \
837
six.reraise(self.PhysicsObjectError, "%s is not a valid leg %s flag" % \
837
840
if name in ['massless','self_antipart','is_part']:
838
841
if not isinstance(value, bool):
839
raise self.PhysicsObjectError, \
840
"%s is not a valid boolean for leg flag %s" % \
842
six.reraise(self.PhysicsObjectError, "%s is not a valid boolean for leg flag %s" % \
843
845
if not isinstance(value, float):
844
raise self.PhysicsObjectError, \
845
"%s is not a valid float for leg flag charge" \
846
raise self.PhysicsObjectError("%s is not a valid float for leg flag charge" \
847
848
return super(FKSLeg,self).filter(name, value)