Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
    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)
Ejemplo n.º 6
0
    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()
Ejemplo n.º 7
0
import luigi

from hps.batch.config import hps as hps_config
hps_config().setup()

from hps.batch.tasks import FileListTask
from hps.batch.jobs.pulser_plots import PulserPlotsProcessor
from hps.lcio.proc import EventManager


class PulserAnalTask(luigi.Task):

    plot_file = luigi.Parameter(default='pulserPlots.root')
    files = luigi.ListParameter(default=['hps_008094.0_pulser_4.2.slcio'])

    def run(self):
        processors = [PulserPlotsProcessor(plot_file_name=self.plot_file)]
        #files = [f.path for f in luigi.task.flatten(self.input())]
        files = [f for f in luigi.task.flatten(self.files)]
        mgr = EventManager(processors, files)
        mgr.process()

    #def requires(self):
    #    return FileListTask(files=['hps_008094.0_pulser_4.2.slcio'])

    def output(self):
        return luigi.LocalTarget(self.plot_file)
Ejemplo n.º 8
0
 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)