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 <cdc/dataobjects/CDCRecoHit.h>
12
13#include <tracking/ckf/cdc/entities/CDCCKFState.h>
14#include <tracking/ckf/cdc/entities/CDCCKFPath.h>
15
16#include <tracking/trackingUtilities/utilities/StringManipulation.h>
17
18#include <framework/core/ModuleParamList.h>
19
20using namespace Belle2;
21
22namespace {
23 TrackingUtilities::ERightLeft setRLInfo(const genfit::MeasuredStateOnPlane& mSoP, CDCCKFState& state)
24 {
25 const auto& mom = TrackingUtilities::Vector3D(mSoP.getMom());
26 const auto& wire = state.getWireHit()->getWire();
27
28 const auto& trackPosition = TrackingUtilities::Vector3D(mSoP.getPos());
29 const auto& hitPosition = wire.getWirePos3DAtZ(trackPosition.z());
30
31 TrackingUtilities::Vector3D trackPosToWire{hitPosition - trackPosition};
32 TrackingUtilities::ERightLeft rlInfo = trackPosToWire.xy().isRightOrLeftOf(mom.xy());
33
34 state.setRLinfo(rlInfo);
35 return rlInfo;
36 }
37}
38
39ExtrapolateAndUpdateCDCStateFilter::ExtrapolateAndUpdateCDCStateFilter()
40{
42}
43
44void ExtrapolateAndUpdateCDCStateFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
45{
46 m_extrapolator.exposeParameters(moduleParamList, prefix);
47
48 moduleParamList->getParameter<std::string>(TrackingUtilities::prefixed(prefix, "direction")).setDefaultValue("forward");
49}
50
52{
53 const CDCCKFPath* path = pair.first;
54 CDCCKFState& state = *(pair.second);
55 const CDCCKFState& lastState = path->back();
56
57 genfit::MeasuredStateOnPlane mSoP = lastState.getTrackState();
58
59 const TrackingUtilities::CDCWireHit* wireHit = state.getWireHit();
60 CDCRecoHit recoHit(wireHit->getHit(), nullptr);
61
62 try {
63 const auto& plane = recoHit.constructPlane(mSoP);
64 if (std::isnan(m_extrapolator.extrapolateToPlane(mSoP, plane))) {
65 return NAN;
66 }
67
68 const auto& measurements = recoHit.constructMeasurementsOnPlane(mSoP);
69 B2ASSERT("Should be exactly two measurements", measurements.size() == 2);
70
71 const auto& rightLeft = setRLInfo(mSoP, state);
72
73 if (rightLeft == TrackingUtilities::ERightLeft::c_Right) {
74 state.setChi2(m_updater.kalmanStep(mSoP, *(measurements[1])));
75 } else {
76 state.setChi2(m_updater.kalmanStep(mSoP, *(measurements[0])));
77 }
78
79 delete measurements[0];
80 delete measurements[1];
81
82 state.setTrackState(mSoP);
83 setRLInfo(mSoP, state);
84
85 return 1. / state.getChi2();
86 } catch (const genfit::Exception& e) {
87 return NAN;
88 }
89}
Define states for CKF algorithm, which can be seed track or CDC wire hit.
Definition CDCCKFState.h:25
void setTrackState(const genfit::MeasuredStateOnPlane &trackState)
Store genfit Measured state on plane.
Definition CDCCKFState.h:69
void setRLinfo(const TrackingUtilities::ERightLeft &rl)
Set right-left info for the hit.
Definition CDCCKFState.h:75
double getChi2() const
Get state chi2.
const TrackingUtilities::CDCWireHit * getWireHit() const
Get CDCWireHit corresponding to the state.
Definition CDCCKFState.h:35
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:62
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:80
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:58
ERightLeft isRightOrLeftOf(const Vector2D &rhs) const
Indicates if the given vector is more left or more right if you looked in the direction of this vecto...
Definition Vector2D.h:484
A three dimensional vector.
Definition Vector3D.h:34
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition Vector3D.h:513
STL class.
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.