Belle II Software  release-06-00-14
PXDUtilities.cc
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #include <pxd/utilities/PXDUtilities.h>
10 #include <framework/logging/Logger.h>
11 #include <pxd/reconstruction/PXDPixelMasker.h>
12 
13 namespace Belle2 {
18  namespace PXD {
19 
20  std::shared_ptr<TrackState> getTrackStateOnModule(
21  const VXD::SensorInfoBase& pxdSensorInfo,
22  RecoTrack& recoTrack, double lambda)
23  {
24  // get sensor plane, always enable alignment.
25  auto centerP = pxdSensorInfo.pointToGlobal(TVector3(0, 0, 0), true);
26  auto normalV = pxdSensorInfo.vectorToGlobal(TVector3(0, 0, 1), true);
27  genfit::SharedPlanePtr sensorPlaneSptr(new genfit::DetPlane(centerP, normalV));
28 
29  // genfit track and measured state on plane
30  const genfit::Track& gfTrack = RecoTrackGenfitAccess::getGenfitTrack(recoTrack);
31  auto statePtr = std::make_shared<TrackState>();
32 
33  try {
34  *statePtr = gfTrack.getFittedState();
35  lambda = statePtr->extrapolateToPlane(sensorPlaneSptr);
36  } catch (...) {
37  B2DEBUG(20, "extrapolation to plane failed! Lambda = " << lambda);
38  return std::shared_ptr<TrackState>(nullptr);
39  }
40  auto intersec = pxdSensorInfo.pointToLocal(statePtr->getPos(), true);
41 
42  // check if the intersection is inside (no tolerance).
43  double tolerance = 0.0;
44  bool inside = pxdSensorInfo.inside(intersec.X(), intersec.Y(), tolerance, tolerance);
45  if (!inside) return std::shared_ptr<TrackState>(nullptr);
46 
47  return statePtr;
48  }
49 
50  bool isCloseToBorder(int u, int v, int checkDistance)
51  {
52 
53  if (u - checkDistance < 0 || u + checkDistance >= 250 ||
54  v - checkDistance < 0 || v + checkDistance >= 768) {
55  return true;
56  }
57  return false;
58  }
59 
60  bool isDefectivePixelClose(int u, int v, int checkDistance, const VxdID& moduleID)
61  {
62 
63  //Iterate over square around the intersection to see if any close pixel is dead
64  for (int u_iter = u - checkDistance; u_iter <= u + checkDistance ; ++u_iter) {
65  for (int v_iter = v - checkDistance; v_iter <= v + checkDistance ; ++v_iter) {
66  if (PXDPixelMasker::getInstance().pixelDead(moduleID, u_iter, v_iter)
67  || !PXDPixelMasker::getInstance().pixelOK(moduleID, u_iter, v_iter)) {
68  return true;
69  }
70  }
71  }
72  return false;
73  }
74  } // end namespace PXD
76 } // end namespace Belle2
static PXDPixelMasker & getInstance()
Main (and only) way to access the PXDPixelMasker.
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
Definition: RecoTrack.cc:396
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:76
Base class to provide Sensor Information for PXD and SVD.
bool inside(double u, double v, double uTolerance=DBL_EPSILON, double vTolerance=DBL_EPSILON) const
Check wether a given point is inside the active area.
TVector3 pointToLocal(const TVector3 &global, bool reco=false) const
Convert a point from global to local coordinates.
TVector3 pointToGlobal(const TVector3 &local, bool reco=false) const
Convert a point from local to global coordinates.
TVector3 vectorToGlobal(const TVector3 &local, bool reco=false) const
Convert a vector from local to global coordinates.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
Detector plane.
Definition: DetPlane.h:59
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:71
const MeasuredStateOnPlane & getFittedState(int id=0, const AbsTrackRep *rep=nullptr, bool biased=true) const
Shortcut to get FittedStates.
Definition: Track.cc:285
bool isCloseToBorder(int u, int v, int checkDistance)
Helper function to check if a pixel is close to the border.
Definition: PXDUtilities.cc:50
std::shared_ptr< TrackState > getTrackStateOnModule(const VXD::SensorInfoBase &pxdSensorInfo, RecoTrack &recoTrack, double lambda=0.0)
Helper function to get a track state on a module.
Definition: PXDUtilities.cc:20
bool isDefectivePixelClose(int u, int v, int checkDistance, const VxdID &moduleID)
Helper function to chheck if a defective (hot/dead) pixel is close.
Definition: PXDUtilities.cc:60
Abstract base class for different kinds of events.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.