13 <contact>software-tracking@belle2.org</contact>
14 <output>ROIFindingValidation.root</output>
16 This module validates the ROI Finding module.
21from tracking
import add_tracking_for_PXDDataReduction_simulation
23from ROOT
import Belle2
27from svd
import add_svd_reconstruction
28from simulation
import add_simulation
29from validationgenerators
import add_evtgen_for_validation
34CONTACT =
'software-tracking@belle2.org'
35OUTPUT_FILE =
'ROIFindingTrackingValidation.root'
43 Create EvtGen input sample and run a simple ROI validation.
45 class ROIFindingTrackingValidationPlots(basf2.Module):
47 """Module to collect information about the ROIs (PXDIntercepts & ROIs) and to
48 generate validation plots on the performance of the ROIFinding module."""
54 output_file_name=None,
60 ## name of this validation output
61 self.validation_name = NAME
63 self.contact = CONTACT
64 ## ## name of the output ROOT file
65 self.output_file_name = OUTPUT_FILE
67 ## count the number of ROIs
69 ## count the number of PXDDigits
71 ## count the number of PXDDigits inside the ROIs
74 # default binning used for resolution plots over pt
75 # self.resolution_pt_binning = [0.05, 0.1, 0.25, 0.4, 0.6, 1., 1.5, 2., 3., 4.]
78 """Receive signal at the start of event processing"""
80 ## list of the number of ROIs in PXD layer 1
81 self.nROIs_L1 = collections.deque()
82 ## list of the number of ROIs in PXD layer 2
83 self.nROIs_L2 = collections.deque()
85 ## list of the ratios of filter to all PXD hits
86 self.drf = collections.deque()
88 ## list of the u-coordinate sigma in PXD layer 1
89 self.statU_L1 = collections.deque()
90 ## list of the v-coordinate sigma in PXD layer 1
91 self.statV_L1 = collections.deque()
92 ## list of the u-coordinate sigma in PXD layer 2
93 self.statU_L2 = collections.deque()
94 ## list of the v-coordinate sigma in PXD layer 2
95 self.statV_L2 = collections.deque()
97 ## list of the hit angular information in PXD layer 1
98 self.theta_phi_L1 = collections.deque()
101 ''' ROIs quantities'''
102 rois = Belle2.PyStoreArray('ROIs')
107 sensor = roi.getSensorID()
108 if (sensor.getLayerNumber() == 1):
109 nL1_ROI = nL1_ROI + 1
111 nL2_ROI = nL2_ROI + 1
113 self.nROIs_L1.append(nL1_ROI)
114 self.nROIs_L2.append(nL2_ROI)
116 self.nROIs = self.nROIs + rois.getEntries()
118 '''Data Reduction Factor '''
119 tot_pxd = Belle2.PyStoreArray('PXDDigits')
120 in_pxd = Belle2.PyStoreArray('filteredPXDDigits')
123 self.drf.append(len(in_pxd) / len(tot_pxd))
125 ''' PXDIntercepts Statistical Error '''
126 inters = Belle2.PyStoreArray('PXDIntercepts')
128 sensor = Belle2.VxdID(inter.getSensorID())
129 if (sensor.getLayerNumber() == 1):
130 self.statU_L1.append(inter.getSigmaU())
131 self.statV_L1.append(inter.getSigmaV())
133 self.statU_L2.append(inter.getSigmaU())
134 self.statV_L2.append(inter.getSigmaV())
137 """Receive signal at the end of event processing"""
139 contact = self.contact
140 basf2.B2RESULT(f"total nROIs = {self.nROIs}")
144 output_tfile = ROOT.TFile(self.output_file_name, 'recreate')
146 h_nROIs_L1 = ValidationPlot('h_nROIs_L1')
147 h_nROIs_L1.hist(self.nROIs_L1, bins=100, lower_bound=0, upper_bound=100)
148 h_nROIs_L1.contact = contact
149 h_nROIs_L1.check = 'average of 25 +/- 10 is expected'
150 h_nROIs_L1.description = 'ROIs on L1'
151 h_nROIs_L1.title = 'ROIs on L1'
152 h_nROIs_L1.xlabel = 'number of ROIs'
153 h_nROIs_L1.ylabel = ''
154 h_nROIs_L1.write(output_tfile)
156 h_nROIs_L2 = ValidationPlot('h_nROIs_L2')
157 h_nROIs_L2.hist(self.nROIs_L2, bins=100, lower_bound=0, upper_bound=100)
158 h_nROIs_L2.contact = contact
159 h_nROIs_L2.check = 'average of 25 +/- 10 is expected'
160 h_nROIs_L2.description = 'ROIs on L2'
161 h_nROIs_L2.title = 'ROIs on L2'
162 h_nROIs_L2.xlabel = 'number of ROIs'
163 h_nROIs_L2.ylabel = ''
164 h_nROIs_L2.write(output_tfile)
166 h_drf = ValidationPlot('h_drf')
167 h_drf.hist(self.drf, bins=100, lower_bound=0, upper_bound=1)
168 h_drf.contact = contact
169 h_drf.check = 'with no bkg, the average should be around 70%'
170 h_drf.description = 'Fraction of PXDDDigits inside ROIs'
171 h_drf.title = 'Fraction of PXDDDigits inside ROIs'
174 h_drf.write(output_tfile)
176 h_statU_L1 = ValidationPlot('h_statU_L1')
177 h_statU_L1.hist(self.statU_L1, bins=100, lower_bound=0, upper_bound=0.2)
178 h_statU_L1.contact = contact
179 h_statU_L1.check = 'average should be around 0.021 cm'
180 h_statU_L1.description = 'Statistical Error of the Intercept on L1 planes, along U'
181 h_statU_L1.title = 'L1 Intercept Statistical Uncertainty along U'
182 h_statU_L1.xlabel = 'U stat uncertainty'
183 h_statU_L1.ylabel = ''
184 h_statU_L1.write(output_tfile)
186 h_statV_L1 = ValidationPlot('h_statV_L1')
187 h_statV_L1.hist(self.statV_L1, bins=100, lower_bound=0, upper_bound=0.2)
188 h_statV_L1.contact = contact
189 h_statV_L1.check = 'average should be around 0.021 cm'
190 h_statV_L1.description = 'Statistical Error of the Intercept on L1 planes, along V'
191 h_statV_L1.title = 'L1 Intercept Statistical Uncertainty along V'
192 h_statV_L1.xlabel = 'V stat uncertainty (cm)'
193 h_statV_L1.ylabel = ''
194 h_statV_L1.write(output_tfile)
196 h_statU_L2 = ValidationPlot('h_statU_L2')
197 h_statU_L2.hist(self.statU_L2, bins=100, lower_bound=0, upper_bound=0.2)
198 h_statU_L2.contact = contact
199 h_statU_L2.check = 'average should be around 0.015 cm'
200 h_statU_L2.description = 'Statistical Error of the Intercept on L2 planes, along U'
201 h_statU_L2.title = 'L2 Intercept Statistical Uncertainty along U'
202 h_statU_L2.xlabel = 'U stat uncertainty (cm)'
203 h_statU_L2.ylabel = ''
204 h_statU_L2.write(output_tfile)
206 h_statV_L2 = ValidationPlot('h_statV_L2')
207 h_statV_L2.hist(self.statV_L2, bins=100, lower_bound=0, upper_bound=0.2)
208 h_statV_L2.contact = contact
209 h_statV_L2.check = 'average should be around 0.016 cm'
210 h_statV_L2.description = 'Statistical Error of the Intercept on L2 planes, along V'
211 h_statV_L2.title = 'L2 Intercept Statistical Uncertainty along V'
212 h_statV_L2.xlabel = 'V stat uncertainty (cm)'
213 h_statV_L2.ylabel = ''
214 h_statV_L2.write(output_tfile)
220 basf2.set_random_seed(1509)
222 path = basf2.create_path()
224 path.add_module('EventInfoSetter', evtNumList=N_EVENTS)
225 add_evtgen_for_validation(path)
226 add_simulation(path, forceSetPXDDataReduction=True, usePXDDataReduction=False)
227 add_svd_reconstruction(path, isROIsimulation=True)
229 pxd_unfiltered_digits = 'PXDDigits'
230 pxd_filtered_digits = 'filteredPXDDigits'
233 svd_reco_tracks = '__ROIsvdRecoTracks'
234 add_tracking_for_PXDDataReduction_simulation(path, ['SVD', 'CDC'], '__ROIsvdClusters') # CDC is not used at the moment!
237 pxdDataRed = basf2.register_module('PXDROIFinder')
239 'recoTrackListName': svd_reco_tracks,
240 'PXDInterceptListName': 'PXDIntercepts',
241 'ROIListName': 'ROIs',
243 pxdDataRed.param(param_pxdDataRed)
244 path.add_module(pxdDataRed)
246 # Filtering of PXDDigits
247 pxd_digifilter = basf2.register_module('PXDdigiFilter')
248 pxd_digifilter.param('ROIidsName', 'ROIs')
249 pxd_digifilter.param('PXDDigitsName', pxd_unfiltered_digits)
250 pxd_digifilter.param('PXDDigitsInsideROIName', pxd_filtered_digits)
251 pxd_digifilter.param('PXDDigitsOutsideROIName', 'PXDDigitsOutside')
252 path.add_module(pxd_digifilter)
254 ROIValidationPlots = ROIFindingTrackingValidationPlots()
255 path.add_module(ROIValidationPlots)
257 path.add_module('Progress')
263if __name__ == '__main__':
267 print("This validation deactivated and thus basf2 is not executed.\n"
268 "If you want to run this validation, please set the 'ACTIVE' flag above to 'True'.\n"