12from ROOT
import Belle2
16b2.logging.log_level = b2.LogLevel.WARNING
22 Lists signs of MCParticle relation weights for VXD Clusters based on
23 MCParticle
and TrueHit information.
25 MCParticle primary/secondary/remapped/none (no relation to MCParticle)
26 Relation sign positive/negative
30 """Initialize the module"""
35 'primary': {
'positive': 0,
'negative': 0},
36 'secondary': {
'positive': 0,
'negative': 0},
37 'remapped': {
'positive': 0,
'negative': 0},
38 'none': {
'positive': 0,
'negative': 0}
42 'primary': {
'positive': 0,
'negative': 0},
43 'secondary': {
'positive': 0,
'negative': 0},
44 'remapped': {
'positive': 0,
'negative': 0},
45 'none': {
'positive': 0,
'negative': 0}
56 Goes through event's PXD and SVD clusters and looks at MCParticles
57 and TrueHits relations
for the sign of relations.
62 for cluster
in pxd_clusters:
64 mcparticle_tag =
'none'
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]
75 mcparticle_relations.weight(mcparticle_index)
76 if mcparticle_weight < 0:
78 if mcparticle.hasStatus(Belle2.MCParticle.c_PrimaryParticle):
79 mcparticle_tag =
'primary'
81 cluster_truehits = cluster.getRelationsTo(
'PXDTrueHits')
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):
90 hit_particle_relations[particle_index]
91 if hit_particle.getArrayIndex() == \
92 mcparticle_array_index:
94 weight = hit_particle_relations.weight(
97 mcparticle_tag =
'remapped'
100 mcparticle_tag =
'secondary'
104 self.sign_stats_pxd[mcparticle_tag][sign_tag] += 1
109 for cluster
in svd_clusters:
111 mcparticle_tag =
'none'
112 sign_tag =
'positive'
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'
128 cluster_truehits = cluster.getRelationsTo(
'SVDTrueHits')
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):
137 hit_particle_relations[particle_index]
138 if hit_particle.getArrayIndex() == \
139 mcparticle_array_index:
141 weight = hit_particle_relations.weight(
144 mcparticle_tag =
'remapped'
147 mcparticle_tag =
'secondary'
149 self.sign_stats_svd[mcparticle_tag][sign_tag] += 1
152 """ Write results """
154 f
'\nResults for PXD: \n{str(self.sign_stats_pxd)}\nResults for SVD: \n{str(self.sign_stats_svd)}\n'
159particlegun = b2.register_module(
'ParticleGun')
161eventinfosetter = b2.register_module(
'EventInfoSetter')
163progress = b2.register_module(
'Progress')
165gearbox = b2.register_module(
'Gearbox')
167geometry = b2.register_module(
'Geometry')
169simulation = b2.register_module(
'FullSim')
172printWeights.set_log_level(b2.LogLevel.INFO)
175eventinfosetter.param({
'evtNumList': [1000],
'runList': [1]})
181 'pdgCodes': [211, -211, 11, -11],
182 'momentumGeneration':
'normalPt',
183 'momentumParams': [2, 1],
184 'phiGeneration':
'normal',
185 'phiParams': [0, 360],
186 'thetaGeneration':
'uniformCos',
187 'thetaParams': [17, 150],
188 'vertexGeneration':
'normal',
189 'xVertexParams': [0, 1],
190 'yVertexParams': [0, 1],
191 'zVertexParams': [0, 1],
192 'independentVertices':
False,
197main = b2.create_path()
198main.add_module(eventinfosetter)
199main.add_module(progress)
200main.add_module(particlegun)
201main.add_module(gearbox)
202main.add_module(geometry)
203main.add_module(simulation)
208main.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_simulation(path, digitsName=None, activatePixelMasks=True, activateGainCorrection=True)
def add_pxd_reconstruction(path, clusterName=None, digitsName=None, usePXDClusterShapes=False, spacePointsName='PXDSpacePoints')
def add_svd_simulation(path, useConfigFromDB=False, daqMode=2, relativeShift=9)
def add_svd_reconstruction(path, isROIsimulation=False, createRecoDigits=False, applyMasking=False)