def setUp(self): """load the model""" import madgraph.interface.master_interface as interface cmd = interface.MasterCmd() cmd.do_import('model sm') self.mybasemodel = cmd._curr_model self.mybasemodel.change_mass_to_complex_scheme() leg1 = base_objects.Leg({'id':22,'state':False}) leg2 = base_objects.Leg({'id':24,'state':False}) leg3 = base_objects.Leg({'id':22,'state':True}) leg4 = base_objects.Leg({'id':24,'state':True}) leg5 = base_objects.Leg({'id':23,'state':True}) legList1 = base_objects.LegList([leg1, leg2, leg3, leg4, leg5]) myproc = base_objects.Process({'legs':legList1, 'model':self.mybasemodel}) myamplitude = diagram_generation.Amplitude({'process': myproc}) self.mymatrixelement = helas_objects.HelasMatrixElement(myamplitude)
def test_find_symmetry_gg_tt_fullylept(self): """Test the find_symmetry function for subprocess groups""" procs = [[21,21, 6, -6]] decayt = [[6,5,-11,12],[6, 5,-13, 14]] decaytx = [[-6,-5,11,-12],[-6, -5, 13,-14]] amplitudes = diagram_generation.AmplitudeList() decay_amps = diagram_generation.DecayChainAmplitudeList() proc = procs[0] my_leglist = base_objects.LegList([\ base_objects.Leg({'id': id, 'state': True}) for id in proc]) my_leglist[0].set('state', False) my_leglist[1].set('state', False) my_process = base_objects.Process({'legs':my_leglist, 'model':self.base_model}) my_amplitude = diagram_generation.Amplitude(my_process) amplitudes.append(my_amplitude) for dect in decayt: my_top_decaylegs = base_objects.LegList([\ base_objects.Leg({'id': id, 'state': True}) for id in dect]) my_top_decaylegs[0].set('state', False) my_decayt_proc = base_objects.Process({'legs':my_top_decaylegs, 'model':self.base_model, 'is_decay_chain': True}) my_decayt = diagram_generation.DecayChainAmplitude(my_decayt_proc) decay_amps.append(my_decayt) for dectx in decaytx: # Define the multiprocess my_topx_decaylegs = base_objects.LegList([\ base_objects.Leg({'id': id, 'state': True}) for id in dectx]) my_topx_decaylegs[0].set('state', False) my_decaytx_proc = base_objects.Process({'legs':my_topx_decaylegs, 'model':self.base_model, 'is_decay_chain': True}) my_decaytx = diagram_generation.DecayChainAmplitude(my_decaytx_proc) decay_amps.append(my_decaytx) amplitudes = diagram_generation.DecayChainAmplitudeList([\ diagram_generation.DecayChainAmplitude({\ 'amplitudes': amplitudes, 'decay_chains': decay_amps})]) subproc_groups = \ group_subprocs.DecayChainSubProcessGroup.group_amplitudes(\ amplitudes).generate_helas_decay_chain_subproc_groups() self.assertEqual(len(subproc_groups), 1) subproc_group = subproc_groups[0] self.assertEqual(len(subproc_group.get('matrix_elements')), 1) symmetry, perms, ident_perms = diagram_symmetry.find_symmetry(\ subproc_group) sol_perms = [list(range(8)), list(range(8)), [0,1,5,6,7,2,3,4]] self.assertEqual(len([s for s in symmetry if s > 0]), 2) self.assertEqual(symmetry, [1, 1, -2]) self.assertEqual(perms, sol_perms)
def test_find_symmetry_qq_qqg_with_subprocess_group(self): """Test the find_symmetry function for subprocess groups""" procs = [[2, -2, 2, -2, 21], [2, 2, 2, 2, 21]] amplitudes = diagram_generation.AmplitudeList() for proc in procs: # Define the multiprocess my_leglist = base_objects.LegList([\ base_objects.Leg({'id': id, 'state': True}) for id in proc]) my_leglist[0].set('state', False) my_leglist[1].set('state', False) my_process = base_objects.Process({ 'legs': my_leglist, 'model': self.base_model }) my_amplitude = diagram_generation.Amplitude(my_process) amplitudes.append(my_amplitude) subproc_group = \ group_subprocs.SubProcessGroup.group_amplitudes(amplitudes,"madevent")[0] symmetry, perms, ident_perms = diagram_symmetry.find_symmetry(\ subproc_group) self.assertEqual(len([s for s in symmetry if s > 0]), 23) self.assertEqual(symmetry, [ 1, 1, 1, 1, -2, -3, -4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -8, -9, -10, -11, -12, -13, -14, -15, -16, -17, -21, -22, -23 ]) return # The test below doesn't apply with the new way of determining # config symmetry for subprocess groups, since we don't demand # that symmetric diagrams have identical particles. # Check that the momentum assignments work matrix_element = \ subproc_group.get('matrix_elements')[1] process = matrix_element.get('processes')[0] evaluator = process_checks.MatrixElementEvaluator(self.base_model, auth_skipping=True, reuse=True) p, w_rambo = evaluator.get_momenta(process) me_value, amp2_org = evaluator.evaluate_matrix_element(\ matrix_element, p) for isym, (sym, perm) in enumerate(zip(symmetry, perms)): new_p = [p[i] for i in perm] if sym >= 0: continue iamp = subproc_group.get('diagram_maps')[1].index(isym + 1) isymamp = subproc_group.get('diagram_maps')[1].index(-sym) me_value, amp2 = evaluator.evaluate_matrix_element(\ matrix_element, new_p) self.assertAlmostEqual(amp2[iamp], amp2_org[isymamp])
def setUp(self): # Set up model mypartlist = base_objects.ParticleList() myinterlist = base_objects.InteractionList() # u and c quarkd and their antiparticles mypartlist.append( base_objects.Particle({ 'name': 'u', 'antiname': 'u~', 'spin': 2, 'color': 3, 'mass': 'ZERO', 'width': 'ZERO', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 2, 'propagating': True, 'is_part': True, 'self_antipart': False })) u = mypartlist[len(mypartlist) - 1] antiu = copy.copy(u) antiu.set('is_part', False) mypartlist.append( base_objects.Particle({ 'name': 'c', 'antiname': 'c~', 'spin': 2, 'color': 3, 'mass': 'MC', 'width': 'ZERO', 'texname': 'c', 'antitexname': '\bar c', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 4, 'propagating': True, 'is_part': True, 'self_antipart': False })) c = mypartlist[len(mypartlist) - 1] antic = copy.copy(c) antic.set('is_part', False) # A gluon mypartlist.append( base_objects.Particle({ 'name': 'g', 'antiname': 'g', 'spin': 3, 'color': 8, 'mass': 'ZERO', 'width': 'ZERO', 'texname': 'g', 'antitexname': 'g', 'line': 'curly', 'charge': 0., 'pdg_code': 21, 'propagating': True, 'is_part': True, 'self_antipart': True })) g = mypartlist[len(mypartlist) - 1] # A photon mypartlist.append( base_objects.Particle({ 'name': 'Z', 'antiname': 'Z', 'spin': 3, 'color': 1, 'mass': 'MZ', 'width': 'WZ', 'texname': 'Z', 'antitexname': 'Z', 'line': 'wavy', 'charge': 0., 'pdg_code': 23, 'propagating': True, 'is_part': True, 'self_antipart': True })) z = mypartlist[len(mypartlist) - 1] # Gluon couplings to quarks myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ g]), 'color': [color.ColorString([color.T(2, 1, 0)])], 'lorentz':['FFV1'], 'couplings':{(0, 0):'GC_10'}, 'orders':{'QCD':1}})) # Gamma couplings to quarks myinterlist.append(base_objects.Interaction({ 'id': 2, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ z]), 'color': [color.ColorString([color.T(1, 0)])], 'lorentz':['FFV2', 'FFV5'], 'couplings':{(0,0): 'GC_35', (0,1): 'GC_47'}, 'orders':{'QED':1}})) self.mymodel.set('particles', mypartlist) self.mymodel.set('interactions', myinterlist) self.mymodel.set('name', 'sm') self.mypythonmodel = helas_call_writers.PythonUFOHelasCallWriter( self.mymodel) myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': 2, 'state': False})) myleglist.append(base_objects.Leg({'id': -2, 'state': False})) myleglist.append(base_objects.Leg({'id': 2, 'state': True})) myleglist.append(base_objects.Leg({'id': -2, 'state': True})) myproc = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) myamplitude = diagram_generation.Amplitude({'process': myproc}) self.mymatrixelement = helas_objects.HelasMultiProcess(myamplitude) myleglist = base_objects.LegList() myleglist.append( base_objects.Leg({ 'id': 4, 'state': False, 'number': 1 })) myleglist.append( base_objects.Leg({ 'id': -4, 'state': False, 'number': 2 })) myleglist.append( base_objects.Leg({ 'id': 4, 'state': True, 'number': 3 })) myleglist.append( base_objects.Leg({ 'id': -4, 'state': True, 'number': 4 })) myproc = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) self.mymatrixelement.get('matrix_elements')[0].\ get('processes').append(myproc) self.exporter = export_python.ProcessExporterPython(\ self.mymatrixelement, self.mypythonmodel)
def test_export_matrix_element_python_madevent_group(self): """Test the result of exporting a subprocess group matrix element""" # Setup a model mypartlist = base_objects.ParticleList() myinterlist = base_objects.InteractionList() # A gluon mypartlist.append( base_objects.Particle({ 'name': 'g', 'antiname': 'g', 'spin': 3, 'color': 8, 'mass': 'zero', 'width': 'zero', 'texname': 'g', 'antitexname': 'g', 'line': 'curly', 'charge': 0., 'pdg_code': 21, 'propagating': True, 'is_part': True, 'self_antipart': True })) g = mypartlist[-1] # A quark U and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'u', 'antiname': 'u~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 2, 'propagating': True, 'is_part': True, 'self_antipart': False })) u = mypartlist[-1] antiu = copy.copy(u) antiu.set('is_part', False) # A quark D and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'd', 'antiname': 'd~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'd', 'antitexname': '\bar d', 'line': 'straight', 'charge': -1. / 3., 'pdg_code': 1, 'propagating': True, 'is_part': True, 'self_antipart': False })) d = mypartlist[-1] antid = copy.copy(d) antid.set('is_part', False) # A photon mypartlist.append( base_objects.Particle({ 'name': 'a', 'antiname': 'a', 'spin': 3, 'color': 1, 'mass': 'zero', 'width': 'zero', 'texname': '\gamma', 'antitexname': '\gamma', 'line': 'wavy', 'charge': 0., 'pdg_code': 22, 'propagating': True, 'is_part': True, 'self_antipart': True })) a = mypartlist[-1] # A Z mypartlist.append( base_objects.Particle({ 'name': 'z', 'antiname': 'z', 'spin': 3, 'color': 1, 'mass': 'MZ', 'width': 'WZ', 'texname': 'Z', 'antitexname': 'Z', 'line': 'wavy', 'charge': 0., 'pdg_code': 23, 'propagating': True, 'is_part': True, 'self_antipart': True })) z = mypartlist[-1] # Gluon and photon couplings to quarks myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ g]), 'color': [], 'lorentz':['L1'], 'couplings':{(0, 0):'GQQ'}, 'orders':{'QCD':1}})) myinterlist.append(base_objects.Interaction({ 'id': 2, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ a]), 'color': [], 'lorentz':['L1'], 'couplings':{(0, 0):'GQED'}, 'orders':{'QED':1}})) myinterlist.append(base_objects.Interaction({ 'id': 3, 'particles': base_objects.ParticleList(\ [antid, \ d, \ g]), 'color': [], 'lorentz':['L1'], 'couplings':{(0, 0):'GQQ'}, 'orders':{'QCD':1}})) myinterlist.append(base_objects.Interaction({ 'id': 4, 'particles': base_objects.ParticleList(\ [antid, \ d, \ a]), 'color': [], 'lorentz':['L1'], 'couplings':{(0, 0):'GQED'}, 'orders':{'QED':1}})) # 3 gluon vertiex myinterlist.append(base_objects.Interaction({ 'id': 5, 'particles': base_objects.ParticleList(\ [g] * 3), 'color': [], 'lorentz':['L1'], 'couplings':{(0, 0):'G'}, 'orders':{'QCD':1}})) # Coupling of Z to quarks myinterlist.append(base_objects.Interaction({ 'id': 6, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ z]), 'color': [], 'lorentz':['L1', 'L2'], 'couplings':{(0, 0):'GUZ1', (0, 1):'GUZ2'}, 'orders':{'QED':1}})) myinterlist.append(base_objects.Interaction({ 'id': 7, 'particles': base_objects.ParticleList(\ [antid, \ d, \ z]), 'color': [], 'lorentz':['L1', 'L2'], 'couplings':{(0, 0):'GDZ1', (0, 0):'GDZ2'}, 'orders':{'QED':1}})) mymodel = base_objects.Model() mymodel.set('particles', mypartlist) mymodel.set('interactions', myinterlist) procs = [[2, -2, 21, 21], [2, -2, 2, -2]] amplitudes = diagram_generation.AmplitudeList() for proc in procs: # Define the multiprocess my_leglist = base_objects.LegList([\ base_objects.Leg({'id': id, 'state': True}) for id in proc]) my_leglist[0].set('state', False) my_leglist[1].set('state', False) my_process = base_objects.Process({ 'legs': my_leglist, 'model': mymodel }) my_amplitude = diagram_generation.Amplitude(my_process) amplitudes.append(my_amplitude) # Calculate diagrams for all processes subprocess_group = group_subprocs.SubProcessGroup.\ group_amplitudes(amplitudes, "madevent")[0] # Test amp2 lines helas_writer = helas_call_writers.PythonUFOHelasCallWriter(mymodel) python_exporter = export_python.ProcessExporterPython( subprocess_group, helas_writer) amp2_lines = \ python_exporter.get_amp2_lines(subprocess_group.\ get('matrix_elements')[0], subprocess_group.get('diagram_maps')[0]) self.assertEqual(amp2_lines, [ 'self.amp2[0]+=abs(amp[0]*amp[0].conjugate())', 'self.amp2[1]+=abs(amp[1]*amp[1].conjugate())', 'self.amp2[2]+=abs(amp[2]*amp[2].conjugate())' ])
def test_run_python_matrix_element(self): """Test a complete running of a Python matrix element without writing any files""" # Import the SM sm_path = import_ufo.find_ufo_path('sm') model = import_ufo.import_model(sm_path) myleglist = base_objects.LegList() myleglist.append( base_objects.Leg({ 'id': -11, 'state': False, 'number': 1 })) myleglist.append( base_objects.Leg({ 'id': 11, 'state': False, 'number': 2 })) myleglist.append( base_objects.Leg({ 'id': 22, 'state': True, 'number': 3 })) myleglist.append( base_objects.Leg({ 'id': 22, 'state': True, 'number': 4 })) myleglist.append( base_objects.Leg({ 'id': 22, 'state': True, 'number': 5 })) myproc = base_objects.Process({'legs': myleglist, 'model': model}) myamplitude = diagram_generation.Amplitude({'process': myproc}) mymatrixelement = helas_objects.HelasMatrixElement(myamplitude) # Create only the needed aloha routines wanted_lorentz = mymatrixelement.get_used_lorentz() aloha_model = create_aloha.AbstractALOHAModel(model.get('name')) aloha_model.compute_subset(wanted_lorentz) # Write out the routines in Python aloha_routines = [] for routine in aloha_model.values(): aloha_routines.append(routine.write(output_dir = None, language = 'Python').\ replace('import wavefunctions', 'import aloha.template_files.wavefunctions as wavefunctions')) # Define the routines to be available globally for routine in aloha_routines: exec(routine, globals()) # Write the matrix element(s) in Python mypythonmodel = helas_call_writers.PythonUFOHelasCallWriter(\ model) exporter = export_python.ProcessExporterPython(\ mymatrixelement, mypythonmodel) matrix_methods = exporter.get_python_matrix_methods() # Calculate parameters and couplings full_model = model_reader.ModelReader(model) full_model.set_parameters_and_couplings() # Define a momentum p = [[ 0.5000000e+03, 0.0000000e+00, 0.0000000e+00, 0.5000000e+03, 0.0000000e+00 ], [ 0.5000000e+03, 0.0000000e+00, 0.0000000e+00, -0.5000000e+03, 0.0000000e+00 ], [ 0.4585788e+03, 0.1694532e+03, 0.3796537e+03, -0.1935025e+03, 0.6607249e-05 ], [ 0.3640666e+03, -0.1832987e+02, -0.3477043e+03, 0.1063496e+03, 0.7979012e-05 ], [ 0.1773546e+03, -0.1511234e+03, -0.3194936e+02, 0.8715287e+02, 0.1348699e-05 ]] # Evaluate the matrix element for the given momenta answer = 1.39189717257175028e-007 for process in matrix_methods.keys(): # Define Python matrix element for process exec(matrix_methods[process]) # Calculate the matrix element for the momentum p value = eval("Matrix_0_epem_aaa().smatrix(p, full_model)") self.assertTrue(abs(value-answer)/answer < 1e-6, "Value is: %.9e should be %.9e" % \ (abs(value), answer))
def test_color_matrix_multi_quarks(self): """Test the color matrix building for qq~ > n*(qq~) with n up to 2""" goal = [fractions.Fraction(9, 1), fractions.Fraction(27, 1)] goal_line1 = [(fractions.Fraction(9, 1), fractions.Fraction(3, 1)), (fractions.Fraction(27, 1), fractions.Fraction(9, 1), fractions.Fraction(9, 1), fractions.Fraction(3, 1), fractions.Fraction(3, 1), fractions.Fraction(9, 1))] goal_den_list = [[1] * 2, [1] * 6] goal_first_line_num = [[9, 3], [27, 9, 9, 3, 3, 9]] for n in range(2): myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': -2, 'state': False})) myleglist.append(base_objects.Leg({'id': 2, 'state': False})) myleglist.extend([ base_objects.Leg({ 'id': -2, 'state': True }), base_objects.Leg({ 'id': 2, 'state': True }) ] * (n + 1)) myprocess = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) myamplitude = diagram_generation.Amplitude() myamplitude.set('process', myprocess) myamplitude.generate_diagrams() col_basis = color_amp.ColorBasis(myamplitude) col_matrix = color_amp.ColorMatrix(col_basis, Nc=3) # Check diagonal for i in range(len(col_basis.items())): self.assertEqual(col_matrix.col_matrix_fixed_Nc[(i, i)], (goal[n], 0)) # Check first line for i in range(len(col_basis.items())): self.assertEqual(col_matrix.col_matrix_fixed_Nc[(0, i)], (goal_line1[n][i], 0)) self.assertEqual(col_matrix.get_line_denominators(), goal_den_list[n]) self.assertEqual( col_matrix.get_line_numerators( 0, col_matrix.get_line_denominators()[0]), goal_first_line_num[n])
def test_color_basis_uux_aggg(self): """Test the color basis building for uu~ > aggg (3! elements)""" myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': -2, 'state': False})) myleglist.append(base_objects.Leg({'id': 2, 'state': False})) myleglist.append(base_objects.Leg({'id': 22, 'state': True})) myleglist.extend([base_objects.Leg({'id': 21, 'state': True})] * 3) myprocess = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) myamplitude = diagram_generation.Amplitude() myamplitude.set('process', myprocess) myamplitude.generate_diagrams() new_col_basis = color_amp.ColorBasis(myamplitude) self.assertEqual(len(new_col_basis), 6) # Test the color flow decomposition self.assertEqual( new_col_basis.color_flow_decomposition( { 1: 3, 2: -3, 3: 1, 4: 8, 5: 8, 6: -8 }, 2), [{ 1: [0, 501], 2: [504, 0], 3: [0, 0], 4: [502, 501], 5: [503, 502], 6: [504, 503] }, { 1: [0, 501], 2: [503, 0], 3: [0, 0], 4: [502, 501], 5: [503, 504], 6: [504, 502] }, { 1: [0, 501], 2: [504, 0], 3: [0, 0], 4: [502, 503], 5: [503, 501], 6: [504, 502] }, { 1: [0, 501], 2: [502, 0], 3: [0, 0], 4: [502, 504], 5: [503, 501], 6: [504, 503] }, { 1: [0, 501], 2: [503, 0], 3: [0, 0], 4: [502, 504], 5: [503, 502], 6: [504, 501] }, { 1: [0, 501], 2: [502, 0], 3: [0, 0], 4: [502, 503], 5: [503, 504], 6: [504, 501] }])
def test_colorize_uux_ggg(self): """Test the colorize function for uu~ > ggg""" myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': 2, 'state': False})) myleglist.append(base_objects.Leg({'id': -2, 'state': False})) myleglist.extend([base_objects.Leg({'id': 21, 'state': True})] * 3) myprocess = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) myamplitude = diagram_generation.Amplitude() myamplitude.set('process', myprocess) myamplitude.generate_diagrams() my_col_basis = color_amp.ColorBasis() # First diagram with two 3-gluon vertices col_dict = my_col_basis.colorize(myamplitude['diagrams'][0], self.mymodel) goal_dict = { (0, 0, 0): color.ColorString([ color.T(-1000, 2, 1), color.f(-1001, 3, 4), color.f(-1000, -1001, 5) ]) } self.assertEqual(col_dict, goal_dict) # Diagram with one 4-gluon vertex col_dict = my_col_basis.colorize(myamplitude['diagrams'][3], self.mymodel) goal_dict = { (0, 0): color.ColorString([ color.T(-1000, 2, 1), color.f(-1001, 3, 5), color.f(-1001, 4, -1000) ]), (0, 1): color.ColorString([ color.T(-1000, 2, 1), color.f(-1002, 3, -1000), color.f(-1002, 4, 5) ]), (0, 2): color.ColorString([ color.T(-1000, 2, 1), color.f(-1003, 3, 4), color.f(-1003, 5, -1000) ]) } self.assertEqual(col_dict, goal_dict)
def test_colorize_funny_model(self): """Test the colorize function for uu~ > ggg""" mypartlist = base_objects.ParticleList() myinterlist = base_objects.InteractionList() mymodel = base_objects.Model() # A gluon mypartlist.append( base_objects.Particle({ 'name': 'g', 'antiname': 'g', 'spin': 3, 'color': 8, 'mass': 'zero', 'width': 'zero', 'texname': 'g', 'antitexname': 'g', 'line': 'curly', 'charge': 0., 'pdg_code': 21, 'propagating': True, 'is_part': True, 'self_antipart': True })) # 3 gluon vertiex myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [mypartlist[0]] * 3), 'color': [color.ColorString([color.f(0, 1, 2)]), color.ColorString([color.f(0, 2, 1)]), color.ColorString([color.f(1, 2, 0)])], 'lorentz':['L1'], 'couplings':{(0, 0):'G', (2,0):'G'}, 'orders':{'QCD':1}})) mymodel.set('particles', mypartlist) mymodel.set('interactions', myinterlist) myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': 21, 'state': False})) myleglist.append(base_objects.Leg({'id': 21, 'state': False})) myleglist.extend([base_objects.Leg({'id': 21, 'state': True})] * 2) myprocess = base_objects.Process({'legs': myleglist, 'model': mymodel}) myamplitude = diagram_generation.Amplitude() myamplitude.set('process', myprocess) myamplitude.generate_diagrams() my_col_basis = color_amp.ColorBasis() # Check that only the color structures that are actually used are included col_dict = my_col_basis.colorize(myamplitude['diagrams'][0], mymodel) goal_dict = { (2, 0): color.ColorString([color.f(1, 2, -1000), color.f(3, 4, -1000)]), (0, 0): color.ColorString([color.f(-1000, 1, 2), color.f(3, 4, -1000)]), (0, 2): color.ColorString([color.f(-1000, 1, 2), color.f(4, -1000, 3)]), (2, 2): color.ColorString([color.f(1, 2, -1000), color.f(4, -1000, 3)]) } self.assertEqual(col_dict, goal_dict)
def perform_color_connections_test(self, combinations): """ Handy wrapping function to test selected cases for the color correlated matrices.""" def compare_result(color_matrices, color_connections, reference): important_info_CM = [(c[0], dict(c[1][1].col_matrix_fixed_Nc)) for c in color_matrices if c[1][1].col_matrix_fixed_Nc is not None] important_info_CC = { k: [(i, cc['tuple_representation']) for i, cc in enumerate(v)] for k, v in color_connections.items() } #pprint(important_info_CM) #pprint(important_info_CC) self.assertListEqual(important_info_CM, reference['color_matrices']) self.assertDictEqual(important_info_CC, reference['color_connections']) for n_gluons, initial_states, max_order, reference in combinations: myleglist = base_objects.LegList() myleglist.append( base_objects.Leg({ 'id': initial_states[0], 'state': False })) myleglist.append( base_objects.Leg({ 'id': initial_states[1], 'state': False })) myleglist.append(base_objects.Leg({'id': 1, 'state': True})) myleglist.append(base_objects.Leg({'id': -1, 'state': True})) myleglist.extend([base_objects.Leg({ 'id': 21, 'state': True })] * (n_gluons)) myprocess = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) myamplitude = diagram_generation.Amplitude() myamplitude.set('process', myprocess) myamplitude.generate_diagrams() col_basis = color_amp.ColorBasis(myamplitude) col_matrix = color_amp.ColorMatrix(col_basis, Nc=3) all_color_matrices, color_connections = col_matrix.build_color_correlated_matrices( myleglist, self.mymodel, order=max_order, Nc=3, Nc_power_min=None, Nc_power_max=None) # Now aggregate all color_connections in a single list: all_color_connections = [] for o in range(max_order.count('N') + 1): all_color_connections.extend(color_connections['N' * o + 'LO']) sorted_color_matrices = sorted(all_color_matrices.items(), key=lambda el: el[0]) compare_result(sorted_color_matrices, color_connections, reference) if False: pprint([( '(%d,%d) -> [ %s | %s ]' % (k[0], k[1], str(all_color_connections[k[0]]['tuple_representation']), str(all_color_connections[k[1]]['tuple_representation'])), (v[0], v[1].col_matrix_fixed_Nc)) for k, v in sorted_color_matrices]) if False: print( "\nA total of %d correlator matrices have been computed (among which %d are zero)" % (len(sorted_color_matrices), len([ _ for _ in sorted_color_matrices if _[1][1].col_matrix_fixed_Nc is None ])))
def __init__(self, start_proc = None, remove_reals = True, ncores_for_proc_gen=0): """initialization: starts either from an amplitude or a process, then init the needed variables. remove_borns tells if the borns not needed for integration will be removed from the born list (mainly used for testing) ncores_for_proc_gen has the following meaning 0 : do things the old way > 0 use ncores_for_proc_gen -1 : use all cores """ self.splittings = {} self.reals = [] self.fks_dirs = [] self.leglist = [] self.myorders = {} self.pdg_codes = [] self.colors = [] # color self.charges = [] # charge self.nlegs = 0 self.fks_ipos = [] self.fks_j_from_i = {} self.real_amps = [] self.remove_reals = remove_reals self.nincoming = 0 self.virt_amp = None self.perturbation = 'QCD' self.ncores_for_proc_gen = ncores_for_proc_gen if not remove_reals in [True, False]: raise fks_common.FKSProcessError(\ 'Not valid type for remove_reals in FKSProcess') if start_proc: if isinstance(start_proc, MG.Process): pertur = start_proc['perturbation_couplings'] if pertur: self.perturbation = sorted(pertur)[0] self.born_proc = fks_common.sort_proc(start_proc,pert = self.perturbation) # filter in Amplitude will legs sorted in bornproc bornproc = copy.copy(self.born_proc) # deepcopy might let T -> array assert bornproc==self.born_proc self.born_amp = diagram_generation.Amplitude(bornproc) elif isinstance(start_proc, diagram_generation.Amplitude): pertur = start_proc.get('process')['perturbation_couplings'] if pertur: self.perturbation = sorted(pertur)[0] self.born_proc = fks_common.sort_proc(start_proc.get('process'),\ pert = self.perturbation) # filter in Amplitude will legs sorted in bornproc bornproc = copy.copy(self.born_proc) assert bornproc == self.born_proc self.born_amp = diagram_generation.Amplitude(bornproc) else: raise fks_common.FKSProcessError(\ 'Not valid start_proc in FKSProcess') self.born_proc.set('legs_with_decays', MG.LegList()) self.leglist = fks_common.to_fks_legs( self.born_proc['legs'], self.born_proc['model']) self.nlegs = len(self.leglist) self.pdg_codes = [leg.get('id') for leg in self.leglist] if self.perturbation == 'QCD': self.colors = [leg.get('color') for leg in self.leglist] # in QCD, charge is irrelevant but impact the combine process ! self.charges = [0. for leg in self.leglist] color = 'color' zero = 1 elif self.perturbation == 'QED': self.colors = [leg.get('color') for leg in self.leglist] self.charges = [leg.get('charge') for leg in self.leglist] color = 'charge' zero = 0. # special treatment of photon is needed ! self.isr = set([leg.get(color) for leg in self.leglist if not leg.get('state')]) != set([zero]) self.fsr = set([leg.get(color) for leg in self.leglist if leg.get('state')]) != set([zero]) for leg in self.leglist: if not leg['state']: self.nincoming += 1 self.orders = self.born_amp['process']['orders'] # this is for cases in which the user specifies e.g. QED=0 if sum(self.orders.values()) == 0: self.orders = fks_common.find_orders(self.born_amp) self.ndirs = 0 # generate reals, when the mode is not LOonly # when is LOonly it is supposed to be a 'fake' NLO process # e.g. to be used in merged sampels at high multiplicities if self.born_proc['NLO_mode'] != 'LOonly': for order in self.born_proc.get('perturbation_couplings'): self.find_reals(order)
def generate_real_amplitude(self): """generates the real emission amplitude starting from self.process""" self.amplitude = diagram_generation.Amplitude(self.process) return self.amplitude
def setUp(self): # Set up model mypartlist = base_objects.ParticleList() myinterlist = base_objects.InteractionList() # A photon mypartlist.append( base_objects.Particle({ 'name': 'a', 'antiname': 'a', 'spin': 3, 'color': 1, 'mass': 'zero', 'width': 'zero', 'texname': '\gamma', 'antitexname': '\gamma', 'line': 'wavy', 'charge': 0., 'pdg_code': 22, 'propagating': True, 'is_part': True, 'self_antipart': True })) a = mypartlist[len(mypartlist) - 1] # W+ and W- mypartlist.append( base_objects.Particle({ 'name': 'w+', 'antiname': 'w-', 'spin': 3, 'color': 1, 'mass': 'wmas', 'width': 'wwid', 'texname': 'W^+', 'antitexname': 'W^-', 'line': 'wavy', 'charge': 1., 'pdg_code': 24, 'propagating': True, 'is_part': True, 'self_antipart': False })) wplus = mypartlist[len(mypartlist) - 1] wminus = copy.copy(wplus) wminus.set('is_part', False) # Z mypartlist.append( base_objects.Particle({ 'name': 'z', 'antiname': 'z', 'spin': 3, 'color': 1, 'mass': 'zmas', 'width': 'zwid', 'texname': 'Z', 'antitexname': 'Z', 'line': 'wavy', 'charge': 1., 'pdg_code': 23, 'propagating': True, 'is_part': True, 'self_antipart': True })) z = mypartlist[len(mypartlist) - 1] # a-a-w+w- 4-vertex myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [a, \ a, wminus, wplus]), 'color': [], 'lorentz':['VVVV1'], 'couplings':{(0, 0):'GC_51'}, 'orders':{'QED':2}})) # w+w-z vertex myinterlist.append(base_objects.Interaction({ 'id': 2, 'particles': base_objects.ParticleList(\ [wminus, wplus, z]), 'color': [], 'lorentz':['VVV1'], 'couplings':{(0, 0):'GC_12'}, 'orders':{'QED':1}})) self.mybasemodel.set('particles', mypartlist) self.mybasemodel.set('interactions', myinterlist) self.mybasemodel.set('name', 'sm') #import madgraph.interface.cmd_interface as cmd #CMD = cmd.MadGraphCmdShell() #CMD._curr_model = self.mybasemodel #CMD._curr_fortran_model = helas_call_writers.FortranUFOHelasCallWriter #CMD.do_generate('a w- > w- a z') #CMD.do_export('matrix_v4 /tmp/') leg1 = base_objects.Leg({'id': 22, 'state': False}) leg2 = base_objects.Leg({'id': 24, 'state': False}) leg3 = base_objects.Leg({'id': 22, 'state': True}) leg4 = base_objects.Leg({'id': 24, 'state': True}) leg5 = base_objects.Leg({'id': 23, 'state': True}) legList1 = base_objects.LegList([leg1, leg2, leg3, leg4, leg5]) myproc = base_objects.Process({ 'legs': legList1, 'model': self.mybasemodel }) myamplitude = diagram_generation.Amplitude({'process': myproc}) self.mymatrixelement = helas_objects.HelasMatrixElement(myamplitude)
def test_color_matrix_multi_gluons(self): """Test the color matrix building for gg > n*g with n up to 3""" goal = [ fractions.Fraction(7, 3), fractions.Fraction(19, 6), fractions.Fraction(455, 108), fractions.Fraction(3641, 648) ] goal_line1 = [(fractions.Fraction(7, 3), fractions.Fraction(-2, 3)), (fractions.Fraction(19, 6), fractions.Fraction(-1, 3), fractions.Fraction(-1, 3), fractions.Fraction(-1, 3), fractions.Fraction(-1, 3), fractions.Fraction(2, 3)), (fractions.Fraction(455, 108), fractions.Fraction(-29, 54), fractions.Fraction(-29, 54), fractions.Fraction(7, 54), fractions.Fraction(7, 54), fractions.Fraction(17, 27), fractions.Fraction(-29, 54), fractions.Fraction(-1, 27), fractions.Fraction(7, 54), fractions.Fraction(-29, 54), fractions.Fraction(5, 108), fractions.Fraction(-1, 27), fractions.Fraction(7, 54), fractions.Fraction(5, 108), fractions.Fraction(17, 27), fractions.Fraction(-1, 27), fractions.Fraction(7, 54), fractions.Fraction(17, 27), fractions.Fraction(-29, 54), fractions.Fraction(-1, 27), fractions.Fraction(-1, 27), fractions.Fraction(17, 27), fractions.Fraction(17, 27), fractions.Fraction(-10, 27))] for n in range(3): myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': 21, 'state': False})) myleglist.append(base_objects.Leg({'id': 21, 'state': False})) myleglist.extend([base_objects.Leg({ 'id': 21, 'state': True })] * (n + 1)) myprocess = base_objects.Process({ 'legs': myleglist, 'model': self.mymodel }) myamplitude = diagram_generation.Amplitude() myamplitude.set('process', myprocess) myamplitude.generate_diagrams() col_basis = color_amp.ColorBasis(myamplitude) col_matrix = color_amp.ColorMatrix(col_basis, Nc=3) # Check diagonal for i in range(len(col_basis.items())): self.assertEqual(col_matrix.col_matrix_fixed_Nc[(i, i)], (goal[n], 0)) # Check first line for i in range(len(col_basis.items())): self.assertEqual(col_matrix.col_matrix_fixed_Nc[(0, i)], (goal_line1[n][i], 0))
def test_triplet_color_flow_output(self): """Test the color flow output for color triplets""" # Test u u > trip~ g myleglist = base_objects.LegList() myleglist.append( base_objects.Leg({ 'id': 2, 'state': False, 'number': 1 })) myleglist.append( base_objects.Leg({ 'id': 6, 'state': False, 'number': 2 })) myleglist.append( base_objects.Leg({ 'id': -9000006, 'state': True, 'number': 3 })) myleglist.append( base_objects.Leg({ 'id': 21, 'state': True, 'number': 4 })) myproc = base_objects.Process({ 'legs': myleglist, 'model': self.base_model }) myamp = diagram_generation.Amplitude(myproc) matrix_element = helas_objects.HelasMatrixElement(myamp) # First build a color representation dictionnary repr_dict = {} for l in myleglist: repr_dict[l.get('number')] = \ self.base_model.get_particle(l.get('id')).get_color() # Get the color flow decomposition col_flow = \ matrix_element.get('color_basis').color_flow_decomposition(repr_dict, 2) self.assertEqual(col_flow, [{ 1: [501, 0], 2: [502, 0], 3: [0, 504], 4: [504, 503] }, { 1: [501, 0], 2: [504, 0], 3: [0, 502], 4: [504, 503] }, { 1: [504, 0], 2: [501, 0], 3: [0, 502], 4: [504, 503] }]) # Test u u > trip~ > u u g myleglist = base_objects.LegList() myleglist.append(base_objects.Leg({'id': 2, 'state': False})) myleglist.append(base_objects.Leg({'id': 6, 'state': False})) myleglist.append(base_objects.Leg({'id': 2, 'state': True})) myleglist.append(base_objects.Leg({'id': 6, 'state': True})) myleglist.append(base_objects.Leg({'id': 21, 'state': True})) myproc = base_objects.Process({ 'legs': myleglist, 'model': self.base_model, 'required_s_channels': [[-9000006]] }) myamp = diagram_generation.Amplitude(myproc) self.assertEqual(len(myamp.get('diagrams')), 5) matrix_element = helas_objects.HelasMatrixElement(myamp) # First build a color representation dictionnary repr_dict = {} for l in myleglist: repr_dict[l.get('number')] = \ self.base_model.get_particle(l.get('id')).get_color() # Get the color flow decomposition col_flow = \ matrix_element.get('color_basis').color_flow_decomposition(repr_dict, 2) self.assertEqual(col_flow, [{ 1: [501, 0], 2: [502, 0], 3: [504, 0], 4: [505, 0], 5: [506, 503] }, { 1: [501, 0], 2: [503, 0], 3: [501, 0], 4: [502, 0], 5: [503, 502] }, { 1: [503, 0], 2: [501, 0], 3: [501, 0], 4: [502, 0], 5: [503, 502] }, { 1: [502, 0], 2: [503, 0], 3: [501, 0], 4: [502, 0], 5: [503, 501] }, { 1: [503, 0], 2: [502, 0], 3: [501, 0], 4: [502, 0], 5: [503, 501] }])
def test_ungrouping_lepton(self): """check that the routines which ungroup the process for the muon/electron processes works as expected""" # Setup A simple model mypartlist = base_objects.ParticleList() myinterlist = base_objects.InteractionList() # A quark U and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'u', 'antiname': 'u~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 2, 'propagating': True, 'is_part': True, 'self_antipart': False })) u = mypartlist[-1] antiu = copy.copy(u) antiu.set('is_part', False) # A quark D and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'd', 'antiname': 'd~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'd', 'antitexname': '\bar d', 'line': 'straight', 'charge': -1. / 3., 'pdg_code': 1, 'propagating': True, 'is_part': True, 'self_antipart': False })) d = mypartlist[-1] antid = copy.copy(d) antid.set('is_part', False) # A quark C and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'c', 'antiname': 'c~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 4, 'propagating': True, 'is_part': True, 'self_antipart': False })) c = mypartlist[-1] antic = copy.copy(c) antic.set('is_part', False) # electron/positront mypartlist.append( base_objects.Particle({ 'name': 'e-', 'antiname': 'e+', 'spin': 2, 'color': 1, 'mass': 'zero', 'width': 'zero', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': 1, 'pdg_code': 11, 'propagating': True, 'is_part': True, 'self_antipart': False })) e = mypartlist[-1] antie = copy.copy(e) mu = copy.copy(e) antie.set('is_part', False) mu.set('name', 'mu-') mu.set('antiname', 'mu+') mu.set('pdg_code', 13) mypartlist.append(mu) antimu = copy.copy(mu) antimu.set('is_part', False) # A Z mypartlist.append( base_objects.Particle({ 'name': 'z', 'antiname': 'z', 'spin': 3, 'color': 1, 'mass': 'MZ', 'width': 'WZ', 'texname': 'Z', 'antitexname': 'Z', 'line': 'wavy', 'charge': 0., 'pdg_code': 23, 'propagating': True, 'is_part': True, 'self_antipart': True })) z = mypartlist[-1] # Coupling of Z to quarks myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [antiu, \ u, \ z]), 'color': [color.ColorString([color.T(1,0)])], 'lorentz':['FFV1', 'FFV2'], 'couplings':{(0, 0):'GUZ1', (0, 1):'GUZ2'}, 'orders':{'QED':1}})) myinterlist.append(base_objects.Interaction({ 'id': 2, 'particles': base_objects.ParticleList(\ [antid, \ d, \ z]), 'color': [color.ColorString([color.T(1,0)])], 'lorentz':['FFV1', 'FFV2'], 'couplings':{(0, 0):'GDZ1', (0, 1):'GDZ2'}, 'orders':{'QED':1}})) myinterlist.append(base_objects.Interaction({ 'id': 3, 'particles': base_objects.ParticleList(\ [antic, \ c, \ z]), 'color': [color.ColorString([color.T(1,0)])], 'lorentz':['FFV1', 'FFV2'], 'couplings':{(0, 0):'GUZ1', (0, 1):'GUZ2'}, 'orders':{'QED':1}})) # Coupling of Z to leptons myinterlist.append(base_objects.Interaction({ 'id': 4, 'particles': base_objects.ParticleList(\ [antie, \ e, \ z]), 'color': [color.ColorString()], 'lorentz':['FFV1', 'FFV2'], 'couplings':{(0, 0):'GLZ1', (0, 1):'GLZ2'}, 'orders':{'QED':1}})) # Coupling of Z to leptons myinterlist.append(base_objects.Interaction({ 'id': 5, 'particles': base_objects.ParticleList(\ [antimu, \ mu, \ z]), 'color': [color.ColorString()], 'lorentz':['FFV1', 'FFV2'], 'couplings':{(0, 0):'GLZ1', (0, 1):'GLZ2'}, 'orders':{'QED':1}})) mymodel = base_objects.Model() mymodel.set('particles', mypartlist) mymodel.set('interactions', myinterlist) mymodel.set('name', 'sm') procs = [[1, -1, 23], [2, -2, 23], [4, -4, 23]] decays = [[23, 11, -11], [23, 13, -13]] coreamplitudes = diagram_generation.AmplitudeList() decayamplitudes = diagram_generation.AmplitudeList() decayprocs = base_objects.ProcessList() #Building the basic objects for proc in procs: # Define the multiprocess my_leglist = base_objects.LegList([\ base_objects.Leg({'id': id, 'state': True}) for id in proc]) my_leglist[0].set('state', False) my_leglist[1].set('state', False) my_process = base_objects.Process({ 'legs': my_leglist, 'model': mymodel }) my_amplitude = diagram_generation.Amplitude(my_process) my_amplitude.set('has_mirror_process', True) coreamplitudes.append(my_amplitude) for proc in decays: # Define the multiprocess my_leglist = base_objects.LegList([\ base_objects.Leg({'id': id, 'state': True}) for id in proc]) my_leglist[0].set('state', False) my_process = base_objects.Process({ 'legs': my_leglist, 'model': mymodel, 'is_decay_chain': True }) my_amplitude = diagram_generation.Amplitude(my_process) decayamplitudes.append(my_amplitude) decayprocs.append(my_process) decays = diagram_generation.DecayChainAmplitudeList([\ diagram_generation.DecayChainAmplitude({\ 'amplitudes': decayamplitudes})]) decay_chains = diagram_generation.DecayChainAmplitude({\ 'amplitudes': coreamplitudes, 'decay_chains': decays}) dc_subproc_group = group_subprocs.DecayChainSubProcessGroup.\ group_amplitudes(\ diagram_generation.DecayChainAmplitudeList([decay_chains])) subproc_groups = \ dc_subproc_group.generate_helas_decay_chain_subproc_groups() ###################### ## Make the test!! ## ###################### self.assertEqual(len(subproc_groups), 1) subproc_groups = subproc_groups.split_lepton_grouping() self.assertEqual(len(subproc_groups), 2) # check that indeed for group in subproc_groups: self.assertEqual(len(group['matrix_elements']), 2) has_muon = any( abs(l['id']) == 13 for l in group['matrix_elements'][0] ['processes'][0]['decay_chains'][0]['legs']) for me in group['matrix_elements']: if abs(me['processes'][0]['legs'][0]['id']) == 1: self.assertEqual(len(me['processes']), 1) else: self.assertEqual(len(me['processes']), 2) for proc in me['processes']: for dec in proc['decay_chains']: if has_muon: self.assertFalse( any(abs(l['id']) == 11 for l in dec['legs'])) else: self.assertFalse( any(abs(l['id']) == 13 for l in dec['legs'])) self.assertNotEqual(group['name'], 'qq_z_z_ll') if has_muon: self.assertEqual(group['name'], 'qq_z_z_mummup') else: self.assertEqual(group['name'], 'qq_z_z_emep') group['name']