Belle II Software development
CylinderDistancePXDPairFilter.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/pxd/filters/relations/CylinderDistancePXDPairFilter.h>
9#include <tracking/trackFindingCDC/filters/base/Filter.icc.h>
10
11#include <tracking/dataobjects/RecoTrack.h>
12
13#include <pxd/geometry/SensorInfo.h>
14#include <vxd/geometry/SensorInfoBase.h>
15#include <vxd/geometry/GeoCache.h>
16
17#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
18#include <framework/core/ModuleParamList.templateDetails.h>
19
20using namespace Belle2;
21using namespace TrackFindingCDC;
22
23TrackFindingCDC::Weight
24CylinderDistancePXDPairFilter::operator()(const std::pair<const CKFToPXDState*, const CKFToPXDState*>& relation)
25{
26 const CKFToPXDState& fromState = *(relation.first);
27 const CKFToPXDState& toState = *(relation.second);
28
29 const CKFToPXDState::stateCache& fromStateCache = fromState.getStateCache();
30 const CKFToPXDState::stateCache& toStateCache = toState.getStateCache();
31
32 B2ASSERT("You have filled the wrong states into this!", toStateCache.isHitState);
33
34 if (not fromStateCache.isHitState) {
35 // We are coming from an SVD / CDC-SVD track, so we can use its position to only look for matching ladders
36 // RecoTracks were fitted before CKF, so the measured states on planes should exist
37 const RecoTrack* seedRecoTrack = fromState.getSeed();
38 genfit::MeasuredStateOnPlane measuredStateOnPlane =
40
41 bool extrapolationSuccessful = true;
42 try {
43 measuredStateOnPlane.extrapolateToCylinder(c_PXDLayerRadii[toStateCache.geoLayer - 1]);
44 } catch (...) {
45 B2DEBUG(20, "ToPXDCKF CylinderDistancePXDPairFilter: extrapolation to cylinder of layer " << toStateCache.geoLayer <<
46 " with radius of " << c_PXDLayerRadii[toStateCache.geoLayer - 1] << " failed");
47 extrapolationSuccessful = false;
48 }
49
50 if (extrapolationSuccessful) {
51 const ROOT::Math::XYZVector& positionOnCylinder = ROOT::Math::XYZVector(measuredStateOnPlane.getPos());
52
53 float phiDiff = positionOnCylinder.Phi() - toStateCache.phi;
54 while (phiDiff > M_PI) phiDiff -= 2. * M_PI;
55 while (phiDiff < -M_PI) phiDiff += 2. * M_PI;
56 const float thetaDiff = positionOnCylinder.Theta() - toStateCache.theta;
57 if (abs(phiDiff) < static_cast<float>(m_param_CylinderExtrapolationToHitPhiCut) and
58 abs(thetaDiff) < static_cast<float>(m_param_CylinderExtrapolationToHitThetaCut)) {
59 return 1.0;
60 } else {
61 return NAN;
62 }
63 } else {
64 // We don't have have an extrapolated position on the layer of the ToState based on this Seed (RecoTrack), so use simple angular filters.
65 float phiDiff = fromStateCache.phi - toStateCache.phi;
66 while (phiDiff > M_PI) phiDiff -= 2. * M_PI;
67 while (phiDiff < -M_PI) phiDiff += 2. * M_PI;
68 const float thetaDiff = fromStateCache.theta - toStateCache.theta;
69 if (abs(phiDiff) < static_cast<float>(m_param_RecoTrackToHitPhiCut) and
70 abs(thetaDiff) < static_cast<float>(m_param_RecoTrackToHitThetaCut)) {
71 return 1.0;
72 }
73 return NAN;
74 }
75 }
76
77 // On same layer we already know from LayerPXDRelationFilter, that we only deal with overlaps in r-phi.
78 // So it's sufficient here to check for same layer number to accept states in the overlap region.
79 if (fromStateCache.geoLayer == toStateCache.geoLayer and
80 fromStateCache.sensorID.getSensorNumber() == toStateCache.sensorID.getSensorNumber()) {
81 // TODO: Checking for equality of sensor numbers seems not to harm the hit efficiency,
82 // but maybe it's safer to allow for a sensor number difference of 1?
83 return 1.0;
84 }
85
86 float phiDiff = fromStateCache.phi - toStateCache.phi;
87 while (phiDiff > M_PI) phiDiff -= 2. * M_PI;
88 while (phiDiff < -M_PI) phiDiff += 2. * M_PI;
89 const float thetaDiff = fromStateCache.theta - toStateCache.theta;
90
91 if (abs(phiDiff) < static_cast<float>(m_param_HitHitPhiCut) and
92 abs(thetaDiff) < static_cast<float>(m_param_HitHitThetaCut)) {
93 return 1.0;
94 }
95
96 return NAN;
97}
98
99void CylinderDistancePXDPairFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
100{
101 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "isBackwardCKF"), m_param_isBackwardCKF,
102 "Does this CKF extrapolate the tracks backward or forward?",
104 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "cylinderExtrapolationToHitPhiCut"),
106 "Cut in phi for the difference between extrapolated position of the Seed to a cylinder with the radius of the ToState layer and the ToState.",
108 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "cylinderExtrapolationToHitThetaCut"),
110 "Cut in theta for the difference between extrapolated position of the Seed to a cylinder with the radius of the ToState layer and the ToState.",
112 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "recoTrackToHitPhiCut"), m_param_RecoTrackToHitPhiCut,
113 "Cut in phi for the difference between RecoTrack information and current hit-based state.",
115 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "recoTrackToHitThetaCut"), m_param_RecoTrackToHitThetaCut,
116 "Cut in theta for the difference between RecoTrack information and current hit-based state.",
118 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "hitHitPhiCut"), m_param_HitHitPhiCut,
119 "Cut in phi between two hit-based states.", m_param_HitHitPhiCut);
120 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "hitHitThetaCut"), m_param_HitHitThetaCut,
121 "Cut in theta between two hit-based states.", m_param_HitHitThetaCut);
122}
const Seed * getSeed() const
Return the track this state is related to.
Definition: CKFState.h:60
Specialized CKF State for extrapolating into the PXD.
Definition: CKFToPXDState.h:27
const struct stateCache & getStateCache() const
Get the cached data of this state.
Definition: CKFToPXDState.h:48
const std::array< double, 2 > c_PXDLayerRadii
PXD layer radii.
double m_param_RecoTrackToHitPhiCut
Filter potential relations in phi between seed states (based on RecoTracks) and hit states.
bool m_param_isBackwardCKF
Is backward or forward ToPXDCKF?
double m_param_CylinderExtrapolationToHitPhiCut
Filter potential relations in phi between seed states (based on MeasuredStateOnPlane) and hit states.
double m_param_CylinderExtrapolationToHitThetaCut
Filter potential relations in theta between seed states (based on MeasuredStateOnPlane) and hit state...
double m_param_HitHitThetaCut
Filter potential relations in theta between hit states.
double m_param_HitHitPhiCut
Filter potential relations in phi between hit states.
double m_param_RecoTrackToHitThetaCut
Filter potential relations in theta between seed states (based on RecoTracks) and hit states.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters.
TrackFindingCDC::Weight operator()(const std::pair< const CKFToPXDState *, const CKFToPXDState * > &relation) override
Return the weight based on azimuthal-angle separation.
The Module parameter list class.
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:79
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlaneFromLastHit(const genfit::AbsTrackRep *representation=nullptr) const
Return genfit's MeasuredStateOnPlane for the last hit in a fit useful for extrapolation of measuremen...
Definition: RecoTrack.cc:619
const genfit::MeasuredStateOnPlane & getMeasuredStateOnPlaneFromFirstHit(const genfit::AbsTrackRep *representation=nullptr) const
Return genfit's MeasuredStateOnPlane for the first hit in a fit useful for extrapolation of measureme...
Definition: RecoTrack.cc:605
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.