Belle II Software development
svdEventT0PerformanceTTree.py
1#!/usr/bin/env python3
2
3
10
11
18
19import basf2 as b2
20from basf2 import conditions as b2conditions
21import rawdata as raw
22import tracking as trk
23import simulation as sim
24import glob
25import argparse
26
27parser = argparse.ArgumentParser(description=__doc__)
28parser.add_argument("--fileDir", default="./",
29 help="Output File Dir")
30parser.add_argument("--fileTag", default="test",
31 help="Output File Tag")
32parser.add_argument("--isMC", action="store_true",
33 help="Use Simulation")
34parser.add_argument("--is3sample", action="store_true",
35 help="Emulate SVD 3 samples")
36parser.add_argument("--RootOutput", action="store_true",
37 help="Store svd clusters before reconstruction to root file")
38parser.add_argument("--noReco", action="store_true",
39 help="Do not perform the reconstruction")
40parser.add_argument("--test", action="store_true",
41 help="Test with small numbers of events")
42args = parser.parse_args()
43b2.B2INFO(f"Steering file args = {args}")
44
45main = b2.create_path()
46
47b2.set_random_seed(1)
48
49if args.isMC:
50 # options for simulation:
51 # expList = [1003]
52 expList = [0]
53 numEvents = 20
54 bkgFiles = glob.glob('/sw/belle2/bkg/*.root') # Phase3 background
55 bkgFiles = None # uncomment to remove background
56 simulateJitter = False
57 ROIfinding = False
58 MCTracking = False
59 eventinfosetter = b2.register_module('EventInfoSetter')
60 eventinfosetter.param('expList', expList)
61 eventinfosetter.param('runList', [0])
62 eventinfosetter.param('evtNumList', [numEvents])
63 main.add_module(eventinfosetter)
64 main.add_module('EvtGenInput')
65
66 sim.add_simulation(
67 main,
68 bkgfiles=bkgFiles,
69 forceSetPXDDataReduction=True,
70 usePXDDataReduction=ROIfinding,
71 simulateT0jitter=simulateJitter)
72
73 if args.is3sample:
74 for m in main.modules():
75 if m.name() == "SVDEventInfoSetter":
76 m.param("daqMode", 1)
77 m.param("relativeShift", 7)
78 m.param("useDB", False)
79
80else:
81 # setup database
82 b2conditions.reset()
83 b2conditions.override_globaltags()
84 b2conditions.globaltags = ["online"]
85 b2conditions.prepend_globaltag("data_reprocessing_prompt")
86 b2conditions.prepend_globaltag("patch_main_release-07")
87
88 MCTracking = False
89
90 if args.test:
91 main.add_module('RootInput', entrySequences=['0:100'])
92 else:
93 main.add_module('RootInput')
94
95 main.add_module("Gearbox")
96 main.add_module('Geometry', useDB=True)
97
98 raw.add_unpackers(main)
99
100 if args.is3sample:
101
102 # change ListName
103 for moda in main.modules():
104 if moda.name() == 'SVDUnpacker':
105 moda.param("svdShaperDigitListName", "SVDShaperDigits6Sample")
106 moda.param("SVDEventInfo", "SVDEventInfo6Sample")
107
108 # emulate 3-sample DAQ for events
109 zsemulator = b2.register_module("SVD3SamplesEmulator")
110 zsemulator.param("outputSVDShaperDigits", "SVDShaperDigits3SampleAll")
111 zsemulator.param("outputSVDEventInfo", "SVDEventInfo")
112 zsemulator.param("chooseStartingSample", False)
113 zsemulator.param("chooseRelativeShift", True)
114 zsemulator.param("relativeShift", 7)
115 zsemulator.param("SVDShaperDigits", "SVDShaperDigits6Sample")
116 zsemulator.param("SVDEventInfo", "SVDEventInfo6Sample")
117 main.add_module(zsemulator)
118
119 zsonline = b2.register_module("SVDZeroSuppressionEmulator")
120 zsonline.param("ShaperDigits", "SVDShaperDigits3SampleAll")
121 zsonline.param("ShaperDigitsIN", "SVDShaperDigits")
122 main.add_module(zsonline)
123
124
125if args.noReco:
126 # clusterizer
127 main.add_module('SVDClusterizer')
128else:
129 # now do reconstruction:
130 # clusterizer added by default
131 trk.add_tracking_reconstruction(
132 main,
133 mcTrackFinding=MCTracking,
134 append_full_grid_cdc_eventt0=True,
135 trackFitHypotheses=[211],
136 skip_full_grid_cdc_eventt0_if_svd_time_present=False) # ,
137 # skipHitPreparerAdding=True)
138
139
140# fill TTrees
141outputFileName = str(args.fileDir)+"SVDEventT0PerformanceTTree"
142if args.isMC:
143 outputFileName += "_MC"
144if args.is3sample:
145 outputFileName += "_emulated3sample"
146
147if not args.noReco:
148 recoFileName = outputFileName + "_" + str(args.fileTag) + ".root"
149 main.add_module('SVDEventT0PerformanceTTree', outputFileName=recoFileName)
150
151if args.RootOutput:
152 rootOutFileName = outputFileName + "_RootOutput_" + str(args.fileTag) + ".root"
153 main.add_module('RootOutput',
154 outputFileName=rootOutFileName,
155 branchNames=['SVDClusters'])
156
157main.add_module('Progress')
158
159b2.print_path(main)
160
161b2.process(main)
162
163print(b2.statistics)