94 def event(self):
95 """ Find clusters with a truehit and save needed information """
98
99
100 self.data.eventt0_all = -1
101 self.data.eventt0_top = -1
102 self.data.eventt0_cdc = -1
103 self.data.eventt0_ecl = -1
104 self.data.eventt0_svd = -1
109 if eventt0.hasEventT0():
110 self.data.eventt0_all = eventt0.getEventT0()
111 if eventt0.hasTemporaryEventT0(svd):
112 tmp = eventt0.getTemporaryEventT0s(Belle2.Const.SVD)
113 self.data.eventt0_svd = tmp.back().eventT0
114 if eventt0.hasTemporaryEventT0(cdc):
115 tmp = eventt0.getTemporaryEventT0s(Belle2.Const.CDC)
116 self.data.eventt0_cdc = tmp.back().eventT0
117 if eventt0.hasTemporaryEventT0(top):
118 tmp = eventt0.getTemporaryEventT0s(Belle2.Const.TOP)
119 self.data.eventt0_top = tmp.back().eventT0
120 if eventt0.hasTemporaryEventT0(ecl):
121 evtT0List_ECL = eventt0.getTemporaryEventT0s(Belle2.Const.ECL)
122
123 smallest_ECL_t0_minChi2 = evtT0List_ECL[0].quality
124 self.data.eventt0_ecl = evtT0List_ECL[0].eventT0
125 for tmp in evtT0List_ECL:
126 if tmp.quality < smallest_ECL_t0_minChi2:
127 smallest_ECL_t0_minChi2 = tmp.quality
128 self.data.eventt0_ecl = tmp.eventT0
129
130 for cluster in clusters:
131
132 cluster_truehits = cluster.getRelationsTo('SVDTrueHits')
133
134
136 sensorID = cluster.getSensorID()
137 self.data.sensor_id = int(sensorID)
138 sensorNum = sensorID.getSensorNumber()
139 self.data.sensor = sensorNum
140 layerNum = sensorID.getLayerNumber()
141 self.data.layer = layerNum
142 if (layerNum == 3):
143 sensorType = 1
144 else:
145 if (sensorNum == 1):
146 sensorType = 0
147 else:
148 sensorType = 1
149 self.data.sensor_type = sensorType
150 ladderNum = sensorID.getLadderNumber()
151 self.data.ladder = ladderNum
152 if cluster.isUCluster():
153 strip_dir = 0
154 else:
155 strip_dir = 1
156
157 self.data.matched = 1
158
159
160
161 if len(cluster_truehits) == 0:
162 self.data.matched = 0
163
164 self.file.cd()
165 self.tree.Fill()
166 continue
167
168
169 energy = 0
170 bestTrueHitIndex = 0
171 for i, trueHit in enumerate(cluster_truehits):
172 if trueHit.getEnergyDep() > energy:
173 energy = trueHit.getEnergyDep()
174 bestTrueHitIndex = i
175 bestTrueHit = cluster_truehits[bestTrueHitIndex]
176
177
178 self.data.cluster_clsTime = cluster.getClsTime()
179 self.data.cluster_clsTimeSigma = cluster.getClsTimeSigma()
180 self.data.cluster_charge = cluster.getCharge()
181 self.data.cluster_seedCharge = cluster.getSeedCharge()
182 self.data.cluster_size = cluster.getSize()
183 self.data.cluster_snr = cluster.getSNR()
184 cluster_position = cluster.getPosition()
185 if cluster.isUCluster():
186 cluster_position = cluster.getPosition(bestTrueHit.getV())
187
188 strip_pitch = sensorInfo.getUPitch(bestTrueHit.getV())
189 else:
190 strip_pitch = sensorInfo.getVPitch(bestTrueHit.getU())
191 self.data.strip_dir = strip_dir
192 self.data.strip_pitch = strip_pitch
193 self.data.cluster_interstripPosition = cluster_position % strip_pitch / strip_pitch
194
195 if cluster.isUCluster():
196 uPos = cluster_position
197 vPos = 0
198 else:
199 uPos = 0
200 vPos = cluster_position
201 localPosition = Math.XYZVector(uPos, vPos, 0)
202 globalPosition = sensorInfo.pointToGlobal(localPosition, True)
203 x = globalPosition.X()
204 y = globalPosition.Y()
205 z = globalPosition.Z()
206
207
208 rho = math.sqrt(x * x + y * y)
209 r = math.sqrt(x * x + y * y + z * z)
210
211 thetaRadians = math.acos(z / r)
212 theta = (thetaRadians * 180) / math.pi
213
214 phiRadians = math.acos(x / rho)
215 if y < 0:
216 phi = 360 - (phiRadians * 180) / math.pi
217 else:
218 phi = (phiRadians * 180) / math.pi
219 self.data.cluster_theta = theta
220 self.data.cluster_phi = phi
221
222 clusterPos = cluster_position
223 clusterPosSigma = cluster.getPositionSigma()
224 if cluster.isUCluster():
225 truehitPos = bestTrueHit.getU()
226 else:
227 truehitPos = bestTrueHit.getV()
228 cluster_residual = clusterPos - truehitPos
229 cluster_pull = cluster_residual / clusterPosSigma
230 self.data.cluster_position = clusterPos
231 self.data.cluster_positionSigma = clusterPosSigma
232 self.data.cluster_residual = cluster_residual
233 self.data.cluster_pull = cluster_pull
234
235 self.data.truehit_position = truehitPos
236 truehit_interstripPosition = truehitPos % strip_pitch / strip_pitch
237 self.data.truehit_interstripPosition = truehit_interstripPosition
238 self.data.truehit_deposEnergy = bestTrueHit.getEnergyDep()
239 self.data.truehit_lossmomentum = bestTrueHit.getEntryMomentum().R() - bestTrueHit.getExitMomentum().R()
240 self.data.truehit_time = bestTrueHit.getGlobalTime()
241
242
243
244
245
246
247
248
249
250
251 self.file.cd()
252 self.tree.Fill()
253
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 GeoCache & getInstance()
Return a reference to the singleton instance.