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/trackFindingCDC/geometry/Vector3D.h>
11#include <tracking/spacePointCreation/SpacePoint.h>
12#include <framework/core/ModuleParamList.h>
13#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
14
15using namespace Belle2;
16using namespace TrackFindingCDC;
17
18void ResidualSVDStateFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
19{
20 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "maximalResidual"), m_param_maximalResidual,
21 "Maximum residual between extrapolated and measured position based on Kalman step.",
23}
24
26{
27 const std::vector<TrackFindingCDC::WithWeight<const CKFToSVDState*>>& previousStates = pair.first;
28 CKFToSVDState* currentState = pair.second;
29
30 const auto* spacePoint = currentState->getHit();
31
32 genfit::MeasuredStateOnPlane firstMeasurement;
33 if (currentState->mSoPSet()) {
34 firstMeasurement = currentState->getMeasuredStateOnPlane();
35 } else {
36 firstMeasurement = previousStates.back()->getMeasuredStateOnPlane();
37 }
38
39 Vector3D position = Vector3D(firstMeasurement.getPos());
40 const Vector3D hitPosition = static_cast<Vector3D>(spacePoint->getPosition());
41
42 const bool sameHemisphere = fabs(position.phi() - hitPosition.phi()) < TMath::PiOver2();
43 if (not sameHemisphere) {
44 return NAN;
45 }
46
47 const double residual = m_kalmanStepper.calculateResidual(firstMeasurement, *currentState);
48 if (residual > m_param_maximalResidual) {
49 return NAN;
50 }
51
52 // add 1e-6 to prevent divisin with 0.
53 return 1 / (residual + 1e-6);
54}
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
The Module parameter list class.
TrackFindingCDC::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.
double calculateResidual(genfit::MeasuredStateOnPlane &measuredStateOnPlane, const CKFToSVDState &state)
Calculate the residual between the mSoP and the measurement in the state.
AObject Object
Type of the object to be analysed.
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.
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:34
Abstract base class for different kinds of events.