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

Public Member Functions

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

Public Attributes

 sign_stats_pxd
 Relation sign statistics for PXDClusters.
 
 sign_stats_svd
 Relation sign statistics for PXDClusters.
 

Detailed Description

Lists signs of MCParticle relation weights for VXD Clusters based on
MCParticle and TrueHit information.
Breakdown of data:
MCParticle primary/secondary/remapped/none (no relation to MCParticle)
Relation sign positive/negative

Definition at line 19 of file CheckNegativeWeights.py.

Constructor & Destructor Documentation

◆ __init__()

def __init__ (   self)
Initialize the module

Definition at line 29 of file CheckNegativeWeights.py.

29 def __init__(self):
30 """Initialize the module"""
31
32 super().__init__()
33
34 self.sign_stats_pxd = {
35 'primary': {'positive': 0, 'negative': 0},
36 'secondary': {'positive': 0, 'negative': 0},
37 'remapped': {'positive': 0, 'negative': 0},
38 'none': {'positive': 0, 'negative': 0}
39 }
40
41 self.sign_stats_svd = {
42 'primary': {'positive': 0, 'negative': 0},
43 'secondary': {'positive': 0, 'negative': 0},
44 'remapped': {'positive': 0, 'negative': 0},
45 'none': {'positive': 0, 'negative': 0}
46 }
47

Member Function Documentation

◆ beginRun()

def beginRun (   self)
 Does nothing 

Definition at line 51 of file CheckNegativeWeights.py.

51 def beginRun(self):
52 """ Does nothing """
53

◆ event()

def event (   self)
Goes through event's PXD and SVD clusters and looks at MCParticles
and TrueHits relations for the sign of relations.

Definition at line 54 of file CheckNegativeWeights.py.

54 def event(self):
55 """
56 Goes through event's PXD and SVD clusters and looks at MCParticles
57 and TrueHits relations for the sign of relations.
58 """
59 # PXD part -------------------------------------------------------
60 pxd_clusters = Belle2.PyStoreArray('PXDClusters')
61
62 for cluster in pxd_clusters:
63 # Determine MCParticle tag and MCParticle relation weight sign
64 mcparticle_tag = 'none'
65 sign_tag = 'positive' # convention if there is no relation
66 # From MCParticles we can determine if the particle is primary
67 # or secondary, and we get the sign of the weight.
68 # To determine if a MCParticle is remapped, we need TrueHit
69 # and the sign of its relation to the MCParticle.
70 mcparticle_relations = cluster.getRelationsTo('MCParticles')
71 n_mcparticle_relations = mcparticle_relations.size()
72 for mcparticle_index in range(n_mcparticle_relations):
73 mcparticle = mcparticle_relations[mcparticle_index]
74 mcparticle_weight = \
75 mcparticle_relations.weight(mcparticle_index)
76 if mcparticle_weight < 0:
77 sign_tag = 'negative'
78 if mcparticle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
79 mcparticle_tag = 'primary'
80 # The primary particle may be remapped. Check TrueHits!
81 cluster_truehits = cluster.getRelationsTo('PXDTrueHits')
82 # Identify the TrueHit related to the current MCParticle.
83 mcparticle_array_index = mcparticle.getArrayIndex()
84 for hit in cluster_truehits:
85 hit_particle_relations = \
86 hit.getRelationsFrom('MCParticles')
87 n_relations = hit_particle_relations.size()
88 for particle_index in range(n_relations):
89 hit_particle = \
90 hit_particle_relations[particle_index]
91 if hit_particle.getArrayIndex() == \
92 mcparticle_array_index:
93 # check sign of the weight
94 weight = hit_particle_relations.weight(
95 particle_index)
96 if weight < 0:
97 mcparticle_tag = 'remapped'
98 break
99 else:
100 mcparticle_tag = 'secondary'
101 # That's it, store the result
102 # If there are more MCParticles per cluster (possible), we
103 # make an entry for each.
104 self.sign_stats_pxd[mcparticle_tag][sign_tag] += 1
105
106 # SVD part -------------------------------------------------------
107 svd_clusters = Belle2.PyStoreArray('SVDClusters')
108
109 for cluster in svd_clusters:
110 # Determine MCParticle tag and MCParticle relation weight sign
111 mcparticle_tag = 'none'
112 sign_tag = 'positive' # convention if there is no relation
113 # From MCParticles we can determine if the particle is primary
114 # or secondary, and we get the sign of the weight.
115 # To determine if a MCParticle is remapped, we need TrueHit
116 # and the sign of its relation to the MCParticle.
117 mcparticle_relations = cluster.getRelationsTo('MCParticles')
118 n_mcparticle_relations = mcparticle_relations.size()
119 for mcparticle_index in range(n_mcparticle_relations):
120 mcparticle = mcparticle_relations[mcparticle_index]
121 mcparticle_weight = \
122 mcparticle_relations.weight(mcparticle_index)
123 if mcparticle_weight < 0:
124 sign_tag = 'negative'
125 if mcparticle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
126 mcparticle_tag = 'primary'
127 # The primary particle may be remapped. Check TrueHits!
128 cluster_truehits = cluster.getRelationsTo('SVDTrueHits')
129 # Identify the TrueHit related to the current MCParticle.
130 mcparticle_array_index = mcparticle.getArrayIndex()
131 for hit in cluster_truehits:
132 hit_particle_relations = \
133 hit.getRelationsFrom('MCParticles')
134 n_relations = hit_particle_relations.size()
135 for particle_index in range(n_relations):
136 hit_particle = \
137 hit_particle_relations[particle_index]
138 if hit_particle.getArrayIndex() == \
139 mcparticle_array_index:
140 # check sign of the weight
141 weight = hit_particle_relations.weight(
142 particle_index)
143 if weight < 0:
144 mcparticle_tag = 'remapped'
145 break
146 else:
147 mcparticle_tag = 'secondary'
148 # That's it, store the result
149 self.sign_stats_svd[mcparticle_tag][sign_tag] += 1
150
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72

◆ initialize()

def initialize (   self)
 Does nothing 

Definition at line 48 of file CheckNegativeWeights.py.

48 def initialize(self):
49 """ Does nothing """
50

◆ terminate()

def terminate (   self)
 Write results 

Definition at line 151 of file CheckNegativeWeights.py.

151 def terminate(self):
152 """ Write results """
153 b2.B2INFO(
154 f'\nResults for PXD: \n{str(self.sign_stats_pxd)}\nResults for SVD: \n{str(self.sign_stats_svd)}\n'
155 )
156
157
158# Particle gun module

Member Data Documentation

◆ sign_stats_pxd

sign_stats_pxd

Relation sign statistics for PXDClusters.

Definition at line 34 of file CheckNegativeWeights.py.

◆ sign_stats_svd

sign_stats_svd

Relation sign statistics for PXDClusters.

Definition at line 41 of file CheckNegativeWeights.py.


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