Belle II Software development
ETF_OldVsNew.py
1#!/usr/bin/env python3
2
3
10
11import basf2
12import os
13import glob
14from ROOT import gROOT, Belle2
15gROOT.ProcessLine("gErrorIgnoreLevel = 4000;") # ignore endless root errors for background files...
16
17"""
18Compare the CDCTrigger2DFitterModule output with the old TRGCDCModule,
19to confirm that the behaviour of the new code is correct.
20"""
21
22# ------------ #
23# user options #
24# ------------ #
25
26# general options
27seed = 1
28evtnum = 1000
29clock = False
30particlegun_params = {
31 'pdgCodes': [-13, 13],
32 'nTracks': 2,
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.]}
43usebkg = False
44bkgdir = '/sw/belle2/bkg/'
45
46# ------------------------- #
47# create path up to trigger #
48# ------------------------- #
49
50# set random seed
51basf2.set_random_seed(seed)
52# suppress messages and warnings during processing:
53basf2.set_log_level(basf2.LogLevel.ERROR)
54
55main = basf2.create_path()
56
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')
66if usebkg:
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')
73if clock:
74 cdcdigitizer.param('TrigTimeJitter', 32.)
75main.add_module(cdcdigitizer)
76
77# ----------- #
78# CDC trigger #
79# ----------- #
80
81trgcdc = basf2.register_module('TRGCDC')
82simMode = 0 # 0: full trigger, 1: only TSF
83if clock:
84 simMode += 2 # 2: full trigger (TSF with clock), 3: only TSF with clock
85trgcdc_params = {
86 'ConfigFile': Belle2.FileSystem.findFile("data/trg/cdc/TRGCDCConfig_0_20101111.dat"),
87 'InnerTSLUTFile': Belle2.FileSystem.findFile("data/trg/cdc/innerLUT_v3.0.coe"),
88 'OuterTSLUTFile': Belle2.FileSystem.findFile("data/trg/cdc/outerLUT_v3.0.coe"),
89 'SimulationMode': 1, # only fast simulation
90 'FastSimulationMode': simMode,
91 'HoughFinderMappingFileMinus': Belle2.FileSystem.findFile("data/trg/cdc/HoughMappingMinus20160223.dat"),
92 'HoughFinderMappingFilePlus': Belle2.FileSystem.findFile("data/trg/cdc/HoughMappingPlus20160223.dat"),
93 'DebugLevel': 0}
94trgcdc.param(trgcdc_params)
95if clock:
96 trgcdc.param('inputCollection', 'CDCHits4Trg')
97main.add_module(trgcdc)
98
99# ETF
100main.add_module('CDCTriggerETF')
101
102
103# ----------- #
104# test module #
105# ----------- #
106
107class TestModule(basf2.Module):
108 """
109 test module to compare the output of TRGCDC and CDCTriggerETF
110 """
111
112 def event(self):
113 """
114 give info for both modules and warnings in the case of mismatches
115 """
116 oldT0 = Belle2.PyStoreObj("CDCTriggerEventTime").obj().getTiming()
117 if Belle2.PyStoreObj("BinnedEventT0").hasBinnedEventT0(Belle2.Const.CDC):
118 newT0 = Belle2.PyStoreObj("BinnedEventT0").obj().getBinnedEventT0(Belle2.Const.CDC)
119 else:
120 newT0 = 9999
121 if oldT0 == newT0:
122 basf2.B2INFO(f"T0 {int(oldT0)}")
123 else:
124 basf2.B2WARNING(f"old T0 {int(oldT0)}, new T0 {int(newT0)}")
125
126
127main.add_module(TestModule(), logLevel=basf2.LogLevel.INFO)
128
129# Process events
130basf2.process(main)
131
132# Print call statistics
133print(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...
Definition: FileSystem.cc:151
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67