~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to models/import_ufo.py

  • Committer: olivier-mattelaer
  • Date: 2019-03-03 20:54:56 UTC
  • mfrom: (281.1.10 2.6.6)
  • mto: (283.1.18 2.7.0)
  • mto: This revision was merged to the branch mainline in revision 284.
  • Revision ID: olivier-mattelaer-20190303205456-zqzilqf1yrmxdr2g
merge with 2.6.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
106
106
    r = random.randint(0,1)
107
107
    r = [r, (1-r)]
108
108
 
 
109
    if 'MG5aMC_WWW' in os.environ and os.environ['MG5aMC_WWW']:
 
110
        data_path.append(os.environ['MG5aMC_WWW']+'/models_db.dat')
 
111
        r.insert(0, 2)
 
112
 
 
113
 
109
114
    for index in r:
110
115
        cluster_path = data_path[index]
111
116
        try:
123
128
def import_model_from_db(model_name, local_dir=False):
124
129
    """ import the model with a given name """
125
130
 
 
131
    if os.path.sep in model_name and os.path.exists(os.path.dirname(model_name)):
 
132
        target = os.path.dirname(model_name)
 
133
        model_name = os.path.basename(model_name)
 
134
    else:
 
135
        target = None
126
136
    data =get_model_db()
127
137
    link = None
128
138
    for line in data:
131
141
            link = split[1]
132
142
            break
133
143
    else:
134
 
        logger.debug('no model with that name found online')
 
144
        logger.debug('no model with that name (%s) found online', model_name)
135
145
        return False
136
146
    
137
147
    #get target directory
138
 
    # 1. PYTHONPATH containing UFO
 
148
    # 1. PYTHONPATH containing UFO --only for omattelaer user
139
149
    # 2. models directory
140
 
    target = None 
141
 
    if 'PYTHONPATH' in os.environ and not local_dir:
 
150
    
 
151
    username = ''
 
152
    if not target:
 
153
        try:
 
154
            import pwd
 
155
            username =pwd.getpwuid( os.getuid() )[ 0 ]  
 
156
        except Exception, error:
 
157
            misc.sprint(str(error))
 
158
            username = ''
 
159
    if username in ['omatt', 'mattelaer', 'olivier'] and target is None and \
 
160
                                    'PYTHONPATH' in os.environ and not local_dir:
142
161
        for directory in os.environ['PYTHONPATH'].split(':'):
143
 
            if 'UFO' in os.path.basename(directory) and os.path.exists(directory) and\
144
 
                    misc.glob('*/couplings.py', path=directory):
145
 
                target= directory 
 
162
            #condition only for my setup --ATLAS did not like it
 
163
            if 'UFOMODEL' == os.path.basename(directory) and os.path.exists(directory) and\
 
164
                misc.glob('*/couplings.py', path=directory) and 'matt' in directory:
 
165
                target= directory
 
166
                   
146
167
    if target is None:
147
168
        target = pjoin(MG5DIR, 'models')    
148
169
    try:
1922
1943
                logger.debug('coupling with small value %s: %s treated as zero' %
1923
1944
                             (name, value))
1924
1945
                zero_coupling.append(name)
 
1946
                continue
1925
1947
            elif not strict_zero and abs(value) < 1e-10:
1926
1948
                return self.detect_identical_couplings(strict_zero=True)
1927
1949
 
2216
2238
            else:
2217
2239
                arg = 'width'
2218
2240
            change_name = [p.name for (p,f) in parameters[1:]]
 
2241
            factor_for_name = [f for (p,f)  in parameters[1:]]
2219
2242
            [p.set(arg, new_name) for p in self['particle_dict'].values() 
2220
 
                                                       if p[arg] in change_name]
 
2243
                                                       if p[arg] in change_name and 
 
2244
                                                       factor_for_name[change_name.index(p[arg])]==1]
2221
2245
            
2222
2246
    def remove_interactions(self, zero_couplings):
2223
2247
        """ remove the interactions and particle counterterms