Belle II Software development
SensorSVDPairFilter.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/svd/filters/relations/SensorSVDPairFilter.h>
9#include <tracking/trackFindingCDC/filters/base/Filter.icc.h>
10
11#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
12#include <framework/core/ModuleParamList.templateDetails.h>
13
14#include <vxd/geometry/GeoCache.h>
15
16using namespace Belle2;
17using namespace TrackFindingCDC;
18
19TrackFindingCDC::Weight
20SensorSVDPairFilter::operator()(const std::pair<const CKFToSVDState*, const CKFToSVDState*>& relation)
21{
22 const CKFToSVDState& fromState = *(relation.first);
23 const CKFToSVDState& toState = *(relation.second);
24
25 const CKFToSVDState::stateCache& fromStateCache = fromState.getStateCache();
26 const CKFToSVDState::stateCache& toStateCache = toState.getStateCache();
27
28 B2ASSERT("You have filled the wrong states into this!", toStateCache.isHitState);
29
30 if (not fromStateCache.isHitState) {
31 // We are coming from a CDC track, so we can use its position to only look for matching ladders
32 // This is done with the sensorCenterPhi, using the state's phi (and/or theta) wouldn't be a SensorFilter anymore.
33 float phiDiff = fromStateCache.phi - toStateCache.sensorCenterPhi;
34 while (phiDiff > M_PI) phiDiff -= 2. * M_PI;
35 while (phiDiff < -M_PI) phiDiff += 2. * M_PI;
36
37 if (fabs(phiDiff) < static_cast<float>(m_param_PhiRecoTrackToHitCut)) {
38 return 1.0;
39 }
40 // If the current state (fromState) is a RecoTrack-based state, but no relations could be created
41 // don't proceed but return
42 return NAN;
43 }
44
45 // On same layer we already know from LayerSVDRelationFilter, that we only deal with overlaps in r-phi.
46 // So it's sufficient here to check for same layer number to accept states in the overlap region.
47 if (fromStateCache.geoLayer == toStateCache.geoLayer and
48 fromStateCache.sensorID.getSensorNumber() == toStateCache.sensorID.getSensorNumber()) {
49 // TODO: Also check for sensors?
50 return 1.0;
51 }
52
53 // Next layer is not an overlap one, so we can just return all hits of the next layer(s)
54 // that are close enough in phi. No cut in theta here since this is the SensorSVXDPairFilter,
55 // a cut in theta is used in the DistanceSVDPairFilter
56 const int sensorNumberDifference =
57 static_cast<int>(fromStateCache.sensorID.getSensorNumber()) - static_cast<int>(toStateCache.sensorID.getSensorNumber());
58 const int layerNumberDifference =
59 static_cast<int>(fromStateCache.geoLayer) - static_cast<int>(toStateCache.geoLayer);
60
61 if ((abs(sensorNumberDifference) > 1 and layerNumberDifference == 1) or (abs(sensorNumberDifference) > 2)) {
62 return NAN;
63 }
64
65 float phiDiff = fromStateCache.sensorCenterPhi - toStateCache.sensorCenterPhi;
66 while (phiDiff > M_PI) phiDiff -= 2. * M_PI;
67 while (phiDiff < -M_PI) phiDiff += 2. * M_PI;
68
69 if (fabs(phiDiff) < static_cast<float>(m_param_PhiHitHitCut)) {
70 return 1.0;
71 }
72
73 return NAN;
74}
75
76void SensorSVDPairFilter::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
77{
78 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "phiRecoTrackToHitCut"), m_param_PhiRecoTrackToHitCut,
79 "Cut in phi for the difference between RecoTrack (seed) mSoP and current hit-based state.", m_param_PhiRecoTrackToHitCut);
80 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "phiHitHitCut"), m_param_PhiHitHitCut,
81 "Cut in phi between two hit-based states.", m_param_PhiHitHitCut);
82}
Specialized CKF State for extrapolating into the SVD.
Definition: CKFToSVDState.h:27
const struct stateCache & getStateCache() const
Get the cached data of this state.
Definition: CKFToSVDState.h:54
The Module parameter list class.
double m_param_PhiHitHitCut
Pre-filter relations in theta between hit states.
TrackFindingCDC::Weight operator()(const std::pair< const CKFToSVDState *, const CKFToSVDState * > &relation) override
Return the weight based on layer.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the parameters.
double m_param_PhiRecoTrackToHitCut
Pre-filter relations in phi between seed states and hit states.
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.