Belle II Software development
eclTrackClusterMatching.py
1#!/usr/bin/env python
2
3
10
11import basf2 as b2
12
13from ROOT import Belle2
14
15import simulation
16import reconstruction
17
18
20 """
21 Module which checks relations/variables have been properly set for track-cluster matching
22 Note that this does not check the performance of the track-cluster matching
23 """
24
25 def event(self):
26 """
27 Load tracks from StoreArray for each event, and perform tests of module
28 """
29
30 tracks = Belle2.PyStoreArray("Tracks")
31
32 for track in tracks:
33 cluster = track.getRelatedTo("ECLClusters")
34 if (cluster):
35 # TEST 1: if cluster is related to track, flag should be set
36 assert cluster.isTrack(), "Cluster does not have track set despite relation existing"
37 # TEST 2: correct track-cluster matching method used (Enter Crystal or Angular Distance)
38 fit_result = track.getTrackFitResultWithClosestMass(211)
39 pt = fit_result.getTransverseMomentum()
40 theta = fit_result.getMomentum().Theta()
41 if (pt < 0.3 and theta > 0.5480334) or (pt > 0.3 and theta > 0.5480334 and theta < 0.561996):
42 assert track.getRelatedTo(
43 "ECLClusters", "EnterCrystal") is not None, "Relation set with EnterCrystal method does not exist"
44 else:
45 assert track.getRelatedTo(
46 "ECLClusters", "AngularDistance") is not None, "Relation set with AngularDistance method does not exist"
47
48
49b2.set_random_seed(42)
50
51main = b2.create_path()
52
53main.add_module('EventInfoSetter', evtNumList=[10])
54
55main.add_module('ParticleGun',
56 pdgCodes=[11],
57 nTracks=5,
58 momentumGeneration='uniform',
59 momentumParams=[0.1, 1])
60
61# specific case - high pt, towards gap
62main.add_module('ParticleGun',
63 pdgCodes=[11],
64 nTracks=1,
65 momentumGeneration='fixed',
66 momentumParams=1,
67 thetaGeneration='uniform',
68 thetaParams=[31.4, 32.2])
69
71
73
74main.add_module(CheckTrackClusterMatching())
75
76b2.process(main)
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
def add_reconstruction(path, components=None, pruneTracks=True, add_trigger_calculation=True, skipGeometryAdding=False, trackFitHypotheses=None, addClusterExpertModules=True, use_second_cdc_hits=False, add_muid_hits=False, reconstruct_cdst=None, event_abort=default_event_abort, use_random_numbers_for_hlt_prescale=True, pxd_filtering_offline=False, create_intercepts_for_pxd_ckf=False, append_full_grid_cdc_eventt0=True, legacy_ecl_charged_pid=False, emulate_HLT=False, skip_full_grid_cdc_eventt0_if_svd_time_present=True)
def add_simulation(path, components=None, bkgfiles=None, bkgOverlay=True, forceSetPXDDataReduction=False, usePXDDataReduction=True, cleanupPXDDataReduction=True, generate_2nd_cdc_hits=False, simulateT0jitter=True, isCosmics=False, FilterEvents=False, usePXDGatedMode=False, skipExperimentCheckForBG=False, save_slow_pions_in_mc=False)
Definition: simulation.py:126