Belle II Software development
ResidualSVDStateFilter.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/ResidualSVDStateFilter.h>
9
10#include <tracking/spacePointCreation/SpacePoint.h>
11#include <framework/core/ModuleParamList.h>
12#include <tracking/trackingUtilities/utilities/StringManipulation.h>
13
14#include <Math/Vector3D.h>
15
16using namespace Belle2;
17using namespace TrackingUtilities;
18
19void ResidualSVDStateFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
20{
21 moduleParamList->addParameter(TrackingUtilities::prefixed(prefix, "maximalResidual"), m_param_maximalResidual,
22 "Maximum residual between extrapolated and measured position based on Kalman step.",
24}
25
27{
28 const std::vector<TrackingUtilities::WithWeight<const CKFToSVDState*>>& previousStates = pair.first;
29 CKFToSVDState* currentState = pair.second;
30
31 const auto* spacePoint = currentState->getHit();
32
33 genfit::MeasuredStateOnPlane firstMeasurement;
34 if (currentState->mSoPSet()) {
35 firstMeasurement = currentState->getMeasuredStateOnPlane();
36 } else {
37 firstMeasurement = previousStates.back()->getMeasuredStateOnPlane();
38 }
39
40 ROOT::Math::XYZVector position = ROOT::Math::XYZVector(firstMeasurement.getPos());
41 const ROOT::Math::XYZVector hitPosition = spacePoint->getPosition();
42
43 const bool sameHemisphere = fabs(position.Phi() - hitPosition.Phi()) < TMath::PiOver2();
44 if (not sameHemisphere) {
45 return NAN;
46 }
47
48 const double residual = m_kalmanStepper.calculateResidual(firstMeasurement, *currentState);
49 if (residual > m_param_maximalResidual) {
50 return NAN;
51 }
52
53 // add 1e-6 to prevent divisin with 0.
54 return 1 / (residual + 1e-6);
55}
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.
The Module parameter list class.
TrackingUtilities::Weight operator()(const BaseSVDStateFilter::Object &pair) final
Return 1/residual and cut at the maximum residual.
SVDKalmanStepper m_kalmanStepper
Kalman Stepper to calculate the residual.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the maximal residual.
double m_param_maximalResidual
Parameter: maximal residual.
std::pair< const std::vector< TrackingUtilities::WithWeight< const CKFToSVDState * > >, CKFToSVDState * > Object
Definition Filter.dcl.h:35
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.