11from ROOT
import Belle2
13from svd
import add_svd_simulation
42 """Set aside all SimHits on a selected sensor/side to create
43 signal/background collisions."""
46 '''initialize python module'''
56 for h
in storesimhits:
62 '''Inject stored SVDSimHits'''
65 '''initialize python module'''
73 self.
simhits.registerInDataStore()
80 simhit = self.
simhits.appendNew()
84if __name__ ==
"__main__":
88 basf2.B2INFO(
'Creating background data...')
90 create_bgfile = basf2.create_path()
91 create_bgfile.add_module(
'EventInfoSetter', expList=[0], runList=[0], evtNumList=[100])
92 create_bgfile.add_module(
'Gearbox')
93 create_bgfile.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
94 create_bgfile.add_module(
'ParticleGun')
95 create_bgfile.add_module(
'FullSim')
96 create_bgfile.add_module(
'BeamBkgTagSetter', backgroundType=
"twoPhoton", realTime=310.0)
97 create_bgfile.add_module(
'RootOutput', outputFileName=
'bgForMixing.root', branchNames=[
'BackgroundMetaData',
'SVDSimHits'])
101 basf2.B2INFO(
'Creating overlay data...')
103 create_ovrfile = basf2.create_path()
104 create_ovrfile.add_module(
'EventInfoSetter', expList=[0], runList=[0], evtNumList=[1])
105 create_ovrfile.add_module(
'Gearbox')
106 create_ovrfile.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
107 create_ovrfile.add_module(
'BeamBkgMixer', backgroundFiles=[
'bgForMixing.root'], minTime=-150, maxTime=150)
109 add_svd_simulation(create_ovrfile)
112 create_ovrfile.add_module(
'RootOutput', outputFileName=
'bgForOverlay.root', branchNames=[
'SVDShaperDigits'])
116 basf2.B2INFO(
'Background mixing...')
118 produce_mixed = basf2.create_path()
119 produce_mixed.add_module(
'EventInfoSetter', expList=[0], runList=[0], evtNumList=[1])
120 produce_mixed.add_module(
'Gearbox')
121 produce_mixed.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
125 produce_mixed.add_module(
'BeamBkgMixer', backgroundFiles=[
'bgForMixing.root'], minTime=-150, maxTime=150)
127 add_svd_simulation(produce_mixed)
129 produce_mixed.add_module(
'SVDShaperDigitSorter')
130 produce_mixed.add_module(
'RootOutput', outputFileName=
'mixedBg.root')
134 basf2.B2INFO(
'Background overlay...')
136 produce_overlaid = basf2.create_path()
137 produce_overlaid.add_module(
'EventInfoSetter', expList=[0], runList=[0], evtNumList=[1])
138 produce_overlaid.add_module(
'Gearbox')
139 produce_overlaid.add_module(
'Geometry', components=[
'MagneticField',
'SVD'])
140 produce_overlaid.add_module(
'BGOverlayInput', inputFileNames=[
'bgForOverlay.root'])
143 add_svd_simulation(produce_overlaid)
145 produce_overlaid.add_module(
'BGOverlayExecutor')
147 produce_overlaid.add_module(
'SVDShaperDigitSorter')
148 produce_overlaid.add_module(
'RootOutput', outputFileName=
'overlaidBg.root')
152 basf2.B2INFO(
'Comparing...')
155 f_mixed = ROOT.TFile(
'mixedBg.root')
156 tree_mixed = f_mixed.Get(
'tree')
158 f_over = ROOT.TFile(
'overlaidBg.root')
159 tree_over = f_over.Get(
'tree')
163 for evt1, evt2
in zip(tree_mixed, tree_over):
164 d_mixed = evt1.SVDShaperDigits
165 d_over = evt2.SVDShaperDigits
166 if (len(d_mixed) != len(d_over)):
167 basf2.B2ERROR(
'Lengths of SVDShaperDigit arrays DIFFER!')
169 for d1, d2
in zip(d_mixed, d_over):
171 match = match
and (d1.getSensorID() == d2.getSensorID())
172 match = match
and (d1.isUStrip() == d2.isUStrip())
173 match = match
and (d1.getCellID() == d2.getCellID())
174 for s1, s2
in zip(d1.getSamples(), d2.getSamples()):
175 match = match
and (int(s1) == int(s2))
179 basf2.B2ERROR(
'Digits do not match.')
183 basf2.B2INFO(f
'Processed {n_good} matching digits.')
A (simplified) python wrapper for StoreArray.
Class to uniquely identify a any structure of the PXD and SVD.
simhits
simHits store array
selected_sensorID
selected sensor info
def clean_working_directory()
def safe_process(*args, **kwargs)