~maddevelopers/mg5amcnlo/2.6.3_rwgt

« back to all changes in this revision

Viewing changes to madgraph/interface/amcatnlo_run_interface.py

  • Committer: olivier-mattelaer
  • Date: 2018-04-29 08:10:16 UTC
  • mfrom: (275.1.80 2.6.2)
  • Revision ID: olivier-mattelaer-20180429081016-9nmfvn1er0zjb23o
pass to 2.6.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1301
1301
#
1302
1302
#   MadAnalysis5
1303
1303
#    
1304
 
    get_allowed_madanalysis = get_allowed_madspin
 
1304
    def get_allowed_madanalysis(self):
 
1305
        
 
1306
        if hasattr(self, 'allowed_madanalysis'):
 
1307
            return self.allowed_madanalysis
 
1308
        
 
1309
        self.allowed_madanalysis = []
 
1310
        
 
1311
        
 
1312
        if 'MA5' not in self.available_module:
 
1313
            return self.allowed_madanalysis
 
1314
        
 
1315
        if self.proc_characteristics['ninitial'] == 1:
 
1316
            self.available_module.remove('MA5')
 
1317
            self.allowed_madanalysis = ['OFF']
 
1318
            return self.allowed_madanalysis
 
1319
        else:
 
1320
            self.allowed_madanalysis = ['OFF', 'ON']
 
1321
            return  self.allowed_madanalysis
1305
1322
    
1306
1323
    def set_default_madanalysis(self):
1307
1324
        """initialise the switch for reweight"""
1683
1700
        self.store_result()
1684
1701
        #check if the param_card defines a scan.
1685
1702
        if self.param_card_iterator:
 
1703
            cpath = pjoin(self.me_dir,'Cards','param_card.dat')
1686
1704
            param_card_iterator = self.param_card_iterator
1687
1705
            self.param_card_iterator = [] #avoid to next generate go trough here
1688
1706
            param_card_iterator.store_entry(self.run_name, self.results.current['cross'],
1689
 
                                            error=self.results.current['error'])
 
1707
                                            error=self.results.current['error'],
 
1708
                                            param_card_path=cpath)
1690
1709
            orig_name = self.run_name
1691
1710
            #go trough the scal
1692
1711
            with misc.TMP_variable(self, 'allow_notification_center', False):
1693
1712
                for i,card in enumerate(param_card_iterator):
1694
 
                    card.write(pjoin(self.me_dir,'Cards','param_card.dat'))
1695
 
                    self.check_param_card(pjoin(self.me_dir,'Cards','param_card.dat'), dependent=True)
 
1713
                    card.write(cpath)
 
1714
                    self.check_param_card(cpath, dependent=True)
1696
1715
                    if not options['force']:
1697
1716
                        options['force'] = True
1698
1717
                    if options['run_name']:
1704
1723
                    self.do_launch("", options=options, argss=argss, switch=switch)
1705
1724
                    #self.exec_cmd("launch -f ",precmd=True, postcmd=True,errorhandling=False)
1706
1725
                    param_card_iterator.store_entry(self.run_name, self.results.current['cross'],
1707
 
                                                    error=self.results.current['error'])
 
1726
                                                    error=self.results.current['error'],
 
1727
                                                    param_card_path=cpath)
1708
1728
            #restore original param_card
1709
1729
            param_card_iterator.write(pjoin(self.me_dir,'Cards','param_card.dat'))
1710
1730
            name = misc.get_scan_name(orig_name, self.run_name)
1711
1731
            path = pjoin(self.me_dir, 'Events','scan_%s.txt' % name)
1712
 
            logger.info("write all cross-section results in %s" % path, '$MG:color:BLACK')
 
1732
            logger.info("write all cross-section results in %s" % path, '$MG:BOLD')
1713
1733
            param_card_iterator.write_summary(path)
1714
1734
            
1715
1735
        if self.allow_notification_center:    
2241
2261
        files_MC_integer=[]
2242
2262
        location=None
2243
2263
        for job in job_group:
2244
 
            files_mint_grids.append(open(pjoin(job['dirname'],'mint_grids'),'r+'))
2245
 
            files_MC_integer.append(open(pjoin(job['dirname'],'grid.MC_integer'),'r+'))
 
2264
            files_mint_grids.append(pjoin(job['dirname'],'mint_grids'))
 
2265
            files_MC_integer.append(pjoin(job['dirname'],'grid.MC_integer'))
2246
2266
            if not location:
2247
2267
                location=pjoin(job['dirname'].rsplit('_',1)[0])
2248
2268
            else:
2253
2273
        # MC_integer grids), but sum the cross section info. The
2254
2274
        # latter is only the only line that contains integers.
2255
2275
        for j,fs in enumerate([files_mint_grids,files_MC_integer]):
2256
 
            linesoffiles=[f.readlines() for f in fs]
 
2276
            linesoffiles=[]
 
2277
            for f in fs:
 
2278
                with open(f,'r+') as fi:
 
2279
                    linesoffiles.append(fi.readlines())
2257
2280
            to_write=[]
2258
2281
            for rowgrp in zip(*linesoffiles):
2259
2282
                try:
2287
2310
                    floatgrps = zip(*floatsbyfile)
2288
2311
                    averages = [sum(floatgrp)/len(floatgrp) for floatgrp in floatgrps]
2289
2312
                    to_write.append(" ".join(str(a) for a in averages) + "\n")
2290
 
            # close the files
2291
 
            for f in fs:
2292
 
                f.close
2293
2313
            # write the data over the master location
2294
2314
            if j==0:
2295
2315
                with open(pjoin(location,'mint_grids'),'w') as f:
2602
2622
            logger.info('The results of this run and the HwU and GnuPlot files with the plots' + \
2603
2623
                        ' have been saved in %s' % pjoin(self.me_dir, 'Events', self.run_name))
2604
2624
        elif self.analyse_card['fo_analysis_format'].lower() == 'root':
2605
 
            misc.call(['./combine_root.sh'] + folder_name, \
 
2625
            rootfiles = []
 
2626
            for job in jobs:
 
2627
                if job['dirname'].endswith('.root'):
 
2628
                    rootfiles.append(job['dirname'])
 
2629
                else:
 
2630
                    rootfiles.append(pjoin(job['dirname'],'MADatNLO.root'))
 
2631
            misc.call(['./combine_root.sh'] + folder_name + rootfiles, \
2606
2632
                      stdout=devnull, 
2607
2633
                      cwd=pjoin(self.me_dir, 'SubProcesses'))
2608
2634
            files.cp(pjoin(self.me_dir, 'SubProcesses', 'MADatNLO.root'),
5161
5187
        """read and parse the test_ME/MC.log file"""
5162
5188
        content = open(log).read()
5163
5189
        if 'FAILED' in content:
5164
 
            logger.info('Output of the failing test:\n'+content[:-1],'$MG:color:BLACK')
 
5190
            logger.info('Output of the failing test:\n'+content[:-1],'$MG:BOLD')
5165
5191
            raise aMCatNLOError('Some tests failed, run cannot continue.\n' + \
5166
5192
                'Please check that widths of final state particles (e.g. top) have been' + \
5167
5193
                ' set to 0 in the param_card.dat.')
5284
5310
            else:
5285
5311
                logger.info("""Your Parton-shower choice is not available for running.
5286
5312
    The events will be generated for the  associated Parton-Shower.
5287
 
    Remember that NLO events without showering are NOT physical.""", '$MG:color:BLACK')           
 
5313
    Remember that NLO events without showering are NOT physical.""", '$MG:BOLD')           
5288
5314
 
5289
5315
        
5290
5316
        # specify the cards which are needed for this run.