Belle II Software  release-08-01-10
SimpleSVDStateFilter.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 #include <tracking/ckf/svd/filters/states/SimpleSVDStateFilter.h>
9 
10 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory3D.h>
11 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
12 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectorySZ.h>
13 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
14 
15 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCBFieldUtil.h>
16 #include <tracking/spacePointCreation/SpacePoint.h>
17 #include <tracking/dataobjects/RecoTrack.h>
18 
19 using namespace Belle2;
20 using namespace TrackFindingCDC;
21 
22 namespace {
24  unsigned int getPTRange(const TrackFindingCDC::Vector3D& momentum)
25  {
26  const double pT = momentum.xy().norm();
27  if (pT > 0.4) {
28  return 0;
29  } else if (pT > 0.2) {
30  return 1;
31  } else {
32  return 2;
33  }
34  }
35 }
36 
37 constexpr const double SimpleSVDStateFilter::m_param_maximumHelixDistance[][3];
38 constexpr const double SimpleSVDStateFilter::m_param_maximumResidual[][3];
39 constexpr const double SimpleSVDStateFilter::m_param_maximumResidual2[][3];
40 
42 {
44 }
45 
47 {
48  const std::vector<TrackFindingCDC::WithWeight<const CKFToSVDState*>>& previousStates = pair.first;
49  CKFToSVDState* currentState = pair.second;
50 
51  const auto* spacePoint = currentState->getHit();
52 
53  genfit::MeasuredStateOnPlane firstMeasurement;
54  if (currentState->mSoPSet()) {
55  firstMeasurement = currentState->getMeasuredStateOnPlane();
56  } else {
57  firstMeasurement = previousStates.back()->getMeasuredStateOnPlane();
58  }
59 
60  Vector3D position = Vector3D(firstMeasurement.getPos());
61  Vector3D momentum = Vector3D(firstMeasurement.getMom());
62 
63  const Vector3D hitPosition = static_cast<Vector3D>(spacePoint->getPosition());
64 
65  const bool sameHemisphere = fabs(position.phi() - hitPosition.phi()) < TMath::PiOver2();
66  if (not sameHemisphere) {
67  return NAN;
68  }
69 
70 
71  double valueToCheck;
72  const MaximalValueArray* maximumValues;
73 
74  if (not currentState->isFitted() and not currentState->mSoPSet()) {
75  // Filter 1
76  const RecoTrack* cdcTrack = previousStates.front()->getSeed();
77 
78  B2ASSERT("A path without a seed?", cdcTrack);
79 
80  const CDCTrajectory3D trajectory(position, 0, momentum, cdcTrack->getChargeSeed(), m_cachedBField);
81 
82  const double arcLength = trajectory.calcArcLength2D(hitPosition);
83  const Vector2D& trackPositionAtHit2D = trajectory.getTrajectory2D().getPos2DAtArcLength2D(arcLength);
84  const double trackPositionAtHitZ = trajectory.getTrajectorySZ().mapSToZ(arcLength);
85  const Vector3D trackPositionAtHit(trackPositionAtHit2D, trackPositionAtHitZ);
86  const Vector3D differenceHelix = trackPositionAtHit - hitPosition;
87 
88  valueToCheck = differenceHelix.norm();
89  maximumValues = &m_param_maximumHelixDistance;
90  } else {
91  // Filter 2 + 3
92  const double residual = m_kalmanStepper.calculateResidual(firstMeasurement, *currentState);
93  valueToCheck = residual;
94  if (currentState->isFitted()) {
95  maximumValues = &m_param_maximumResidual2;
96  } else {
97  maximumValues = &m_param_maximumResidual;
98  }
99  }
100 
101  const unsigned int layer = currentState->getGeometricalLayer();
102  if (valueToCheck > (*maximumValues)[layer - 3][getPTRange(momentum)]) {
103  return NAN;
104  }
105 
106  return valueToCheck;
107 }
bool isFitted() const
Check if state was already fitted.
Definition: CKFState.h:100
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlane() const
Get the mSoP if already set during extrapolation (or fitting)
Definition: CKFState.h:93
const Hit * getHit() const
Return the SP this state is related to. May be nullptr.
Definition: CKFState.h:66
bool mSoPSet() const
Is the mSoP already set? (= state was already extrapolated)
Definition: CKFState.h:106
Specialized CKF State for extrapolating into the SVD.
Definition: CKFToSVDState.h:27
unsigned int getGeometricalLayer() const
Extract the real layer this state sits on.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
short int getChargeSeed() const
Return the charge seed stored in the reco track. ATTENTION: This is not the fitted charge.
Definition: RecoTrack.h:508
static constexpr const MaximalValueArray m_param_maximumResidual
Maximum distance calculated with normal extrapolation in filter 3. Numbers calculated on MC.
void beginRun() final
Set the cached B field.
TrackFindingCDC::Weight operator()(const BaseSVDStateFilter::Object &pair) final
Function to evaluate the object.
static constexpr const MaximalValueArray m_param_maximumHelixDistance
Maximum distance calculated with helix extrapolation in filter 1. Numbers calculated on MC.
double[4][3] MaximalValueArray
Shortcut for a 4x3 array.
static constexpr const MaximalValueArray m_param_maximumResidual2
Maximum distance calculated with normal extrapolation in filter 2. Numbers calculated on MC.
static double getBFieldZ()
Getter for the signed magnetic field stength in z direction at the origin ( in Tesla )
Vector2D getPos2DAtArcLength2D(double arcLength2D)
Getter for the position at a given two dimensional arc length.
Particle full three dimensional trajectory.
double calcArcLength2D(const Vector3D &point) const
Calculate the travel distance from the start position of the trajectory.
CDCTrajectory2D getTrajectory2D() const
Getter for the two dimensional trajectory.
CDCTrajectorySZ getTrajectorySZ() const
Getter for the sz trajectory.
double mapSToZ(const double s=0) const
Translates the travel distance to the z coordinate.
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:33
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:35
A three dimensional vector.
Definition: Vector3D.h:33
#StateOnPlane with additional covariance matrix.
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:34
Abstract base class for different kinds of events.