xopto.mcbase.mcrun module¶
- class RunMinPacketsBase(min_packets: float, batch_size: int, selection: slice)[source]¶
Bases:
object
Object for running MC simulations until the desired number of packets is collected by the selected detector.
- Parameters
min_packets (int) – Minimum required number of packets.
min_weight (float) – Minimum weight that needs to be collected by the detector.
batch_size (int) – Number of packets to launch in a single simulation.
- property batch_size: int¶
Number of packets processed / launched in one simulation run / batch.
- property min_packets: int¶
The minimum number of packets that needs to be collected by the selected detector.
- process_batch(result: tuple) → Tuple[float, int, tuple][source]¶
Implement this method in a subclass. Return True if the batch is complete.
- Parameters
result (tuple) – Result as returned by the Monte Carlo simulation.
- Returns
total_weight (float) – The total accumulated weight.
num_packets (int) – The total number of packets accumulated after processing this batch.
result (tuple) – Simulation result ready for the next Monte Carlo simulation.
- run(mc_obj: xopto.mcbase.mcobject.McObject, min_packets: Optional[int] = None, out: Optional[tuple] = None, *args, **kwargs) → tuple[source]¶
Repeat simulations in batches until the required minimum weight is collected by the selected detector and optionally the minimum number of packets is launched.
- Parameters
mc_obj (mcobject.McObject) – Simulator instance.
min_packets (int) – Optional minimum number of packets to launch and simulate. If None (default), there is no restriction on te minimum number of packets that need to be simulated.
out (tuple) – Output from the previous run of the simulator.
*args (tuple) – Positional arguments passed to the simulator.
**kwargs (dict) – Keyword arguments passed to the simulator.
- Returns
result – Accumulated results as returned by the Mont Carlo simulator instance.
- Return type
tuple
- property selection: int¶
A slice / region or index of the detector that is used to compute the collected weight. If None (default), the entire detector contributes to the total weight.
- class RunMinWeightBase(min_weight: float, batch_size: int, selection: Optional[slice] = None)[source]¶
Bases:
object
Base class for running MC simulations until the desired weight is collected by the selected detector.
- Parameters
min_weight (float) – Minimum weight that needs to be collected by the detector.
batch_size (int) – Number of packets to launch in a single simulation.
- property batch_size: int¶
Number of packets processed / launched in one simulation run / batch.
- property min_weight: int¶
The minimum total weight that needs to be collected by the selected detector.
- process_batch(result: tuple) → Tuple[float, int, tuple][source]¶
Implement this method in a subclass. :param result: Result as returned by the Monte Carlo simulation. :type result: tuple
- Returns
total_weight (float) – The total accumulated weight.
num_packets (int) – The total number of packets accumulated after processing this batch.
result (tuple) – Simulation result ready for the next Monte Carlo simulation.
- run(mc_obj: xopto.mcbase.mcobject.McObject, min_packets: Optional[int] = None, out: Optional[tuple] = None, *args, **kwargs) → tuple[source]¶
Repeat simulations in batches until the required minimum weight is collected by the selected detector and optionally the minimum number of packets is launched.
- Parameters
mc_obj (mcobject.McObject) – Simulator instance.
min_packets (int) – Optional minimum number of packets to launch and simulate. If None (default), there is no restriction on te minimum number of packets that need to be simulated.
out (tuple) – Output from the previous run of the simulator.
*args (tuple) – Positional arguments passed to the simulator.
**kwargs (dict) – Keyword arguments passed to the simulator.
- Returns
result – Accumulated results as returned by the Mont Carlo simulator instance.
- Return type
tuple
- property selection: int¶
A slice / region or index of the detector that is used to compute the collected weight. If None (default), the entire detector contributes to the total weight.