~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to madgraph/various/banner.py

  • Committer: olivier-mattelaer
  • Date: 2019-09-26 11:09:58 UTC
  • mfrom: (282.1.19 2.6.7)
  • mto: (283.1.18 2.7.0)
  • mto: This revision was merged to the branch mainline in revision 284.
  • Revision ID: olivier-mattelaer-20190926110958-38wrjh8hemq9zibw
merge with 2.6.7 + change L meaning for spin1 

Show diffs side-by-side

added added

removed removed

Lines of Context:
686
686
        try:    
687
687
            _tag = results_object[run].tags[-1] 
688
688
        except Exception,error:
689
 
            return Banner()      
 
689
            if os.path.exists( pjoin(results_object.path,'Events','%s_banner.txt' % (run))):
 
690
                tag = None
 
691
            else:
 
692
                return Banner()      
690
693
    else:
691
694
        _tag = tag
692
 
                                          
 
695
    
693
696
    path = results_object.path
694
 
    banner_path = pjoin(path,'Events',run,'%s_%s_banner.txt' % (run, tag))
695
 
    
 
697
    if tag:               
 
698
        banner_path = pjoin(path,'Events',run,'%s_%s_banner.txt' % (run, tag))
 
699
    else:
 
700
        banner_path = pjoin(results_object.path,'Events','%s_banner.txt' % (run))
 
701
      
696
702
    if not os.path.exists(banner_path):
697
703
        if level != "parton" and tag != _tag:
698
704
            return recover_banner(results_object, level, _run, results_object[_run].tags[0])
712
718
 
713
719
        # security if the banner was remove (or program canceled before created it)
714
720
        return Banner()  
 
721
    
715
722
    banner = Banner(banner_path)
716
723
    
717
724
    
1207
1214
            if value in allowed:
1208
1215
                valid=True     
1209
1216
            elif isinstance(value, str):
1210
 
                value = value.lower()
1211
 
                allowed = [v.lower() for v in allowed]
 
1217
                value = value.lower().strip()
 
1218
                allowed = [str(v).lower() for v in allowed]
1212
1219
                if value in allowed:
1213
1220
                    i = allowed.index(value)
1214
1221
                    value = self.allowed_value[lower_name][i]
1343
1350
                elif value.endswith(('k', 'M')) and value[:-1].isdigit():
1344
1351
                    convert = {'k':1000, 'M':1000000}
1345
1352
                    value =int(value[:-1]) * convert[value[-1]] 
1346
 
                else:
1347
 
                    try:
1348
 
                        value = float(value.replace('d','e'))
1349
 
                    except ValueError:
1350
 
                        raise InvalidCmd, "%s can not be mapped to an integer" % value                    
1351
 
                    try:
1352
 
                        new_value = int(value)
1353
 
                    except ValueError:
1354
 
                        raise InvalidCmd, "%s can not be mapped to an integer" % value
1355
 
                    else:
1356
 
                        if value == new_value:
1357
 
                            value = new_value
1358
 
                        else:
1359
 
                            raise InvalidCmd, "incorect input: %s need an integer for %s" % (value,name)
1360
 
            elif targettype == float:
1361
 
                value = value.replace('d','e') # pass from Fortran formatting
1362
 
                try:
1363
 
                    value = float(value)
1364
 
                except ValueError:
 
1353
                elif '/' in value or '*' in value:               
1365
1354
                    try:
1366
1355
                        split = re.split('(\*|/)',value)
1367
1356
                        v = float(split[0])
1372
1361
                                v /=  float(split[2*i+2])
1373
1362
                    except:
1374
1363
                        v=0
1375
 
                        raise InvalidCmd, "%s can not be mapped to a float" % value
 
1364
                        raise InvalidCmd, "%s can not be mapped to an integer" % value
1376
1365
                    finally:
1377
 
                        value = v
 
1366
                        value = int(v)
 
1367
                        if value != v:
 
1368
                            raise InvalidCmd, "%s can not be mapped to an integer" % v
 
1369
                else:
 
1370
                    try:
 
1371
                        value = float(value.replace('d','e'))
 
1372
                    except ValueError:
 
1373
                        raise InvalidCmd, "%s can not be mapped to an integer" % value                    
 
1374
                    try:
 
1375
                        new_value = int(value)
 
1376
                    except ValueError:
 
1377
                        raise InvalidCmd, "%s can not be mapped to an integer" % value
 
1378
                    else:
 
1379
                        if value == new_value:
 
1380
                            value = new_value
 
1381
                        else:
 
1382
                            raise InvalidCmd, "incorect input: %s need an integer for %s" % (value,name)
 
1383
                     
 
1384
            elif targettype == float:
 
1385
                if value.endswith(('k', 'M')) and value[:-1].isdigit():
 
1386
                    convert = {'k':1000, 'M':1000000}
 
1387
                    value = 1.*int(value[:-1]) * convert[value[-1]] 
 
1388
                else:
 
1389
                    value = value.replace('d','e') # pass from Fortran formatting
 
1390
                    try:
 
1391
                        value = float(value)
 
1392
                    except ValueError:
 
1393
                        try:
 
1394
                            split = re.split('(\*|/)',value)
 
1395
                            v = float(split[0])
 
1396
                            for i in range((len(split)//2)):
 
1397
                                if split[2*i+1] == '*':
 
1398
                                    v *=  float(split[2*i+2])
 
1399
                                else:
 
1400
                                    v /=  float(split[2*i+2])
 
1401
                        except:
 
1402
                            v=0
 
1403
                            raise InvalidCmd, "%s can not be mapped to a float" % value
 
1404
                        finally:
 
1405
                            value = v
1378
1406
            else:
1379
1407
                raise InvalidCmd, "type %s is not handle by the card" % targettype
1380
1408
            
1434
1462
        self.add_param('colored_pdgs', [1,2,3,4,5])
1435
1463
        self.add_param('complex_mass_scheme', False)
1436
1464
        self.add_param('pdg_initial1', [0])
1437
 
        self.add_param('pdg_initial2', [0])        
 
1465
        self.add_param('pdg_initial2', [0])
 
1466
        self.add_param('limitations', [], typelist=str)        
1438
1467
 
1439
1468
    def read(self, finput):
1440
1469
        """Read the input file, this can be a path to a file, 
2367
2396
                comment = line[len(nline):]
2368
2397
                nline = nline.split('=')
2369
2398
                if python_template and nline[0].startswith('$'):
2370
 
                    block_name = nline[0][1:]
 
2399
                    block_name = nline[0][1:].strip()
2371
2400
                    this_group = [b for b in self.blocks if b.name == block_name]
2372
2401
                    if not this_group:
2373
2402
                        logger.debug("block %s not defined", block_name)
3251
3280
            else:
3252
3281
                continue
3253
3282
            break
 
3283
 
 
3284
        
3254
3285
        if no_systematics:
3255
3286
            self['use_syst'] = False
3256
3287
            self['systematics_program'] = 'none'
3272
3303
            else:
3273
3304
                continue
3274
3305
            break
 
3306
 
 
3307
        if 'MLM' in proc_characteristic['limitations']:
 
3308
            if self['dynamical_scale_choice'] ==  -1:
 
3309
                self['dynamical_scale_choice'] = 3
 
3310
            if self['ickkw']  == 1:
 
3311
                logger.critical("MLM matching/merging not compatible with the model! You need to use another method to remove the double counting!")
 
3312
            self['ickkw'] = 0
 
3313
            
3275
3314
            
3276
3315
    def write(self, output_file, template=None, python_template=False,
3277
3316
              **opt):