9"""Contains functions that operate on populated path adjust some module parameters"""
14def adjust_module(path, module_type, params=None, **kwds):
15 """Set parameters of the module with the given type in the path to the given parameters
20 Module path to be adjusted.
22 Type of the module to adjusted as returned by Module.type()
24 Dictionary of parameters served to Module.param(params)
26 Keyword parameters served to Module.param(params)
30 for module
in path.modules():
31 if module.type() == module_type:
34 for sub_path
in module.get_all_condition_paths():
35 adjust_module(sub_path, module_type, params=params, **kwds)
38def skip_modules_after(path, module_type):
39 """Inserts a conditional path at the module of the given type such that modules after are skipped.
44 Module path to be adjusted.
46 Type of the module to adjusted as returned by Module.type()
48 for module
in path.modules():
49 if module.type() == module_type:
50 module.return_value(
False)
51 module.if_false(basf2.create_path())
55def disable_deltas(path):
56 """Disables the generation of delta electrons in FullSim
63 for module
in path.modules():
64 if module.type() ==
'FullSim':
65 module.param(
'ProductionCut', 1000000.)
68def keep_secondaries(path):
69 """Keep all secondaries from the FullSim
76 for module
in path.modules():
77 if module.type() ==
'FullSim':
79 "StoreAllSecondaries":
True,
80 "SecondariesEnergyCut": 0,
85def enable_wire_by_wire_mode(path):
86 """Enables the wire by wire material distribution in the CDC
92 for module
in path.modules():
94 if module.type() ==
'Gearbox':
95 module.param(
'override',
96 [(
"/DetectorComponent[@name='CDC']//MaterialDefinitionMode",
100 if module.type() ==
'FullSim':
102 module.param(
'deltaChordInMagneticField', 0.001)