16 from ROOT
import Belle2
21 """A module to gather data on charge sharing in the SVD."""
24 """Initialize the module"""
26 super(SVDChargeSharing, self).
__init__()
28 self.
filefile = open(
'SVDChargeSharingData.txt',
'w')
31 """ Write legend for file columns """
33 self.
filefile.write(
'sensor_type layer ladder sensor truehit_index cluster_index ')
34 self.
filefile.write(
'truehit_u truehit_eta_u truehit_v truehit_eta_v charge_keV ')
35 self.
filefile.write(
'theta_u theta_v cluster_isU cluster_pos cluster_eta ')
36 self.
filefile.write(
'cluster_charge_ADU seed_charge_ADU cluster_size\n')
39 """Find clusters with a truehit and print some stats."""
44 nClusters = clusters.getEntries()
45 print(
"nClusters = "+str(nClusters))
49 for cluster_index
in range(nClusters):
50 cluster = clusters[cluster_index]
52 truehit = cluster.getRelated(
'SVDTrueHits')
61 info = geoCache.get(sensorID)
62 layer = sensorID.getLayerNumber()
63 ladder = sensorID.getLadderNumber()
64 sensor = sensorID.getSensorNumber()
66 if sensor == 1
and layer != 3:
69 sensorType =
'barrel' if layer > 3
else 'layer3'
70 s +=
'{sID} {layer} {ladder} {sensor} {indexT:4d} {indexC:4d} '.format(
75 indexT=truehit.getArrayIndex(),
79 truehit_u = truehit.getU()
80 truehit_v = truehit.getV()
81 pitch_u = info.getUPitch()
82 truehit_eta_u = (truehit_u / pitch_u) % 1
83 pitch_v = info.getVPitch()
84 truehit_eta_v = (truehit_v / pitch_v) % 1
85 thetaU = math.atan2(truehit.getExitU() - truehit.getEntryU(),
87 thetaV = math.atan2(truehit.getExitV() - truehit.getEntryV(),
89 s +=
'{uTH:10.5f} {uTHeta:10.5f} {vTH:10.5f} {vTHeta:10.5f} {eTH:10.7f} '.format(
90 uTH=truehit_u, uTHeta=truehit_eta_u,
91 vTH=truehit_v, vTHeta=truehit_eta_v,
92 eTH=1.0e6 * truehit.getEnergyDep()
93 ) +
'{thetaU:6.3f} {thetaV:6.3f} '.format(
94 thetaU=thetaU, thetaV=thetaV
97 cluster_pitch = (pitch_u
if cluster.isUCluster()
else pitch_v)
98 cluster_eta = (cluster.getPosition() / cluster_pitch) % 1
99 s +=
'{isU} {uvC:10.5f} {uvCeta:10.5f} {eC:10.1f} '.format(
100 isU=cluster.isUCluster(),
101 uvC=cluster.getPosition(),
103 eC=cluster.getCharge()
104 ) +
'{eSeed:10.1f} {size:5d}'.format(
105 eSeed=cluster.getSeedCharge(),
106 size=cluster.getSize())
109 self.
filefile.write(s)
112 """ Close the output file."""
114 self.
filefile.close()
A (simplified) python wrapper for StoreArray.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Class to uniquely identify a any structure of the PXD and SVD.