def test_read_particles(self): """Test the output of import particles.dat file""" particles_dat_str = """# Test string with particles.dat formating ve ve~ F S ZERO ZERO S ve 12 w+ w- V W MW WW S W 24 T1 T1 T D ZERO ZERO O T1 8000002 # And now some bad format entries # which should be ignored with a warning k+ k- X S ZERO ZERO O K 60 1x k- X S ZERO ZERO O K 60 k+ k- S S ZERO ZERO V K 60""" fsock = StringIO.StringIO(particles_dat_str) goal_part_list = base_objects.ParticleList(\ [base_objects.Particle({'name':'ve', 'antiname':'ve~', 'spin':2, 'color':1, 'mass':'ZERO', 'width':'ZERO', 'texname':'ve', 'antitexname':'ve', 'line':'straight', 'charge': 0., 'pdg_code':12, 'propagating':True, 'is_part':True, 'self_antipart':False}), base_objects.Particle({'name':'w+', 'antiname':'w-', 'spin':3, 'color':1, 'mass':'MW', 'width':'WW', 'texname':'W', 'antitexname':'W', 'line':'wavy', 'charge':0., 'pdg_code':24, 'propagating':True, 'is_part':True, 'self_antipart':False}), base_objects.Particle({'name':'t1', 'antiname':'t1', 'spin':5, 'color':8, 'mass':'ZERO', 'width':'ZERO', 'texname':'T1', 'antitexname':'T1', 'line':'dashed', 'charge': 0., 'pdg_code':8000002, 'propagating':True, 'is_part':True, 'self_antipart':True})]) self.assertEqual(import_v4.read_particles_v4(fsock), goal_part_list)
def test_particle_save(self): """Test the particle save routine""" mypartlist = \ base_objects.ParticleList(\ [base_objects.Particle({'name':'ve', 'antiname':'ve~', 'spin':2, 'color':1, 'mass':'ZERO', 'width':'ZERO', 'texname':'ve', 'antitexname':'ve', 'line':'straight', 'charge': 0., 'pdg_code':12, 'propagating':True, 'is_part':True, 'self_antipart':False}), base_objects.Particle({'name':'w+', 'antiname':'w-', 'spin':3, 'color':1, 'mass':'MW', 'width':'WW', 'texname':'W', 'antitexname':'W', 'line':'wavy', 'charge':0., 'pdg_code':24, 'propagating':True, 'is_part':True, 'self_antipart':False})]) fsock = StringIO.StringIO() save_model.save_particles(fsock, mypartlist) goal_str = "particles = [\n%s,%s]" % (str( mypartlist[0]), str(mypartlist[1])) self.assertEqual(fsock.getvalue(), goal_str)
def test_write_qnumber(self): """ check if we can writte qnumber """ particleList = base_objects.ParticleList() particle = base_objects.Particle() particleList.append(particle) self.model.set('particles', particleList) particle.set('pdg_code', 100) particle.set('color', 1) particle.set('spin', 1) particle.set('charge', 0.0) self.writter.write_qnumber() text = self.content.getvalue() self.assertTrue('Block QNUMBERS 100' in text) self.assertTrue('1 0' in text) self.assertTrue('2 1' in text) self.assertTrue('3 1' in text) self.assertTrue('4 1' in text) # a second particle particle.set('pdg_code', 40) particle.set('color', 3) particle.set('spin', 3) particle.set('charge', 1/3) particle.set('self_antipart', True) self.content.truncate(0) self.writter.write_qnumber() text = self.content.getvalue() self.assertTrue('Block QNUMBERS 40' in text) self.assertTrue('1 1' in text) self.assertTrue('2 3' in text) self.assertTrue('3 3' in text) self.assertTrue('4 0' in text)
def test_interaction_save(self): """Test the interaction save routine""" mypart = base_objects.Particle({ 'name': 't', 'antiname': 't~', 'spin': 2, 'color': 3, 'mass': 'mt', 'width': 'wt', 'texname': 't', 'antitexname': '\\overline{t}', 'line': 'straight', 'charge': 2. / 3., 'pdg_code': 6, 'propagating': True, 'is_part': True }) myinterlist = base_objects.InteractionList([\ base_objects.Interaction({'id': 1, 'particles': base_objects.ParticleList([mypart] * 4), 'color': [], 'lorentz':['L1', 'L2'], 'couplings':{(0, 0):'g00', (0, 1):'g01', (1, 0):'g10', (1, 1):'g11'}, 'orders':{'QCD':1, 'QED':1}})]) fsock = StringIO.StringIO() save_model.save_interactions(fsock, myinterlist) goal_str = "interactions = [\n%s]" % str(myinterlist[0]) self.assertEqual(fsock.getvalue(), goal_str)
def setUp(self): """ Setup a toy-model with gluon and down-quark only """ # A gluon self.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 })) # A quark D and its antiparticle self.mypartlist.append( base_objects.Particle({ 'name': 'd', 'antiname': 'd~', 'spin': 2, 'color': 3, 'mass': 'dmass', 'width': 'zero', 'texname': 'd', 'antitexname': '\bar d', 'line': 'straight', 'charge': -1. / 3., 'pdg_code': 1, 'propagating': True, 'is_part': True, 'self_antipart': False })) antid = copy.copy(self.mypartlist[1]) antid.set('is_part', False) # 3 gluon vertex self.myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [self.mypartlist[0]] * 3), 'color': [], 'lorentz':['L1'], 'couplings':{(0, 0):'G'}, 'orders':{'QCD':1}})) # 4 gluon vertex self.myinterlist.append(base_objects.Interaction({ 'id': 2, 'particles': base_objects.ParticleList(\ [self.mypartlist[0]] * 4), 'color': [], 'lorentz':['L1'], 'couplings':{(0, 0):'G^2'}, 'orders':{'QCD':2}})) # Gluon coupling to the down-quark self.myinterlist.append(base_objects.Interaction({ 'id': 3, 'particles': base_objects.ParticleList(\ [self.mypartlist[1], \ antid, \ self.mypartlist[0]]), 'color': [], 'lorentz':['L1'], 'couplings':{(0, 0):'GQQ'}, 'orders':{'QCD':1}})) self.mymodel.set('particles', self.mypartlist) self.mymodel.set('interactions', self.myinterlist) self.myproc.set('model', self.mymodel) self.myloopmodel = save_load_object.load_from_file(os.path.join(_input_file_path,\ 'test_toyLoopModel.pkl')) box_diagram, box_struct = self.def_box() pent_diagram, pent_struct = self.def_pent() self.box_drawing = draw_lib.LoopFeynmanDiagram(box_diagram, box_struct, self.myloopmodel)
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 setUp(self): # Set up 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[len(mypartlist) - 1] # A quark U and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'u', 'antiname': 'u~', 'spin': 2, 'color': 3, 'mass': 'mu', '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) # A quark D and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'd', 'antiname': 'd~', 'spin': 2, 'color': 3, 'mass': 'mu', '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[len(mypartlist) - 1] antid = copy.copy(d) antid.set('is_part', False) # A electron and positron mypartlist.append( base_objects.Particle({ 'name': 'e+', 'antiname': 'e-', 'spin': 2, 'color': 1, 'mass': 'me', 'width': 'zero', 'texname': 'e^+', 'antitexname': 'e^-', 'line': 'straight', 'charge': -1., 'pdg_code': 11, 'propagating': True, 'is_part': True, 'self_antipart': False })) eminus = mypartlist[len(mypartlist) - 1] eplus = copy.copy(eminus) eplus.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[len(mypartlist) - 1] # A T particle mypartlist.append( base_objects.Particle({ 'name': 'T1', 'antiname': 'T1', 'spin': 5, 'color': 1, 'mass': 'zero', 'width': 'zero', 'texname': 'T', 'antitexname': 'T', 'line': 'double', 'charge': 0., 'pdg_code': 8000002, 'propagating': False, 'is_part': True, 'self_antipart': True })) T1 = mypartlist[len(mypartlist) - 1] # A U squark and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'su', 'antiname': 'su~', 'spin': 1, 'color': 3, 'mass': 'Musq2', 'width': 'Wusq2', 'texname': '\tilde u', 'antitexname': '\bar {\tilde u}', 'line': 'dashed', 'charge': 2. / 3., 'pdg_code': 1000002, 'propagating': True, 'is_part': True, 'self_antipart': False })) su = mypartlist[len(mypartlist) - 1] antisu = copy.copy(su) antisu.set('is_part', False) # A E slepton and its antiparticle mypartlist.append( base_objects.Particle({ 'name': 'sl2-', 'antiname': 'sl2+', 'spin': 1, 'color': 1, 'mass': 'Msl2', 'width': 'Wsl2', 'texname': '\tilde e^-', 'antitexname': '\tilde e^+', 'line': 'dashed', 'charge': 1., 'pdg_code': 1000011, 'propagating': True, 'is_part': True, 'self_antipart': False })) seminus = mypartlist[len(mypartlist) - 1] seplus = copy.copy(seminus) seplus.set('is_part', False) # A neutralino mypartlist.append( base_objects.Particle({ 'name': 'n1', 'antiname': 'n1', 'spin': 2, 'color': 1, 'mass': 'Mneu1', 'width': 'Wneu1', 'texname': '\chi_0^1', 'antitexname': '\chi_0^1', 'line': 'straight', 'charge': 0., 'pdg_code': 1000022, 'propagating': True, 'is_part': True, 'self_antipart': True })) n1 = 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(u) 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] # Gluon and photon couplings to quarks myinterlist.append(base_objects.Interaction({ 'id': 3, 'particles': base_objects.ParticleList(\ [u, \ antiu, \ g]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'GG'}, 'orders':{'QCD':1}})) myinterlist.append(base_objects.Interaction({ 'id': 4, 'particles': base_objects.ParticleList(\ [d, \ antid, \ a]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX15'}, 'orders':{'QED':1}})) myinterlist.append(base_objects.Interaction({ 'id': 10, 'particles': base_objects.ParticleList(\ [d, \ antid, \ g]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'GG'}, 'orders':{'QCD':1}})) myinterlist.append(base_objects.Interaction({ 'id': 11, 'particles': base_objects.ParticleList(\ [u, \ antiu, \ a]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX15'}, 'orders':{'QED':1}})) # Tgg coupling myinterlist.append(base_objects.Interaction({ 'id': 5, 'particles': base_objects.ParticleList(\ [g, \ g, \ T1]), 'color': [], 'lorentz':['A'], 'couplings':{(0, 0):'MGVX2'}, 'orders':{'QCD':1}})) # ggg coupling myinterlist.append(base_objects.Interaction({ 'id': 15, 'particles': base_objects.ParticleList(\ [g, \ g, \ g]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX1'}, 'orders':{'QCD':1}})) # Coupling of e to gamma myinterlist.append(base_objects.Interaction({ 'id': 7, 'particles': base_objects.ParticleList(\ [eminus, \ eplus, \ a]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX12'}, 'orders':{'QED':1}})) # Gluon coupling to su myinterlist.append(base_objects.Interaction({ 'id': 105, 'particles': base_objects.ParticleList(\ [g, \ su, \ antisu]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX74'}, 'orders':{'QCD':1}})) # Coupling of n1 to u and su myinterlist.append(base_objects.Interaction({ 'id': 101, 'particles': base_objects.ParticleList(\ [n1, \ u, \ antisu]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX570'}, 'orders':{'QED':1}})) myinterlist.append(base_objects.Interaction({ 'id': 102, 'particles': base_objects.ParticleList(\ [antiu, \ n1, \ su]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX575'}, 'orders':{'QED':1}})) # Coupling of n1 to e and se myinterlist.append(base_objects.Interaction({ 'id': 103, 'particles': base_objects.ParticleList(\ [n1, \ eminus, \ seplus]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX350'}, 'orders':{'QED':1}})) myinterlist.append(base_objects.Interaction({ 'id': 104, 'particles': base_objects.ParticleList(\ [eplus, \ n1, \ seminus]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX494'}, 'orders':{'QED':1}})) # Coupling of n1 to z myinterlist.append(base_objects.Interaction({ 'id': 106, 'particles': base_objects.ParticleList(\ [n1, \ n1, z]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'GZN11'}, 'orders':{'QED':1}})) # g-gamma-su-subar coupling myinterlist.append(base_objects.Interaction({ 'id': 100, 'particles': base_objects.ParticleList(\ [a, g, su, antisu]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX89'}, 'orders':{'QED':1, 'QCD':1}})) # w+w-w+w- coupling myinterlist.append(base_objects.Interaction({ 'id': 8, 'particles': base_objects.ParticleList(\ [wplus, wminus, wplus, wminus]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX6'}, 'orders':{'QED':2}})) # w+w-zz coupling myinterlist.append(base_objects.Interaction({ 'id': 9, 'particles': base_objects.ParticleList(\ [wplus, wminus, z, z]), 'color': [], 'lorentz':[''], 'couplings':{(0, 0):'MGVX8'}, 'orders':{'QED':2}})) self.mybasemodel.set('particles', mypartlist) self.mybasemodel.set('interactions', myinterlist) self.mybasemodel.set('name', 'sm') self.mymodel.set('model', self.mybasemodel)
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 setUp(self): # A gluon self.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 })) # A quark U and its antiparticle self.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 })) antiu = copy.copy(self.mypartlist[1]) antiu.set('is_part', False) # A quark D and its antiparticle self.mypartlist.append( base_objects.Particle({ 'name': 'd', 'antiname': 'd~', 'spin': 2, 'color': 3, 'mass': 'zero', 'width': 'zero', 'texname': 'u', 'antitexname': '\bar u', 'line': 'straight', 'charge': -1. / 3., 'pdg_code': 1, 'propagating': True, 'is_part': True, 'self_antipart': False })) antid = copy.copy(self.mypartlist[2]) antid.set('is_part', False) # 3 gluon vertiex self.myinterlist.append(base_objects.Interaction({ 'id': 1, 'particles': base_objects.ParticleList(\ [self.mypartlist[0]] * 3), 'color': [color.ColorString([color.f(0, 1, 2)])], 'lorentz':['L1'], 'couplings':{(0, 0):'G'}, 'orders':{'QCD':1}})) # 4 gluon vertex self.myinterlist.append(base_objects.Interaction({ 'id': 2, 'particles': base_objects.ParticleList(\ [self.mypartlist[0]] * 4), 'color': [color.ColorString([color.f(-1, 0, 2), color.f(-1, 1, 3)]), color.ColorString([color.f(-1, 0, 3), color.f(-1, 1, 2)]), color.ColorString([color.f(-1, 0, 1), color.f(-1, 2, 3)])], 'lorentz':['L(p1,p2,p3)', 'L(p2,p3,p1)', 'L3'], 'couplings':{(0, 0):'G^2', (1, 1):'G^2', (2, 2):'G^2'}, 'orders':{'QCD':2}})) # Gluon couplings to up and down quarks self.myinterlist.append(base_objects.Interaction({ 'id': 3, 'particles': base_objects.ParticleList(\ [self.mypartlist[1], \ antiu, \ self.mypartlist[0]]), 'color': [color.ColorString([color.T(2, 0, 1)])], 'lorentz':['L1'], 'couplings':{(0, 0):'GQQ'}, 'orders':{'QCD':1}})) self.myinterlist.append(base_objects.Interaction({ 'id': 4, 'particles': base_objects.ParticleList(\ [self.mypartlist[2], \ antid, \ self.mypartlist[0]]), 'color': [color.ColorString([color.T(2, 0, 1)])], 'lorentz':['L1'], 'couplings':{(0, 0):'GQQ'}, 'orders':{'QCD':1}})) self.mymodel.set('particles', self.mypartlist) self.mymodel.set('interactions', self.myinterlist)
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)
import madgraph.core.color_algebra as color import copy # Particles #========================================================================================= # A gluon gluon = 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 }) # Up quark up = base_objects.Particle({ 'name': 'u', 'antiname': 'u~', 'spin': 2, 'color': 3, 'mass': 'zero',
def loadLoopToyModel(): """Setup the Loop Toy QCD model with d,dx,u,ux and the gluon""" mypartlist = base_objects.ParticleList() myinterlist = base_objects.InteractionList() myloopmodel = loop_base_objects.LoopModel() # 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, 'propagator':0, 'is_part':True, 'counterterm':{('QCD', ((6,),)): {0: 'UVWfct_G_1', -1: 'UVWfct_G_1_1eps'}, ('QCD', ((5,),)): {0: 'UVWfct_G_0', -1: 'UVWfct_G_0_1eps'}}, 'self_antipart':True})) # 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':'u', 'line':'straight', 'charge':2. / 3., 'pdg_code':2, 'propagating':True, 'propagator':'', 'is_part':True, 'self_antipart':False})) antiu = copy.copy(mypartlist[1]) 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':'d', 'line':'straight', 'charge':-1. / 3., 'pdg_code':1, 'propagating':True, 'propagator':'', 'is_part':True, 'self_antipart':False})) antid = copy.copy(mypartlist[2]) antid.set('is_part', False) myloopmodel.set('particles', mypartlist) myloopmodel.set('couplings', ['QCD']) myloopmodel.set('interactions', myinterlist) myloopmodel.set('perturbation_couplings', ['QCD']) myloopmodel.set('order_hierarchy', {'QCD':1}) return myloopmodel
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']