Belle II Software  release-05-01-25
adjustments.py
1 """Contains functions that operate on populated path adjust some module parameters"""
2 
3 import basf2
4 
5 
6 def adjust_module(path, module_type, params={}, **kwds):
7  """Set parameters of the module with the given type in the path to the given parameters
8 
9  Arguments
10  ---------
11  path : basf2.Path
12  Module path to be adjusted.
13  module_type : str
14  Type of the module to adjusted as returned by Module.type()
15  params : dict
16  Dictionary of parameters served to Module.param(params)
17  **kwds
18  Keyword parameters served to Module.param(params)
19  """
20  for module in path.modules():
21  if module.type() == module_type:
22  module.param(params)
23  module.param(kwds)
24  for sub_path in module.get_all_condition_paths():
25  adjust_module(sub_path, module_type, params=params, **kwds)
26 
27 
28 def skip_modules_after(path, module_type):
29  """Inserts a conditional path at the module of the given type such that modules after are skipped.
30 
31  Arguments
32  ---------
33  path : basf2.Path
34  Module path to be adjusted.
35  module_type : str
36  Type of the module to adjusted as returned by Module.type()
37  """
38  for module in path.modules():
39  if module.type() == module_type:
40  module.return_value(False)
41  module.if_false(basf2.create_path())
42  return
43 
44 
45 def disable_deltas(path):
46  """Disables the generation of delta electrons in FullSim
47 
48  Arguments
49  ---------
50  path : basf2.Path
51  """
52 
53  for module in path.modules():
54  if module.type() == 'FullSim':
55  module.param('ProductionCut', 1000000.)
56 
57 
58 def keep_secondaries(path):
59  """Keep all secondaries from the FullSim
60 
61  Arguments
62  ---------
63  path : basf2.Path
64  """
65 
66  for module in path.modules():
67  if module.type() == 'FullSim':
68  module.param({
69  "StoreAllSecondaries": True,
70  "SecondariesEnergyCut": 0,
71  "trajectoryStore": 2,
72  })
73 
74 
76  """Enables the wire by wire material distribution in the CDC
77 
78  Arguments
79  ---------
80  path : basf2.Path
81  """
82  for module in path.modules():
83 
84  if module.type() == 'Gearbox':
85  module.param('override',
86  [("/DetectorComponent[@name='CDC']//MaterialDefinitionMode",
87  "2", ""),
88  ]
89  )
90  if module.type() == 'FullSim':
91  # per Ozaki-san's recommendatation for wire-by-wire CDC mode
92  module.param('deltaChordInMagneticField', 0.001)
tracking.adjustments.skip_modules_after
def skip_modules_after(path, module_type)
Definition: adjustments.py:28
tracking.adjustments.adjust_module
def adjust_module(path, module_type, params={}, **kwds)
Definition: adjustments.py:6
tracking.adjustments.enable_wire_by_wire_mode
def enable_wire_by_wire_mode(path)
Definition: adjustments.py:75
tracking.adjustments.disable_deltas
def disable_deltas(path)
Definition: adjustments.py:45
tracking.adjustments.keep_secondaries
def keep_secondaries(path)
Definition: adjustments.py:58