6 <contact> G. Caria, gcaria@student.unimelb.edu.au </contact>
8 This module is used for the SVD validation.
9 It gets information about truehits and clusters, saving
10 in a ttree in a ROOT file.
21 from ROOT
import Belle2
22 from ROOT
import gROOT, AddressOf
23 from ROOT
import PyConfig
24 from ROOT
import TVector3
27 gROOT.ProcessLine(
'struct EventData {\
37 float cluster_position;\
38 float cluster_positionSigma;\
39 float cluster_clsTime;\
40 float cluster_clsTimeSigma;\
41 float cluster_charge;\
42 float cluster_seedCharge;\
45 float cluster_interstripPosition;\
47 float cluster_residual;\
48 float truehit_position;\
49 float truehit_interstripPosition;\
50 float truehit_deposEnergy;\
51 float truehit_lossmomentum;\
55 from ROOT
import EventData
59 '''class to produced the validation ttree '''
62 """Initialize the module"""
64 super(SVDValidationTTree, self).
__init__()
66 self.
file = ROOT.TFile(
'../SVDValidationTTree.root',
'recreate')
67 '''Output ROOT file'''
68 self.
tree = ROOT.TTree(
'tree',
'Event data of SVD validation events')
69 '''TTrees for output data'''
70 self.
data = EventData()
71 '''Instance of the EventData class'''
74 for key
in EventData.__dict__:
77 if isinstance(self.
data.__getattribute__(key), int):
79 self.
tree.Branch(key, AddressOf(self.
data, key), key + formstring)
85 """Find clusters with a truehit and save needed information"""
90 for cluster
in clusters:
91 cluster_truehits = cluster.getRelationsTo(
'SVDTrueHits')
93 if len(cluster_truehits) != 1:
95 for truehit
in cluster_truehits:
99 sensorID = cluster.getSensorID()
100 self.data.sensor_id = int(sensorID)
101 sensorNum = sensorID.getSensorNumber()
102 self.data.sensor = sensorNum
103 layerNum = sensorID.getLayerNumber()
104 self.data.layer = layerNum
112 self.data.sensor_type = sensorType
113 ladderNum = sensorID.getLadderNumber()
114 self.data.ladder = ladderNum
116 self.data.cluster_clsTime = cluster.getClsTime()
117 self.data.cluster_clsTimeSigma = cluster.getClsTimeSigma()
118 self.data.cluster_charge = cluster.getCharge()
119 self.data.cluster_seedCharge = cluster.getSeedCharge()
120 self.data.cluster_size = cluster.getSize()
121 self.data.cluster_snr = cluster.getSNR()
122 cluster_position = cluster.getPosition()
123 if cluster.isUCluster():
124 cluster_position = cluster.getPosition(truehit.getV())
126 if cluster.isUCluster():
128 strip_pitch = sensorInfo.getUPitch(truehit.getV())
131 strip_pitch = sensorInfo.getVPitch(truehit.getU())
132 self.data.strip_dir = strip_dir
133 self.data.strip_pitch = strip_pitch
134 cluster_interstripPosition = cluster_position % strip_pitch / strip_pitch
135 self.data.cluster_interstripPosition = cluster_interstripPosition
137 if cluster.isUCluster():
138 uPos = cluster_position
142 vPos = cluster_position
143 localPosition = TVector3(uPos, vPos, 0)
144 globalPosition = sensorInfo.pointToGlobal(localPosition,
True)
145 x = globalPosition[0]
146 y = globalPosition[1]
147 z = globalPosition[2]
150 rho = math.sqrt(x * x + y * y)
151 r = math.sqrt(x * x + y * y + z * z)
153 thetaRadians = math.acos(z / r)
154 theta = (thetaRadians * 180) / math.pi
156 phiRadians = math.acos(x / rho)
158 phi = 360 - (phiRadians * 180) / math.pi
160 phi = (phiRadians * 180) / math.pi
161 self.data.cluster_theta = theta
162 self.data.cluster_phi = phi
164 clusterPos = cluster_position
165 clusterPosSigma = cluster.getPositionSigma()
166 if cluster.isUCluster():
167 truehitPos = truehit.getU()
169 truehitPos = truehit.getV()
170 cluster_residual = clusterPos - truehitPos
171 cluster_pull = cluster_residual / clusterPosSigma
172 self.data.cluster_position = clusterPos
173 self.data.cluster_positionSigma = clusterPosSigma
174 self.data.cluster_residual = cluster_residual
175 self.data.cluster_pull = cluster_pull
177 self.data.truehit_position = truehitPos
178 truehit_interstripPosition = truehitPos % strip_pitch / strip_pitch
179 self.data.truehit_interstripPosition = truehit_interstripPosition
180 self.data.truehit_deposEnergy = truehit.getEnergyDep()
181 self.data.truehit_lossmomentum = truehit.getEntryMomentum().Mag() - truehit.getExitMomentum().Mag()
182 self.data.truehit_time = truehit.getGlobalTime()
188 """Close the output file. """