13 from ROOT
import Belle2
17 b2.logging.log_level = b2.LogLevel.WARNING
23 Lists signs of MCParticle relation weights for VXD Clusters based on
24 MCParticle and TrueHit information.
26 MCParticle primary/secondary/remapped/none (no relation to MCParticle)
27 Relation sign positive/negative
31 """Initialize the module"""
33 super(CheckNegativeWeights, self).
__init__()
36 'primary': {
'positive': 0,
'negative': 0},
37 'secondary': {
'positive': 0,
'negative': 0},
38 'remapped': {
'positive': 0,
'negative': 0},
39 'none': {
'positive': 0,
'negative': 0}
43 'primary': {
'positive': 0,
'negative': 0},
44 'secondary': {
'positive': 0,
'negative': 0},
45 'remapped': {
'positive': 0,
'negative': 0},
46 'none': {
'positive': 0,
'negative': 0}
57 Goes through event's PXD and SVD clusters and looks at MCParticles
58 and TrueHits relations for the sign of relations.
63 for cluster
in pxd_clusters:
65 mcparticle_tag =
'none'
71 mcparticle_relations = cluster.getRelationsTo(
'MCParticles')
72 n_mcparticle_relations = mcparticle_relations.size()
73 for mcparticle_index
in range(n_mcparticle_relations):
74 mcparticle = mcparticle_relations[mcparticle_index]
76 mcparticle_relations.weight(mcparticle_index)
77 if mcparticle_weight < 0:
79 if mcparticle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
80 mcparticle_tag =
'primary'
82 cluster_truehits = cluster.getRelationsTo(
'PXDTrueHits')
84 mcparticle_array_index = mcparticle.getArrayIndex()
85 for hit
in cluster_truehits:
86 hit_particle_relations = \
87 hit.getRelationsFrom(
'MCParticles')
88 n_relations = hit_particle_relations.size()
89 for particle_index
in range(n_relations):
91 hit_particle_relations[particle_index]
92 if hit_particle.getArrayIndex() == \
93 mcparticle_array_index:
95 weight = hit_particle_relations.weight(
98 mcparticle_tag =
'remapped'
101 mcparticle_tag =
'secondary'
105 self.sign_stats_pxd[mcparticle_tag][sign_tag] += 1
110 for cluster
in svd_clusters:
112 mcparticle_tag =
'none'
113 sign_tag =
'positive'
118 mcparticle_relations = cluster.getRelationsTo(
'MCParticles')
119 n_mcparticle_relations = mcparticle_relations.size()
120 for mcparticle_index
in range(n_mcparticle_relations):
121 mcparticle = mcparticle_relations[mcparticle_index]
122 mcparticle_weight = \
123 mcparticle_relations.weight(mcparticle_index)
124 if mcparticle_weight < 0:
125 sign_tag =
'negative'
126 if mcparticle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
127 mcparticle_tag =
'primary'
129 cluster_truehits = cluster.getRelationsTo(
'SVDTrueHits')
131 mcparticle_array_index = mcparticle.getArrayIndex()
132 for hit
in cluster_truehits:
133 hit_particle_relations = \
134 hit.getRelationsFrom(
'MCParticles')
135 n_relations = hit_particle_relations.size()
136 for particle_index
in range(n_relations):
138 hit_particle_relations[particle_index]
139 if hit_particle.getArrayIndex() == \
140 mcparticle_array_index:
142 weight = hit_particle_relations.weight(
145 mcparticle_tag =
'remapped'
148 mcparticle_tag =
'secondary'
150 self.sign_stats_svd[mcparticle_tag][sign_tag] += 1
153 """ Write results """
155 '\nResults for PXD: \n{pxd}\nResults for SVD: \n{svd}\n'.format(
163 particlegun = b2.register_module(
'ParticleGun')
165 eventinfosetter = b2.register_module(
'EventInfoSetter')
167 progress = b2.register_module(
'Progress')
169 gearbox = b2.register_module(
'Gearbox')
171 geometry = b2.register_module(
'Geometry')
173 simulation = b2.register_module(
'FullSim')
176 printWeights.set_log_level(b2.LogLevel.INFO)
179 eventinfosetter.param({
'evtNumList': [1000],
'runList': [1]})
185 'pdgCodes': [211, -211, 11, -11],
186 'momentumGeneration':
'normalPt',
187 'momentumParams': [2, 1],
188 'phiGeneration':
'normal',
189 'phiParams': [0, 360],
190 'thetaGeneration':
'uniformCos',
191 'thetaParams': [17, 150],
192 'vertexGeneration':
'normal',
193 'xVertexParams': [0, 1],
194 'yVertexParams': [0, 1],
195 'zVertexParams': [0, 1],
196 'independentVertices':
False,
201 main = b2.create_path()
202 main.add_module(eventinfosetter)
203 main.add_module(progress)
204 main.add_module(particlegun)
205 main.add_module(gearbox)
206 main.add_module(geometry)
207 main.add_module(simulation)
212 main.add_module(printWeights)
A (simplified) python wrapper for StoreArray.
sign_stats_svd
Relation sign statistics for PXDClusters.
sign_stats_pxd
Relation sign statistics for PXDClusters.
def add_pxd_reconstruction(path, clusterName=None, digitsName=None, usePXDClusterShapes=False, spacePointsName='PXDSpacePoints')
def add_pxd_simulation(path, digitsName=None, activatePixelMasks=True, activateGainCorrection=True)
def add_svd_simulation(path, useConfigFromDB=False, daqMode=2, relativeShift=9)
def add_svd_reconstruction(path, isROIsimulation=False, createRecoDigits=False, applyMasking=False)