def run(self): config = hps_config() bin_jar = config.hps_java_bin_jar cmd = ['java', '-jar', bin_jar] if self.resource: cmd.append('-r') cmd.extend(["-i%s" % i.path for i in luigi.task.flatten(self.input())]) outputs = luigi.task.flatten(self.output()) if len(outputs) > 1: raise Exception( "Too many outputs for this task (only one output is accepted)." ) if self.batch: cmd.append('-b') if self.detector is not None: cmd.append('-d %s' % self.detector) if self.run_number is not None: cmd.append('-R %d' % self.run_number) if self.nevents is not None: cmd.append('-n %d' % self.nevents) if self.define is not None: for key, value in self.define.iteritems(): cmd.append('-D%s=%s' % (key, value)) cmd.append("-DoutputFile=%s" % os.path.splitext(outputs[0].path)[0]) cmd.append(self.steering) #print("Running JobManager with cmd: %s" % " ".join(cmd)) # FIXME: For some reason passing the list results in a weird error with the run number :( run_process(cmd, use_shell=True)
def run(self): config = hps_config() bin_jar = config.hps_java_bin_jar cmd = [ hps_config().java, self.java_opts, '-cp', bin_jar, 'org.hps.evio.EvioToLcio' ] cmd.append('-d %s' % self.detector) if self.run_number != -1: cmd.append('-R %d' % self.run_number) if self.event_print_interval != -1: cmd.append('-e %d' % self.event_print_interval) cmd.append('-DoutputFile=%s' % self.output_file) if self.nevents != -1: cmd.append('-n %d' % self.nevents) if self.resource: cmd.append('-r') if self.steering is not None: cmd.append('-x %s' % self.steering) if self.headless: cmd.append('-b') if self.write_raw_output: cmd.append('-l %s' % self.lcio_output_file) for i in self.evio_files: cmd.append(i) run_process(cmd, use_shell=True)
def run(self): import hps.util as _util compare_script = '%s/%s' % (os.path.dirname( _util.__file__), 'ComparePlots.py') cmd = "python %s simCompare %s %s %s %s" % (compare_script, self.input( )[0].path, self.input()[1].path, self.label1, self.label2) run_process(cmd)
def run(self): if not os.access(os.getcwd(), os.W_OK): raise Exception("Current dir is not writable: " + os.getcwd()) config = hps_config() slic_env = config.slic_setup_script lcdd_path = config.get_lcdd_path(self.detector) config.create_fieldmap_symlink() run_script_name = self.task_id + '.sh' run_script = open(run_script_name, 'w') run_script.write('#!/bin/bash\n') run_script.write('. %s\n' % slic_env) run_script.write('slic -g %s -l %s -m %s -m %s -o %s -r %d\n' % (lcdd_path, self.physics_list, self.init_macro, self.gen_macro, self.output_file, self.nevents)) run_script.close() os.chmod(run_script.name, stat.S_IEXEC) cmd = './%s' % run_script.name try: run_process(cmd) finally: os.remove(run_script.name)
def run(self): db = DQMPipelineDatabase() try: dqm_files = {} for i in luigi.task.flatten(self.input()): dqm_file = i.path rec = db.find_dqm(dqm_file)[0] run_number = rec[1] if run_number not in dqm_files: dqm_files[run_number] = [] dqm_files[run_number].append(dqm_file) # TODO: Each of these should probably be a separate task by run number for run_number, filelist in dqm_files.iteritems(): cmd = ['hadd'] targetfile = '%s/hps_%06d_dqm.root' % (self.output_dir, run_number) self.output_files.append(targetfile) cmd.append(targetfile) if os.path.exists(targetfile): oldtargetfile = '%s.old' % targetfile shutil.copy(targetfile, oldtargetfile) os.remove(targetfile) cmd.append(oldtargetfile) cmd.append(' '.join(filelist)) run_process(cmd, use_shell=True) for f in filelist: rec = db.find_dqm(f)[0] db.aggregated(rec[0]) db.commit() logging.info("Marked DQM file '%s' as aggregated." % f) finally: db.close() self.ran = True
def run(self): db = DQMPipelineDatabase() try: cmd = ['. %s/bin/thisroot.sh && hadd' % dqm_config().root_dir] cmd.append(self.targetfile) if os.path.exists(self.targetfile): logging.debug("Replacing old aggregated file '%s'." % self.targetfile) oldtargetfile = '%s.old' % self.targetfile shutil.copy(self.targetfile, oldtargetfile) os.remove(self.targetfile) cmd.append(oldtargetfile) cmd.append(' '.join(self.dqm_files)) run_process(cmd, use_shell=True) logging.info("Created aggregated DQM file at '%s' for run %d." % (self.targetfile, self.run_number)) for f in self.dqm_files: rec = db.find_dqm(f)[0] db.aggregate(rec[0]) db.commit() logging.info("DQM file '%s' is aggregated." % f) finally: db.close()
def run(self): config = hps_config() bin_jar = config.hps_java_bin_jar cmd = [ 'java', '-cp', bin_jar, 'org.hps.util.FilterMCBunches', '-e', str(self.spacing), '-E', str(self.ecal_hit_ecut), '-w', str(self.nevents) ] if self.enable_ecal_energy_filter: cmd.append('-d') for i in luigi.task.flatten(self.input()): cmd.append(i.path) for o in luigi.task.flatten(self.output()): cmd.append(o.path) #print("Running FilterMCBunches: " + " ".join(cmd)) run_process(cmd)
def run(self): if not os.access(os.getcwd(), os.W_OK): raise Exception("Current dir is not writable: " + os.getcwd()) config = hps_config() sim_env = config.sim_setup_script config.create_fieldmap_symlink() lcdd_path = config.get_lcdd_path(self.detector) run_macro_name = self.task_id + '.mac' run_macro = open(run_macro_name, 'w') run_macro.write('/lcdd/url %s\n' % lcdd_path) run_macro.write('/hps/physics/list %s\n' % self.physics_list) run_macro.write('/run/initialize\n') run_macro.write('/hps/plugins/load EventPrintPlugin\n') run_macro.write('/hps/plugins/EventPrintPlugin/modulus 10\n') run_macro.write( '/random/setSeeds 1234 56789\n') # FIXME: hard-coded random init run_macro.write('/hps/lcio/file %s\n' % self.output_file) run_macro.write('/control/execute %s\n' % self.gen_macro) run_macro.write('/run/beamOn %d\n' % self.nevents) run_macro.close() run_script_name = self.task_id + '.sh' run_script = open(run_script_name, 'w') run_script.write('#!/bin/bash\n') run_script.write('. %s\n' % sim_env) run_script.write('hps-sim %s\n' % run_macro.name) run_script.close() os.chmod(run_script.name, stat.S_IEXEC) cmd = './%s' % run_script.name try: run_process(cmd) finally: os.remove(run_script.name) os.remove(run_macro.name)
def run(self): if not os.access(os.getcwd(), os.W_OK): raise Exception("Current dir is not writable: " + os.getcwd()) config = hps_config() slic_env = config.slic_setup_script lcdd_path = config.get_lcdd_path(self.detector) config.create_fieldmap_symlink() #input_files = luigi.task.flatten(self.input()) #if len(input_files) == 0: # raise Exception("No stdhep input files") init_macro = open('slic_init.mac', 'w') init_macro.write('/lcio/fileExists append') init_macro.close() run_script_name = self.task_id + '.sh' run_script = open(run_script_name, 'w') run_script.write('#!/bin/bash\n') run_script.write('. %s\n' % slic_env) for stdhep_file in self.stdhep_files: run_script.write('slic -g %s -l %s -m %s -i %s -o %s -r %d\n' % (lcdd_path, self.physics_list, init_macro.name, stdhep_file, self.output_file, self.nevents)) run_script.close() os.chmod(run_script.name, stat.S_IEXEC) cmd = './%s' % run_script.name try: run_process(cmd) finally: os.remove(run_script.name) os.remove(init_macro.name) config.remove_fieldmap_symlink()
def run(self): lcio_jar = hps_config().lcio_jar cmd = ['java', '-jar', lcio_jar, self.lcio_cmd] for i in luigi.task.flatten(self.input()): cmd.append('-f %s' % i.path) run_process(cmd)