15 This module is used for the SVD validation.
16 It gets information about clusters and truehits, saving in a ttree in a ROOT file.
18 <noexecute>SVD validation helper class</noexecute>
28 from ROOT
import Belle2
29 from ROOT
import gROOT, addressof
30 from ROOT
import TVector3
33 gROOT.ProcessLine(
'struct EventDataCluster {\
40 int cluster_truehits_number;\
45 float cluster_position;\
46 float cluster_positionSigma;\
47 float cluster_clsTime;\
48 float cluster_clsTimeSigma;\
49 float cluster_charge;\
50 float cluster_seedCharge;\
53 float cluster_interstripPosition;\
55 float cluster_residual;\
56 float truehit_position;\
57 float truehit_interstripPosition;\
58 float truehit_deposEnergy;\
59 float truehit_lossmomentum;\
69 from ROOT
import EventDataCluster
73 '''class to produce the ttree for cluster reconstruction validation'''
76 """Initialize the module"""
78 super(SVDValidationTTreeCluster, self).
__init__()
81 self.
filefile = ROOT.TFile(
'../SVDValidationTTreeCluster.root',
'recreate')
83 self.
treetree = ROOT.TTree(
'tree',
'Event data of SVD validation events')
85 self.
datadata = EventDataCluster()
88 for key
in EventDataCluster.__dict__:
91 if isinstance(self.
datadata.__getattribute__(key), int):
93 self.
treetree.Branch(key, addressof(self.
datadata, key), key + formstring)
96 """ Find clusters with a truehit and save needed information """
101 self.
datadata.eventt0_all = -1
102 self.
datadata.eventt0_top = -1
103 self.
datadata.eventt0_cdc = -1
104 self.
datadata.eventt0_ecl = -1
105 self.
datadata.eventt0_svd = -1
110 if eventt0.hasEventT0():
111 self.
datadata.eventt0_all = eventt0.getEventT0()
112 if eventt0.hasTemporaryEventT0(svd):
113 tmp = eventt0.getTemporaryEventT0s(Belle2.Const.SVD)
114 self.
datadata.eventt0_svd = tmp.back().eventT0
115 if eventt0.hasTemporaryEventT0(cdc):
116 tmp = eventt0.getTemporaryEventT0s(Belle2.Const.CDC)
117 self.
datadata.eventt0_cdc = tmp.back().eventT0
118 if eventt0.hasTemporaryEventT0(top):
119 tmp = eventt0.getTemporaryEventT0s(Belle2.Const.TOP)
120 self.
datadata.eventt0_top = tmp.back().eventT0
121 if eventt0.hasTemporaryEventT0(ecl):
122 evtT0List_ECL = eventt0.getTemporaryEventT0s(Belle2.Const.ECL)
124 smallest_ECL_t0_minChi2 = evtT0List_ECL[0].quality
125 self.
datadata.eventt0_ecl = evtT0List_ECL[0].eventT0
126 for tmp
in evtT0List_ECL:
127 if tmp.quality < smallest_ECL_t0_minChi2:
128 smallest_ECL_t0_minChi2 = tmp.quality
129 self.
datadata.eventt0_ecl = tmp.eventT0
131 for cluster
in clusters:
133 cluster_truehits = cluster.getRelationsTo(
'SVDTrueHits')
137 sensorID = cluster.getSensorID()
138 self.
datadata.sensor_id = int(sensorID)
139 sensorNum = sensorID.getSensorNumber()
140 self.
datadata.sensor = sensorNum
141 layerNum = sensorID.getLayerNumber()
142 self.
datadata.layer = layerNum
150 self.
datadata.sensor_type = sensorType
151 ladderNum = sensorID.getLadderNumber()
152 self.
datadata.ladder = ladderNum
153 if cluster.isUCluster():
158 self.
datadata.matched = 1
162 if len(cluster_truehits) == 0:
163 self.
datadata.matched = 0
172 for i, trueHit
in enumerate(cluster_truehits):
173 if trueHit.getEnergyDep() > energy:
174 energy = trueHit.getEnergyDep()
176 bestTrueHit = cluster_truehits[bestTrueHitIndex]
179 self.
datadata.cluster_clsTime = cluster.getClsTime()
180 self.
datadata.cluster_clsTimeSigma = cluster.getClsTimeSigma()
181 self.
datadata.cluster_charge = cluster.getCharge()
182 self.
datadata.cluster_seedCharge = cluster.getSeedCharge()
183 self.
datadata.cluster_size = cluster.getSize()
184 self.
datadata.cluster_snr = cluster.getSNR()
185 cluster_position = cluster.getPosition()
186 if cluster.isUCluster():
187 cluster_position = cluster.getPosition(bestTrueHit.getV())
189 strip_pitch = sensorInfo.getUPitch(bestTrueHit.getV())
191 strip_pitch = sensorInfo.getVPitch(bestTrueHit.getU())
192 self.
datadata.strip_dir = strip_dir
193 self.
datadata.strip_pitch = strip_pitch
194 self.
datadata.cluster_interstripPosition = cluster_position % strip_pitch / strip_pitch
196 if cluster.isUCluster():
197 uPos = cluster_position
201 vPos = cluster_position
202 localPosition = TVector3(uPos, vPos, 0)
203 globalPosition = sensorInfo.pointToGlobal(localPosition,
True)
204 x = globalPosition.X()
205 y = globalPosition.Y()
206 z = globalPosition.Z()
209 rho = math.sqrt(x * x + y * y)
210 r = math.sqrt(x * x + y * y + z * z)
212 thetaRadians = math.acos(z / r)
213 theta = (thetaRadians * 180) / math.pi
215 phiRadians = math.acos(x / rho)
217 phi = 360 - (phiRadians * 180) / math.pi
219 phi = (phiRadians * 180) / math.pi
220 self.
datadata.cluster_theta = theta
221 self.
datadata.cluster_phi = phi
223 clusterPos = cluster_position
224 clusterPosSigma = cluster.getPositionSigma()
225 if cluster.isUCluster():
226 truehitPos = bestTrueHit.getU()
228 truehitPos = bestTrueHit.getV()
229 cluster_residual = clusterPos - truehitPos
230 cluster_pull = cluster_residual / clusterPosSigma
231 self.
datadata.cluster_position = clusterPos
232 self.
datadata.cluster_positionSigma = clusterPosSigma
233 self.
datadata.cluster_residual = cluster_residual
234 self.
datadata.cluster_pull = cluster_pull
236 self.
datadata.truehit_position = truehitPos
237 truehit_interstripPosition = truehitPos % strip_pitch / strip_pitch
238 self.
datadata.truehit_interstripPosition = truehit_interstripPosition
239 self.
datadata.truehit_deposEnergy = bestTrueHit.getEnergyDep()
240 self.
datadata.truehit_lossmomentum = bestTrueHit.getEntryMomentum().R() - bestTrueHit.getExitMomentum().R()
241 self.
datadata.truehit_time = bestTrueHit.getGlobalTime()
256 """Close the output file. """
258 self.
filefile.Write()
259 self.
filefile.Close()
The DetectorSet class for sets of detector IDs in the form of EDetector values.
A (simplified) python wrapper for StoreArray.
a (simplified) python wrapper for StoreObjPtr.
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.