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