21from ROOT
import Belle2
28def setup_Geometry(path=None):
30 Sets the geometry. Should be used in all VXDTF2 related scripts to ensure to use the same geometry
in all
31 trainings / validation steps!
32 param path: the path to append the geometry
36 b2.B2WARNING("This function is deprecated and should not be used anymore! The geometry should now be loaded from the DB")
39def setup_VXDTF2(path=None,
42 filter_overlapping=True,
43 use_segment_network_filters=True,
45 quality_estimator='circleFit',
46 overlap_filter='greedy',
48 setup_name='SVDOnlyDefault',
49 log_level=b2.LogLevel.INFO,
52 Convenience Method to setup the redesigned vxd track finding module chain.
53 Reuslt is a store array containing reco tracks called
'RecoTracks'.
54 :param path: basf2.Path
55 :param sec_map_file: training data
for segment network.
56 :param setup_name: name of the setup within all the sectormaps
in the sec_map_file which should be used,
57 :param use_pxd:
if true use pxd hits. Default
False.
58 :param use_svd:
if true use svd hits. Default
True.
59 :param quality_estimator: which fit to use to determine track quality. Options
'circle',
'random'. Default
'circle'.
60 :param filter_overlapping:
if true overlapping tracks are reduced to a single track using the qualitiy indicator.
61 :param use_segment_network_filters:
if true use filters
for segmentMap training. Default
True.
62 :param observe_network_filters: FOR DEBUG ONLY! If true results
for FilterVariables are stored to a root file. Default
False.
63 :param overlap_filter: which filter network to use. Options
'hopfield',
'greedy'. Default
'hopfield'.
64 :param log_level: LogLevel of all modules
in the chain
65 :param debug_level: debug level of all modules
in the chain.
77 spCreatorPXD = b2.register_module(
'PXDSpacePointCreator')
78 spCreatorPXD.logging.log_level = log_level
79 spCreatorPXD.logging.debug_level = debug_level
80 spCreatorPXD.param(
'NameOfInstance',
'PXDSpacePoints')
81 spCreatorPXD.param(
'SpacePoints',
'SpacePoints')
82 modules.append(spCreatorPXD)
85 spCreatorSVD = b2.register_module(
'SVDSpacePointCreator')
86 spCreatorSVD.logging.log_level = log_level
87 spCreatorSVD.logging.debug_level = debug_level
88 spCreatorSVD.param(
'OnlySingleClusterSpacePoints',
False)
89 spCreatorSVD.param(
'NameOfInstance',
'SVDSpacePoints')
90 spCreatorSVD.param(
'SpacePoints',
'SpacePoints')
91 modules.append(spCreatorSVD)
94 secMapBootStrap = b2.register_module(
'SectorMapBootstrap')
95 secMapBootStrap.param(
'ReadSectorMap',
True)
97 secMapBootStrap.param(
'SectorMapsInputFile', sec_map_file)
98 secMapBootStrap.param(
'WriteSectorMap',
False)
99 secMapBootStrap.param(
'SetupToRead',
"")
100 modules.append(secMapBootStrap)
103 regEventLevelTrackingInfo = b2.register_module(
'RegisterEventLevelTrackingInfo')
104 modules.append(regEventLevelTrackingInfo)
111 segNetProducer = b2.register_module(
'SegmentNetworkProducer')
113 segNetProducer.param(
'NetworkOutputName',
'test2Hits')
114 segNetProducer.param(
'allFiltersOff',
not use_segment_network_filters)
115 segNetProducer.param(
'SpacePointsArrayNames', [
'SpacePoints'])
116 segNetProducer.param(
'printNetworks',
False)
117 segNetProducer.param(
'sectorMapName', setup_name)
118 segNetProducer.param(
'addVirtualIP',
False)
120 segNetProducer.logging.log_level = log_level
121 segNetProducer.logging.debug_level = debug_level
122 modules.append(segNetProducer)
129 cellOmat = b2.register_module(
'TrackFinderVXDCellOMat')
130 cellOmat.param(
'NetworkName',
'test2Hits')
131 cellOmat.param(
'SpacePointTrackCandArrayName',
'SPTCs')
132 cellOmat.param(
'printNetworks',
False)
133 cellOmat.param(
'strictSeeding',
True)
134 cellOmat.logging.log_level = log_level
135 cellOmat.logging.debug_level = debug_level
136 modules.append(cellOmat)
145 qualityEstimator = b2.register_module(
'QualityEstimatorVXD')
146 qualityEstimator.param(
'EstimationMethod', quality_estimator)
147 qualityEstimator.param(
'SpacePointTrackCandsStoreArrayName',
'SPTCs')
148 qualityEstimator.logging.log_level = log_level
149 qualityEstimator.logging.debug_level = debug_level
150 modules.append(qualityEstimator)
152 maxCandidateSelection = b2.register_module(
'BestVXDTrackCandidatesSelector')
153 maxCandidateSelection.param(
'NameSpacePointTrackCands',
'SPTCs')
154 maxCandidateSelection.param(
'SubsetCreation',
True)
155 maxCandidateSelection.param(
'NewNameSpacePointTrackCands',
'')
156 maxCandidateSelection.logging.log_level = log_level
157 maxCandidateSelection.logging.debug_level = debug_level
158 modules.append(maxCandidateSelection)
161 vIPRemover = b2.register_module(
'SPTCvirtualIPRemover')
162 vIPRemover.param(
'tcArrayName',
'')
163 vIPRemover.param(
'maxTCLengthForVIPKeeping', 0)
164 vIPRemover.logging.log_level = log_level
165 vIPRemover.logging.debug_level = debug_level
166 modules.append(vIPRemover)
173 if filter_overlapping:
174 overlapResolver = b2.register_module(
'SVDOverlapResolver')
175 overlapResolver.logging.log_level = log_level
176 overlapResolver.logging.debug_level = debug_level
177 overlapResolver.param(
'NameSpacePointTrackCands',
'')
178 overlapResolver.param(
'ResolveMethod', overlap_filter.lower())
179 overlapResolver.param(
'NameSVDClusters',
'')
180 modules.append(overlapResolver)
186 momSeedRetriever = b2.register_module(
'SPTCmomentumSeedRetriever')
187 momSeedRetriever.param(
'tcArrayName',
'')
188 momSeedRetriever.logging.log_level = log_level
189 momSeedRetriever.logging.debug_level = debug_level
190 modules.append(momSeedRetriever)
192 converter = b2.register_module(
'SPTC2RTConverter')
193 converter.param(
'spacePointsTCsStoreArrayName',
'')
194 converter.logging.log_level = log_level
195 converter.logging.debug_level = debug_level
196 modules.append(converter)
199 for module
in modules:
200 path.add_module(module)
205def setup_RTCtoSPTCConverters(
207 SVDSPscollection='SVDSpacePoints',
208 PXDSPscollection='PXDSpacePoints',
210 sptcOutput='checkedSPTCs',
212 logLevel=b2.LogLevel.INFO,
215 useOnlyFittedTracks=False):
216 """This function adds the modules needed to convert Reco-TCs to SpacePointTCs to given path.
218 @param path
if set to 0 (standard) the created modules will
not be added, but returned.
219 If a path
is given,
'None' is returned but will be added to given path instead.
221 @param SPscollection the name of the storeArray containing SPs of both SVD
and PXD.
223 @param RTCinput defines the name of input-Reco-TCs.
225 @param sptcOutput defines the name of output-SPTCs.
227 @param usePXD If
False pxdClusters are ignored.
229 @param logLevel set to logLevel level of your choice.
231 @param debugVal set to debugLevel of choice - will be ignored
if logLevel
is not set to LogLevel.DEBUG
233 @param useNoKick enable the training sample selection based on track parameters (
and produce a TFile of its effect)
235 @param useOnlyFittedTracks:
if True only fitted RecoTracks will be transformed to SpacePointTrackCands
237 print("setup RTCtoSPTCConverters...")
244 detectorTypes.append(
'PXD')
246 spacePointNames.append(PXDSPscollection)
247 trueHitNames.append(
'')
248 clusterNames.append(
'')
250 spacePointNames.append(SVDSPscollection)
251 detectorTypes.append(
'SVD')
252 trueHitNames.append(
'')
253 clusterNames.append(
'')
257 sp2thConnector = b2.register_module(
'SpacePoint2TrueHitConnector')
258 sp2thConnector.logging.log_level = logLevel
259 sp2thConnector.param(
'DetectorTypes', detectorTypes)
260 sp2thConnector.param(
'TrueHitNames', trueHitNames)
261 sp2thConnector.param(
'ClusterNames', clusterNames)
262 sp2thConnector.param(
'SpacePointNames', spacePointNames)
263 sp2thConnector.param(
'outputSuffix',
'_relTH')
264 sp2thConnector.param(
'storeSeperate',
False)
265 sp2thConnector.param(
'registerAll',
False)
266 sp2thConnector.param(
'maxGlobalPosDiff', 0.05)
267 sp2thConnector.param(
'maxPosSigma', 5)
268 sp2thConnector.param(
'minWeight', 0)
269 sp2thConnector.param(
'requirePrimary',
True)
270 sp2thConnector.param(
'positionAnalysis',
False)
273 recoTrackCandConverter = b2.register_module(
'RT2SPTCConverter')
274 recoTrackCandConverter.logging.log_level = logLevel
275 recoTrackCandConverter.param(
'RecoTracksName', RTCinput)
276 recoTrackCandConverter.param(
'SpacePointTCName',
'SPTracks')
277 recoTrackCandConverter.param(
'SVDSpacePointStoreArrayName', SVDSPscollection)
278 recoTrackCandConverter.param(
'PXDSpacePointStoreArrayName',
None)
280 recoTrackCandConverter.param(
'PXDSpacePointStoreArrayName', PXDSPscollection)
281 recoTrackCandConverter.param(
'useTrueHits',
True)
282 recoTrackCandConverter.param(
'ignorePXDHits',
not usePXD)
283 recoTrackCandConverter.param(
'useSingleClusterSP',
False)
284 recoTrackCandConverter.param(
'minSP', 3)
285 recoTrackCandConverter.param(
'skipProblematicCluster',
False)
286 recoTrackCandConverter.param(
'convertFittedOnly', useOnlyFittedTracks)
288 if os.environ.get(
'USE_BEAST2_GEOMETRY'):
294 recoTrackCandConverter.param(
'noKickCutsFile', NoKickCuts)
295 recoTrackCandConverter.param(
'noKickOutput',
True)
297 recoTrackCandConverter.param(
'noKickCutsFile',
"")
300 sptcReferee = b2.register_module(
'SPTCReferee')
301 sptcReferee.logging.log_level = logLevel
302 sptcReferee.param(
'sptcName',
'SPTracks')
303 sptcReferee.param(
'newArrayName', sptcOutput)
304 sptcReferee.param(
'storeNewArray',
True)
305 sptcReferee.param(
'checkCurling',
True)
306 sptcReferee.param(
'splitCurlers',
True)
307 sptcReferee.param(
'keepOnlyFirstPart',
True)
308 sptcReferee.param(
'kickSpacePoint',
True)
309 sptcReferee.param(
'checkSameSensor',
True)
310 sptcReferee.param(
'useMCInfo',
True)
314 return [sp2thConnector, recoTrackCandConverter, sptcReferee]
316 path.add_module(sp2thConnector)
317 path.add_module(recoTrackCandConverter)
318 path.add_module(sptcReferee)
322def setup_sim(path=0, useEDeposit=True, useMultipleScattering=True, allowDecay=True, verbose=False):
323 """This function adds the g4simulation to given path.
325 @param path
if set to 0 (standard) g4sim will
not be added, but returned.
326 If a path
is given,
'None' is returned but will be added to given path instead.
328 @param useEDeposit
if False, particles will
not have eDeposit. WARMING:
if you still want to get hits
for that case:
329 useEDeposit: If you want to work w/o E-deposit, edit pxd/data/PXD.xml
and svd/data/SVD.xml,
330 where you have to activate see neutrons = true.
332 @param useMultipleScattering
if False, multiple scattering
in matter
is deactivated.
334 @param allowDecay
if False, particles can
not decay.
336 @param verbose
if True, some extra debug output
is given.
338 print("setup FullSim...")
339 g4sim = b2.register_module(
'FullSim')
340 g4sim.param(
'StoreAllSecondaries',
True)
343 uiCommandList.append(
'/process/list')
345 uiCommandList.append(
'/process/inactivate Decay all')
347 uiCommandList.append(
'/process/inactivate StepLimiter all')
348 uiCommandList.append(
'/process/inactivate muIoni all')
349 uiCommandList.append(
'/process/inactivate hIoni all')
350 uiCommandList.append(
'/process/inactivate ionIoni all')
351 uiCommandList.append(
'/process/inactivate eIoni all')
352 uiCommandList.append(
'/process/inactivate eBrem all')
353 uiCommandList.append(
'/process/inactivate hBrems all')
354 uiCommandList.append(
'/process/inactivate muBrems all')
355 uiCommandList.append(
'/process/inactivate hPairProd all')
356 uiCommandList.append(
'/process/inactivate muPairProd all')
357 uiCommandList.append(
'/process/inactivate annihil all')
358 uiCommandList.append(
'/process/inactivate phot all')
359 uiCommandList.append(
'/process/inactivate compt all')
360 uiCommandList.append(
'/process/inactivate conv all')
363 uiCommandList.append(
'/process/inactivate electronNuclear all')
364 uiCommandList.append(
'/process/inactivate positronNuclear all')
365 uiCommandList.append(
'/process/inactivate muonNuclear all')
366 uiCommandList.append(
'/process/inactivate photonNuclear all')
367 uiCommandList.append(
'/process/inactivate Decay all')
368 uiCommandList.append(
'/process/inactivate hadElastic all')
369 uiCommandList.append(
'/process/inactivate neutronInelastic all')
370 uiCommandList.append(
'/process/inactivate nCapture all')
371 uiCommandList.append(
'/process/inactivate nFission all')
372 uiCommandList.append(
'/process/inactivate protonInelastic all')
373 uiCommandList.append(
'/process/inactivate ionInelastic all')
374 uiCommandList.append(
'/process/inactivate pi+Inelastic all')
375 uiCommandList.append(
'/process/inactivate pi-Inelastic all')
376 uiCommandList.append(
'/process/inactivate kaon+Inelastic all')
377 uiCommandList.append(
'/process/inactivate kaon-Inelastic all')
378 uiCommandList.append(
'/process/inactivate kaon0LInelastic all')
379 uiCommandList.append(
'/process/inactivate kaon0SInelastic all')
380 uiCommandList.append(
'/process/inactivate anti_protonInelastic all')
381 uiCommandList.append(
'/process/inactivate anti_neutronInelastic all')
382 uiCommandList.append(
'/process/inactivate lambdaInelastic all')
383 uiCommandList.append(
'/process/inactivate anti-lambdaInelastic all')
384 uiCommandList.append(
'/process/inactivate sigma-Inelastic all')
385 uiCommandList.append(
'/process/inactivate anti_sigma-Inelastic all')
386 uiCommandList.append(
'/process/inactivate sigma+Inelastic all')
387 uiCommandList.append(
'/process/inactivate anti_sigma+Inelastic all')
388 uiCommandList.append(
'/process/inactivate xi-Inelastic all')
389 uiCommandList.append(
'/process/inactivate anti_xi-Inelastic all')
390 uiCommandList.append(
'/process/inactivate xi0Inelastic all')
391 uiCommandList.append(
'/process/inactivate anti_xi0Inelastic all')
392 uiCommandList.append(
'/process/inactivate omega-Inelastic all')
393 uiCommandList.append(
'/process/inactivate anti_omega-Inelastic all')
395 uiCommandList.append(
'/process/inactivate hFritiofCaptureAtRest all')
396 uiCommandList.append(
'/process/inactivate hBertiniCaptureAtRest all')
397 uiCommandList.append(
'/process/inactivate muMinusCaptureAtRest all')
398 uiCommandList.append(
'/process/inactivate dInelastic all')
399 uiCommandList.append(
'/process/inactivate anti_deuteronInelastic all')
400 uiCommandList.append(
'/process/inactivate tInelastic all')
401 uiCommandList.append(
'/process/inactivate anti_tritonInelastic all')
402 uiCommandList.append(
'/process/inactivate He3Inelastic all')
403 uiCommandList.append(
'/process/inactivate anti_He3Inelastic all')
404 uiCommandList.append(
'/process/inactivate alphaInelastic all')
405 uiCommandList.append(
'/process/inactivate anti_alphaInelastic all')
406 uiCommandList.append(
'/process/inactivate ExtEnergyLoss all')
407 uiCommandList.append(
'/process/inactivate OpAbsorption all')
408 uiCommandList.append(
'/process/inactivate OpRayleigh all')
409 uiCommandList.append(
'/process/inactivate OpMieHG all')
410 uiCommandList.append(
'/process/inactivate OpBoundary all')
411 uiCommandList.append(
'/process/inactivate OpWLS all')
412 uiCommandList.append(
'/process/inactivate Cerenkov all')
413 uiCommandList.append(
'/process/inactivate Scintillation all')
415 if not useMultipleScattering:
416 uiCommandList.append(
'/process/inactivate msc all')
417 uiCommandList.append(
'/process/inactivate CoulombScat all')
422 uiCommandList.append(
'/particle/select pi+')
423 uiCommandList.append(
'/particle/process/dump')
424 uiCommandList.append(
'/particle/select pi-')
425 uiCommandList.append(
'/particle/process/dump')
426 uiCommandList.append(
'/particle/select e+')
427 uiCommandList.append(
'/particle/process/dump')
428 uiCommandList.append(
'/particle/select e-')
429 uiCommandList.append(
'/particle/process/dump')
430 uiCommandList.append(
'/particle/select mu+')
431 uiCommandList.append(
'/particle/process/dump')
432 uiCommandList.append(
'/particle/select mu-')
433 uiCommandList.append(
'/particle/select kaon+')
434 uiCommandList.append(
'/particle/process/dump')
435 uiCommandList.append(
'/particle/select kaon-')
436 uiCommandList.append(
'/particle/process/dump')
437 g4sim.param(
'UICommandsAtIdle', uiCommandList)
443 path.add_module(g4sim)
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...