Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why Number of filters: 0? #701

Open
jizhang02 opened this issue Feb 26, 2025 · 0 comments
Open

Why Number of filters: 0? #701

jizhang02 opened this issue Feb 26, 2025 · 0 comments

Comments

@jizhang02
Copy link
Contributor

Hello,

When I test the code below, I printed out the Filters, but the result is 0, I don't understand because there should be some filter info.

# filter on iec phantom
import opengate as gate
import opengate.contrib.phantoms.nemaiec as gate_iec
from opengate.userhooks import check_production_cuts

# create the simulation
sim = gate.Simulation()

# main options
sim.g4_verbose = False
sim.g4_verbose_level = 1
sim.visu = True
sim.random_seed = 12332567

# units
m = gate.g4_units.m
cm = gate.g4_units.cm
keV = gate.g4_units.keV
MeV = gate.g4_units.MeV
Bq = gate.g4_units.Bq
nm = gate.g4_units.nm
mm = gate.g4_units.mm

#  change world size
sim.world.size = [1 * m, 1 * m, 1 * m]

# iec phantom
iec_phantom = gate_iec.add_iec_phantom(sim)

# default source for tests
source = sim.add_source("GenericSource", "mysource")
source.energy.mono = 1 * MeV
source.particle = "gamma"
source.position.type = "sphere"
source.position.radius = 1 * cm
source.direction.type = "iso"
source.activity = 100 * Bq

# filter: keep gamma
f = sim.add_filter("ParticleFilter", "f")
f.particle = "gamma"
# filter: keep e-
fp = sim.add_filter("ParticleFilter", "fp")
fp.particle = "e-"
# filter: energy
fk = sim.add_filter("KineticEnergyFilter", "fk")
fk.energy_min = 100 * keV

# add dose actor
dose = sim.add_actor("DoseActor", "dose")
dose.output_filename = "test023_iec_phantom.mhd"
dose.attached_to = "iec"
dose.size = [100, 100, 100]
dose.spacing = [2 * mm, 2 * mm, 2 * mm]
dose.filters = [fp, fk]

# add stat actor
stat = sim.add_actor("SimulationStatisticsActor", "Stats")
stat.track_types_flag = True
stat.filters.append(f)

print("Filters: ", sim.filter_manager)
print(sim.filter_manager.dump())

# change physics
sim.physics_manager.physics_list_name = "QGSP_BERT_EMZ"
sim.physics_manager.global_production_cuts.all = 0.1 * mm
sim.user_hook_after_init = check_production_cuts

# start simulation
#sim.run(start_new_process=True) # start the simulation in a subprocess
sim.run()
print(stat)

the output is as below:

c:\Users\zhang\miniconda3\envs\gate\Lib\site-packages\opengate_core
Filters:   (0)
Number of filters: 0
Simulation: create RunManager (single thread)
Simulation: initialize Geometry
Simulation: initialize Physics
Simulation: initialize Source
Simulation: initialize Visualization
Simulation: initialize G4RunManager
Simulation: initialize PhysicsEngine after RunManager initialization
Simulation: initialize actors
Simulation: check volumes overlap
Simulation: initialize user fct
Entered hook
Known regions are:
*****
DefaultRegionForTheWorld
Cuts in this region:
gamma: 0.1
electron: 0.1
proton: 0.1
positron: 0.1
*****
DefaultRegionForParallelWorld
Cuts in this region:
gamma: 0.1
electron: 0.1
proton: 0.1
positron: 0.1
--------------------------------------------------------------------------------
Simulation: START 
Simulation: STOP. Run: 1. Time: 5.9 seconds.
--------------------------------------------------------------------------------
runs                1 
events              92 
tracks              188 
steps               564 
init                5.8755 s
duration            1.80689 s
pps                 50 
tps                 104 
sps                 312 
start_time          Wed Feb 26 11:12:54 2025 
stop_time           Wed Feb 26 11:13:02 2025 
sim_start_time      0.0 ps
sim_stop_time       1.0 s
threads             1 
arch                Windows 
python              3.12.8 
track_types
                        e-: 92
                        gamma: 96
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant