Belle II Software  release-05-01-25
LayerPXDRelationFilter.icc.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun, Christian Wessel *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #include <tracking/ckf/pxd/filters/relations/LayerPXDRelationFilter.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 
19 namespace Belle2 {
25  template <class AFilter, class APrefilter>
27  {
30  }
31 
32  template <class AFilter, class APrefilter>
34 
35  template <class AFilter, class APrefilter>
36  std::vector<CKFToPXDState*>
38  const std::vector<CKFToPXDState*>& states) const
39  {
40  std::vector<CKFToPXDState*> possibleNextStates;
41 
42  const CKFToPXDState::stateCache& currentStateCache = currentState->getStateCache();
43  const unsigned int& currentLayer = currentStateCache.geoLayer;
44  const unsigned int& nextPossibleLayer = std::max(static_cast<int>(currentLayer) - 1 - m_param_hitJumping, 0);
45 
46  // Patch for the PXD layer 2 overlap inefficiency fix
47  // previous implementation of maximumLadderNumber was calculated using GeoCache gave incorrect value for exp1003
48  // Geometrically, PXD layer 1 has 8 ladders, pxd layer 2 has 12 ladder
49  int numberOfLaddersForLayer[2] = {8, 12};
50 
51  for (CKFToPXDState* nextState : states) {
52  const CKFToPXDState::stateCache& nextStateCache = nextState->getStateCache();
53  const unsigned int nextLayer = nextStateCache.geoLayer;
54  if (nextLayer < std::min(currentLayer, nextPossibleLayer) or std::max(currentLayer, nextPossibleLayer) < nextLayer) {
55  continue;
56  }
57 
58  if (currentLayer == nextLayer) {
59  // next layer is an overlap one, so lets return all hits from the same layer, that are on a
60  // ladder which is below the last added hit.
61  const unsigned int fromLadderNumber = currentStateCache.ladder;
62  const unsigned int maximumLadderNumber = numberOfLaddersForLayer[currentLayer - 1];
63 
64  // the reason for this strange formula is the numbering scheme in the VXD.
65  // we first substract 1 from the ladder number to have a ladder counting from 0 to N - 1,
66  // then we add (PXD)/subtract(PXD) one to get to the next (overlapping) ladder and do a % N to also cope for the
67  // highest number. Then we add 1 again, to go from the counting from 0 .. N-1 to 1 .. N.
68  // The + maximumLadderNumber in between makes sure, we are not ending with negative numbers
69  const int direction = 1;
70  const unsigned int overlappingLadder =
71  ((fromLadderNumber + maximumLadderNumber - 1) + direction) % maximumLadderNumber + 1;
72 
73  if (nextStateCache.ladder != overlappingLadder) {
74  continue;
75  }
76 
77  // Next we make sure to not have any cycles in our graph: we do this by defining only the halves of the
78  // sensor as overlapping. So if the first hit is coming from sensor 1 and the second from sensor 2,
79  // they are only related if the one from sensor 1 is on the half, that is pointing towards sensor 2
80  // and the one on sensor 2 is on the half that is pointing towards sensor 1.
81  //
82  // X X X
83  // ----|---- ----|---- ----|----
84  // This is fine: X This not: X This not: X
85  // ----|---- ----|---- ----|----
86 
87  // for PXD its the other way round!
88  if (currentStateCache.localNormalizedu <= 0.8) {
89  continue;
90  }
91 
92  if (nextStateCache.localNormalizedu > 0.2) {
93  continue;
94  }
95  }
96 
97  // Some loose prefiltering of possible states
98  TrackFindingCDC::Weight weight = m_prefilter(std::make_pair(currentState, nextState));
99  if (std::isnan(weight)) {
100  continue;
101  }
102 
103  possibleNextStates.push_back(nextState);
104  }
105 
106  return possibleNextStates;
107  }
108 
109  template <class AFilter, class APrefilter>
110  void LayerPXDRelationFilter<AFilter, APrefilter>::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
111  {
112  moduleParamList->addParameter(TrackFindingCDC::prefixed(prefix, "hitJumping"), m_param_hitJumping,
113  "Make it possible to jump over N layers.", m_param_hitJumping);
114 
115  m_filter.exposeParameters(moduleParamList, prefix);
116  m_prefilter.exposeParameters(moduleParamList, TrackFindingCDC::prefixed("pre", prefix));
117  }
118 
119  template <class AFilter, class APrefilter>
120  TrackFindingCDC::Weight LayerPXDRelationFilter<AFilter, APrefilter>::operator()(const CKFToPXDState& from, const CKFToPXDState& to)
121  {
122  return m_filter(std::make_pair(&from, &to));
123  }
125 }
Belle2::CKFToPXDState
Specialized CKF State for extrapolating into the PXD.
Definition: CKFToPXDState.h:29
Belle2::LayerPXDRelationFilter::m_filter
AFilter m_filter
Filter for rejecting the states.
Definition: LayerPXDRelationFilter.dcl.h:54
Belle2::TrackFindingCDC::CompositeProcessingSignalListener::addProcessingSignalListener
void addProcessingSignalListener(ProcessingSignalListener *psl)
Register a processing signal listener to be notified.
Definition: CompositeProcessingSignalListener.cc:57
Belle2::LayerPXDRelationFilter::operator()
TrackFindingCDC::Weight operator()(const CKFToPXDState &from, const CKFToPXDState &to) override
Main filter method returning the weight of the neighborhood relation.
Definition: LayerPXDRelationFilter.icc.h:128
Belle2::LayerPXDRelationFilter::m_prefilter
APrefilter m_prefilter
Loose pre-filter to reject possibleTos.
Definition: LayerPXDRelationFilter.dcl.h:56
Belle2::LayerPXDRelationFilter::LayerPXDRelationFilter
LayerPXDRelationFilter()
Add the filter as listener.
Definition: LayerPXDRelationFilter.icc.h:34
Belle2::LayerPXDRelationFilter::getPossibleTos
std::vector< CKFToPXDState * > getPossibleTos(CKFToPXDState *from, const std::vector< CKFToPXDState * > &states) const override
Selects the objects possibly related to the given one from the given pool of objects.
Definition: LayerPXDRelationFilter.icc.h:45
Belle2::CKFToPXDState::getStateCache
const struct stateCache & getStateCache() const
Get the cached data of this state.
Definition: CKFToPXDState.h:50
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::LayerPXDRelationFilter::~LayerPXDRelationFilter
~LayerPXDRelationFilter()
Default destructor.
Belle2::LayerPXDRelationFilter::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) override
Expose the set of parameters of the filter to the module parameter list.
Definition: LayerPXDRelationFilter.icc.h:118