Exemple #1
0
 def __init__(self, meta):
     self.reader = ProtoSetReader("stacking_simple.bin", CylinderProtoSet)
     filters = Filters(complevel=3, fletcher32=True)
     self.reader.set_filters(filters)
     self.path_hdf5 = "result.hdf5"
     self.counter = 0
     self.mess_templte = Template(MESSEGE)
     self.meta = meta
     self.step = 0.001
Exemple #2
0
 def test_proto_set_convertor(self):
     readers = [
         ProtoSetReader("gammaSeed.bin", CylinderProtoSet),
         ProtoSetReader("positronSeed.bin", CylinderProtoSet),
         ProtoSetReader("histogram.bin", HistogramProtoSet)
     ]
     path = "/home/zelenyy/npm/phd/phd-code/cxx/thunderstorm/run"
     filters = Filters(complevel=3, fletcher32=True)
     convertor = ConverterFromBinToHDF5(readers)
     for reader in readers:
         reader.set_filters(filters)
     convertor.convert(path, "./test.hdf5")
Exemple #3
0
def main():
    args = create_parser().parse_args()
    path = args.input

    readers = [
        ProtoSetReader("treeTracking.bin", CylinderProtoSet),
        ProtoSetReader("gammaSeed.bin", CylinderProtoSet),
        ProtoSetReader("positronSeed.bin", CylinderProtoSet),
        ProtoSetReader("histogram.bin", HistogramProtoSet)]

    convertor = get_convertor(readers)
    convertor.convert(path, args.output)
    if args.clear:
        shutil.rmtree(path)
Exemple #4
0
 def test_cumulator2D(self):
     if os.path.exists("test_cumulator2d.hdf5"):
         os.remove("test_cumulator2d.hdf5")
     path = "/home/zelenyy/npm/phd/phd-code/cxx/thunderstorm/run"
     readers = [
         ProtoSetReader("electron_deposit_cumulator2d.bin",
                        Cumulator2DProtoSet),
         ProtoSetReader("electron_number_cumulator2d.bin",
                        Cumulator2DProtoSet)
     ]
     filters = Filters(complevel=3, fletcher32=True)
     convertor = ConverterFromBinToHDF5(readers)
     for reader in readers:
         reader.set_filters(filters)
     convertor.convert(path, "./test_cumulator2d.hdf5")
def main():
    logging.basicConfig(filename="run.log")
    logging.root.setLevel(logging.DEBUG)

    values_macros = {
        "type": ["pie"],
        "physics": ["FTFP_BERT_opt4"],
        "high": [4225],
        "low": [3225],
        "cut": [0.05],
        'number': [10],
        'posZ': [499.5],
        'particle': ['mu-', 'mu+'],
        'field_z': [0.0, 200.0, 220.0],
    }
    meta = Meta(values_macros)

    input_data = no_gdmL_input_generator(meta, INPUT_TEMPLATE)
    command = "../../build/thunderstorm/geant4-thunderstorm.exe"
    readers = [
        ProtoSetReader("particle_detector.bin", ParticleDetectorProtoSet)
    ]

    multirun_command(input_data,
                     command,
                     post_processor=get_convertor(readers,
                                                  "./result.hdf5",
                                                  clear=True))
    return 0
def main():
    logging.basicConfig(filename="run.log")
    logging.root.setLevel(logging.DEBUG)

    input_data = input_generator_critical_energy()
    command = "../../build/thunderstorm/geant4-thunderstorm.exe"
    readers = [
        ProtoSetReader("stacking_simple.bin", CylinderProtoSet),
        ProtoSetReader("tracking_post.bin", CylinderProtoSet),
    ]
    multirun_command(input_data,
                     command,
                     post_processor=get_convertor(readers,
                                                  "./result.hdf5",
                                                  clear=True))
    return 0
Exemple #7
0
def main():
    logging.basicConfig(filename="run.log")
    logging.root.setLevel(logging.DEBUG)

    gdml_template = os.path.join(ROOT_PATH, "template", "cylinder.gdml")

    values_gdml = {
        'height': [0],
        'cellHeight': [600],
        'fieldValueZ': [10e-4],  #np.arange(2,11)*1e-4,
    }

    values_macros = {
        "physics": ["standard_opt_4"],
        "cut": [0.005],
        'number': [int(10)],
        'energy': np.arange(),
        'posZ': [200],
        'direction': ['0 0 -1'],
        'particle': 'e-'
    }
    meta = Meta({"macros": values_macros, "gdml": values_gdml})

    input_data = general_input_generator(meta, gdml_template, INPUT_TEMPLATE)
    command = "../../build/thunderstorm/geant4-thunderstorm.exe"
    readers = [ProtoSetReader("stacking_simple.bin", CylinderProtoSet)]
    multirun_command(input_data,
                     command,
                     post_processor=get_convertor(readers,
                                                  "./result.hdf5",
                                                  clear=False))
    return 0
Exemple #8
0
class CriticalEnergyProcessor(Processor):
    def __init__(self, meta):
        self.reader = ProtoSetReader("stacking_simple.bin", CylinderProtoSet)
        filters = Filters(complevel=3, fletcher32=True)
        self.reader.set_filters(filters)
        self.path_hdf5 = "result.hdf5"
        self.counter = 0
        self.mess_templte = Template(MESSEGE)
        self.meta = meta
        self.step = 0.001

    def init_messege(self) -> str:
        return self.mess_templte.substitute(self.meta)

    def process(self, event):
        group_path = self.convert(event.pathname)
        os.remove(event.pathname)
        with tables.open_file(self.path_hdf5) as h5file:
            table: Table = h5file.get_node(group_path, "stacking_simple")
            n_electron = table.nrows
            n_primary = table.attrs["number"]
            gamma = n_electron / n_primary
            if gamma > 1:
                return None
            else:
                self.meta["energy"] = self.meta["energy"] + self.step
                return self.init_messege()

    def accept(self, event):
        return event.name == "stacking_simple.bin"

    def convert(self, path):
        with tables.open_file(self.path_hdf5, mode="a") as h5file:
            group = h5file.create_group(
                h5file.root, "sim{}".format(str(self.counter).rjust(4, '0')))
            self.reader(path, h5file, group)
            for table in h5file.iter_nodes(group):
                if (isinstance(table, Group)):
                    continue
                for key, value in self.meta.items():
                    table.attrs[key] = value
            self.counter += 1
            return group._v_pathname
Exemple #9
0
    def test_cumulator(self):
        if os.path.exists("test_cumulator.hdf5"):
            os.remove("test_cumulator.hdf5")
        path = "/home/zelenyy/data/thunderstorm/test"
        readers = [
            ProtoSetReader("electron_z_cumulator.bin", Cumulator1DProtoSet),
            ProtoSetReader("electron_time_cumulator.bin", Cumulator1DProtoSet)
        ]
        filters = Filters(complevel=3, fletcher32=True)
        convertor = ConverterFromBinToHDF5(readers)
        for reader in readers:
            reader.set_filters(filters)
        convertor.convert(path, "./test_cumulator.hdf5")

        with tables.open_file("test_cumulator.hdf5") as h5file:
            for i in range(10):
                name = "event" + str(i).rjust(5, "0")
                # data = h5file.get_node("/test/electron_z_cumulator", name)
                data = h5file.get_node("/test/electron_time_cumulator", name)
                plt.plot(data)
                plt.show()
Exemple #10
0
def main():
    logging.basicConfig(filename="run.log")
    logging.root.setLevel(logging.DEBUG)

    gdml_template = os.path.join(ROOT_PATH, "template", "cylinder.gdml")

    values_macros = {
        "cut": [0.05],
        "physics": ["standard_opt_4"],
        'number': [2],
        'energy': [1.0],
        'direction': ['0 0 -1'],
        'particle': 'e-'
    }
    meta = Meta({
        "macros": values_macros,
    })
    # fields = [10e-4, 7e-4, 6.0e-4, 5.5e-4, 5.0e-4, 4.5e-4, 4.0e-4]
    # heights = [200, 300, 400, 400, 500, 700, 1000]
    fields = [10e-4, 7e-4]
    heights = [200, 300]
    ggfh = GGFieldHeigth(fields, heights)
    input_data = input_generator_custom_gdml_dwyer2003(meta, gdml_template,
                                                       INPUT_TEMPLATE, ggfh)
    command = "../../build/thunderstorm/geant4-thunderstorm.exe"
    readers = [
        ProtoSetReader("treeTracking.bin", CylinderProtoSet),
        ProtoSetReader("gammaSeed.bin", CylinderProtoSet),
        ProtoSetReader("positronSeed.bin", CylinderProtoSet),
        ProtoSetReader("histogram.bin", HistogramProtoSet)
    ]
    multirun_command(input_data,
                     command,
                     post_processor=get_convertor(readers,
                                                  "./result.hdf5",
                                                  clear=True))
    return 0
Exemple #11
0
def main():
    args = create_parser().parse_args()
    logging.basicConfig(filename="run.log")
    logging.root.setLevel(logging.DEBUG)

    gdml_path = DEFOULT_PATH
    physics = "FTFP_BERT_opt4"
    if args.with_spacecraft:
        gdml_path = SPACECART_PATH
    if args.without_standard:
        physics = "withoutEmStandard"
    input_data = input_generator_neutron(gdml_path, physics)
    command = "../../build/thunderstorm/geant4-thunderstorm.exe"
    readers = [
        ProtoSetReader("stacking_simple.bin", CylinderProtoSet),
        ProtoSetReader("tracking_post.bin", CylinderProtoSet)
    ]
    multirun_command(input_data,
                     command,
                     post_processor=get_convertor(readers,
                                                  args.output,
                                                  clear=True),
                     n_cpu_cores=12)
    return 0