Belle II Software development
LayerRelationFilter.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/vxdHoughTracking/filters/relations/LayerRelationFilter.dcl.h>
11#include <tracking/trackFindingCDC/filters/base/RelationFilter.icc.h>
12#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
13#include <tracking/spacePointCreation/SpacePoint.h>
14#include <framework/core/ModuleParamList.templateDetails.h>
15#include <vxd/geometry/GeoCache.h>
16
17namespace Belle2 {
22 namespace vxdHoughTracking {
23
24 template <class AFilter>
26 {
28 }
29
30 template <class AFilter>
31 void LayerRelationFilter<AFilter>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
32 {
33 moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "hitJumping"), m_hitJumping,
34 "Make it possible to jump over N layers.", m_hitJumping);
35
36 m_filter.exposeParameters(moduleParamList, prefix);
37 }
38
39 template <class AFilter>
41 {
42 Super::beginRun();
43
44 // Fill maximum number cache
45 auto& geoCache = VXD::GeoCache::getInstance();
46 const auto& layers = geoCache.getLayers(VXD::SensorInfoBase::SensorType::SVD);
47 for (const auto& layerVXDID : layers) {
48 m_maximalLadderCache[layerVXDID.getLayerNumber()] = geoCache.getLadders(layerVXDID).size();
49 }
50 }
51
52 template <class AFilter>
54
55 template <class AFilter>
56 std::vector<VXDHoughState*>
57 LayerRelationFilter<AFilter>::getPossibleTos(VXDHoughState* currentHit, const std::vector<VXDHoughState*>& hits) const
58 {
59 std::vector<VXDHoughState*> possibleNextHits;
60 possibleNextHits.reserve(hits.size());
61
62 const VXDHoughState::DataCache& currentVXDHoughState = currentHit->getDataCache();
63 const unsigned int currentLayer = currentVXDHoughState.layer;
64 const unsigned int nextPossibleLayer = std::max(static_cast<int>(currentLayer) - 1 - m_hitJumping, 0);
65
66 for (VXDHoughState* nextHit : hits) {
67 if (currentHit == nextHit) {
68 continue;
69 }
70
71 const VXDHoughState::DataCache& nextVXDHoughState = nextHit->getDataCache();
72 const unsigned int nextLayer = nextVXDHoughState.layer;
73
74 if (std::max(currentLayer, nextPossibleLayer) >= nextLayer and nextLayer >= std::min(currentLayer, nextPossibleLayer)) {
75
76 if (currentLayer == nextLayer) {
77 // next layer is an overlap one, so lets return all hits from the same layer, that are on a
78 // ladder which is below the last added hit.
79 const unsigned int fromLadderNumber = currentVXDHoughState.ladder;
80 const unsigned int maximumLadderNumber = m_maximalLadderCache.at(currentLayer);
81
82 // the reason for this strange formula is the numbering scheme in the VXD.
83 // we first subtract 1 from the ladder number to have a ladder counting from 0 to N - 1,
84 // then we add (PXD)/subtract(SVD) one to get to the next (overlapping) ladder and do a % N to also cope for the
85 // highest number. Then we add 1 again, to go from the counting from 0 .. N-1 to 1 .. N.
86 // The + maximumLadderNumber in between makes sure, we are not ending with negative numbers
87 const int direction = -1;
88 const unsigned int overlappingLadder =
89 ((fromLadderNumber + maximumLadderNumber - 1) + direction) % maximumLadderNumber + 1;
90
91 if (nextVXDHoughState.ladder != overlappingLadder) {
92 continue;
93 }
94
95 // Next we make sure to not have any cycles in our graph: we do this by defining only the halves of the
96 // sensor as overlapping. So if the first hit is coming from sensor 1 and the second from sensor 2,
97 // they are only related if the one from sensor 1 is on the half, that is pointing towards sensor 2
98 // and the one on sensor 2 is on the half that is pointing towards sensor 1.
99 //
100 // X X X
101 // ----|---- ----|---- ----|----
102 // This is fine: X This not: X This not: X
103 // ----|---- ----|---- ----|----
104 if (currentVXDHoughState.localNormalizedu > 0.2) {
105 continue;
106 }
107
108 if (nextVXDHoughState.localNormalizedu <= 0.8) {
109 continue;
110 }
111 }
112
113 possibleNextHits.push_back(nextHit);
114 }
115 }
116
117 return possibleNextHits;
118 }
119
120 template <class AFilter>
121 TrackFindingCDC::Weight LayerRelationFilter<AFilter>::operator()(const VXDHoughState& from, const VXDHoughState& to)
122 {
123 return m_filter(std::make_pair(&from, &to));
124 }
125
126 }
128}
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
TrackFindingCDC::Weight operator()(const VXDHoughState &from, const VXDHoughState &to) final
Get the weight of the relation between from and to.
void beginRun() final
Initialize the maximal ladder cache.
std::vector< VXDHoughState * > getPossibleTos(VXDHoughState *from, const std::vector< VXDHoughState * > &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.
AFilter m_filter
Filter for rejecting the states.
Simple container for hit information to be used during intercept finding.
Definition: VXDHoughState.h:24
const DataCache getDataCache() const
Get the cached data of this state.
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.
Cache containing the most important information of this state which will often be needed.
Definition: VXDHoughState.h:70
float localNormalizedu
Local normalized uCoordinate of this state, only set if based on SpacePoint.
Definition: VXDHoughState.h:82
unsigned short layer
Geometrical Layer this state is based on.
Definition: VXDHoughState.h:96
unsigned short ladder
Ladder this state is based on (only use for SpacePoint based states)
Definition: VXDHoughState.h:98