Belle II Software  release-05-02-19
ExtrapolateAndUpdateCDCStateFilter.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/cdc/filters/states/ExtrapolateAndUpdateCDCStateFilter.h>
11 
12 #include <tracking/trackFindingCDC/numerics/ERightLeft.h>
13 #include <cdc/dataobjects/CDCRecoHit.h>
14 
15 #include <tracking/ckf/cdc/entities/CDCCKFState.h>
16 #include <tracking/ckf/cdc/entities/CDCCKFPath.h>
17 
18 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
19 #include <framework/core/ModuleParamList.h>
20 
21 using namespace Belle2;
22 
23 namespace {
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 
40 ExtrapolateAndUpdateCDCStateFilter::ExtrapolateAndUpdateCDCStateFilter()
41 {
43 }
44 
45 void 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 
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 }
genfit::Exception
Exception class for error handling in GENFIT (provides storage for diagnostic information)
Definition: Exception.h:48
Belle2::Vector3D
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:35
Belle2::ExtrapolateAndUpdateCDCStateFilter::m_updater
KalmanStepper< 1 > m_updater
Kalman filter updater.
Definition: ExtrapolateAndUpdateCDCStateFilter.h:51
Belle2::Advancer::extrapolateToPlane
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:24
Belle2::TrackFindingCDC::Vector2D::isRightOrLeftOf
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:467
genfit::MeasuredStateOnPlane
#StateOnPlane with additional covariance matrix.
Definition: MeasuredStateOnPlane.h:39
Belle2::KalmanStepper::kalmanStep
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:58
Belle2::ModuleParamList::getParameter
ModuleParam< T > & getParameter(const std::string &name) const
Returns a reference to a parameter.
Definition: ModuleParamList.templateDetails.h:90
Belle2::CDCCKFState::setRLinfo
void setRLinfo(const TrackFindingCDC::ERightLeft &rl)
Set right-left info for the hit.
Definition: CDCCKFState.h:87
Belle2::CDCRecoHit::constructPlane
genfit::SharedPlanePtr constructPlane(const genfit::StateOnPlane &state) const override
Methods that actually interface to Genfit.
Definition: CDCRecoHit.cc:82
Belle2::CDCRecoHit::constructMeasurementsOnPlane
std::vector< genfit::MeasurementOnPlane * > constructMeasurementsOnPlane(const genfit::StateOnPlane &state) const override
build MeasurementsOnPlane
Definition: CDCRecoHit.cc:142
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::addProcessingSignalListener
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Definition: CompositeProcessingSignalListener.cc:57
Belle2::CDCRecoHit
This class is used to transfer CDC information to the track fit.
Definition: CDCRecoHit.h:43
Belle2::ExtrapolateAndUpdateCDCStateFilter::operator()
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,...
Definition: ExtrapolateAndUpdateCDCStateFilter.cc:52
Belle2::CDCCKFState::setTrackState
void setTrackState(const genfit::MeasuredStateOnPlane &trackState)
Store genfit Measured state on plane.
Definition: CDCCKFState.h:81
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::CDCCKFState::getChi2
double getChi2() const
Get state chi2.
Definition: CDCCKFState.h:142
Belle2::TrackFindingCDC::Vector3D
A three dimensional vector.
Definition: Vector3D.h:34
Belle2::CDCCKFPath
std::vector< CDCCKFState > CDCCKFPath
Shortcut for the collection of CDC CKF-algorithm states.
Definition: CDCCKFPath.h:29
Belle2::CDCCKFState::setChi2
void setChi2(double chi2)
Set set chi2.
Definition: CDCCKFState.h:136
Belle2::TrackFindingCDC::NRightLeft::ERightLeft
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:35
Belle2::CDCCKFState::getTrackState
const genfit::MeasuredStateOnPlane & getTrackState() const
Get genfit track state (but first check if already present)
Definition: CDCCKFState.h:74
Belle2::TrackFindingCDC::Vector3D::xy
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition: Vector3D.h:500
Belle2::ExtrapolateAndUpdateCDCStateFilter::m_extrapolator
Advancer m_extrapolator
Kalman filter extrapolator.
Definition: ExtrapolateAndUpdateCDCStateFilter.h:48
Belle2::ExtrapolateAndUpdateCDCStateFilter::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters of the sub findlets.
Definition: ExtrapolateAndUpdateCDCStateFilter.cc:45
Belle2::CDCCKFState
Define states for CKF algorithm, which can be seed track or CDC wire hit.
Definition: CDCCKFState.h:37
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::Advancer::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the parameters.
Definition: Advancer.cc:54
Belle2::CDCCKFState::getWireHit
const TrackFindingCDC::CDCWireHit * getWireHit() const
Get CDCWireHit corresponding to the state.
Definition: CDCCKFState.h:47
Belle2::TrackFindingCDC::Filter::Object
AObject Object
Type of the object to be analysed.
Definition: Filter.dcl.h:43