14from ROOT
import gROOT, Belle2
15gROOT.ProcessLine(
"gErrorIgnoreLevel = 4000;")
18Compare the CDCTriggerTSFModule output with the old TRGCDCModule,
19to confirm that the behaviour of the new code is correct.
31 'pdgCodes': [-13, 13],
33 'momentumGeneration':
'inversePt',
34 'momentumParams': [0.3, 10.],
35 'thetaGeneration':
'uniform',
36 'thetaParams': [35, 123],
37 'phiGeneration':
'uniform',
38 'phiParams': [0, 360],
39 'vertexGeneration':
'fixed',
40 'xVertexParams': [0.],
41 'yVertexParams': [0.],
42 'zVertexParams': [0.]}
44bkgdir =
'/sw/belle2/bkg/'
51basf2.set_random_seed(seed)
53basf2.set_log_level(basf2.LogLevel.ERROR)
55main = basf2.create_path()
57main.add_module(
'EventInfoSetter', evtNumList=evtnum)
58main.add_module(
'Progress')
59main.add_module(
'Gearbox')
60main.add_module(
'Geometry', components=[
'CDC',
61 'MagneticFieldConstant4LimitedRCDC'])
62particlegun = basf2.register_module(
'ParticleGun')
63particlegun.param(particlegun_params)
64main.add_module(particlegun)
65main.add_module(
'FullSim')
67 bkgmixer = basf2.register_module(
'BeamBkgMixer')
68 bkgfiles = glob.glob(os.path.join(bkgdir,
'*[!(PXD)(ECL)]??.root'))
69 bkgmixer.param(
'backgroundFiles', bkgfiles)
70 bkgmixer.param(
'components', [
'CDC'])
71 main.add_module(bkgmixer)
72cdcdigitizer = basf2.register_module(
'CDCDigitizer')
74 cdcdigitizer.param(
'TrigTimeJitter', 32.)
75main.add_module(cdcdigitizer)
81trgcdc = basf2.register_module(
'TRGCDC')
90 'FastSimulationMode': simMode,
93trgcdc.param(trgcdc_params)
95 trgcdc.param(
'inputCollection',
'CDCHits4Trg')
96main.add_module(trgcdc)
98tsf = basf2.register_module(
'CDCTriggerTSF')
102 'TSHitCollectionName':
'TSHits',
103 'ClockSimulation': clock}
106 tsf.param(
'CDCHitCollectionName',
'CDCHits4Trg')
116 test module to compare the output of TRGCDC and CDCTriggerTSF
121 give info for both output lists
and warnings
in the case of mismatches
125 if oldHits.getEntries() == newHits.getEntries():
126 basf2.B2INFO(f
"{int(oldHits.getEntries())} hits")
128 basf2.B2WARNING(f
"old version: {int(oldHits.getEntries())}, new version: {int(newHits.getEntries())}")
129 for i
in range(max(oldHits.getEntries(), newHits.getEntries())):
130 if i < oldHits.getEntries():
131 oldString = f
"ID {oldHits[i].getSegmentID():d} priority {oldHits[i].getPriorityPosition():d} LR " + \
132 f
"{oldHits[i].getLeftRight():d} fastest T {oldHits[i].fastestTime():d} " + \
133 f
"priority T {oldHits[i].priorityTime():d} found T {oldHits[i].foundTime():d}"
136 if i < newHits.getEntries():
137 newString = f
"ID {newHits[i].getSegmentID():d} priority {newHits[i].getPriorityPosition():d} " + \
138 f
"LR {newHits[i].getLeftRight():d} fastest T {newHits[i].fastestTime():d} " + \
139 f
"priority T {newHits[i].priorityTime():d} found T {newHits[i].foundTime():d}"
142 if oldString == newString:
143 basf2.B2INFO(oldString)
145 basf2.B2WARNING(
"old: " + oldString)
146 basf2.B2WARNING(
"new: " + newString)
149 oldCDCRels = oldHits[i].getRelationsTo(
"CDCHits4Trg")
150 newCDCRels = newHits[i].getRelationsTo(
"CDCHits4Trg")
152 oldCDCRels = oldHits[i].getRelationsTo(
"CDCHits")
153 newCDCRels = newHits[i].getRelationsTo(
"CDCHits")
154 if len(oldCDCRels) == len(newCDCRels):
155 basf2.B2INFO(f
"{len(oldCDCRels)} related CDCHits")
157 basf2.B2WARNING(f
"old version: {len(oldCDCRels)} related CDCHits")
158 basf2.B2WARNING(f
"new version: {len(newCDCRels)} related CDCHits")
159 for irel
in range(max(len(oldCDCRels), len(newCDCRels))):
160 if irel < len(oldCDCRels):
161 oldString = f
"relation to hit {int(oldCDCRels[irel].getArrayIndex())}, weight {oldCDCRels.weight(irel):.1f}"
163 oldString =
"no relation"
164 if irel < len(newCDCRels):
165 newString = f
"relation to hit {int(newCDCRels[irel].getArrayIndex())}, weight {newCDCRels.weight(irel):.1f}"
167 newString =
"no relation"
168 if oldString == newString:
169 basf2.B2INFO(oldString)
171 basf2.B2WARNING(oldString)
172 basf2.B2WARNING(newString)
175main.add_module(
TestModule(), logLevel=basf2.LogLevel.INFO)
181print(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.