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 <cdc/dataobjects/CDCRecoHit.h>
11
12#include <tracking/ckf/cdc/entities/CDCCKFState.h>
13#include <tracking/ckf/cdc/entities/CDCCKFPath.h>
14
15#include <tracking/trackFindingCDC/numerics/ERightLeft.h>
16#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
17#include <tracking/trackFindingCDC/topology/CDCWire.h>
18
19#include <framework/core/ModuleParamList.h>
20
21using namespace Belle2;
22
23namespace {
24 TrackFindingCDC::ERightLeft setRLInfo(const genfit::MeasuredStateOnPlane& mSoP, CDCCKFState& state)
25 {
26 const auto& mom = TrackFindingCDC::Vector3D(mSoP.getMom());
27 const auto& wire = state.getWireHit()->getWire();
28
29 const auto& trackPosition = TrackFindingCDC::Vector3D(mSoP.getPos());
30 const auto& hitPosition = wire.getWirePos3DAtZ(trackPosition.z());
31
32 TrackFindingCDC::Vector3D trackPosToWire{hitPosition - trackPosition};
33 TrackFindingCDC::ERightLeft rlInfo = trackPosToWire.xy().isRightOrLeftOf(mom.xy());
34
35 state.setRLinfo(rlInfo);
36 return rlInfo;
37 }
38}
39
40ExtrapolateAndUpdateCDCStateFilter::ExtrapolateAndUpdateCDCStateFilter()
41{
43}
44
45void ExtrapolateAndUpdateCDCStateFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
46{
47 m_extrapolator.exposeParameters(moduleParamList, prefix);
48
49 moduleParamList->getParameter<std::string>(TrackFindingCDC::prefixed(prefix, "direction")).setDefaultValue("forward");
50}
51
53{
54 const CDCCKFPath* path = pair.first;
55 CDCCKFState& state = *(pair.second);
56 const CDCCKFState& lastState = path->back();
57
58 genfit::MeasuredStateOnPlane mSoP = lastState.getTrackState();
59
60 const TrackFindingCDC::CDCWireHit* wireHit = state.getWireHit();
61 CDCRecoHit recoHit(wireHit->getHit(), nullptr);
62
63 try {
64 const auto& plane = recoHit.constructPlane(mSoP);
65 if (std::isnan(m_extrapolator.extrapolateToPlane(mSoP, plane))) {
66 return NAN;
67 }
68
69 const auto& measurements = recoHit.constructMeasurementsOnPlane(mSoP);
70 B2ASSERT("Should be exactly two measurements", measurements.size() == 2);
71
72 const auto& rightLeft = setRLInfo(mSoP, state);
73
74 if (rightLeft == TrackFindingCDC::ERightLeft::c_Right) {
75 state.setChi2(m_updater.kalmanStep(mSoP, *(measurements[1])));
76 } else {
77 state.setChi2(m_updater.kalmanStep(mSoP, *(measurements[0])));
78 }
79
80 delete measurements[0];
81 delete measurements[1];
82
83 state.setTrackState(mSoP);
84 setRLInfo(mSoP, state);
85
86 return 1. / state.getChi2();
87 } catch (const genfit::Exception& e) {
88 return NAN;
89 }
90}
Define states for CKF algorithm, which can be seed track or CDC wire hit.
Definition CDCCKFState.h:24
const genfit::MeasuredStateOnPlane & getTrackState() const
Get genfit track state (but first check if already present)
Definition CDCCKFState.h:61
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
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,...
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
The Module parameter list class.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:55
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
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.