15 from ROOT
import gROOT, Belle2
16 gROOT.ProcessLine(
"gErrorIgnoreLevel = 4000;")
19 Compare the CDCTriggerTSFModule output with the old TRGCDCModule,
20 to confirm that the behaviour of the new code is correct.
31 particlegun_params = {
32 'pdgCodes': [-13, 13],
34 'momentumGeneration':
'inversePt',
35 'momentumParams': [0.3, 10.],
36 'thetaGeneration':
'uniform',
37 'thetaParams': [35, 123],
38 'phiGeneration':
'uniform',
39 'phiParams': [0, 360],
40 'vertexGeneration':
'fixed',
41 'xVertexParams': [0.],
42 'yVertexParams': [0.],
43 'zVertexParams': [0.]}
45 bkgdir =
'/sw/belle2/bkg/'
52 basf2.set_random_seed(seed)
54 basf2.set_log_level(basf2.LogLevel.ERROR)
56 main = basf2.create_path()
58 main.add_module(
'EventInfoSetter', evtNumList=evtnum)
59 main.add_module(
'Progress')
60 main.add_module(
'Gearbox')
61 main.add_module(
'Geometry', components=[
'CDC',
62 'MagneticFieldConstant4LimitedRCDC'])
63 particlegun = basf2.register_module(
'ParticleGun')
64 particlegun.param(particlegun_params)
65 main.add_module(particlegun)
66 main.add_module(
'FullSim')
68 bkgmixer = basf2.register_module(
'BeamBkgMixer')
69 bkgfiles = glob.glob(os.path.join(bkgdir,
'*[!(PXD)(ECL)]??.root'))
70 bkgmixer.param(
'backgroundFiles', bkgfiles)
71 bkgmixer.param(
'components', [
'CDC'])
72 main.add_module(bkgmixer)
73 cdcdigitizer = basf2.register_module(
'CDCDigitizer')
75 cdcdigitizer.param(
'TrigTimeJitter', 32.)
76 main.add_module(cdcdigitizer)
82 trgcdc = basf2.register_module(
'TRGCDC')
91 'FastSimulationMode': simMode,
94 trgcdc.param(trgcdc_params)
96 trgcdc.param(
'inputCollection',
'CDCHits4Trg')
97 main.add_module(trgcdc)
99 tsf = basf2.register_module(
'CDCTriggerTSF')
103 'TSHitCollectionName':
'TSHits',
104 'ClockSimulation': clock}
105 tsf.param(tsf_params)
107 tsf.param(
'CDCHitCollectionName',
'CDCHits4Trg')
117 test module to compare the output of TRGCDC and CDCTriggerTSF
122 give info for both output lists and warnings in the case of mismatches
126 if oldHits.getEntries() == newHits.getEntries():
127 basf2.B2INFO(
"%d hits" % oldHits.getEntries())
129 basf2.B2WARNING(
"old version: %d, new version: %d" %
130 (oldHits.getEntries(), newHits.getEntries()))
131 for i
in range(max(oldHits.getEntries(), newHits.getEntries())):
132 if i < oldHits.getEntries():
133 oldString =
"ID %d priority %d LR %d fastest T %d priority T %d found T %d" % \
134 (oldHits[i].getSegmentID(), oldHits[i].getPriorityPosition(),
135 oldHits[i].getLeftRight(), oldHits[i].fastestTime(),
136 oldHits[i].priorityTime(), oldHits[i].foundTime())
139 if i < newHits.getEntries():
140 newString =
"ID %d priority %d LR %d fastest T %d priority T %d found T %d" % \
141 (newHits[i].getSegmentID(), newHits[i].getPriorityPosition(),
142 newHits[i].getLeftRight(), newHits[i].fastestTime(),
143 newHits[i].priorityTime(), newHits[i].foundTime())
146 if oldString == newString:
147 basf2.B2INFO(oldString)
149 basf2.B2WARNING(
"old: " + oldString)
150 basf2.B2WARNING(
"new: " + newString)
153 oldCDCRels = oldHits[i].getRelationsTo(
"CDCHits4Trg")
154 newCDCRels = newHits[i].getRelationsTo(
"CDCHits4Trg")
156 oldCDCRels = oldHits[i].getRelationsTo(
"CDCHits")
157 newCDCRels = newHits[i].getRelationsTo(
"CDCHits")
158 if len(oldCDCRels) == len(newCDCRels):
159 basf2.B2INFO(
"%d related CDCHits" % len(oldCDCRels))
161 basf2.B2WARNING(
"old version: %d related CDCHits" % len(oldCDCRels))
162 basf2.B2WARNING(
"new version: %d related CDCHits" % len(newCDCRels))
163 for irel
in range(max(len(oldCDCRels), len(newCDCRels))):
164 if irel < len(oldCDCRels):
165 oldString =
"relation to hit %d, weight %.1f" % \
166 (oldCDCRels[irel].getArrayIndex(), oldCDCRels.weight(irel))
168 oldString =
"no relation"
169 if irel < len(newCDCRels):
170 newString =
"relation to hit %d, weight %.1f" % \
171 (newCDCRels[irel].getArrayIndex(), newCDCRels.weight(irel))
173 newString =
"no relation"
174 if oldString == newString:
175 basf2.B2INFO(oldString)
177 basf2.B2WARNING(oldString)
178 basf2.B2WARNING(newString)
181 main.add_module(
TestModule(), logLevel=basf2.LogLevel.INFO)
187 print(basf2.statistics)
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
A (simplified) python wrapper for StoreArray.