Belle II Software  release-08-01-10
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 <framework/geometry/VectorUtil.h>
12 #include <pxd/reconstruction/PXDPixelMasker.h>
13 
14 namespace Belle2 {
19  namespace PXD {
20 
21  std::shared_ptr<TrackState> getTrackStateOnModule(
22  const VXD::SensorInfoBase& pxdSensorInfo,
23  RecoTrack& recoTrack, double lambda)
24  {
25  // get sensor plane, always enable alignment.
26  auto centerP = pxdSensorInfo.pointToGlobal(ROOT::Math::XYZVector(0, 0, 0), true);
27  auto normalV = pxdSensorInfo.vectorToGlobal(ROOT::Math::XYZVector(0, 0, 1), true);
28  genfit::SharedPlanePtr sensorPlaneSptr(new genfit::DetPlane(XYZToTVector(centerP), XYZToTVector(normalV)));
29 
30  // genfit track and measured state on plane
31  const genfit::Track& gfTrack = RecoTrackGenfitAccess::getGenfitTrack(recoTrack);
32  auto statePtr = std::make_shared<TrackState>();
33 
34  try {
35  *statePtr = gfTrack.getFittedState();
36  lambda = statePtr->extrapolateToPlane(sensorPlaneSptr);
37  } catch (...) {
38  B2DEBUG(20, "extrapolation to plane failed! Lambda = " << lambda);
39  return std::shared_ptr<TrackState>(nullptr);
40  }
41  auto intersec = pxdSensorInfo.pointToLocal(ROOT::Math::XYZVector(statePtr->getPos()), true);
42 
43  // check if the intersection is inside (no tolerance).
44  double tolerance = 0.0;
45  bool inside = pxdSensorInfo.inside(intersec.X(), intersec.Y(), tolerance, tolerance);
46  if (!inside) return std::shared_ptr<TrackState>(nullptr);
47 
48  return statePtr;
49  }
50 
51  bool isCloseToBorder(int u, int v, int checkDistance)
52  {
53 
54  if (u - checkDistance < 0 || u + checkDistance >= 250 ||
55  v - checkDistance < 0 || v + checkDistance >= 768) {
56  return true;
57  }
58  return false;
59  }
60 
61  bool isDefectivePixelClose(int u, int v, int checkDistance, const VxdID& moduleID)
62  {
63 
64  //Iterate over square around the intersection to see if any close pixel is dead
65  for (int u_iter = u - checkDistance; u_iter <= u + checkDistance ; ++u_iter) {
66  for (int v_iter = v - checkDistance; v_iter <= v + checkDistance ; ++v_iter) {
67  if (PXDPixelMasker::getInstance().pixelDead(moduleID, u_iter, v_iter)
68  || !PXDPixelMasker::getInstance().pixelOK(moduleID, u_iter, v_iter)) {
69  return true;
70  }
71  }
72  }
73  return false;
74  }
75 
76  } // end namespace PXD
78 } // 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:404
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
Base class to provide Sensor Information for PXD and SVD.
ROOT::Math::XYZVector pointToLocal(const ROOT::Math::XYZVector &global, bool reco=false) const
Convert a point from global to local coordinates.
ROOT::Math::XYZVector pointToGlobal(const ROOT::Math::XYZVector &local, bool reco=false) const
Convert a point from local to global coordinates.
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.
ROOT::Math::XYZVector vectorToGlobal(const ROOT::Math::XYZVector &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:294
static constexpr auto XYZToTVector
Helper function to convert XYZVector to TVector3.
Definition: VectorUtil.h:24
bool isCloseToBorder(int u, int v, int checkDistance)
Helper function to check if a pixel is close to the border.
Definition: PXDUtilities.cc:51
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:21
bool isDefectivePixelClose(int u, int v, int checkDistance, const VxdID &moduleID)
Helper function to check if a defective (hot/dead) pixel is close.
Definition: PXDUtilities.cc:61
Abstract base class for different kinds of events.
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.