~maddevelopers/mg5amcnlo/2.6.6_bug_1813292

« back to all changes in this revision

Viewing changes to madgraph/interface/madevent_interface.py

  • Committer: olivier-mattelaer
  • Date: 2017-05-26 07:48:55 UTC
  • mfrom: (271.1.33 2.5.5)
  • Revision ID: olivier-mattelaer-20170526074855-r463wfxlom110fiu
passĀ theĀ 2.5.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
1066
1066
        input_file = pjoin(self.me_dir,'Events',self.run_name, 'unweighted_events.lhe')
1067
1067
        if not os.path.exists('%s.gz'%input_file):
1068
1068
            if os.path.exists(input_file):
1069
 
                misc.gzip(input_file, keep=True, stdout='%s.gz'%input_file)
 
1069
                misc.gzip(input_file, stdout='%s.gz'%input_file)
1070
1070
            else:
1071
1071
                raise self.InvalidCmd('No event file corresponding to %s run. '
1072
1072
                                                                % self.run_name)
2023
2023
        args = self.split_arg(line)
2024
2024
        # Check argument's validity
2025
2025
        mode = self.check_generate_events(args)
2026
 
        self.ask_run_configuration(mode, args)
 
2026
        switch_mode = self.ask_run_configuration(mode, args)
2027
2027
        if not args:
2028
2028
            # No run name assigned -> assigned one automaticaly 
2029
2029
            self.set_run_name(self.find_available_run_name(self.me_dir), None, 'parton')
2120
2120
                if self.run_card['time_of_flight']>=0:
2121
2121
                    self.exec_cmd("add_time_of_flight --threshold=%s" % self.run_card['time_of_flight'] ,postcmd=False)
2122
2122
 
 
2123
                if switch_mode['analysis'] == 'EXROOTANALYSIS':
 
2124
                    input = pjoin(self.me_dir, 'Events', self.run_name,'unweighted_events.lhe.gz')
 
2125
                    output = pjoin(self.me_dir, 'Events', self.run_name, 'unweighted_events.root')
 
2126
                    self.create_root_file(input , output)
 
2127
 
2123
2128
                self.exec_cmd('madanalysis5_parton --no_default', postcmd=False, printcmd=False)
2124
2129
                # shower launches pgs/delphes if needed    
2125
2130
                self.exec_cmd('shower --no_default', postcmd=False, printcmd=False)
3201
3206
                                     sum_axsec) 
3202
3207
                        partials +=1
3203
3208
            
 
3209
            if not hasattr(self,'proc_characteristic'):
 
3210
                self.proc_characteristic = self.get_characteristics()
 
3211
                
3204
3212
            nb_event = AllEvent.unweight(pjoin(self.me_dir, "Events", self.run_name, "unweighted_events.lhe.gz"),
3205
3213
                              get_wgt, trunc_error=1e-2, event_target=self.run_card['nevents'],
3206
 
                              log_level=logging.DEBUG, normalization=self.run_card['event_norm'])
 
3214
                              log_level=logging.DEBUG, normalization=self.run_card['event_norm'],
 
3215
                              proc_charac=self.proc_characteristic)
3207
3216
            
3208
3217
            if partials:
3209
3218
                for i in range(partials):
3220
3229
        
3221
3230
        
3222
3231
        self.to_store.append('event')
3223
 
        eradir = self.options['exrootanalysis_path']
3224
 
        madir = self.options['madanalysis_path']
3225
 
        td = self.options['td_path']
3226
 
        if eradir and misc.is_executable(pjoin(eradir,'ExRootLHEFConverter'))  and\
3227
 
           os.path.exists(pjoin(self.me_dir, 'Events', 'unweighted_events.lhe')):
3228
 
                if not os.path.exists(pjoin(self.me_dir, 'Events', self.run_name)):
3229
 
                    os.mkdir(pjoin(self.me_dir, 'Events', self.run_name))
3230
 
                self.create_root_file(output='%s/unweighted_events.root' % \
3231
 
                                                                  self.run_name)
3232
3232
    
3233
3233
    ############################################################################ 
3234
3234
    def correct_bias(self):
5528
5528
        self.update_status('Creating root files', level='parton')
5529
5529
 
5530
5530
        eradir = self.options['exrootanalysis_path']
 
5531
        totar = False
 
5532
        if input.endswith('.gz'):
 
5533
            misc.gunzip(input, keep=True)
 
5534
            totar = True
 
5535
            input = input[:-3]
 
5536
            
5531
5537
        try:
5532
5538
            misc.call(['%s/ExRootLHEFConverter' % eradir, 
5533
5539
                             input, output],
5535
5541
        except Exception:
5536
5542
            logger.warning('fail to produce Root output [problem with ExRootAnalysis]')
5537
5543
    
 
5544
        if totar:
 
5545
            if os.path.exists('%s.gz' % input):
 
5546
                try:
 
5547
                    os.remove(input)
 
5548
                except:
 
5549
                    pass
 
5550
            else:
 
5551
                misc.gzip(input,keep=False)
 
5552
            
 
5553
    
5538
5554
    def run_syscalc(self, mode='parton', event_path=None, output=None):
5539
5555
        """create the syscalc output""" 
5540
5556
 
5746
5762
            if hadron_card_present or parton_card_present:
5747
5763
                switch['analysis'] = 'MADANALYSIS_5'
5748
5764
 
 
5765
        # ExRootanalysis
 
5766
        eradir = self.options['exrootanalysis_path']
 
5767
        if eradir and misc.is_executable(pjoin(eradir,'ExRootLHEFConverter')):
 
5768
            valid_options['analysis'].insert(0,'EXROOTANALYSIS')
 
5769
            if switch['analysis'] in ['OFF', void]:
 
5770
                switch['analysis'] = 'EXROOTANALYSIS'
 
5771
 
 
5772
                 
 
5773
 
5749
5774
        if len(valid_options['analysis'])>1:                
5750
5775
            available_mode.append('3')
5751
5776
            if switch['analysis'] == void:
5817
5842
                return red%switch_value
5818
5843
            elif switch_value in ['ON','MADANALYSIS_4','MADANALYSIS_5',
5819
5844
                                  'PYTHIA8','PYTHIA6','PGS','DELPHES-ATLAS',
5820
 
                                  'DELPHES-CMS','DELPHES']:
 
5845
                                  'DELPHES-CMS','DELPHES', 'EXROOTANALYSIS']:
5821
5846
                return green%switch_value
5822
5847
            else:
5823
5848
                return bold%switch_value                
5970
5995
        
5971
5996
        if self.force:
5972
5997
            self.check_param_card(pjoin(self.me_dir,'Cards','param_card.dat' ))
5973
 
            return
 
5998
            return switch
5974
5999
 
5975
6000
        if answer == 'auto':
5976
6001
            self.ask_edit_cards(cards, plot=False, mode='auto')
5977
6002
        else:
5978
6003
            self.ask_edit_cards(cards, plot=False)
5979
 
        return
 
6004
        return switch
5980
6005
    
5981
6006
    ############################################################################
5982
6007
    def ask_pythia_run_configuration(self, mode=None, pythia_version=6):