Belle II Software  release-06-01-15
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 27 of file test_cluster_position_estimator.py.

Member Function Documentation

◆ event()

def event (   self)
Fill the residual and pull histograms

Definition at line 103 of file test_cluster_position_estimator.py.

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

◆ terminate()

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

Definition at line 242 of file test_cluster_position_estimator.py.


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