Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,20 @@ void GateDigitizerProjectionActor::EnableSquaredImage(const bool b) {
// FIXME check if weight exists ?
}

// Called when the simulation starts
// Resolve the input collections once. Their contents change for each event,
// but the collection objects and their attribute schema are simulation-wide.
void GateDigitizerProjectionActor::StartSimulationAction() {
// Get the input hits collection
auto *hcm = GateDigiCollectionManager::GetInstance();
fInputDigiCollections.clear();
for (const auto &name : fInputDigiCollectionNames) {
auto *hc = hcm->GetDigiCollection(name);
fInputDigiCollections.push_back(hc);
CheckRequiredAttribute(hc, "PostPosition");
}
}

void GateDigitizerProjectionActor::BeginOfRunActionMasterThread(int run_id) {
void GateDigitizerProjectionActor::BeginOfRunActionMasterThread(
int /*run_id*/) {
// Set the image to the correct position/orientation
AttachImageToVolume<ImageType>(fImage, fPhysicalVolumeName, G4ThreeVector(),
fDetectorOrientationMatrix);
Expand Down Expand Up @@ -153,7 +155,7 @@ void GateDigitizerProjectionActor::BeginOfRunAction(const G4Run *run) {
void GateDigitizerProjectionActor::EndOfEventAction(const G4Event * /*event*/) {
const auto run = G4RunManager::GetRunManager()->GetCurrentRun()->GetRunID();
for (size_t channel = 0; channel < fInputDigiCollections.size(); channel++) {
const auto slice = channel + run * fInputDigiCollections.size();
const auto slice = channel;
ProcessSlice(slice, channel);
}
}
Expand Down Expand Up @@ -233,11 +235,10 @@ void GateDigitizerProjectionActor::ScoreSquaredValue(
}

GateDigitizerProjectionActor::ImageType::RegionType
GateDigitizerProjectionActor::GetRunRegion(const int run_id) const {
GateDigitizerProjectionActor::GetRunRegion(const int /*run_id*/) const {
auto region = fImage->GetLargestPossibleRegion();
auto index = region.GetIndex();
auto size = region.GetSize();
index[2] += run_id * fInputDigiCollections.size();
size[2] = fInputDigiCollections.size();
region.SetIndex(index);
region.SetSize(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,32 @@
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>

class PyDigitizerProjectionActor : public GateDigitizerProjectionActor {
public:
// Inherit the constructors
using GateDigitizerProjectionActor::GateDigitizerProjectionActor;

void BeginOfRunActionMasterThread(int run_id) override {
PYBIND11_OVERLOAD(void, GateDigitizerProjectionActor,
BeginOfRunActionMasterThread, run_id);
}

int EndOfRunActionMasterThread(int run_id) override {
PYBIND11_OVERLOAD(int, GateDigitizerProjectionActor,
EndOfRunActionMasterThread, run_id);
}
};

void init_GateDigitizerProjectionActor(py::module &m) {

py::class_<GateDigitizerProjectionActor,
py::class_<GateDigitizerProjectionActor, PyDigitizerProjectionActor,
std::unique_ptr<GateDigitizerProjectionActor, py::nodelete>,
GateVActor>(m, "GateDigitizerProjectionActor")
.def(py::init<py::dict &>())
.def("BeginOfRunActionMasterThread",
&GateDigitizerProjectionActor::BeginOfRunActionMasterThread)
.def("EndOfRunActionMasterThread",
&GateDigitizerProjectionActor::EndOfRunActionMasterThread)
.def_readwrite("fImage", &GateDigitizerProjectionActor::fImage)
.def_readwrite("fSquaredImage",
&GateDigitizerProjectionActor::fSquaredImage)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/user_guide_chemistry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ This combines the main pieces in one small script:
source.position.translation = [0, 0, 0]
source.direction.type = "momentum"
source.direction.momentum = [0, 0, 1]
source.n = 1
source.number_of_primaries = 1

chem_actor = sim.add_actor("ChemicalCountingActor", "chem_actor")
chem_actor.attached_to = target
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ Example:
source.image = "activity_0.mhd"
source.direction.type = "iso"
source.energy.mono = 1 * MeV
source.n = [2000, 2000, 2000]
source.number_of_primaries = [2000, 2000, 2000]

source.add_dynamic_parametrisation(
image=[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ GATE 10
source.position.translation = [1060 * mm, 0 * mm, 0 * mm]
source.direction.type = "focused"
source.direction.focus_point = [1000 * mm, 0 * mm, 0 * mm]
source.n = 720000 / sim.number_of_threads
source.number_of_primaries = 720000
source.visualization.count = 2000
source.visualization.color = "red"
source.visualization.size = 5
Expand Down
9 changes: 6 additions & 3 deletions docs/source/user_guide/user_guide_multijobs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ their output again. This is useful in two main situations:
- local execution on a workstation, where several jobs can run in parallel on
the same machine
- server execution, where the split jobs are submitted to a scheduler such as
Slurm or HTCondor
Slurm, HTCondor or PBS.

This section focuses on the current user-facing workflow in GATE 10.

Expand Down Expand Up @@ -186,8 +186,8 @@ Server-based execution
Server-based multi-job execution is intended to be file-based:

1. prepare a campaign folder containing ``simulation.json`` and the required
input files, probably locally
2. transfer the campaign folder to the server
input files, probably locally. To create the ```simulation.json`` file, you can use ``sim.to_json_file()`` in your script instead of ``sim.run(...)``.
2. transfer the campaign folder to the server. Be aware of the paths used in the .json file for material database or other input files. They should be valid on the server.
3. split the simulation on the server
4. submit the child jobs through a scheduler
5. inspect job status
Expand Down Expand Up @@ -246,6 +246,9 @@ As a convenience, the command also looks for a default file named
``jobs_backend_options.json`` inside the campaign folder when no
``--backend-options-json`` or ``--backend`` argument is provided.

You can find examples you can adapt in the ``contrib/cluster`` folder for slurm and pbs backends.
The backend options are usually site-specific and should be adapted to the target server.


.. Example: Slurm
.. ~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/user_guide_optical_photons.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Optical photon polarization is not yet implemented. A random polarization is the
source.particle = 'opticalphoton'
source.position.type = 'point'
source.position.translation = [0, 0, 0]
source.n = 100
source.number_of_primaries = 100
source.energy.mono = 1.9*eV
source.mother = 'world
source.direction.type = "iso"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ a source description to the simulation, you do:
.. code:: python

source1 = sim.add_source('GenericSource', 'source1')
source1.n = 100
source1.number_of_primaries = 100

source2 = sim.add_source('VoxelSource', 'source2')
source2.activity = 10 * g4_units.Bq

There are several source types, each one with different parameter. In
this example, ``source1.n`` indicates that this source will generate 100
this example, ``source1.number_of_primaries`` indicates that this source will generate 100
Events. The second source manages the time and will generate 10 Events
per second, so according to the simulation run timing, a different
number of Events will be generated.
Expand Down Expand Up @@ -59,11 +59,11 @@ A minimal working example would be:
.. code:: python

source = sim.add_source("GenericSource", "mySource")
source.n = [10000, 150000, 36]
source.number_of_primaries = [10000, 150000, 36]

sim.run_timing_intervals = [[0, 1 * sec], [2 * sec, 2.5 * sec], [4 * sec, 5 * sec]]

Please note that sim.run_timing_intervals must have the same length as source.n.
Please note that ``sim.run_timing_intervals`` must have the same length as ``source.number_of_primaries``.
By default, all particles of a given run will be emitted at a timestamp equal to the minimum time of the corresponding timing interval.

Coordinate system
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ All parameters are stored into a dict-like structure (a Box). Particle
can be ‘gamma’, ‘e+’, ‘e-’, ‘proton’ (all Geant4 names). The number of
particles that will be generated by the source can be described by an
activity ``source.activity = 10 * MBq`` or by a number of particle
``source.n = 100``.
``source.number_of_primaries = 100``.

The positions from where the particles will be generated are defined by a
shape (‘box’, ‘sphere’, ‘point’, ‘disc’), defined by several parameters
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ a 120 MeV/n carbon ion beam.
source.energy.mono = 1440 * MeV
source.particle = "ion 6 12" # carbon
source.position.translation = [100 * mm, 0 * mm, 0 * cm]
source.n = 20000
source.number_of_primaries = 20000
source.direction.partPhSp_x = [
2.3335754 * mm,
2.3335754 * mrad,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ simulation:
# tps
n_sim = 80000 # particles to simulate per beam
tps = sim.add_source("TreatmentPlanPBSource", "TPSource")
tps.n = n_sim
tps.number_of_primaries = n_sim
tps.beam_model = beamline
tps.plan_path = ref_path / "TreatmentPlan2Spots.txt"
tps.beam_nr = 1
Expand Down
2 changes: 1 addition & 1 deletion docs/source/user_guide/user_guide_sources.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Alternatively, you can specify the fixed number of primary particles to be gener

.. code-block:: python

source1.n = 100
source1.number_of_primaries = 100

Note, however, that certain functionality regarding simulations with multiple runs is currently not supported when sources specify the fixed number of particles as above.

Expand Down
11 changes: 10 additions & 1 deletion opengate/actors/biasingactors.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,20 @@ class ScatterSplittingFreeFlightActor(
False,
{"doc": "Print debug information during the stepping action of the actor."},
),
"particles": (
[
"gamma",
],
{
"doc": "For scatter splitting free flight, only gamma is supported",
"override": True,
"read_only": True,
},
),
}

# Do NOT work with GammaGeneralProc
processes = ["compt", "phot", "conv", "Rayl"]
particles = ["gamma"]

user_output_config = {
"info": {
Expand Down
Loading
Loading