Belle II Software development
LayerSVDRelationFilter.icc.h
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#pragma once
9
10#include <tracking/ckf/svd/filters/relations/LayerSVDRelationFilter.dcl.h>
11#include <tracking/trackFindingCDC/filters/base/RelationFilter.icc.h>
12
13#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
14
15#include <tracking/spacePointCreation/SpacePoint.h>
16#include <framework/core/ModuleParamList.templateDetails.h>
17#include <vxd/geometry/GeoCache.h>
18
19namespace Belle2 {
25 template <class AFilter, class APrefilter>
27 {
30 }
31
32 template <class AFilter, class APrefilter>
34 {
35 Super::beginRun();
36
37 // Fill maximum number cache
38 auto& geoCache = VXD::GeoCache::getInstance();
39 const auto& layers = geoCache.getLayers(VXD::SensorInfoBase::SensorType::SVD);
40 for (const auto& layerVXDID : layers) {
41 m_maximalLadderCache[layerVXDID.getLayerNumber()] = geoCache.getLadders(layerVXDID).size();
42 }
43 }
44
45 template <class AFilter, class APrefilter>
47
48 template <class AFilter, class APrefilter>
49 std::vector<CKFToSVDState*>
51 const std::vector<CKFToSVDState*>& states) const
52 {
53 std::vector<CKFToSVDState*> possibleNextStates;
54 possibleNextStates.reserve(states.size());
55
56 const CKFToSVDState::stateCache& currentStateCache = currentState->getStateCache();
57 const unsigned int currentLayer = currentStateCache.geoLayer;
58 const unsigned int nextPossibleLayer = std::max(static_cast<int>(currentLayer) - 1 - m_param_hitJumping, 0);
59
60 for (CKFToSVDState* nextState : states) {
61 if (currentState == nextState) {
62 continue;
63 }
64
65 const CKFToSVDState::stateCache& nextStateCache = nextState->getStateCache();
66 const unsigned int nextLayer = nextStateCache.geoLayer;
67
68 if (std::max(currentLayer, nextPossibleLayer) >= nextLayer and nextLayer >= std::min(currentLayer, nextPossibleLayer)) {
69
70 if (currentLayer == nextLayer) {
71 // next layer is an overlap one, so lets return all hits from the same layer, that are on a
72 // ladder which is below the last added hit.
73 const unsigned int fromLadderNumber = currentStateCache.ladder;
74 const unsigned int maximumLadderNumber = m_maximalLadderCache.find(currentLayer)->second;
75
76 // the reason for this strange formula is the numbering scheme in the VXD.
77 // we first subtract 1 from the ladder number to have a ladder counting from 0 to N - 1,
78 // then we add (PXD)/subtract(SVD) one to get to the next (overlapping) ladder and do a % N to also cope for the
79 // highest number. Then we add 1 again, to go from the counting from 0 .. N-1 to 1 .. N.
80 // The + maximumLadderNumber in between makes sure, we are not ending with negative numbers
81 const int direction = -1;
82 const unsigned int overlappingLadder =
83 ((fromLadderNumber + maximumLadderNumber - 1) + direction) % maximumLadderNumber + 1;
84
85 if (nextStateCache.ladder != overlappingLadder) {
86 continue;
87 }
88
89 // Next we make sure to not have any cycles in our graph: we do this by defining only the halves of the
90 // sensor as overlapping. So if the first hit is coming from sensor 1 and the second from sensor 2,
91 // they are only related if the one from sensor 1 is on the half, that is pointing towards sensor 2
92 // and the one on sensor 2 is on the half that is pointing towards sensor 1.
93 //
94 // X X X
95 // ----|---- ----|---- ----|----
96 // This is fine: X This not: X This not: X
97 // ----|---- ----|---- ----|----
98 if (currentStateCache.localNormalizedu > 0.2f) {
99 continue;
100 }
101
102 if (nextStateCache.localNormalizedu <= 0.8f) {
103 continue;
104 }
105 }
106
107 // Some loose prefiltering of possible states
108 TrackFindingCDC::Weight weight = m_prefilter(std::make_pair(currentState, nextState));
109 if (std::isnan(weight)) {
110 continue;
111 }
112
113
114 possibleNextStates.push_back(nextState);
115 }
116 }
117
118 return possibleNextStates;
119 }
120
121 template <class AFilter, class APrefilter>
123 {
124 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "hitJumping"), m_param_hitJumping,
125 "Make it possible to jump over N layers.", m_param_hitJumping);
126
127 m_filter.exposeParameters(moduleParamList, prefix);
128 m_prefilter.exposeParameters(moduleParamList, TrackFindingCDC::prefixed("pre", prefix));
129 }
130
131 template <class AFilter, class APrefilter>
133 {
134 return m_filter(std::make_pair(&from, &to));
135 }
137}
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
APrefilter m_prefilter
Loose pre-filter to reject possibleTos.
AFilter m_filter
Filter for rejecting the states.
The Module parameter list class.
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:214
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
void beginRun() final
Initialize the maximal ladder cache.
LayerSVDRelationFilter()
Add the filter as listener.
std::vector< CKFToSVDState * > getPossibleTos(CKFToSVDState *from, const std::vector< CKFToSVDState * > &states) const final
Return all states the given state is possible related to.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters of the filter.
~LayerSVDRelationFilter()
Default destructor.
TrackFindingCDC::Weight operator()(const CKFToSVDState &from, const CKFToSVDState &to) final
Give a final weight to the possibilities by asking the filter.
Abstract base class for different kinds of events.