Belle II Software  release-08-01-10
PXDPositionEstimation Class Reference
Inheritance diagram for PXDPositionEstimation:
Collaboration diagram for PXDPositionEstimation:

Public Member Functions

def initialize (self)
 
def event (self)
 
def terminate (self)
 

Public Attributes

 nclusters
 Counter for all clusters.
 
 nfound_shapes
 Counter for cluster where shape likelyhood was found in payload.
 
 nfound_offset
 Counter for clusters where position correction was found in payload.
 
 rfile
 Output file to store all plots.
 
 hist_map_momentum
 Histograms for true particle momenta.
 
 hist_map_theta_u
 Histograms for true particle angle thetaU.
 
 hist_map_theta_v
 Histograms for true particle angle thetaV.
 
 hist_map_clustercharge
 Histograms for cluster charge related to particle.
 
 hist_map_residual_u
 Histograms for u residuals.
 
 hist_map_residual_v
 Histograms for v residuals.
 
 hist_map_residual_v_special
 Histograms for v residuals for smaller thetaV range.
 
 hist_map_residual_pull_u
 Histograms for u residual pulls.
 
 hist_map_residual_pull_v
 Histograms for v residual pulls.
 
 binlimits
 ThetaV angle ranges for v residuals.
 

Detailed Description

Histogram the difference position residuals and pulls between clusters and truehits.

Definition at line 26 of file test_cluster_position_estimator.py.

Member Function Documentation

◆ event()

def event (   self)
Fill the residual and pull histograms

Definition at line 106 of file test_cluster_position_estimator.py.

106  def event(self):
107  """Fill the residual and pull histograms"""
108 
109  # Get truehits
110  truehits = Belle2.PyStoreArray("PXDTrueHits")
111 
112  for truehit in truehits:
113  if isinstance(truehit, Belle2.PXDTrueHit):
114  sensor_info = Belle2.VXD.GeoCache.get(truehit.getSensorID())
115  clusters = truehit.getRelationsFrom("PXDClusters")
116 
117  # now check if we find a cluster
118  for j, cls in enumerate(clusters):
119  # we ignore all clusters where less then 100 electrons come from
120  # our truehit
121  if clusters.weight(j) < 100:
122  continue
123 
124  mom = truehit.getMomentum()
125  tu = mom[0] / mom[2]
126  tv = mom[1] / mom[2]
127  thetaU = math.atan(tu) * 180 / math.pi
128  thetaV = math.atan(tv) * 180 / math.pi
129 
130  # Only look at primary particles -> check if the following is needed
131  # for mcp in truehit.getRelationsFrom("MCParticles"):
132  # if not mcp.hasStatus(1):
133  # reject = True
134 
135  # Get instance of position estimator
137  clusterkind = cls.getKind()
138 
139  # Clusterkinds 0,1,2,3 refer to all cases which can currently
140  # be corrected. Cases where a cluster pixel touches a sensor
141  # edge or contains pixel with varying vPitch are excluded here.
142  if clusterkind <= 3 and mom.Mag() > 0.02:
143 
144  self.nclusters += 1
145 
146  # Fill momentum and angles for clusterkind
147  self.hist_map_momentum[clusterkind].Fill(mom.Mag())
148  self.hist_map_theta_u[clusterkind].Fill(thetaU)
149  self.hist_map_theta_v[clusterkind].Fill(thetaV)
150  self.hist_map_clustercharge[clusterkind].Fill(cls.getCharge())
151 
152  # Fill clusterkind=4 for all PXD sensors
153  self.hist_map_momentum[4].Fill(mom.Mag())
154  self.hist_map_theta_u[4].Fill(thetaU)
155  self.hist_map_theta_v[4].Fill(thetaV)
156  self.hist_map_clustercharge[4].Fill(cls.getCharge())
157 
158  # Fill the histograms (mode=2)
159  mode = 2
160  pull_u = (truehit.getU() - cls.getU()) / cls.getUSigma()
161  pull_v = (truehit.getV() - cls.getV()) / cls.getVSigma()
162 
163  self.hist_map_residual_u[(clusterkind, mode)].Fill(truehit.getU() - cls.getU())
164  self.hist_map_residual_v[(clusterkind, mode)].Fill(truehit.getV() - cls.getV())
165  self.hist_map_residual_pull_u[(clusterkind, mode)].Fill(pull_u)
166  self.hist_map_residual_pull_v[(clusterkind, mode)].Fill(pull_v)
167 
168  if thetaV >= self.binlimits[0][0] and thetaV < self.binlimits[0][1]:
169  self.hist_map_residual_v_special[(clusterkind, mode, 0)].Fill(truehit.getV() - cls.getV())
170  elif thetaV >= self.binlimits[1][0] and thetaV < self.binlimits[1][1]:
171  self.hist_map_residual_v_special[(clusterkind, mode, 1)].Fill(truehit.getV() - cls.getV())
172  else:
173  self.hist_map_residual_v_special[(clusterkind, mode, 2)].Fill(truehit.getV() - cls.getV())
174 
175  shape_likelyhood = PositionEstimator.getShapeLikelyhood(cls, tu, tv)
176  if shape_likelyhood > 0:
177  self.nfound_shapes += 1
178 
179  offset = PositionEstimator.getClusterOffset(cls, tu, tv)
180  if offset:
181  # Now, we can safely querry the correction
182  self.nfound_offset += 1
183 
184  # We need to explicitely add a shift to the offsets
185  # This is not needed when working with PXDRecoHits
186  shiftU = sensor_info.getUCellPosition(cls.getUStart())
187  shiftV = sensor_info.getVCellPosition(cls.getVStart())
188 
189  # Fill the histograms (mode=0)
190  mode = 0
191  pull_u = (truehit.getU() - shiftU - offset.getU()) / (math.sqrt(offset.getUSigma2()))
192  pull_v = (truehit.getV() - shiftV - offset.getV()) / (math.sqrt(offset.getVSigma2()))
193 
194  self.hist_map_residual_u[(clusterkind, mode)].Fill(truehit.getU() - shiftU - offset.getU())
195  self.hist_map_residual_v[(clusterkind, mode)].Fill(truehit.getV() - shiftV - offset.getV())
196  self.hist_map_residual_pull_u[(clusterkind, mode)].Fill(pull_u)
197  self.hist_map_residual_pull_v[(clusterkind, mode)].Fill(pull_v)
198 
199  if thetaV >= self.binlimits[0][0] and thetaV < self.binlimits[0][1]:
200  self.hist_map_residual_v_special[(clusterkind, mode, 0)].Fill(
201  truehit.getV() - shiftV - offset.getV())
202  elif thetaV >= self.binlimits[1][0] and thetaV < self.binlimits[1][1]:
203  self.hist_map_residual_v_special[(clusterkind, mode, 1)].Fill(
204  truehit.getV() - shiftV - offset.getV())
205  else:
206  self.hist_map_residual_v_special[(clusterkind, mode, 2)].Fill(
207  truehit.getV() - shiftV - offset.getV())
208 
209  # Fill the histograms (mode=1)
210  mode = 1
211  self.hist_map_residual_u[(clusterkind, mode)].Fill(truehit.getU() - shiftU - offset.getU())
212  self.hist_map_residual_v[(clusterkind, mode)].Fill(truehit.getV() - shiftV - offset.getV())
213  self.hist_map_residual_pull_u[(clusterkind, mode)].Fill(pull_u)
214  self.hist_map_residual_pull_v[(clusterkind, mode)].Fill(pull_v)
215 
216  if thetaV >= self.binlimits[0][0] and thetaV < self.binlimits[0][1]:
217  self.hist_map_residual_v_special[(clusterkind, mode, 0)].Fill(
218  truehit.getV() - shiftV - offset.getV())
219  elif thetaV >= self.binlimits[1][0] and thetaV < self.binlimits[1][1]:
220  self.hist_map_residual_v_special[(clusterkind, mode, 1)].Fill(
221  truehit.getV() - shiftV - offset.getV())
222  else:
223  self.hist_map_residual_v_special[(clusterkind, mode, 2)].Fill(
224  truehit.getV() - shiftV - offset.getV())
225 
226  else:
227 
228  # Fill the histograms (mode=1)
229  mode = 1
230  pull_u = (truehit.getU() - cls.getU()) / cls.getUSigma()
231  pull_v = (truehit.getV() - cls.getV()) / cls.getVSigma()
232 
233  self.hist_map_residual_u[(clusterkind, mode)].Fill(truehit.getU() - cls.getU())
234  self.hist_map_residual_v[(clusterkind, mode)].Fill(truehit.getV() - cls.getV())
235  self.hist_map_residual_pull_u[(clusterkind, mode)].Fill(pull_u)
236  self.hist_map_residual_pull_v[(clusterkind, mode)].Fill(pull_v)
237 
238  if thetaV >= self.binlimits[0][0] and thetaV < self.binlimits[0][1]:
239  self.hist_map_residual_v_special[(clusterkind, mode, 0)].Fill(truehit.getV() - cls.getV())
240  elif thetaV >= self.binlimits[1][0] and thetaV < self.binlimits[1][1]:
241  self.hist_map_residual_v_special[(clusterkind, mode, 1)].Fill(truehit.getV() - cls.getV())
242  else:
243  self.hist_map_residual_v_special[(clusterkind, mode, 2)].Fill(truehit.getV() - cls.getV())
244 
Class PXDTrueHit - Records of tracks that either enter or leave the sensitive volume.
Definition: PXDTrueHit.h:31
static PXDClusterPositionEstimator & getInstance()
Main (and only) way to access the PXDClusterPositionEstimator.
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
static const SensorInfoBase & get(Belle2::VxdID id)
Return a reference to the SensorInfo of a given SensorID.
Definition: GeoCache.h:139

◆ initialize()

def initialize (   self)
Create histograms for pulls and residuals

Definition at line 31 of file test_cluster_position_estimator.py.

◆ terminate()

def terminate (   self)
Format and write all histograms and plot them

Definition at line 245 of file test_cluster_position_estimator.py.


The documentation for this class was generated from the following file: