16from ROOT
import Belle2
21 """A simple module to check the reconstruction of PXDTrueHits."""
24 """Initialize the module"""
28 self.
file = open(
'PXDHitErrorOutput.txt',
'w')
32 self.
fHisto = ROOT.TFile(
'PXDPulls.root',
'RECREATE')
34 self.
h_pull_u = ROOT.TH1F(
'h_pull_u',
'Pulls in u', 150, -10, 5)
36 self.
h_pull_v = ROOT.TH1F(
'h_pull_v',
'Pulls in v', 100, -5, 5)
39 """ Write legend for file columns """
41 self.
file.write(
'vxd.id layer ladder sensor truehit.index cluster.index ')
42 self.
file.write(
'truehit.u truehit.v truehit.time truehit.charge theta.u theta.v ')
43 self.
file.write(
'u v u.error v.error rho charge seed size u.size v.size u.pull v.pull\n')
46 """Find clusters with a truehit and print some stats."""
51 nClusters = clusters.getEntries()
54 relClustersToTrueHits = \
55 Belle2.PyRelationArray(
'PXDClustersToPXDTrueHits')
62 for cluster_index
in range(nClusters):
63 cluster = clusters[cluster_index]
65 relClustersToTrueHits.getToIndices(cluster_index)
69 if len(cluster_truehits) != 1:
72 for truehit_index
in cluster_truehits:
73 truehit = truehits[truehit_index]
77 sensorID = truehit.getRawSensorID()
78 [layer, ladder, sensor] = self.
decode(sensorID)
80 s_id = f
'{sensorID} {layer} {ladder} {sensor} {truehit_index:4d} {cluster_index:4d} '
83 thetaU = math.atan2(truehit.getExitU() - truehit.getEntryU(),
85 thetaV = math.atan2(truehit.getExitV() - truehit.getEntryV(),
87 s_th = f
'{truehit.getU():10.5f} {truehit.getV():10.5f} {truehit.getGlobalTime():10.2f} ' + \
88 f
'{truehit.getEnergyDep():10.7f} {thetaU:6.3f} {thetaV:6.3f} '
94 cluster_pull_u = (cluster.getU() - truehit.getU()) \
96 cluster_pull_v = (cluster.getV() - truehit.getV()) \
98 except ZeroDivisionError:
99 if cluster.getUSigma() < 1.0e-8:
100 b2.B2ERROR(f
'Zero error in u, clsize {cluster.getUSize()}.')
102 b2.B2ERROR(f
'Zero error in v, clsize {cluster.getVSize()}.')
105 f
'{cluster.getU():10.5f} {cluster.getV():10.5f} {cluster.getUSigma():10.5f} {cluster.getVSigma():10.5f} ' + \
106 f
'{cluster.getRho():10.4f} {cluster.getCharge():9.1f} {cluster.getSeedCharge():9.1f} ' + \
107 f
'{cluster.getSize():5d} {cluster.getUSize():5d} {cluster.getVSize():5d} ' + \
108 f
'{cluster_pull_u:10.3f} {cluster_pull_v:10.3f}'
113 if cluster.getUSize() == 2:
115 if cluster.getVSize() == 2:
119 """ Close the output file."""
130 """ Utility to decode sensor IDs """
134 result.append(vxdid / f)
A (simplified) python wrapper for StoreArray.
vxdid_factors
Factors for decoding VXDId's.
h_pull_v
Histogram for v pulls.
h_pull_u
Histogram for u pulls.
fHisto
File to save histograms.