Esempio n. 1
0
    def test_simple_import(self):
        """ check that basic quantity are define """

        #remove pkl file
        try:
            model_path = os.path.join(MG5DIR, 'models', 'sm')
            os.remove(os.path.join(model_path, 'model.pkl'))
        except:
            pass

        import_ufo._import_once = []
        sm_path = import_ufo.find_ufo_path('sm')
        model = import_ufo.import_model(sm_path)

        self.assertNotEqual(model.get('particles'), None)
        self.assertNotEqual(model.get('particles'), [], "empty particles list")

        self.assertNotEqual(model.get('interactions'), None)
        self.assertNotEqual(model.get('interactions'), [])

        # try with the pickle:
        sm_path = import_ufo.find_ufo_path('sm')
        model = import_ufo.import_model(sm_path)

        self.assertNotEqual(model.get('particles'), None)
        self.assertNotEqual(model.get('particles'), [], "empty particles list")

        self.assertNotEqual(model.get('interactions'), None)
        self.assertNotEqual(model.get('interactions'), [])
Esempio n. 2
0
 def test_simple_import(self):
     """ check that basic quantity are define """
     
     #remove pkl file
     try:
         model_path = os.path.join(MG5DIR, 'models', 'sm')
         os.remove(os.path.join(model_path,'model.pkl'))
     except:
         pass
     
     import_ufo._import_once = []
     sm_path = import_ufo.find_ufo_path('sm')
     model = import_ufo.import_model(sm_path)
 
     self.assertNotEqual(model.get('particles'),None)
     self.assertNotEqual(model.get('particles'),[], "empty particles list")
 
     self.assertNotEqual(model.get('interactions'),None)
     self.assertNotEqual(model.get('interactions'),[])    
     
     
     # try with the pickle:
     sm_path = import_ufo.find_ufo_path('sm')
     model = import_ufo.import_model(sm_path)
 
     self.assertNotEqual(model.get('particles'),None)
     self.assertNotEqual(model.get('particles'),[], "empty particles list")
 
     self.assertNotEqual(model.get('interactions'),None)
     self.assertNotEqual(model.get('interactions'),[])            
Esempio n. 3
0
    def test_ImportUFONoSideEffectNLO(self):
        """Checks that there are no side effects of the import of the NLO UFO sm"""
        ufo_model = ufomodels.load_model(import_ufo.find_ufo_path('loop_sm'),False)
        original_all_particles = copy.copy(ufo_model.all_particles)
        original_all_vertices = copy.copy(ufo_model.all_vertices)
        original_all_couplings = copy.copy(ufo_model.all_couplings)
        original_all_lorentz = copy.copy(ufo_model.all_lorentz)
        original_all_parameters = copy.copy(ufo_model.all_parameters)
        original_all_orders = copy.copy(ufo_model.all_orders)
        original_all_functions = copy.copy(ufo_model.all_functions)
        original_all_CTvertices = copy.copy(ufo_model.all_CTvertices)
        original_all_CTparameters = copy.copy(ufo_model.all_CTparameters)


        ufo2mg5_converter = import_ufo.UFOMG5Converter(ufo_model)
        model = ufo2mg5_converter.load_model()
        parameters, couplings = import_ufo.OrganizeModelExpression(ufo_model).main()        

        self.assertEqual(original_all_particles,ufo_model.all_particles)
        self.assertEqual(original_all_vertices,ufo_model.all_vertices)
#        self.assertEqual(original_all_couplings,ufo_model.all_couplings)
        self.assertEqual(original_all_lorentz,ufo_model.all_lorentz)
        self.assertEqual(original_all_parameters,ufo_model.all_parameters)
        self.assertEqual(original_all_orders,ufo_model.all_orders)
        self.assertEqual(original_all_functions,ufo_model.all_functions)
        self.assertEqual(original_all_CTvertices,ufo_model.all_CTvertices)
        self.assertEqual(original_all_CTparameters,ufo_model.all_CTparameters)
Esempio n. 4
0
    def setUp(self):
        
        self.path = tempfile.mkdtemp(prefix='unitest_usermod') 

        #Read the full SM
        self.sm_path = import_ufo.find_ufo_path('sm')
        self.base_model = usermod.UFOModel(self.sm_path)
Esempio n. 5
0
    def test_mssm_equivalence(self):
        """Test the UFO and MG4 MSSM model correspond to the same model """
        
        # import UFO model
        sm_path = import_ufo.find_ufo_path('mssm')
        ufo_model = import_ufo.import_model(sm_path)
        #converter = import_ufo.UFOMG5Converter(model)
        #ufo_model = converter.load_model()
        ufo_model.pass_particles_name_in_mg_default()
        
        # import MG4 model
        model = base_objects.Model()
        if not MG4DIR:
            raise MadGraph5Error, "Please provide a valid MG/ME path with -d"
        v4_path = os.path.join(MG4DIR, 'models', 'mssm_v4')
        if not os.path.isdir(v4_path):
            v4_path = os.path.join(MG4DIR, 'Models', 'mssm')
            if not os.path.isdir(v4_path):
                raise MadGraph5Error, \
                      "Please provide a valid MG/ME path with -d"

        model.set('particles', files.read_from_file(
               os.path.join(v4_path,'particles.dat'),
               import_v4.read_particles_v4))
        model.set('interactions', files.read_from_file(
            os.path.join(v4_path,'interactions.dat'),
            import_v4.read_interactions_v4,
            model['particles']))
        
        model.pass_particles_name_in_mg_default()
        # Checking the particles
        for particle in model['particles']:
            ufo_particle = ufo_model.get("particle_dict")[particle['pdg_code']]
            self.check_particles(particle, ufo_particle)

        # Skip test below until equivalence has been created by Benj and Claude
        return

        
        # Checking the interactions
        nb_vertex = 0
        ufo_vertices = []
        for ufo_vertex in ufo_model['interactions']:
            pdg_code_ufo = [abs(part['pdg_code']) for part in ufo_vertex['particles']]
            int_name = [part['name'] for part in ufo_vertex['particles']]
            rep = (pdg_code_ufo, int_name)
            pdg_code_ufo.sort()
            ufo_vertices.append(pdg_code_ufo)
        mg4_vertices = []
        for vertex in model['interactions']:
            pdg_code_mg4 = [abs(part['pdg_code']) for part in vertex['particles']]
            pdg_code_mg4.sort()

            try:
                ufo_vertices.remove(pdg_code_mg4)
            except ValueError:
                mg4_vertices.append(pdg_code_mg4)

        self.assertEqual(ufo_vertices, [])  
        self.assertEqual(mg4_vertices, [])  
Esempio n. 6
0
    def test_ImportUFONoSideEffectLO(self):
        """Checks that there are no side effects of the import of the LO UFO sm"""       
        ufo_model = ufomodels.load_model(import_ufo.find_ufo_path('sm'),False)
        original_all_particles = copy.copy(ufo_model.all_particles)
        original_all_vertices = copy.copy(ufo_model.all_vertices)
        original_all_couplings = copy.copy(ufo_model.all_couplings)
        original_all_lorentz = copy.copy(ufo_model.all_lorentz)
        original_all_parameters = copy.copy(ufo_model.all_parameters)
        original_all_orders = copy.copy(ufo_model.all_orders)
        original_all_functions = copy.copy(ufo_model.all_functions)

        ufo2mg5_converter = import_ufo.UFOMG5Converter(ufo_model)
        model = ufo2mg5_converter.load_model()
        # It is important to run import_ufo.OrganizeModelExpression(ufo_model).main() 
        # since this reverts some of the changes done in load_model()
        # There *is* side effects in-between, namely the expression of the CTcouplings
        # which contained CTparameters have been substituted to dictionaries.
        parameters, couplings = import_ufo.OrganizeModelExpression(ufo_model).main()        

        self.assertEqual(original_all_particles,ufo_model.all_particles)        
        self.assertEqual(original_all_vertices,ufo_model.all_vertices)
        self.assertEqual(original_all_couplings,ufo_model.all_couplings)
        self.assertEqual(original_all_lorentz,ufo_model.all_lorentz)
        self.assertEqual(original_all_parameters,ufo_model.all_parameters)
        self.assertEqual(original_all_orders,ufo_model.all_orders)
        self.assertEqual(original_all_functions,ufo_model.all_functions)
Esempio n. 7
0
    def test_ImportUFONoSideEffectNLO(self):
        """Checks that there are no side effects of the import of the NLO UFO sm"""
        ufo_model = ufomodels.load_model(import_ufo.find_ufo_path('loop_sm'),
                                         False)
        original_all_particles = copy.copy(ufo_model.all_particles)
        original_all_vertices = copy.copy(ufo_model.all_vertices)
        original_all_couplings = copy.copy(ufo_model.all_couplings)
        original_all_lorentz = copy.copy(ufo_model.all_lorentz)
        original_all_parameters = copy.copy(ufo_model.all_parameters)
        original_all_orders = copy.copy(ufo_model.all_orders)
        original_all_functions = copy.copy(ufo_model.all_functions)
        original_all_CTvertices = copy.copy(ufo_model.all_CTvertices)
        original_all_CTparameters = copy.copy(ufo_model.all_CTparameters)

        ufo2mg5_converter = import_ufo.UFOMG5Converter(ufo_model)
        model = ufo2mg5_converter.load_model()
        parameters, couplings = import_ufo.OrganizeModelExpression(
            ufo_model).main()

        self.assertEqual(original_all_particles, ufo_model.all_particles)
        self.assertEqual(original_all_vertices, ufo_model.all_vertices)
        #        self.assertEqual(original_all_couplings,ufo_model.all_couplings)
        self.assertEqual(original_all_lorentz, ufo_model.all_lorentz)
        self.assertEqual(original_all_parameters, ufo_model.all_parameters)
        self.assertEqual(original_all_orders, ufo_model.all_orders)
        self.assertEqual(original_all_functions, ufo_model.all_functions)
        self.assertEqual(original_all_CTvertices, ufo_model.all_CTvertices)
        self.assertEqual(original_all_CTparameters, ufo_model.all_CTparameters)
    def test_ImportUFONoSideEffectLO(self):
        """Checks that there are no side effects of the import of the LO UFO sm"""       
        ufo_model = ufomodels.load_model(import_ufo.find_ufo_path('sm'),False)
        original_all_particles = copy.copy(ufo_model.all_particles)
        original_all_vertices = copy.copy(ufo_model.all_vertices)
        original_all_couplings = copy.copy(ufo_model.all_couplings)
        original_all_lorentz = copy.copy(ufo_model.all_lorentz)
        original_all_parameters = copy.copy(ufo_model.all_parameters)
        original_all_orders = copy.copy(ufo_model.all_orders)
        original_all_functions = copy.copy(ufo_model.all_functions)

        ufo2mg5_converter = import_ufo.UFOMG5Converter(ufo_model)
        model = ufo2mg5_converter.load_model()
        # It is important to run import_ufo.OrganizeModelExpression(ufo_model).main() 
        # since this reverts some of the changes done in load_model()
        # There *is* side effects in-between, namely the expression of the CTcouplings
        # which contained CTparameters have been substituted to dictionaries.
        parameters, couplings = import_ufo.OrganizeModelExpression(ufo_model).main()        

        self.assertEqual(original_all_particles,ufo_model.all_particles)        
        self.assertEqual(original_all_vertices,ufo_model.all_vertices)
        self.assertEqual(original_all_couplings,ufo_model.all_couplings)
        self.assertEqual(original_all_lorentz,ufo_model.all_lorentz)
        self.assertEqual(original_all_parameters,ufo_model.all_parameters)
        self.assertEqual(original_all_orders,ufo_model.all_orders)
        self.assertEqual(original_all_functions,ufo_model.all_functions)
Esempio n. 9
0
    def setUp(self):
        
        self.path = tempfile.mkdtemp(prefix='unitest_usermod') 

        #Read the full SM
        self.sm_path = import_ufo.find_ufo_path('sm')
        self.base_model = usermod.UFOModel(self.sm_path)
Esempio n. 10
0
    def test_mssm_equivalence(self):
        """Test the UFO and MG4 MSSM model correspond to the same model """
        
        # import UFO model
        mssm_path = import_ufo.find_ufo_path('MSSM_SLHA2')
        ufo_model = import_ufo.import_model(mssm_path)
        #converter = import_ufo.UFOMG5Converter(model)
        #ufo_model = converter.load_model()
        ufo_model.pass_particles_name_in_mg_default()
        
        # import MG4 model
        
        model = base_objects.Model()
        if not MG4DIR:
            raise MadGraph5Error("Please provide a valid MG/ME path with -d")
        v4_path = os.path.join(MG4DIR, 'models', 'mssm_v4')
        if not os.path.isdir(v4_path):
            import_ufo.import_model_from_db('mssm_v4', local_dir=True)
                

        model.set('particles', files.read_from_file(
               os.path.join(v4_path,'particles.dat'),
               import_v4.read_particles_v4))
        model.set('interactions', files.read_from_file(
            os.path.join(v4_path,'interactions.dat'),
            import_v4.read_interactions_v4,
            model['particles']))
        
        #model.pass_particles_name_in_mg_default()
        # Checking the particles
        for particle in model['particles']:
            ufo_particle = ufo_model.get("particle_dict")[particle['pdg_code']]
            self.check_particles(particle, ufo_particle)

        # Skip test below until equivalence has been created by Benj and Claude
        return

        
        # Checking the interactions
        nb_vertex = 0
        ufo_vertices = []
        for ufo_vertex in ufo_model['interactions']:
            pdg_code_ufo = [abs(part['pdg_code']) for part in ufo_vertex['particles']]
            int_name = [part['name'] for part in ufo_vertex['particles']]
            rep = (pdg_code_ufo, int_name)
            pdg_code_ufo.sort()
            ufo_vertices.append(pdg_code_ufo)
        mg4_vertices = []
        for vertex in model['interactions']:
            pdg_code_mg4 = [abs(part['pdg_code']) for part in vertex['particles']]
            pdg_code_mg4.sort()

            try:
                ufo_vertices.remove(pdg_code_mg4)
            except ValueError:
                mg4_vertices.append(pdg_code_mg4)

        self.assertEqual(ufo_vertices, [])  
        self.assertEqual(mg4_vertices, [])  
Esempio n. 11
0
    def test_ImportUFONoSideEffectNLO(self):
        """Checks that there are no side effects of the import of the NLO UFO sm"""
        ufo_model = ufomodels.load_model(import_ufo.find_ufo_path('loop_sm'),False)
        original_all_particles = copy.copy(ufo_model.all_particles)
        original_all_vertices = copy.copy(ufo_model.all_vertices)
        original_all_couplings = copy.copy(ufo_model.all_couplings)
        original_all_lorentz = copy.copy(ufo_model.all_lorentz)
        original_all_parameters = copy.copy(ufo_model.all_parameters)
        original_all_orders = copy.copy(ufo_model.all_orders)
        original_all_functions = copy.copy(ufo_model.all_functions)
        original_all_CTvertices = copy.copy(ufo_model.all_CTvertices)
        original_all_CTparameters = copy.copy(ufo_model.all_CTparameters)


        ufo2mg5_converter = import_ufo.UFOMG5Converter(ufo_model)
        model = ufo2mg5_converter.load_model()
        # It is important to run import_ufo.OrganizeModelExpression(ufo_model).main() 
        # since this reverts some of the changes done in load_model()
        # There *is* side effects in-between, namely the expression of the CTcouplings
        # which contained CTparameters have been substituted to dictionaries.
        parameters, couplings = import_ufo.OrganizeModelExpression(ufo_model).main()        

        self.assertEqual(original_all_particles,ufo_model.all_particles)
        self.assertEqual(original_all_vertices,ufo_model.all_vertices)
        self.assertEqual(original_all_couplings,ufo_model.all_couplings)
        self.assertEqual(original_all_lorentz,ufo_model.all_lorentz)
        self.assertEqual(original_all_parameters,ufo_model.all_parameters)
        self.assertEqual(original_all_orders,ufo_model.all_orders)
        self.assertEqual(original_all_functions,ufo_model.all_functions)
        self.assertEqual(original_all_CTvertices,ufo_model.all_CTvertices)
        self.assertEqual(original_all_CTparameters,ufo_model.all_CTparameters)

        # Also test that one new lorentz struture has been added within the model
        # and that the associate optimization is working as expected.
        self.assertEqual(len(original_all_lorentz) + 1, len(model['lorentz']))
        new_l = [l for l  in model['lorentz'] if l not in original_all_lorentz][0]
        new_name = new_l.name
        self.assertEqual(new_l.name, 'R2RGA_VVVV1')
        # find interactions with that lorentz structure
        int_with_it = []
        for id, vertices in model.get('interaction_dict').items():
            if new_name in vertices['lorentz']:
                int_with_it.append(vertices)
        self.assertEqual(len(int_with_it), 2)
        # check the first one
        vert = int_with_it[0]
        pdg = [p['pdg_code'] for p in vert['particles']]
        self.assertEqual(pdg, [21,21,21,21])
        # check the equivalent vertex in the original model
        old_vert = [ v for v in ufo_model.all_CTvertices if pdg == [p.pdg_code for p in v.particles]]
        #pick one
        old_vert = old_vert[0]
        
        # find the number of coupling associate to this lorentz structure
        ind = vert['lorentz'].index(new_name)
        coup_name = [ c for ((l,col),c) in vert['couplings'].items() if l ==ind]
        nb_old = len([ c for ((l,col),c) in vert['couplings'].items() if c == coup_name[0]])
        nb_new = len([ c for ((l,col,k),c) in old_vert.couplings.items() if c.name == coup_name[0]])
        self.assertEqual(3*nb_old, nb_new)
Esempio n. 12
0
 def setUp(self):
     """Set up decay model"""
     # Read the full SM
     sm_path = import_ufo.find_ufo_path("sm")
     self.base_model = import_ufo.import_full_model(sm_path)
     model = copy.deepcopy(self.base_model)
     self.model = import_ufo.RestrictModel(model)
     self.restrict_file = os.path.join(_file_path, os.path.pardir, "input_files", "restrict_sm.dat")
Esempio n. 13
0
 def setUp(self):
     m_path = import_ufo.find_ufo_path('triplet_diquarks')
     self.base_model = import_ufo.import_model(m_path)
     self.full_model = model_reader.ModelReader(self.base_model)
     self.full_model.set_parameters_and_couplings()
     # Set top quark mass to 0 to compare with literature expression
     self.full_model.get('parameter_dict')['mdl_MT'] = 0.
     self.full_model.get('parameter_dict')['mdl_WT'] = 0.
Esempio n. 14
0
 def setUp(self):
     m_path = import_ufo.find_ufo_path('triplet_diquarks')
     self.base_model = import_ufo.import_model(m_path)
     self.full_model = model_reader.ModelReader(self.base_model)
     self.full_model.set_parameters_and_couplings()
     # Set top quark mass to 0 to compare with literature expression
     self.full_model.get('parameter_dict')['mdl_MT'] = 0.
     self.full_model.get('parameter_dict')['mdl_WT'] = 0.
Esempio n. 15
0
 def setUp(self):
     m_path = import_ufo.find_ufo_path("triplet_diquarks")
     self.base_model = import_ufo.import_model(m_path)
     self.full_model = model_reader.ModelReader(self.base_model)
     self.full_model.set_parameters_and_couplings()
     # Set top quark mass to 0 to compare with literature expression
     self.full_model.get("parameter_dict")["MT"] = 0.0
     self.full_model.get("parameter_dict")["WT"] = 0.0
    def test_sm_equivalence(self):
        """Test the UFO and MG4 SM model correspond to the same model """

        # import UFO model
        sm_path = import_ufo.find_ufo_path('sm')
        ufo_model = import_ufo.import_model(sm_path)
        ufo_model.pass_particles_name_in_mg_default()

        # import MG4 model
        model = base_objects.Model()
        v4_path = os.path.join(MG4DIR, 'models', 'sm_v4')
        if not os.path.isdir(v4_path):
            v4_path = os.path.join(MG4DIR, 'Models', 'sm')
            if not os.path.isdir(v4_path):
                raise MadGraph5Error, \
                      "Please provide a valid MG/ME path with -d"

        model.set(
            'particles',
            files.read_from_file(os.path.join(v4_path, 'particles.dat'),
                                 import_v4.read_particles_v4))
        model.set(
            'interactions',
            files.read_from_file(os.path.join(v4_path, 'interactions.dat'),
                                 import_v4.read_interactions_v4,
                                 model['particles']))
        model.pass_particles_name_in_mg_default()

        # Checking the particles
        for particle in model['particles']:
            ufo_particle = ufo_model.get("particle_dict")[particle['pdg_code']]
            self.check_particles(particle, ufo_particle)

        # Checking the interactions
        nb_vertex = 0
        ufo_vertices = []
        for ufo_vertex in ufo_model['interactions']:
            pdg_code_ufo = [
                abs(part['pdg_code']) for part in ufo_vertex['particles']
            ]
            int_name = [part['name'] for part in ufo_vertex['particles']]
            rep = (pdg_code_ufo, int_name)
            pdg_code_ufo.sort()
            ufo_vertices.append(pdg_code_ufo)
        mg4_vertices = []
        for vertex in model['interactions']:
            pdg_code_mg4 = [
                abs(part['pdg_code']) for part in vertex['particles']
            ]
            pdg_code_mg4.sort()

            try:
                ufo_vertices.remove(pdg_code_mg4)
            except ValueError:
                mg4_vertices.append(pdg_code_mg4)

        self.assertEqual(ufo_vertices, [[25, 25, 25, 25]])
        self.assertEqual(mg4_vertices, [])
Esempio n. 17
0
 def setUp(self):
     """Set up decay model"""
     #Read the full SM
     sm_path = import_ufo.find_ufo_path('sm')
     self.base_model = import_ufo.import_full_model(sm_path)
     model = copy.deepcopy(self.base_model)
     self.model = import_ufo.RestrictModel(model)
     self.restrict_file = os.path.join(_file_path, os.path.pardir,
                                  'input_files', 'restrict_sm.dat')
Esempio n. 18
0
    def setUp(self):
        """Set up decay model"""
        #Read the full SM
        sm_path = import_ufo.find_ufo_path('sm')
        self.base_model = import_ufo.import_full_model(sm_path)

        model = copy.deepcopy(self.base_model)
        self.model = import_ufo.RestrictModel(model)
        self.restrict_file = os.path.join(_file_path, os.path.pardir,
                                     'input_files', 'restrict_sm.dat')
        self.model.set_parameters_and_couplings(self.restrict_file)
 def test_ImportUFOcheckgoldstone(self):
     """Check goldstone is correct in NLO UFO"""
     ufo_model = ufomodels.load_model(import_ufo.find_ufo_path('loop_qcd_qed_sm'),False)
     original_all_particles = copy.copy(ufo_model.all_particles)
     for part in original_all_particles:
         if part.name.lower() in ['g0','g+']:
             if hasattr(part,"GoldstoneBoson"):
                 self.assertEqual(part.GoldstoneBoson,True)
             elif hasattr(part,"goldstoneboson"):
                 self.assertEqual(part.goldstoneboson,True)
             else:
                 raise import_ufo.UFOImportError, "Goldstone %s has no attribute of goldstnoneboson in loop_qcd_qed_sm"%part.name
Esempio n. 20
0
    def setUp(self):
        
        self.path = tempfile.mkdtemp(prefix='unitest_usermod') 

        #Read the full SM
        self.sm_path = import_ufo.find_ufo_path('sm')
        self.base_model = usermod.UFOModel(self.sm_path)
        self.mymodel = Model()
        for key in self.mymodel.__dict__:
            obj = getattr(self.mymodel, key)
            for o in obj[:]:
                obj.pop()
Esempio n. 21
0
 def test_ImportUFOcheckgoldstone(self):
     """Check goldstone is correct in NLO UFO"""
     ufo_model = ufomodels.load_model(import_ufo.find_ufo_path('loop_qcd_qed_sm'),False)
     original_all_particles = copy.copy(ufo_model.all_particles)
     for part in original_all_particles:
         if part.name.lower() in ['g0','g+']:
             if hasattr(part,"GoldstoneBoson"):
                 self.assertEqual(part.GoldstoneBoson,True)
             elif hasattr(part,"goldstoneboson"):
                 self.assertEqual(part.goldstoneboson,True)
             else:
                 raise import_ufo.UFOImportError, "Goldstone %s has no attribute of goldstnoneboson in loop_qcd_qed_sm"%part.name
Esempio n. 22
0
    def setUp(self):

        self.path = tempfile.mkdtemp(prefix='unitest_usermod')

        #Read the full SM
        self.sm_path = import_ufo.find_ufo_path('sm')
        self.base_model = usermod.UFOModel(self.sm_path)
        self.mymodel = Model()
        for key in self.mymodel.__dict__:
            obj = getattr(self.mymodel, key)
            for o in obj[:]:
                obj.pop()
Esempio n. 23
0
    def test_write_model(self):
        """ Check that we can write all the require UFO files """
        
        output = pjoin(self.path, 'usrmod')
        self.base_model.write(output)
        sm_path = import_ufo.find_ufo_path('sm')
        self.assertEqual(12, 
                len([1 for name in os.listdir(sm_path) if name.endswith('.py')]), 
               'New file in  UFO format, usrmod need to be modified')

        self.assertEqual(11, 
                len([1 for name in os.listdir(output) if name.endswith('.py')]))

        sys.path.insert(0, os.path.dirname(output))
        import usrmod
Esempio n. 24
0
    def test_write_model(self):
        """ Check that we can write all the require UFO files """
        
        output = pjoin(self.path, 'usrmod')
        self.base_model.write(output)
        sm_path = import_ufo.find_ufo_path('sm')
        self.assertEqual(12, 
                len([1 for name in os.listdir(sm_path) if name.endswith('.py')]), 
               'New file in  UFO format, usrmod need to be modified')

        self.assertEqual(11, 
                len([1 for name in os.listdir(output) if name.endswith('.py')]))

        sys.path.insert(0, os.path.dirname(output))
        import usrmod
Esempio n. 25
0
 def test_get_nflav_sm_nomasses(self):
     """Tests the get_nflav_function for the SM, with the no_masses restriction"""
     sm_path = import_ufo.find_ufo_path('sm')
     model = import_ufo.import_model(sm_path + '-no_masses')
     self.assertEqual(model.get_nflav(), 5)
Esempio n. 26
0
 def setUp(self):
     m_path = import_ufo.find_ufo_path('sextet_diquarks')
     self.base_model = import_ufo.import_model(m_path)
 def setUp(self):
     sm_path = import_ufo.find_ufo_path('mssm')
     self.base_model = import_ufo.import_model(sm_path)
Esempio n. 28
0
 def setUp(self):
     sm_path = import_ufo.find_ufo_path('MSSM_SLHA2')
     self.base_model = import_ufo.import_model(sm_path)
Esempio n. 29
0
 def test_get_nflav_sm_nomasses(self):
     """Tests the get_nflav_function for the SM, with the no_masses restriction"""
     sm_path = import_ufo.find_ufo_path('sm')
     model = import_ufo.import_model(sm_path + '-no_masses')
     self.assertEqual(model.get_nflav(), 5)
Esempio n. 30
0
 def test_get_nflav_sm(self):
     """Tests the get_nflav_function for the full SM.
     Here b and c quark are massive"""
     sm_path = import_ufo.find_ufo_path('sm')
     model = import_ufo.import_full_model(sm_path)
     self.assertEqual(model.get_nflav(), 3)
Esempio n. 31
0
 def setUp(self):
     sm_path = import_ufo.find_ufo_path('mssm')
     self.base_model = import_ufo.import_model(sm_path)
Esempio n. 32
0
 def setUp(self):
     """Set up decay model"""
     #Read the full SM
     sm_path = import_ufo.find_ufo_path('heft')
     self.base_model = import_ufo.import_full_model(sm_path)
 def setUp(self):
     """Set up decay model"""
     #Read the full SM
     sm_path = import_ufo.find_ufo_path('sm')
     self.base_model = import_ufo.import_model(sm_path)
     self.model_reader = model_reader.ModelReader(self.base_model)
Esempio n. 34
0
    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))
Esempio n. 35
0
 def setUp(self):
     """Set up decay model"""
     #Read the full SM
     sm_path = import_ufo.find_ufo_path('heft')
     self.base_model = import_ufo.import_full_model(sm_path)
Esempio n. 36
0
 def test_get_nflav_sm(self):
     """Tests the get_nflav_function for the full SM.
     Here b and c quark are massive"""
     sm_path = import_ufo.find_ufo_path('sm')
     model = import_ufo.import_full_model(sm_path)
     self.assertEqual(model.get_nflav(), 3)
Esempio n. 37
0
    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))
Esempio n. 38
0
 def setUp(self):
     m_path = import_ufo.find_ufo_path("sextet_diquarks")
     self.base_model = import_ufo.import_model(m_path)
Esempio n. 39
0
 def setUp(self):
     """Set up decay model"""
     #Read the full SM
     sm_path = import_ufo.find_ufo_path('sm')
     self.base_model = import_ufo.import_model(sm_path)
     self.model_reader = model_reader.ModelReader(self.base_model)