Belle II Software  release-05-01-25
ResidualSVDStateFilter.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2017 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/ckf/svd/filters/states/ResidualSVDStateFilter.h>
11 
12 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
13 #include <tracking/spacePointCreation/SpacePoint.h>
14 #include <framework/core/ModuleParamList.h>
15 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
16 
17 using namespace Belle2;
18 using namespace TrackFindingCDC;
19 
20 void ResidualSVDStateFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
21 {
22  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "maximalResidual"), m_param_maximalResidual,
23  "Maximal residual.", m_param_maximalResidual);
24 }
25 
27 {
28  const std::vector<TrackFindingCDC::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  Vector3D position = Vector3D(firstMeasurement.getPos());
41  const Vector3D hitPosition = static_cast<Vector3D>(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 }
Belle2::Vector3D
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:35
genfit::MeasuredStateOnPlane
#StateOnPlane with additional covariance matrix.
Definition: MeasuredStateOnPlane.h:39
Belle2::CKFState::getMeasuredStateOnPlane
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlane() const
Get the mSoP if already set during extrapolation (or fitting)
Definition: CKFState.h:103
Belle2::ResidualSVDStateFilter::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the maximal residual.
Definition: ResidualSVDStateFilter.cc:20
Belle2::CKFState::mSoPSet
bool mSoPSet() const
Is the mSoP already set? (= state was already extrapolated)
Definition: CKFState.h:116
Belle2::ModuleParamList::addParameter
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Definition: ModuleParamList.templateDetails.h:38
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ResidualSVDStateFilter::operator()
TrackFindingCDC::Weight operator()(const BaseSVDStateFilter::Object &pair) final
Return 1/residual and cut at the maximum residual.
Definition: ResidualSVDStateFilter.cc:26
Belle2::CKFState::getHit
const Hit * getHit() const
Return the SP this state is related to. May be nullptr.
Definition: CKFState.h:76
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::CKFToSVDState
Specialized CKF State for extrapolating into the SVD.
Definition: CKFToSVDState.h:29
Belle2::TrackFindingCDC::Filter::Object
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:43