6 <contact> SVD Software Group, svd-software@belle2.org </contact>
8 This module is used for the SVD validation.
9 It gets information about clusters and truehits, saving in a ttree in a ROOT file.
20 from ROOT
import Belle2
21 from ROOT
import gROOT, AddressOf
22 from ROOT
import TVector3
25 gROOT.ProcessLine(
'struct EventDataCluster {\
32 int cluster_truehits_number;\
36 float cluster_position;\
37 float cluster_positionSigma;\
38 float cluster_clsTime;\
39 float cluster_clsTimeSigma;\
40 float cluster_charge;\
41 float cluster_seedCharge;\
44 float cluster_interstripPosition;\
46 float cluster_residual;\
47 float truehit_position;\
48 float truehit_interstripPosition;\
49 float truehit_deposEnergy;\
50 float truehit_lossmomentum;\
55 from ROOT
import EventDataCluster
59 '''class to produce the ttree for cluster validation'''
62 """Initialize the module"""
64 super(SVDValidationTTreeCluster, self).
__init__()
65 self.
file = ROOT.TFile(
'../SVDValidationTTreeCluster.root',
'recreate')
66 '''Output ROOT file'''
67 self.
tree = ROOT.TTree(
'tree',
'Event data of SVD validation events')
68 '''TTrees for output data'''
69 self.
data = EventDataCluster()
70 '''Instance of the EventData class'''
73 for key
in EventDataCluster.__dict__:
76 if isinstance(self.
data.__getattribute__(key), int):
78 self.
tree.Branch(key, AddressOf(self.
data, key), key + formstring)
81 """ Find clusters with a truehit and save needed information """
83 for cluster
in clusters:
84 cluster_truehits = cluster.getRelationsTo(
'SVDTrueHits')
85 cluster_TrueHit_Length = len(cluster_truehits)
86 if (cluster_TrueHit_Length == 0)
or (cluster_TrueHit_Length != 1):
88 sensorID = cluster.getSensorID()
89 self.
data.sensor_id = int(sensorID)
90 sensorNum = sensorID.getSensorNumber()
91 self.
data.sensor = sensorNum
92 layerNum = sensorID.getLayerNumber()
93 self.
data.layer = layerNum
101 self.
data.sensor_type = sensorType
102 ladderNum = sensorID.getLadderNumber()
103 self.
data.ladder = ladderNum
105 self.
data.strip_dir = -1
106 self.
data.cluster_truehits_number = cluster_TrueHit_Length
112 for truehit
in cluster_truehits:
113 self.
data.cluster_truehits_number = cluster_TrueHit_Length
116 sensorID = cluster.getSensorID()
117 self.
data.sensor_id = int(sensorID)
118 sensorNum = sensorID.getSensorNumber()
119 self.
data.sensor = sensorNum
120 layerNum = sensorID.getLayerNumber()
121 self.
data.layer = layerNum
129 self.
data.sensor_type = sensorType
130 ladderNum = sensorID.getLadderNumber()
131 self.
data.ladder = ladderNum
133 self.
data.cluster_clsTime = cluster.getClsTime()
134 self.
data.cluster_clsTimeSigma = cluster.getClsTimeSigma()
135 self.
data.cluster_charge = cluster.getCharge()
136 self.
data.cluster_seedCharge = cluster.getSeedCharge()
137 self.
data.cluster_size = cluster.getSize()
138 self.
data.cluster_snr = cluster.getSNR()
139 cluster_position = cluster.getPosition()
140 if cluster.isUCluster():
141 cluster_position = cluster.getPosition(truehit.getV())
143 if cluster.isUCluster():
145 strip_pitch = sensorInfo.getUPitch(truehit.getV())
148 strip_pitch = sensorInfo.getVPitch(truehit.getU())
149 self.
data.strip_dir = strip_dir
150 self.
data.strip_pitch = strip_pitch
151 cluster_interstripPosition = cluster_position % strip_pitch / strip_pitch
152 self.
data.cluster_interstripPosition = cluster_interstripPosition
154 if cluster.isUCluster():
155 uPos = cluster_position
159 vPos = cluster_position
160 localPosition = TVector3(uPos, vPos, 0)
161 globalPosition = sensorInfo.pointToGlobal(localPosition,
True)
162 x = globalPosition[0]
163 y = globalPosition[1]
164 z = globalPosition[2]
167 rho = math.sqrt(x * x + y * y)
168 r = math.sqrt(x * x + y * y + z * z)
170 thetaRadians = math.acos(z / r)
171 theta = (thetaRadians * 180) / math.pi
173 phiRadians = math.acos(x / rho)
175 phi = 360 - (phiRadians * 180) / math.pi
177 phi = (phiRadians * 180) / math.pi
178 self.
data.cluster_theta = theta
179 self.
data.cluster_phi = phi
181 clusterPos = cluster_position
182 clusterPosSigma = cluster.getPositionSigma()
183 if cluster.isUCluster():
184 truehitPos = truehit.getU()
186 truehitPos = truehit.getV()
187 cluster_residual = clusterPos - truehitPos
188 cluster_pull = cluster_residual / clusterPosSigma
189 self.
data.cluster_position = clusterPos
190 self.
data.cluster_positionSigma = clusterPosSigma
191 self.
data.cluster_residual = cluster_residual
192 self.
data.cluster_pull = cluster_pull
194 self.
data.truehit_position = truehitPos
195 truehit_interstripPosition = truehitPos % strip_pitch / strip_pitch
196 self.
data.truehit_interstripPosition = truehit_interstripPosition
197 self.
data.truehit_deposEnergy = truehit.getEnergyDep()
198 self.
data.truehit_lossmomentum = truehit.getEntryMomentum().Mag() - truehit.getExitMomentum().Mag()
199 self.
data.truehit_time = truehit.getGlobalTime()
205 """Close the output file. """