Belle II Software development
ExtrapolateAndUpdateCDCStateFilter.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/cdc/filters/states/ExtrapolateAndUpdateCDCStateFilter.h>
9
10#include <tracking/trackingUtilities/numerics/ERightLeft.h>
11#include <tracking/trackingUtilities/geometry/VectorUtil.h>
12#include <cdc/dataobjects/CDCRecoHit.h>
13
14#include <tracking/ckf/cdc/entities/CDCCKFState.h>
15#include <tracking/ckf/cdc/entities/CDCCKFPath.h>
16
17#include <tracking/trackingUtilities/utilities/StringManipulation.h>
18
19#include <framework/core/ModuleParamList.h>
20
21#include <Math/Vector3D.h>
22
23using namespace Belle2;
24
25namespace {
26 TrackingUtilities::ERightLeft setRLInfo(const genfit::MeasuredStateOnPlane& mSoP, CDCCKFState& state)
27 {
28 const auto& mom = ROOT::Math::XYZVector(mSoP.getMom());
29 const auto& wire = state.getWireHit()->getWire();
30
31 const auto& trackPosition = ROOT::Math::XYZVector(mSoP.getPos());
32 const auto& hitPosition = wire.getWirePos3DAtZ(trackPosition.z());
33
34 ROOT::Math::XYZVector trackPosToWire{hitPosition - trackPosition};
35 TrackingUtilities::ERightLeft rlInfo = VectorUtil::isRightOrLeftOf(VectorUtil::getXYVector(trackPosToWire),
36 VectorUtil::getXYVector(mom));
37
38 state.setRLinfo(rlInfo);
39 return rlInfo;
40 }
41}
42
43ExtrapolateAndUpdateCDCStateFilter::ExtrapolateAndUpdateCDCStateFilter()
44{
46}
47
48void ExtrapolateAndUpdateCDCStateFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
49{
50 m_extrapolator.exposeParameters(moduleParamList, prefix);
51
52 moduleParamList->getParameter<std::string>(TrackingUtilities::prefixed(prefix, "direction")).setDefaultValue("forward");
53}
54
56{
57 const CDCCKFPath* path = pair.first;
58 CDCCKFState& state = *(pair.second);
59 const CDCCKFState& lastState = path->back();
60
61 genfit::MeasuredStateOnPlane mSoP = lastState.getTrackState();
62
63 const TrackingUtilities::CDCWireHit* wireHit = state.getWireHit();
64 CDCRecoHit recoHit(wireHit->getHit(), nullptr);
65
66 try {
67 const auto& plane = recoHit.constructPlane(mSoP);
68 if (std::isnan(m_extrapolator.extrapolateToPlane(mSoP, plane))) {
69 return NAN;
70 }
71
72 const auto& measurements = recoHit.constructMeasurementsOnPlane(mSoP);
73 B2ASSERT("Should be exactly two measurements", measurements.size() == 2);
74
75 const auto& rightLeft = setRLInfo(mSoP, state);
76
77 if (rightLeft == TrackingUtilities::ERightLeft::c_Right) {
78 state.setChi2(m_updater.kalmanStep(mSoP, *(measurements[1])));
79 } else {
80 state.setChi2(m_updater.kalmanStep(mSoP, *(measurements[0])));
81 }
82
83 delete measurements[0];
84 delete measurements[1];
85
86 state.setTrackState(mSoP);
87 setRLInfo(mSoP, state);
88
89 return 1. / state.getChi2();
90 } catch (const genfit::Exception& e) {
91 return NAN;
92 }
93}
Define states for CKF algorithm, which can be seed track or CDC wire hit.
Definition CDCCKFState.h:26
void setTrackState(const genfit::MeasuredStateOnPlane &trackState)
Store genfit Measured state on plane.
Definition CDCCKFState.h:70
void setRLinfo(const TrackingUtilities::ERightLeft &rl)
Set right-left info for the hit.
Definition CDCCKFState.h:76
double getChi2() const
Get state chi2.
const TrackingUtilities::CDCWireHit * getWireHit() const
Get CDCWireHit corresponding to the state.
Definition CDCCKFState.h:36
void setChi2(double chi2)
Set set chi2.
const genfit::MeasuredStateOnPlane & getTrackState() const
Get genfit track state (but first check if already present)
Definition CDCCKFState.h:63
This class is used to transfer CDC information to the track fit.
Definition CDCRecoHit.h:32
std::vector< genfit::MeasurementOnPlane * > constructMeasurementsOnPlane(const genfit::StateOnPlane &state) const override
build MeasurementsOnPlane
genfit::SharedPlanePtr constructPlane(const genfit::StateOnPlane &state) const override
Methods that actually interface to Genfit.
Definition CDCRecoHit.cc:81
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
TrackingUtilities::Weight operator()(const BaseCDCStateFilter::Object &pair) final
Extrapolate along the path (pair.first) to the CDC wireHit-state (pair.second). Return 1/chi2 if Ok,...
The Module parameter list class.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:56
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
std::vector< CDCCKFState > CDCCKFPath
Shortcut for the collection of CDC CKF-algorithm states.
Definition CDCCKFPath.h:19
Abstract base class for different kinds of events.