~madteam/mg5amcnlo/series2.0

« back to all changes in this revision

Viewing changes to madgraph/various/lhe_parser.py

mwrge with 2.7.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
54
54
logger = logging.getLogger("madgraph.lhe_parser")
55
55
 
56
56
if six.PY3:
57
 
    unicode = str
 
57
    six.text_type = str
58
58
 
59
59
class Particle(object):
60
60
    """ """
451
451
                return event.wgt
452
452
            get_wgt  = weight
453
453
            unwgt_name = "central weight"
454
 
        elif isinstance(get_wgt, (str,unicode)):
 
454
        elif isinstance(get_wgt, (str,six.text_type)):
455
455
            unwgt_name =get_wgt 
456
456
            def get_wgt(event):
457
457
                event.parse_reweight()
1183
1183
        """
1184
1184
 
1185
1185
 
1186
 
        if isinstance(get_wgt, (str,unicode)):
 
1186
        if isinstance(get_wgt, (str,six.text_type)):
1187
1187
            unwgt_name =get_wgt 
1188
1188
            def get_wgt_multi(event):
1189
1189
                event.parse_reweight()
1227
1227
        """ """
1228
1228
        
1229
1229
        try:
1230
 
            str_type = (str,unicode)
 
1230
            str_type = (str,six.text_type)
1231
1231
        except NameError:
1232
1232
            str_type = (str)
1233
1233
        
1535
1535
        if not hasattr(Event, 'loweight_pattern'):
1536
1536
            Event.loweight_pattern = re.compile('''<rscale>\s*(?P<nqcd>\d+)\s+(?P<ren_scale>[\d.e+-]+)\s*</rscale>\s*\n\s*
1537
1537
                                    <asrwt>\s*(?P<asrwt>[\s\d.+-e]+)\s*</asrwt>\s*\n\s*
1538
 
                                    <pdfrwt\s+beam=["']?1["']?\>\s*(?P<beam1>[\s\d.e+-]*)\s*</pdfrwt>\s*\n\s*
1539
 
                                    <pdfrwt\s+beam=["']?2["']?\>\s*(?P<beam2>[\s\d.e+-]*)\s*</pdfrwt>\s*\n\s*
 
1538
                                    <pdfrwt\s+beam=["']?(?P<idb1>1|2)["']?\>\s*(?P<beam1>[\s\d.e+-]*)\s*</pdfrwt>\s*\n\s*
 
1539
                                    <pdfrwt\s+beam=["']?(?P<idb2>1|2)["']?\>\s*(?P<beam2>[\s\d.e+-]*)\s*</pdfrwt>\s*\n\s*
1540
1540
                                    <totfact>\s*(?P<totfact>[\d.e+-]*)\s*</totfact>
1541
1541
            ''',re.X+re.I+re.M)
1542
1542
        
1554
1554
            self.loweight['asrwt'] =[float(x) for x in info.group('asrwt').split()[1:]]
1555
1555
            self.loweight['tot_fact'] = float(info.group('totfact'))
1556
1556
            
1557
 
            args = info.group('beam1').split()
 
1557
            if info.group('idb1') == info.group('idb2'):
 
1558
                raise Exception('%s not parsed'% text)
 
1559
            
 
1560
            if info.group('idb1') =="1":
 
1561
                args = info.group('beam1').split()
 
1562
            else:
 
1563
                args = info.group('beam2').split()
1558
1564
            npdf = int(args[0])
1559
1565
            self.loweight['n_pdfrw1'] = npdf
1560
1566
            self.loweight['pdf_pdg_code1'] = [int(i) for i in args[1:1+npdf]]
1561
1567
            self.loweight['pdf_x1'] = [float(i) for i in args[1+npdf:1+2*npdf]]
1562
1568
            self.loweight['pdf_q1'] = [float(i) for i in args[1+2*npdf:1+3*npdf]]
1563
 
            args = info.group('beam2').split()
 
1569
            if info.group('idb2') =="2":
 
1570
                args = info.group('beam2').split()
 
1571
            else:
 
1572
                args = info.group('beam1').split()
1564
1573
            npdf = int(args[0])
1565
1574
            self.loweight['n_pdfrw2'] = npdf
1566
1575
            self.loweight['pdf_pdg_code2'] = [int(i) for i in args[1:1+npdf]]
2288
2297
                    continue
2289
2298
                replace = {}
2290
2299
                replace['values'] = self.syscalc_data[k]
2291
 
                if isinstance(k, (str, unicode)):
 
2300
                if isinstance(k, (str, six.text_type)):
2292
2301
                    replace['key'] = k
2293
2302
                    replace['opts'] = ''
2294
2303
                else:
2440
2449
            px = obj[1]
2441
2450
            py = obj[2] 
2442
2451
            pz = obj[3]
2443
 
        elif  isinstance(obj, (str, unicode)):
 
2452
        elif  isinstance(obj, (str, six.text_type)):
2444
2453
            obj = [float(i) for i in obj.split()]
2445
2454
            assert len(obj) ==4
2446
2455
            E = obj[0]
2647
2656
        """ """
2648
2657
 
2649
2658
        self.real_type = real_type
2650
 
        if isinstance(input, (str, unicode)):
 
2659
        if isinstance(input, (str, six.text_type)):
2651
2660
            self.parse(input)
2652
2661
        
2653
2662
    def __str__(self, mode='display'):
3009
3018
        self.modified = False #set on True if we decide to change internal infor
3010
3019
                              # that need to be written in the event file.
3011
3020
                              #need to be set manually when this is the case
3012
 
        if isinstance(input, (str,unicode)):
 
3021
        if isinstance(input, (str,six.text_type)):
3013
3022
            self.parse(input)
3014
3023
        
3015
3024