def do_launch(self, line): """end of the configuration launched the code""" if self.options['ms_dir'] and os.path.exists( pjoin(self.options['ms_dir'], 'madspin.pkl')): return self.run_from_pickle() args = self.split_arg(line) self.check_launch(args) for part in self.list_branches.keys(): if part in self.mg5cmd._multiparticles: if any(pid in self.final_state for pid in self.mg5cmd._multiparticles[part]): break pid = self.mg5cmd._curr_model.get('name2pdg')[part] if pid in self.final_state: break else: logger.info("Nothing to decay ...") return model_line = self.banner.get('proc_card', 'full_model_line') if not self.seed: import random self.seed = random.randint(0, int(30081 * 30081)) self.do_set('seed %s' % self.seed) logger.info('Will use seed %s' % self.seed) self.history.insert(0, 'set seed %s' % self.seed) if self.seed > 30081 * 30081: # can't use too big random number msg = 'Random seed too large ' + str(self.seed) + ' > 30081*30081' raise Exception, msg self.options['seed'] = self.seed text = '%s\n' % '\n'.join([line for line in self.history if line]) self.banner.add_text('madspin', text) self.update_status('generating Madspin matrix element') generate_all = madspin.decay_all_events(self, self.banner, self.events_file, self.options) self.update_status('running MadSpin') generate_all.run() self.branching_ratio = generate_all.branching_ratio evt_path = self.events_file.name try: self.events_file.close() except: pass misc.call(['gzip -f %s' % evt_path], shell=True) decayed_evt_file = evt_path.replace('.lhe', '_decayed.lhe') shutil.move(pjoin(self.options['curr_dir'], 'decayed_events.lhe'), decayed_evt_file) misc.call(['gzip -f %s' % decayed_evt_file], shell=True) if not self.mother: logger.info("Decayed events have been written in %s.gz" % decayed_evt_file) # Now arxiv the shower card used if RunMaterial is present ms_card_path = pjoin(self.options['curr_dir'], 'Cards', 'madspin_card.dat') run_dir = os.path.realpath(os.path.dirname(decayed_evt_file)) if os.path.exists(ms_card_path): if os.path.exists(pjoin(run_dir, 'RunMaterial.tar.gz')): misc.call(['tar', '-xzpf', 'RunMaterial.tar.gz'], cwd=run_dir) base_path = pjoin(run_dir, 'RunMaterial') else: base_path = pjoin(run_dir) evt_name = os.path.basename(decayed_evt_file).replace('.lhe', '') ms_card_to_copy = pjoin(base_path, 'madspin_card_for_%s.dat' % evt_name) count = 0 while os.path.exists(ms_card_to_copy): count += 1 ms_card_to_copy = pjoin(base_path,'madspin_card_for_%s_%d.dat'%\ (evt_name,count)) files.cp(str(ms_card_path), str(ms_card_to_copy)) if os.path.exists(pjoin(run_dir, 'RunMaterial.tar.gz')): misc.call( ['tar', '-czpf', 'RunMaterial.tar.gz', 'RunMaterial'], cwd=run_dir) shutil.rmtree(pjoin(run_dir, 'RunMaterial'))
def do_launch(self, line): """end of the configuration launched the code""" if self.options["spinmode"] in ["none"]: return self.run_bridge(line) elif self.options["spinmode"] == "bridge": raise Exception, "Bridge mode not yet available due to lack of validation." if self.options['ms_dir'] and os.path.exists(pjoin(self.options['ms_dir'], 'madspin.pkl')): return self.run_from_pickle() args = self.split_arg(line) self.check_launch(args) for part in self.list_branches.keys(): if part in self.mg5cmd._multiparticles: if any(pid in self.final_state for pid in self.mg5cmd._multiparticles[part]): break pid = self.mg5cmd._curr_model.get('name2pdg')[part] if pid in self.final_state: break # else: # logger.info("Nothing to decay ...") # return model_line = self.banner.get('proc_card', 'full_model_line') if not self.seed: self.seed = random.randint(0, int(30081*30081)) self.do_set('seed %s' % self.seed) logger.info('Will use seed %s' % self.seed) self.history.insert(0, 'set seed %s' % self.seed) if self.seed > 30081*30081: # can't use too big random number msg = 'Random seed too large ' + str(self.seed) + ' > 30081*30081' raise Exception, msg self.options['seed'] = self.seed text = '%s\n' % '\n'.join([ line for line in self.history if line]) self.banner.add_text('madspin' , text) self.update_status('generating Madspin matrix element') generate_all = madspin.decay_all_events(self, self.banner, self.events_file, self.options) self.update_status('running MadSpin') generate_all.run() self.branching_ratio = generate_all.branching_ratio try: self.err_branching_ratio = generate_all.err_branching_ratio except Exception: self.err_branching_ratio = 0 evt_path = self.events_file.name try: self.events_file.close() except: pass misc.gzip(evt_path) decayed_evt_file=evt_path.replace('.lhe', '_decayed.lhe') misc.gzip(pjoin(self.options['curr_dir'],'decayed_events.lhe'), stdout=decayed_evt_file) if not self.mother: logger.info("Decayed events have been written in %s.gz" % decayed_evt_file) # Now arxiv the shower card used if RunMaterial is present ms_card_path = pjoin(self.options['curr_dir'],'Cards','madspin_card.dat') run_dir = os.path.realpath(os.path.dirname(decayed_evt_file)) if os.path.exists(ms_card_path): if os.path.exists(pjoin(run_dir,'RunMaterial.tar.gz')): misc.call(['tar','-xzpf','RunMaterial.tar.gz'], cwd=run_dir) base_path = pjoin(run_dir,'RunMaterial') else: base_path = pjoin(run_dir) evt_name = os.path.basename(decayed_evt_file).replace('.lhe', '') ms_card_to_copy = pjoin(base_path,'madspin_card_for_%s.dat'%evt_name) count = 0 while os.path.exists(ms_card_to_copy): count += 1 ms_card_to_copy = pjoin(base_path,'madspin_card_for_%s_%d.dat'%\ (evt_name,count)) files.cp(str(ms_card_path),str(ms_card_to_copy)) if os.path.exists(pjoin(run_dir,'RunMaterial.tar.gz')): misc.call(['tar','-czpf','RunMaterial.tar.gz','RunMaterial'], cwd=run_dir) shutil.rmtree(pjoin(run_dir,'RunMaterial'))