Belle II Software development
HitCleaner Class Reference
Inheritance diagram for HitCleaner:

Public Member Functions

def __init__ (self)
 
def initialize (self)
 
def event (self)
 
def terminate (self)
 

Public Attributes

 number_of_tracks
 count the tracks
 
 number_of_deleted_hits
 count the deleted hits
 
 number_of_hits
 count the hits
 
 cdc_hit_look_up
 function to look up CDC MC hits
 
 mc_matcher_lookup
 function to match track candidatess to MC track candidates
 

Detailed Description

A small hit cleaner module to set the track information according to mc information.
This is surely not for later usage but for testing the genfitter module

Definition at line 71 of file modules.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)
Constructor

Definition at line 76 of file modules.py.

76 def __init__(self):
77 """Constructor"""
78 super().__init__()
79
80
81 self.number_of_tracks = 0
82
83 self.number_of_deleted_hits = 0
84
85 self.number_of_hits = 0
86

Member Function Documentation

◆ event()

def event (   self)
Event method of the module

Definition at line 94 of file modules.py.

94 def event(self):
95 """Event method of the module"""
96 tracks = Belle2.PyStoreArray("TrackCands")
97 cdc_hits = Belle2.PyStoreArray("CDCHits")
98 mc_particles = Belle2.PyStoreArray("MCParticles")
99
100 cdc_hit_lookup = self.cdc_hit_look_up
101 cdc_hit_lookup.fill()
102
103 mc_matcher_lookup = self.mc_matcher_lookup
104
105 self.number_of_tracks += tracks.getEntries()
106
107 for track in tracks:
108 # Store all Hit IDs and reset the track
109 hitIDs = track.getHitIDs(Belle2.Const.CDC)
110 # hits = [cdc_hits[i] for i in hitIDs]
111 good_hits = []
112
113 relation_track_particle = [0] * mc_particles.getEntries()
114
115 # Now only add those hits which do belong to the track (with MC Info)
116 for i in hitIDs:
117 current_mc_track = cdc_hit_lookup.getMCTrackId(cdc_hits[i])
118 if 0 <= current_mc_track:
119 relation_track_particle[current_mc_track] += 1
120
121 should_belong_to_track = np.argmax(relation_track_particle)
122
123 deleted_hits = sum(relation_track_particle) - relation_track_particle[should_belong_to_track]
124
125 # plane_IDs_of_good_hits = []
126 for i, hitID in enumerate(hitIDs):
127 current_mc_track = cdc_hit_lookup.getMCTrackId(cdc_hits[hitID])
128 if current_mc_track == should_belong_to_track:
129 good_hits.append(hitID)
130
131 self.number_of_deleted_hits += deleted_hits
132 self.number_of_hits += len(hitIDs)
133
134 # Set the position and momentum
135 mc_track = mc_matcher_lookup.getAnyChargeMatchedMCRecoTrack(track)
136
137 if mc_track:
138 mc_trajectory = Belle2.TrackFindingCDC.CDCTrajectory3D(Belle2.TrackFindingCDC.Vector3D(mc_track.getPosSeed()),
139 Belle2.TrackFindingCDC.Vector3D(mc_track.getMomSeed()),
140 mc_track.getChargeSeed())
141 startingPosition = Belle2.TrackFindingCDC.Vector3D(track.getPosSeed().X(), track.getPosSeed().Y(), 0)
142 sStartingPosition = mc_trajectory.calcArcLength2D(startingPosition)
143 zStartingPosition = mc_trajectory.getTrajectorySZ().mapSToZ(sStartingPosition)
144 mc_trajectory.setLocalOrigin(Belle2.TrackFindingCDC.Vector3D(startingPosition.xy(), zStartingPosition))
145
146 # pos = ROOT.TVector3(
147 # mc_trajectory.getSupport().x(), mc_trajectory.getSupport().y(), mc_trajectory.getSupport().z())
148 # mom = ROOT.TVector3(
149 # mc_trajectory.getMom3DAtSupport().x(),
150 # mc_trajectory.getMom3DAtSupport().y(),
151 # mc_trajectory.getMom3DAtSupport().z())
152
153 # track.setPosMomSeedAndPdgCode(pos, mom , int(mc_track.getChargeSeed() * 211))
154 track.setPdgCode(int(track.getChargeSeed() * 211))
155
156 else:
157 # track.reset()
158 track.setPdgCode(int(track.getChargeSeed() * 211))
159
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
Particle full three dimensional trajectory.
A three dimensional vector.
Definition: Vector3D.h:33

◆ initialize()

def initialize (   self)
Initialization signal at the start of the event processing

Definition at line 87 of file modules.py.

87 def initialize(self):
88 """Initialization signal at the start of the event processing"""
89
90 self.cdc_hit_look_up = Belle2.TrackFindingCDC.CDCMCHitLookUp()
91
92 self.mc_matcher_lookup = Belle2.TrackMatchLookUp("MCTrackCands", "TrackCands")
93
Interface class to the Monte Carlo information for individual hits.
Class to provide convenient methods to look up matching information between pattern recognition and M...

◆ terminate()

def terminate (   self)
Termination signal at the end of the event processing

Definition at line 160 of file modules.py.

160 def terminate(self):
161 """Termination signal at the end of the event processing"""
162 print(f"Number of tracks in total: {int(self.number_of_tracks)}")
163 print(f"Number of hits in total: {int(self.number_of_hits)}")
164 print(f"Number of deleted hits: {int(self.number_of_deleted_hits)}")
165
166 print(f"Number of deleted hits per track: {1.0 * self.number_of_deleted_hits / self.number_of_tracks:f}")
167 print(f"Ratio of deleted hits: {100.0 * self.number_of_deleted_hits / self.number_of_hits:f}")

Member Data Documentation

◆ cdc_hit_look_up

cdc_hit_look_up

function to look up CDC MC hits

Definition at line 90 of file modules.py.

◆ mc_matcher_lookup

mc_matcher_lookup

function to match track candidatess to MC track candidates

Definition at line 92 of file modules.py.

◆ number_of_deleted_hits

number_of_deleted_hits

count the deleted hits

Definition at line 83 of file modules.py.

◆ number_of_hits

number_of_hits

count the hits

Definition at line 85 of file modules.py.

◆ number_of_tracks

number_of_tracks

count the tracks

Definition at line 81 of file modules.py.


The documentation for this class was generated from the following file: