Belle II Software development
VXDHarvester Class Reference
Inheritance diagram for VXDHarvester:
PXDHarvester SVDHarvester

Public Member Functions

def __init__ (self, clusters, detector, output_file_name, use_mc_info=True)
 
def is_valid_cluster (self, cluster)
 
def get_tools (self, cluster)
 
def peel (self, track_cand)
 

Public Attributes

 svd_tools
 cached accessor to the SVD-tools singleton
 
 pxd_tools
 cached accessor to the PXD-tools singleton
 
 clusters
 cached copy of the name of the cluster StoreArray
 
 detector
 cached copy of the detector identifier (PXD or SVD)
 
 use_mc_info
 if true the MC information is used
 

Static Public Attributes

refiners save_tree = refiners.SaveTreeRefiner()
 Refiners to be executed at the end of the harvesting / termination of the module Save a tree of all collected variables in a sub folder.
 

Detailed Description

 A base class for the VXD hitwise analysis. Collect dE/dX and the correct p of each hit of the MC particles. 

Definition at line 154 of file harvester.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self,
  clusters,
  detector,
  output_file_name,
  use_mc_info = True 
)
Constructor

Reimplemented in PXDHarvester, and SVDHarvester.

Definition at line 158 of file harvester.py.

158 def __init__(self, clusters, detector, output_file_name, use_mc_info=True):
159 """Constructor"""
160 HarvestingModule.__init__(self, foreach="TrackCands", output_file_name=output_file_name)
161
162
163 self.svd_tools = Belle2.VXDMomentumEstimationTools("Belle2::SVDCluster").getInstance()
164
165 self.pxd_tools = Belle2.VXDMomentumEstimationTools("Belle2::PXDCluster").getInstance()
166
167
168 self.clusters = clusters
169
170 self.detector = detector
171
172
173 self.use_mc_info = use_mc_info
174
Tools needed for the VXD momentum estimation to, e.g.

Member Function Documentation

◆ get_tools()

def get_tools (   self,
  cluster 
)
Get the PXD tools for a PXD cluster or the SVD tools for an SVD cluster

Definition at line 192 of file harvester.py.

192 def get_tools(self, cluster):
193 """Get the PXD tools for a PXD cluster or the SVD tools for an SVD cluster"""
194 return VXDMomentumEnergyEstimator.do_for_each_hit_type(
195 cluster,
196 lambda cluster: self.svd_tools,
197 lambda cluster: self.pxd_tools)
198

◆ is_valid_cluster()

def is_valid_cluster (   self,
  cluster 
)
Determine if a cluster has an associated SpacePoint and is associated with a primary pion MCParticle

Definition at line 175 of file harvester.py.

175 def is_valid_cluster(self, cluster):
176 """Determine if a cluster has an associated SpacePoint and is associated with a primary pion MCParticle"""
177 mc_particles = cluster.getRelationsTo("MCParticles")
178
179 space_point = cluster.getRelated("SpacePoints")
180
181 if space_point is None:
182 return False
183
184 for mc_particle in mc_particles:
185 if (mc_particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle) and
186 abs(mc_particle.getPDG()) == 211):
187
188 return True
189
190 return False
191

◆ peel()

def peel (   self,
  track_cand 
)
Aggregate the cluster and MCParticle (for primary pion) information associated with the track candidate

Definition at line 199 of file harvester.py.

199 def peel(self, track_cand):
200 """Aggregate the cluster and MCParticle (for primary pion) information associated with the track candidate"""
201 vxd_hit_ids = track_cand.getHitIDs(self.detector)
202
203 vxd_hits = Belle2.PyStoreArray(self.clusters)
204
205 for vxd_hit_id in vxd_hit_ids:
206 cluster = vxd_hits[vxd_hit_id]
207
208 if not self.is_valid_cluster(cluster):
209 continue
210
211 tools = self.get_tools(cluster)
212
213 mc_particles = cluster.getRelationsTo("MCParticles")
214
215 for mc_particle in mc_particles:
216 if (mc_particle.hasStatus(Belle2.MCParticle.c_PrimaryParticle) and abs(mc_particle.getPDG()) == 211):
217
218 if self.use_mc_info:
219 track_momentum = mc_particle.getMomentum()
220 track_position = mc_particle.getProductionVertex()
221 track_charge = mc_particle.getCharge()
222 else:
223 track_momentum = track_cand.getMomSeed()
224 track_position = track_cand.getPosSeed()
225 track_charge = track_cand.getChargeSeed()
226
227 b_field = Belle2.BFieldManager.getField(XYZVector(track_position)).Z() / Belle2.Unit.T
228 track_helix = Belle2.Helix(track_position, track_momentum, int(track_charge), b_field)
229
230 cluster_charge = tools.getCalibratedCharge(cluster)
231 path_length = tools.getPathLength(cluster, track_helix)
232 cluster_thickness = tools.getThicknessOfCluster(cluster)
233 cluster_radius = tools.getRadiusOfCluster(cluster)
234 cluster_width = tools.getWidthOfCluster(cluster)
235 cluster_length = tools.getLengthOfCluster(cluster)
236
237 perp_s_at_cluster_entry = track_helix.getArcLength2DAtCylindricalR(cluster_radius)
238 perp_s_at_cluster_exit = track_helix.getArcLength2DAtCylindricalR(cluster_radius + cluster_thickness)
239
240 mc_momentum = tools.getEntryMomentumOfMCParticle(cluster)
241 mc_position = tools.getEntryPositionOfMCParticle(cluster)
242
243 mc_b_field = Belle2.BFieldManager.getField(mc_position).Z() / Belle2.Unit.T
244 mc_helix = Belle2.Helix(mc_position, mc_momentum, int(track_charge), mc_b_field)
245 mc_path_length = tools.getPathLength(cluster, mc_helix)
246
247 cluster_is_u = VXDMomentumEnergyEstimator.do_for_each_hit_type(
248 cluster,
249 lambda cluster: cluster.isUCluster(),
250 lambda cluster: np.NaN)
251
252 cluster_is_pxd = VXDMomentumEnergyEstimator.do_for_each_hit_type(
253 cluster,
254 lambda cluster: False,
255 lambda cluster: True)
256
257 cluster_layer = tools.getLayerOfCluster(cluster)
258 cluster_segment = tools.getSegmentNumberOfCluster(cluster)
259 cluster_ladder = tools.getLadderOfCluster(cluster)
260 cluster_sensor = tools.getSensorNumberOfCluster(cluster)
261
262 cluster_dict = dict(cluster_charge=cluster_charge,
263 cluster_thickness=cluster_thickness,
264 cluster_radius=cluster_radius,
265 cluster_is_u=cluster_is_u,
266 cluster_is_pxd=cluster_is_pxd,
267 cluster_layer=cluster_layer,
268 cluster_segment=cluster_segment,
269 cluster_ladder=cluster_ladder,
270 cluster_width=cluster_width,
271 cluster_length=cluster_length,
272 cluster_sensor=cluster_sensor)
273
274 mc_at_hit_dict = dict(mc_helix_perigee_x=mc_helix.getPerigeeX(),
275 mc_helix_perigee_y=mc_helix.getPerigeeY(),
276 mc_helix_perigee_z=mc_helix.getPerigeeZ(),
277 mc_helix_momentum_x=mc_helix.getMomentumX(mc_b_field),
278 mc_helix_momentum_y=mc_helix.getMomentumY(mc_b_field),
279 mc_helix_momentum_z=mc_helix.getMomentumZ(mc_b_field),
280 mc_position=mc_position.Mag(),
281 mc_position_x=mc_position.X(),
282 mc_position_y=mc_position.Y(),
283 mc_position_z=mc_position.Z(),
284 mc_momentum=mc_momentum.Mag(),
285 mc_momentum_x=mc_momentum.X(),
286 mc_momentum_y=mc_momentum.Y(),
287 mc_momentum_z=mc_momentum.Z())
288
289 dedx_dict = dict(dedx=cluster_charge / path_length,
290 dedx_with_mc=cluster_charge / mc_path_length,
291 dedx_with_thickness=cluster_charge / cluster_thickness,
292 p=mc_momentum.Mag(),
293 perp_s_at_cluster_entry=perp_s_at_cluster_entry,
294 perp_s_at_cluster_exit=perp_s_at_cluster_exit,
295 track_charge=track_charge,
296 path_length=path_length,
297 mc_path_length=mc_path_length,
298 p_origin=mc_particle.getMomentum().R())
299
300 track_dict = dict(track_helix_perigee_x=track_helix.getPerigeeX(),
301 track_helix_perigee_y=track_helix.getPerigeeY(),
302 track_helix_perigee_z=track_helix.getPerigeeZ(),
303 track_helix_momentum_x=track_helix.getMomentumX(b_field),
304 track_helix_momentum_y=track_helix.getMomentumY(b_field),
305 track_helix_momentum_z=track_helix.getMomentumZ(b_field))
306
307 result_dict = dict()
308 result_dict.update(cluster_dict)
309 result_dict.update(mc_at_hit_dict)
310 result_dict.update(dedx_dict)
311 result_dict.update(track_dict)
312
313 yield result_dict
314
Helix parameter class.
Definition: Helix.h:48
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
static void getField(const double *pos, double *field)
return the magnetic field at a given position.
Definition: BFieldManager.h:91

Member Data Documentation

◆ clusters

clusters

cached copy of the name of the cluster StoreArray

Definition at line 168 of file harvester.py.

◆ detector

detector

cached copy of the detector identifier (PXD or SVD)

Definition at line 170 of file harvester.py.

◆ pxd_tools

pxd_tools

cached accessor to the PXD-tools singleton

Definition at line 165 of file harvester.py.

◆ save_tree

refiners save_tree = refiners.SaveTreeRefiner()
static

Refiners to be executed at the end of the harvesting / termination of the module Save a tree of all collected variables in a sub folder.

Definition at line 317 of file harvester.py.

◆ svd_tools

svd_tools

cached accessor to the SVD-tools singleton

Definition at line 163 of file harvester.py.

◆ use_mc_info

use_mc_info

if true the MC information is used

Definition at line 173 of file harvester.py.


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