Belle II Software  release-05-01-25
PXDUtilities.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2021 Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Qingyuan Liu *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #include <pxd/utilities/PXDUtilities.h>
12 #include <framework/logging/Logger.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(TVector3(0, 0, 0), true);
27  auto normalV = pxdSensorInfo.vectorToGlobal(TVector3(0, 0, 1), true);
28  genfit::SharedPlanePtr sensorPlaneSptr(new genfit::DetPlane(centerP, normalV));
29 
30  // genfit track and measured state on plane
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(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  } // end namespace PXD
53 } // end namespace Belle2
genfit::SharedPlanePtr
std::shared_ptr< genfit::DetPlane > SharedPlanePtr
Shared Pointer to a DetPlane.
Definition: SharedPlanePtr.h:40
Belle2::RecoTrackGenfitAccess::getGenfitTrack
static genfit::Track & getGenfitTrack(RecoTrack &recoTrack)
Give access to the RecoTrack's genfit::Track.
Definition: RecoTrack.cc:389
genfit::Track
Collection of TrackPoint objects, AbsTrackRep objects and FitStatus objects.
Definition: Track.h:71
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
genfit::Track::getFittedState
const MeasuredStateOnPlane & getFittedState(int id=0, const AbsTrackRep *rep=nullptr, bool biased=true) const
Shortcut to get FittedStates.
Definition: Track.cc:285
genfit::DetPlane
Detector plane.
Definition: DetPlane.h:59