15 import xml.etree.ElementTree
as xml
19 b2.logging.log_level = b2.LogLevel.WARNING
24 """A utility module to manipulate the threshold on deposited energy
25 in PXD and SVD SensitiveDetector.
29 """Initialize the module"""
31 super(SetVXDSensitiveThreshold, self).
__init__()
39 self.
pathpath =
'data/{comp}/{COMP}.xml'
41 self.
xmlpathxmlpath =
'Content/SensitiveThreshold'
44 """ Set the threshold value in PXD or SVD file."""
46 filename = self.
pathpath.format(comp=component.lower(),
47 COMP=component.upper())
48 tree = xml.parse(filename)
49 for node
in tree.getroot().findall(self.
xmlpathxmlpath):
50 if component.lower() ==
'pxd':
54 node.text =
'{val}'.format(val=value)
56 file = open(filename,
'w')
57 tree.write(file, encoding=
'UTF-8', xml_declaration=
True)
61 """ Set the required threshold value """
73 """ Set the previuos threshold value """
75 self.set_threshold(
'PXD', self.old_pxd_threshold)
76 self.set_threshold(
'SVD', self.old_svd_threshold)
80 particlegun = b2.register_module(
'ParticleGun')
82 eventinfosetter = b2.register_module(
'EventInfoSetter')
84 progress = b2.register_module(
'Progress')
88 gearbox = b2.register_module(
'Gearbox')
90 geometry = b2.register_module(
'Geometry')
92 simulation = b2.register_module(
'FullSim')
94 pxddigi = b2.register_module(
'PXDDigitizer')
96 pxdclust = b2.register_module(
'PXDClusterizer')
98 svddigi = b2.register_module(
'SVDDigitizer')
100 svdclust = b2.register_module(
'SVDClusterizer')
102 output = b2.register_module(
'RootOutput')
105 eventinfosetter.param({
'evtNumList': [10],
'runList': [1]})
123 'pdgCodes': [211, -211, 11, -11],
124 'momentumGeneration':
'normalPt',
125 'momentumParams': [5, 1],
126 'phiGeneration':
'normal',
127 'phiParams': [180, 30],
128 'thetaGeneration':
'uniformCosinus',
129 'thetaParams': [17, 150],
130 'vertexGeneration':
'normal',
131 'xVertexParams': [0, 2],
132 'yVertexParams': [0, 2],
133 'zVertexParams': [0, 0],
134 'independentVertices':
False,
138 geometry.param(
'Components', [
'MagneticField',
'PXD',
'SVD'])
145 main = b2.create_path()
146 main.add_module(eventinfosetter)
147 main.add_module(progress)
148 main.add_module(particlegun)
149 main.add_module(set_thr)
150 main.add_module(gearbox)
151 main.add_module(geometry)
152 main.add_module(simulation)
153 main.add_module(pxddigi)
154 main.add_module(pxdclust)
155 main.add_module(svddigi)
156 main.add_module(svdclust)
157 main.add_module(output)
threshold
The threshold value to be set.
xmlpath
XML path to the threshold setting.
def __init__(self, threshold)
def set_threshold(self, component, value)
old_svd_threshold
The current svd threshold value.
path
Filesystem path to the .xml file.
old_pxd_threshold
The current pxd threshold value.