14 <contact> G. Caria, gcaria@student.unimelb.edu.au </contact>
16 This module is used for the SVD validation.
17 It gets information about truehits and clusters, saving
18 in a ttree in a ROOT file.
28 from ROOT
import Belle2
29 from ROOT
import gROOT, addressof
30 from ROOT
import TVector3
33 gROOT.ProcessLine(
'struct EventData {\
43 float cluster_position;\
44 float cluster_positionSigma;\
45 float cluster_clsTime;\
46 float cluster_clsTimeSigma;\
47 float cluster_charge;\
48 float cluster_seedCharge;\
51 float cluster_interstripPosition;\
53 float cluster_residual;\
54 float truehit_position;\
55 float truehit_interstripPosition;\
56 float truehit_deposEnergy;\
57 float truehit_lossmomentum;\
61 from ROOT
import EventData
65 '''class to produced the validation ttree '''
68 """Initialize the module"""
70 super(SVDValidationTTree, self).
__init__()
73 self.
filefile = ROOT.TFile(
'../SVDValidationTTree.root',
'recreate')
75 self.
treetree = ROOT.TTree(
'tree',
'Event data of SVD validation events')
77 self.
datadata = EventData()
80 for key
in EventData.__dict__:
83 if isinstance(self.
datadata.__getattribute__(key), int):
85 self.
treetree.Branch(key, addressof(self.
datadata, key), key + formstring)
91 """Find clusters with a truehit and save needed information"""
96 for cluster
in clusters:
97 cluster_truehits = cluster.getRelationsTo(
'SVDTrueHits')
99 if len(cluster_truehits) != 1:
101 for truehit
in cluster_truehits:
105 sensorID = cluster.getSensorID()
106 self.data.sensor_id = int(sensorID)
107 sensorNum = sensorID.getSensorNumber()
108 self.data.sensor = sensorNum
109 layerNum = sensorID.getLayerNumber()
110 self.data.layer = layerNum
118 self.data.sensor_type = sensorType
119 ladderNum = sensorID.getLadderNumber()
120 self.data.ladder = ladderNum
122 self.data.cluster_clsTime = cluster.getClsTime()
123 self.data.cluster_clsTimeSigma = cluster.getClsTimeSigma()
124 self.data.cluster_charge = cluster.getCharge()
125 self.data.cluster_seedCharge = cluster.getSeedCharge()
126 self.data.cluster_size = cluster.getSize()
127 self.data.cluster_snr = cluster.getSNR()
128 cluster_position = cluster.getPosition()
129 if cluster.isUCluster():
130 cluster_position = cluster.getPosition(truehit.getV())
132 if cluster.isUCluster():
134 strip_pitch = sensorInfo.getUPitch(truehit.getV())
137 strip_pitch = sensorInfo.getVPitch(truehit.getU())
138 self.data.strip_dir = strip_dir
139 self.data.strip_pitch = strip_pitch
140 cluster_interstripPosition = cluster_position % strip_pitch / strip_pitch
141 self.data.cluster_interstripPosition = cluster_interstripPosition
143 if cluster.isUCluster():
144 uPos = cluster_position
148 vPos = cluster_position
149 localPosition = TVector3(uPos, vPos, 0)
150 globalPosition = sensorInfo.pointToGlobal(localPosition,
True)
151 x = globalPosition[0]
152 y = globalPosition[1]
153 z = globalPosition[2]
156 rho = math.sqrt(x * x + y * y)
157 r = math.sqrt(x * x + y * y + z * z)
159 thetaRadians = math.acos(z / r)
160 theta = (thetaRadians * 180) / math.pi
162 phiRadians = math.acos(x / rho)
164 phi = 360 - (phiRadians * 180) / math.pi
166 phi = (phiRadians * 180) / math.pi
167 self.data.cluster_theta = theta
168 self.data.cluster_phi = phi
170 clusterPos = cluster_position
171 clusterPosSigma = cluster.getPositionSigma()
172 if cluster.isUCluster():
173 truehitPos = truehit.getU()
175 truehitPos = truehit.getV()
176 cluster_residual = clusterPos - truehitPos
177 cluster_pull = cluster_residual / clusterPosSigma
178 self.data.cluster_position = clusterPos
179 self.data.cluster_positionSigma = clusterPosSigma
180 self.data.cluster_residual = cluster_residual
181 self.data.cluster_pull = cluster_pull
183 self.data.truehit_position = truehitPos
184 truehit_interstripPosition = truehitPos % strip_pitch / strip_pitch
185 self.data.truehit_interstripPosition = truehit_interstripPosition
186 self.data.truehit_deposEnergy = truehit.getEnergyDep()
187 self.data.truehit_lossmomentum = truehit.getEntryMomentum().Mag() - truehit.getExitMomentum().Mag()
188 self.data.truehit_time = truehit.getGlobalTime()
194 """Close the output file. """
196 self.
filefile.Write()
197 self.
filefile.Close()
a (simplified) python wrapper for StoreArray.
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
data
instance of EventData class
tree
TTree for output data.