16 from ROOT
import Belle2
23 def setup_Geometry(path=None):
25 Sets the geometry. Should be used in all VXDTF2 related scripts to ensure to use the same geometry in all
26 trainings / validation steps!
27 param path: the path to append the geometry
31 basf2.B2WARNING(
"This function is deprecated and should not be used anymore! The geometry should now be loaded from the DB")
34 def setup_VXDTF2(path=None,
37 filter_overlapping=True,
38 use_segment_network_filters=True,
40 quality_estimator='circleFit',
41 overlap_filter='greedy',
43 setup_name='SVDOnlyDefault',
44 log_level=LogLevel.INFO,
47 Convenience Method to setup the redesigned vxd track finding module chain.
48 Reuslt is a store array containing reco tracks called 'RecoTracks'.
49 :param path: basf2.Path
50 :param sec_map_file: training data for segment network.
51 :param setup_name: name of the setup within all the sectormaps in the sec_map_file which should be used,
52 :param use_pxd: if true use pxd hits. Default False.
53 :param use_svd: if true use svd hits. Default True.
54 :param quality_estimator: which fit to use to determine track quality. Options 'circle', 'random'. Default 'circle'.
55 :param filter_overlapping: if true overlapping tracks are reduced to a single track using the qualitiy indicator.
56 :param use_segment_network_filters: if true use filters for segmentMap training. Default True.
57 :param observe_network_filters: FOR DEBUG ONLY! If true results for FilterVariables are stored to a root file. Default False.
58 :param overlap_filter: which filter network to use. Options 'hopfield', 'greedy'. Default 'hopfield'.
59 :param log_level: LogLevel of all modules in the chain
60 :param debug_level: debug level of all modules in the chain.
72 spCreatorPXD = register_module(
'PXDSpacePointCreator')
73 spCreatorPXD.logging.log_level = log_level
74 spCreatorPXD.logging.debug_level = debug_level
75 spCreatorPXD.param(
'NameOfInstance',
'PXDSpacePoints')
76 spCreatorPXD.param(
'SpacePoints',
'SpacePoints')
77 modules.append(spCreatorPXD)
80 spCreatorSVD = register_module(
'SVDSpacePointCreator')
81 spCreatorSVD.logging.log_level = log_level
82 spCreatorSVD.logging.debug_level = debug_level
83 spCreatorSVD.param(
'OnlySingleClusterSpacePoints',
False)
84 spCreatorSVD.param(
'NameOfInstance',
'SVDSpacePoints')
85 spCreatorSVD.param(
'SpacePoints',
'SpacePoints')
86 modules.append(spCreatorSVD)
89 secMapBootStrap = register_module(
'SectorMapBootstrap')
90 secMapBootStrap.param(
'ReadSectorMap',
True)
92 secMapBootStrap.param(
'SectorMapsInputFile', sec_map_file)
93 secMapBootStrap.param(
'WriteSectorMap',
False)
94 secMapBootStrap.param(
'SetupToRead',
"")
95 modules.append(secMapBootStrap)
102 segNetProducer = register_module(
'SegmentNetworkProducer')
103 segNetProducer.param(
'CreateNeworks', 3)
104 segNetProducer.param(
'NetworkOutputName',
'test2Hits')
105 segNetProducer.param(
'allFiltersOff',
not use_segment_network_filters)
106 segNetProducer.param(
'SpacePointsArrayNames', [
'SpacePoints'])
107 segNetProducer.param(
'printNetworks',
False)
108 segNetProducer.param(
'sectorMapName', setup_name)
109 segNetProducer.param(
'addVirtualIP',
False)
110 segNetProducer.param(
'observerType', observerType)
111 segNetProducer.logging.log_level = log_level
112 segNetProducer.logging.debug_level = debug_level
113 modules.append(segNetProducer)
120 cellOmat = register_module(
'TrackFinderVXDCellOMat')
121 cellOmat.param(
'NetworkName',
'test2Hits')
122 cellOmat.param(
'SpacePointTrackCandArrayName',
'SPTCs')
123 cellOmat.param(
'printNetworks',
False)
124 cellOmat.param(
'strictSeeding',
True)
125 cellOmat.logging.log_level = log_level
126 cellOmat.logging.debug_level = debug_level
127 modules.append(cellOmat)
136 qualityEstimator = register_module(
'QualityEstimatorVXD')
137 qualityEstimator.param(
'EstimationMethod', quality_estimator)
138 qualityEstimator.param(
'SpacePointTrackCandsStoreArrayName',
'SPTCs')
139 qualityEstimator.logging.log_level = log_level
140 qualityEstimator.logging.debug_level = debug_level
141 modules.append(qualityEstimator)
143 maxCandidateSelection = register_module(
'BestVXDTrackCandidatesSelector')
144 maxCandidateSelection.param(
'NameSpacePointTrackCands',
'SPTCs')
145 maxCandidateSelection.param(
'SubsetCreation',
True)
146 maxCandidateSelection.param(
'NewNameSpacePointTrackCands',
'')
147 maxCandidateSelection.logging.log_level = log_level
148 maxCandidateSelection.logging.debug_level = debug_level
149 modules.append(maxCandidateSelection)
152 vIPRemover = register_module(
'SPTCvirtualIPRemover')
153 vIPRemover.param(
'tcArrayName',
'')
154 vIPRemover.param(
'maxTCLengthForVIPKeeping', 0)
155 vIPRemover.logging.log_level = log_level
156 vIPRemover.logging.debug_level = debug_level
157 modules.append(vIPRemover)
164 if filter_overlapping:
165 overlapResolver = register_module(
'SVDOverlapResolver')
166 overlapResolver.logging.log_level = log_level
167 overlapResolver.logging.debug_level = debug_level
168 overlapResolver.param(
'NameSpacePointTrackCands',
'')
169 overlapResolver.param(
'ResolveMethod', overlap_filter.lower())
170 overlapResolver.param(
'NameSVDClusters',
'')
171 modules.append(overlapResolver)
177 momSeedRetriever = register_module(
'SPTCmomentumSeedRetriever')
178 momSeedRetriever.param(
'tcArrayName',
'')
179 momSeedRetriever.logging.log_level = log_level
180 momSeedRetriever.logging.debug_level = debug_level
181 modules.append(momSeedRetriever)
183 converter = register_module(
'SPTC2RTConverter')
184 converter.param(
'spacePointsTCsStoreArrayName',
'')
185 converter.logging.log_level = log_level
186 converter.logging.debug_level = debug_level
187 modules.append(converter)
190 for module
in modules:
191 path.add_module(module)
196 def setup_RTCtoSPTCConverters(
198 SVDSPscollection='SVDSpacePoints',
199 PXDSPscollection='PXDSpacePoints',
201 sptcOutput='checkedSPTCs',
203 logLevel=LogLevel.INFO,
206 useOnlyFittedTracks=False):
207 """This function adds the modules needed to convert Reco-TCs to SpacePointTCs to given path.
209 @param path if set to 0 (standard) the created modules will not be added, but returned.
210 If a path is given, 'None' is returned but will be added to given path instead.
212 @param SPscollection the name of the storeArray containing SPs of both SVD and PXD.
214 @param RTCinput defines the name of input-Reco-TCs.
216 @param sptcOutput defines the name of output-SPTCs.
218 @param usePXD If False pxdClusters are ignored.
220 @param logLevel set to logLevel level of your choice.
222 @param debugVal set to debugLevel of choice - will be ignored if logLevel is not set to LogLevel.DEBUG
224 @param useNoKick enable the training sample selection based on track parameters (and produce a TFile of its effect)
226 @param useOnlyFittedTracks: if True only fitted RecoTracks will be transformed to SpacePointTrackCands
228 print(
"setup RTCtoSPTCConverters...")
235 detectorTypes.append(
'PXD')
237 spacePointNames.append(PXDSPscollection)
238 trueHitNames.append(
'')
239 clusterNames.append(
'')
241 spacePointNames.append(SVDSPscollection)
242 detectorTypes.append(
'SVD')
243 trueHitNames.append(
'')
244 clusterNames.append(
'')
248 sp2thConnector = register_module(
'SpacePoint2TrueHitConnector')
249 sp2thConnector.logging.log_level = logLevel
250 sp2thConnector.param(
'DetectorTypes', detectorTypes)
251 sp2thConnector.param(
'TrueHitNames', trueHitNames)
252 sp2thConnector.param(
'ClusterNames', clusterNames)
253 sp2thConnector.param(
'SpacePointNames', spacePointNames)
254 sp2thConnector.param(
'outputSuffix',
'_relTH')
255 sp2thConnector.param(
'storeSeperate',
False)
256 sp2thConnector.param(
'registerAll',
False)
257 sp2thConnector.param(
'maxGlobalPosDiff', 0.05)
258 sp2thConnector.param(
'maxPosSigma', 5)
259 sp2thConnector.param(
'minWeight', 0)
260 sp2thConnector.param(
'requirePrimary',
True)
261 sp2thConnector.param(
'positionAnalysis',
False)
264 recoTrackCandConverter = register_module(
'RT2SPTCConverter')
265 recoTrackCandConverter.logging.log_level = logLevel
266 recoTrackCandConverter.param(
'RecoTracksName', RTCinput)
267 recoTrackCandConverter.param(
'SpacePointTCName',
'SPTracks')
268 recoTrackCandConverter.param(
'SVDSpacePointStoreArrayName', SVDSPscollection)
269 recoTrackCandConverter.param(
'PXDSpacePointStoreArrayName',
None)
271 recoTrackCandConverter.param(
'PXDSpacePointStoreArrayName', PXDSPscollection)
272 recoTrackCandConverter.param(
'useTrueHits',
True)
273 recoTrackCandConverter.param(
'ignorePXDHits',
not usePXD)
274 recoTrackCandConverter.param(
'useSingleClusterSP',
False)
275 recoTrackCandConverter.param(
'minSP', 3)
276 recoTrackCandConverter.param(
'skipProblematicCluster',
False)
277 recoTrackCandConverter.param(
'convertFittedOnly', useOnlyFittedTracks)
279 if os.environ.get(
'USE_BEAST2_GEOMETRY'):
285 recoTrackCandConverter.param(
'noKickCutsFile', NoKickCuts)
286 recoTrackCandConverter.param(
'noKickOutput',
True)
288 recoTrackCandConverter.param(
'noKickCutsFile',
"")
291 sptcReferee = register_module(
'SPTCReferee')
292 sptcReferee.logging.log_level = logLevel
293 sptcReferee.param(
'sptcName',
'SPTracks')
294 sptcReferee.param(
'newArrayName', sptcOutput)
295 sptcReferee.param(
'storeNewArray',
True)
296 sptcReferee.param(
'checkCurling',
True)
297 sptcReferee.param(
'splitCurlers',
True)
298 sptcReferee.param(
'keepOnlyFirstPart',
True)
299 sptcReferee.param(
'kickSpacePoint',
True)
300 sptcReferee.param(
'checkSameSensor',
True)
301 sptcReferee.param(
'useMCInfo',
True)
305 return [sp2thConnector, recoTrackCandConverter, sptcReferee]
307 path.add_module(sp2thConnector)
308 path.add_module(recoTrackCandConverter)
309 path.add_module(sptcReferee)
313 def setup_sim(path=0, useEDeposit=True, useMultipleScattering=True, allowDecay=True, verbose=False):
314 """This function adds the g4simulation to given path.
316 @param path if set to 0 (standard) g4sim will not be added, but returned.
317 If a path is given, 'None' is returned but will be added to given path instead.
319 @param useEDeposit if False, particles will not have eDeposit. WARMING: if you still want to get hits for that case:
320 useEDeposit: If you want to work w/o E-deposit, edit pxd/data/PXD.xml and svd/data/SVD.xml,
321 where you have to activate see neutrons = true.
323 @param useMultipleScattering if False, multiple scattering in matter is deactivated.
325 @param allowDecay if False, particles can not decay.
327 @param verbose if True, some extra debug output is given.
329 print(
"setup FullSim...")
330 g4sim = register_module(
'FullSim')
331 g4sim.param(
'StoreAllSecondaries',
True)
334 uiCommandList.append(
'/process/list')
336 uiCommandList.append(
'/process/inactivate Decay all')
338 uiCommandList.append(
'/process/inactivate StepLimiter all')
339 uiCommandList.append(
'/process/inactivate muIoni all')
340 uiCommandList.append(
'/process/inactivate hIoni all')
341 uiCommandList.append(
'/process/inactivate ionIoni all')
342 uiCommandList.append(
'/process/inactivate eIoni all')
343 uiCommandList.append(
'/process/inactivate eBrem all')
344 uiCommandList.append(
'/process/inactivate hBrems all')
345 uiCommandList.append(
'/process/inactivate muBrems all')
346 uiCommandList.append(
'/process/inactivate hPairProd all')
347 uiCommandList.append(
'/process/inactivate muPairProd all')
348 uiCommandList.append(
'/process/inactivate annihil all')
349 uiCommandList.append(
'/process/inactivate phot all')
350 uiCommandList.append(
'/process/inactivate compt all')
351 uiCommandList.append(
'/process/inactivate conv all')
354 uiCommandList.append(
'/process/inactivate electronNuclear all')
355 uiCommandList.append(
'/process/inactivate positronNuclear all')
356 uiCommandList.append(
'/process/inactivate muonNuclear all')
357 uiCommandList.append(
'/process/inactivate photonNuclear all')
358 uiCommandList.append(
'/process/inactivate Decay all')
359 uiCommandList.append(
'/process/inactivate hadElastic all')
360 uiCommandList.append(
'/process/inactivate neutronInelastic all')
361 uiCommandList.append(
'/process/inactivate nCapture all')
362 uiCommandList.append(
'/process/inactivate nFission all')
363 uiCommandList.append(
'/process/inactivate protonInelastic all')
364 uiCommandList.append(
'/process/inactivate ionInelastic all')
365 uiCommandList.append(
'/process/inactivate pi+Inelastic all')
366 uiCommandList.append(
'/process/inactivate pi-Inelastic all')
367 uiCommandList.append(
'/process/inactivate kaon+Inelastic all')
368 uiCommandList.append(
'/process/inactivate kaon-Inelastic all')
369 uiCommandList.append(
'/process/inactivate kaon0LInelastic all')
370 uiCommandList.append(
'/process/inactivate kaon0SInelastic all')
371 uiCommandList.append(
'/process/inactivate anti_protonInelastic all')
372 uiCommandList.append(
'/process/inactivate anti_neutronInelastic all')
373 uiCommandList.append(
'/process/inactivate lambdaInelastic all')
374 uiCommandList.append(
'/process/inactivate anti-lambdaInelastic all')
375 uiCommandList.append(
'/process/inactivate sigma-Inelastic all')
376 uiCommandList.append(
'/process/inactivate anti_sigma-Inelastic all')
377 uiCommandList.append(
'/process/inactivate sigma+Inelastic all')
378 uiCommandList.append(
'/process/inactivate anti_sigma+Inelastic all')
379 uiCommandList.append(
'/process/inactivate xi-Inelastic all')
380 uiCommandList.append(
'/process/inactivate anti_xi-Inelastic all')
381 uiCommandList.append(
'/process/inactivate xi0Inelastic all')
382 uiCommandList.append(
'/process/inactivate anti_xi0Inelastic all')
383 uiCommandList.append(
'/process/inactivate omega-Inelastic all')
384 uiCommandList.append(
'/process/inactivate anti_omega-Inelastic all')
386 uiCommandList.append(
'/process/inactivate hFritiofCaptureAtRest all')
387 uiCommandList.append(
'/process/inactivate hBertiniCaptureAtRest all')
388 uiCommandList.append(
'/process/inactivate muMinusCaptureAtRest all')
389 uiCommandList.append(
'/process/inactivate dInelastic all')
390 uiCommandList.append(
'/process/inactivate anti_deuteronInelastic all')
391 uiCommandList.append(
'/process/inactivate tInelastic all')
392 uiCommandList.append(
'/process/inactivate anti_tritonInelastic all')
393 uiCommandList.append(
'/process/inactivate He3Inelastic all')
394 uiCommandList.append(
'/process/inactivate anti_He3Inelastic all')
395 uiCommandList.append(
'/process/inactivate alphaInelastic all')
396 uiCommandList.append(
'/process/inactivate anti_alphaInelastic all')
397 uiCommandList.append(
'/process/inactivate ExtEnergyLoss all')
398 uiCommandList.append(
'/process/inactivate OpAbsorption all')
399 uiCommandList.append(
'/process/inactivate OpRayleigh all')
400 uiCommandList.append(
'/process/inactivate OpMieHG all')
401 uiCommandList.append(
'/process/inactivate OpBoundary all')
402 uiCommandList.append(
'/process/inactivate OpWLS all')
403 uiCommandList.append(
'/process/inactivate Cerenkov all')
404 uiCommandList.append(
'/process/inactivate Scintillation all')
406 if not useMultipleScattering:
407 uiCommandList.append(
'/process/inactivate msc all')
408 uiCommandList.append(
'/process/inactivate CoulombScat all')
413 uiCommandList.append(
'/particle/select pi+')
414 uiCommandList.append(
'/particle/process/dump')
415 uiCommandList.append(
'/particle/select pi-')
416 uiCommandList.append(
'/particle/process/dump')
417 uiCommandList.append(
'/particle/select e+')
418 uiCommandList.append(
'/particle/process/dump')
419 uiCommandList.append(
'/particle/select e-')
420 uiCommandList.append(
'/particle/process/dump')
421 uiCommandList.append(
'/particle/select mu+')
422 uiCommandList.append(
'/particle/process/dump')
423 uiCommandList.append(
'/particle/select mu-')
424 uiCommandList.append(
'/particle/select kaon+')
425 uiCommandList.append(
'/particle/process/dump')
426 uiCommandList.append(
'/particle/select kaon-')
427 uiCommandList.append(
'/particle/process/dump')
428 g4sim.param(
'UICommandsAtIdle', uiCommandList)
434 path.add_module(g4sim)