Belle II Software development
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/trackingUtilities/eventdata/trajectories/CDCTrajectory3D.h>
11#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
12#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectorySZ.h>
13
14#include <tracking/trackingUtilities/eventdata/trajectories/CDCBFieldUtil.h>
15#include <tracking/spacePointCreation/SpacePoint.h>
16#include <tracking/dataobjects/RecoTrack.h>
17
18#include <Math/Vector2D.h>
19#include <Math/Vector3D.h>
20
21using namespace Belle2;
22using namespace TrackingUtilities;
23
24namespace {
26 unsigned int getPTRange(const ROOT::Math::XYZVector& momentum)
27 {
28 const double pT = momentum.Rho();
29 if (pT > 0.4) {
30 return 0;
31 } else if (pT > 0.2) {
32 return 1;
33 } else {
34 return 2;
35 }
36 }
37}
38
40constexpr const double SimpleSVDStateFilter::m_param_maximumResidual[][3];
41constexpr const double SimpleSVDStateFilter::m_param_maximumResidual2[][3];
42
47
49{
50 const std::vector<TrackingUtilities::WithWeight<const CKFToSVDState*>>& previousStates = pair.first;
51 CKFToSVDState* currentState = pair.second;
52
53 const auto* spacePoint = currentState->getHit();
54
55 genfit::MeasuredStateOnPlane firstMeasurement;
56 if (currentState->mSoPSet()) {
57 firstMeasurement = currentState->getMeasuredStateOnPlane();
58 } else {
59 firstMeasurement = previousStates.back()->getMeasuredStateOnPlane();
60 }
61
62 const ROOT::Math::XYZVector position = ROOT::Math::XYZVector(firstMeasurement.getPos());
63 const ROOT::Math::XYZVector momentum = ROOT::Math::XYZVector(firstMeasurement.getMom());
64
65 const ROOT::Math::XYZVector& hitPosition = spacePoint->getPosition();
66
67 const bool sameHemisphere = fabs(position.Phi() - hitPosition.Phi()) < TMath::PiOver2();
68 if (not sameHemisphere) {
69 return NAN;
70 }
71
72
73 double valueToCheck;
74 const MaximalValueArray* maximumValues;
75
76 if (not currentState->isFitted() and not currentState->mSoPSet()) {
77 // Filter 1
78 const RecoTrack* cdcTrack = previousStates.front()->getSeed();
79
80 B2ASSERT("A path without a seed?", cdcTrack);
81
82 const CDCTrajectory3D trajectory(position, 0, momentum, cdcTrack->getChargeSeed(), m_cachedBField);
83
84 const double arcLength = trajectory.calcArcLength2D(hitPosition);
85 const ROOT::Math::XYVector& trackPositionAtHit2D = trajectory.getTrajectory2D().getPos2DAtArcLength2D(arcLength);
86 const double trackPositionAtHitZ = trajectory.getTrajectorySZ().mapSToZ(arcLength);
87 const ROOT::Math::XYZVector trackPositionAtHit(trackPositionAtHit2D.X(), trackPositionAtHit2D.Y(), trackPositionAtHitZ);
88 const ROOT::Math::XYZVector differenceHelix = trackPositionAtHit - hitPosition;
89
90 valueToCheck = differenceHelix.R();
91 maximumValues = &m_param_maximumHelixDistance;
92 } else {
93 // Filter 2 + 3
94 const double residual = m_kalmanStepper.calculateResidual(firstMeasurement, *currentState);
95 valueToCheck = residual;
96 if (currentState->isFitted()) {
97 maximumValues = &m_param_maximumResidual2;
98 } else {
99 maximumValues = &m_param_maximumResidual;
100 }
101 }
102
103 const unsigned int layer = currentState->getGeometricalLayer();
104 if (valueToCheck > (*maximumValues)[layer - 3][getPTRange(momentum)]) {
105 return NAN;
106 }
107
108 return valueToCheck;
109}
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 isFitted() const
Check if state was already fitted.
Definition CKFState.h:100
bool mSoPSet() const
Is the mSoP already set? (= state was already extrapolated)
Definition CKFState.h:106
Specialized CKF State for extrapolating into the SVD.
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.
TrackingUtilities::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.
SVDKalmanStepper m_kalmanStepper
Kalman stepper (CKF) for SVD.
double m_cachedBField
Cache for the B field at the IP.
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 strength in z direction at the origin ( in Tesla )
ROOT::Math::XYVector getPos2DAtArcLength2D(double arcLength2D)
Getter for the position at a given two dimensional arc length.
Particle full three dimensional trajectory.
CDCTrajectory2D getTrajectory2D() const
Getter for the two dimensional trajectory.
CDCTrajectorySZ getTrajectorySZ() const
Getter for the sz trajectory.
double calcArcLength2D(const ROOT::Math::XYZVector &point) const
Calculate the travel distance from the start position of the trajectory.
double mapSToZ(const double s=0) const
Translates the travel distance to the z coordinate.
std::pair< const std::vector< TrackingUtilities::WithWeight< const CKFToSVDState * > >, CKFToSVDState * > Object
Definition Filter.dcl.h:35
Abstract base class for different kinds of events.