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/trackFindingCDC/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/trackFindingCDC/utilities/StringManipulation.h>
17#include <framework/core/ModuleParamList.h>
18
19using namespace Belle2;
20
21namespace {
22 TrackFindingCDC::ERightLeft setRLInfo(const genfit::MeasuredStateOnPlane& mSoP, CDCCKFState& state)
23 {
24 const auto& mom = TrackFindingCDC::Vector3D(mSoP.getMom());
25 const auto& wire = state.getWireHit()->getWire();
26
27 const auto& trackPosition = TrackFindingCDC::Vector3D(mSoP.getPos());
28 const auto& hitPosition = wire.getWirePos3DAtZ(trackPosition.z());
29
30 TrackFindingCDC::Vector3D trackPosToWire{hitPosition - trackPosition};
31 TrackFindingCDC::ERightLeft rlInfo = trackPosToWire.xy().isRightOrLeftOf(mom.xy());
32
33 state.setRLinfo(rlInfo);
34 return rlInfo;
35 }
36}
37
38ExtrapolateAndUpdateCDCStateFilter::ExtrapolateAndUpdateCDCStateFilter()
39{
41}
42
43void ExtrapolateAndUpdateCDCStateFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
44{
45 m_extrapolator.exposeParameters(moduleParamList, prefix);
46
47 moduleParamList->getParameter<std::string>(TrackFindingCDC::prefixed(prefix, "direction")).setDefaultValue("forward");
48}
49
51{
52 const CDCCKFPath* path = pair.first;
53 CDCCKFState& state = *(pair.second);
54 const CDCCKFState& lastState = path->back();
55
56 genfit::MeasuredStateOnPlane mSoP = lastState.getTrackState();
57
58 const TrackFindingCDC::CDCWireHit* wireHit = state.getWireHit();
59 CDCRecoHit recoHit(wireHit->getHit(), nullptr);
60
61 try {
62 const auto& plane = recoHit.constructPlane(mSoP);
63 if (std::isnan(m_extrapolator.extrapolateToPlane(mSoP, plane))) {
64 return NAN;
65 }
66
67 const auto& measurements = recoHit.constructMeasurementsOnPlane(mSoP);
68 B2ASSERT("Should be exactly two measurements", measurements.size() == 2);
69
70 const auto& rightLeft = setRLInfo(mSoP, state);
71
72 if (rightLeft == TrackFindingCDC::ERightLeft::c_Right) {
73 state.setChi2(m_updater.kalmanStep(mSoP, *(measurements[1])));
74 } else {
75 state.setChi2(m_updater.kalmanStep(mSoP, *(measurements[0])));
76 }
77
78 delete measurements[0];
79 delete measurements[1];
80
81 state.setTrackState(mSoP);
82 setRLInfo(mSoP, state);
83
84 return 1. / state.getChi2();
85 } catch (const genfit::Exception& e) {
86 return NAN;
87 }
88}
double extrapolateToPlane(genfit::MeasuredStateOnPlane &measuredStateOnPlane, const genfit::SharedPlanePtr &plane) const
Extrapolate the mSoP of one plane to another plane and return the traveled distance or NAN,...
Definition: Advancer.cc:22
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the parameters.
Definition: Advancer.cc:52
Define states for CKF algorithm, which can be seed track or CDC wire hit.
Definition: CDCCKFState.h:25
void setRLinfo(const TrackFindingCDC::ERightLeft &rl)
Set right-left info for the hit.
Definition: CDCCKFState.h:75
void setTrackState(const genfit::MeasuredStateOnPlane &trackState)
Store genfit Measured state on plane.
Definition: CDCCKFState.h:69
double getChi2() const
Get state chi2.
Definition: CDCCKFState.h:130
void setChi2(double chi2)
Set set chi2.
Definition: CDCCKFState.h:124
const genfit::MeasuredStateOnPlane & getTrackState() const
Get genfit track state (but first check if already present)
Definition: CDCCKFState.h:62
const TrackFindingCDC::CDCWireHit * getWireHit() const
Get CDCWireHit corresponding to the state.
Definition: CDCCKFState.h:35
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
Definition: CDCRecoHit.cc:140
genfit::SharedPlanePtr constructPlane(const genfit::StateOnPlane &state) const override
Methods that actually interface to Genfit.
Definition: CDCRecoHit.cc:80
TrackFindingCDC::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,...
KalmanStepper< 1 > m_updater
Kalman filter updater.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
double kalmanStep(genfit::MeasuredStateOnPlane &measuredStateOnPlane, const genfit::MeasurementOnPlane &measurementOnPlane) const
Kalman update of the mSoP using the measurement. Is just a wrapper around the other kalmanStepper wor...
Definition: KalmanStepper.h:48
The Module parameter list class.
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:35
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:453
A three dimensional vector.
Definition: Vector3D.h:33
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition: Vector3D.h:508
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
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.