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