Belle II Software  release-08-01-10
FeasibleRLFacetFilter.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/trackFindingCDC/filters/facet/FeasibleRLFacetFilter.h>
9 
10 #include <tracking/trackFindingCDC/eventdata/hits/CDCFacet.h>
11 #include <tracking/trackFindingCDC/eventdata/hits/CDCRLWireHitTriple.h>
12 
13 #include <tracking/trackFindingCDC/numerics/Modulo.h>
14 
15 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
16 
17 #include <framework/core/ModuleParamList.templateDetails.h>
18 
19 using namespace Belle2;
20 using namespace TrackFindingCDC;
21 
23  : m_param_hardRLCut(hardRLCut)
24 {
25 }
26 
28  const std::string& prefix)
29 {
30  Super::exposeParameters(moduleParamList, prefix);
31  moduleParamList->addParameter(prefixed(prefix, "hardRLCut"),
33  "Switch to disallow the boarderline possible hit and "
34  "right left passage information.",
36 }
37 
39 {
40  if (this->isFeasible(facet)) {
41  return 3;
42  } else {
43  return NAN;
44  }
45 }
46 
47 bool FeasibleRLFacetFilter::isFeasible(const CDCRLWireHitTriple& rlWireHitTriple) const
48 {
49  const CDCRLWireHitTriple::Shape shape = rlWireHitTriple.getShape();
50  const short oClockDelta = shape.getOClockDelta();
51  const short absOClockDelta = std::abs(oClockDelta);
52  const short cellExtend = shape.getCellExtend();
53 
54  if (cellExtend + absOClockDelta > 6) {
55  // funny formula, but basically checks the triple to be a progressing forward and not turning back in itself.
56  return false;
57  }
58 
59  const ERightLeft startRLInfo = rlWireHitTriple.getStartRLInfo();
60  const ERightLeft middleRLInfo = rlWireHitTriple.getMiddleRLInfo();
61  const ERightLeft endRLInfo = rlWireHitTriple.getEndRLInfo();
62 
63  const short stableTwist = -sign(shape.getOClockDelta()) * middleRLInfo;
64  const bool startToMiddleIsCrossing = startRLInfo != middleRLInfo;
65  const bool middleToEndIsCrossing = middleRLInfo != endRLInfo;
66 
67  const bool bothAreCrossing = startToMiddleIsCrossing and middleToEndIsCrossing;
68 
69  const bool startToMiddleIsLong = shape.getStartToMiddleCellDistance() > shape.getMiddleToEndCellDistance();
70  const bool shortArmIsCrossing = startToMiddleIsLong ? middleToEndIsCrossing : startToMiddleIsCrossing;
71 
72  const bool onlyOneShortArm = isOdd(cellExtend);
73  const bool shortArmsAreCrossing = bothAreCrossing or (onlyOneShortArm and shortArmIsCrossing);
74  const bool noneAreCrossing = not startToMiddleIsCrossing and not middleToEndIsCrossing;
75 
76  const bool orthoHard = stableTwist > 0 and shortArmsAreCrossing;
77  const bool ortho = stableTwist > 0 and not noneAreCrossing;
78  const bool meta = stableTwist > 0 or noneAreCrossing;
79  const bool para = not bothAreCrossing;
80 
81  // Redundant check saves a bit of computation time.
82  if (oClockDelta == 0) {
83  return para;
84  }
85 
86  switch (cellExtend) {
87  case 2:
88  switch (absOClockDelta) {
89  case 0:
90  return para;
91  break;
92 
93  case 2:
94  return ortho or (not m_param_hardRLCut and meta);
95  break;
96 
97  case 4:
98  return orthoHard or (not m_param_hardRLCut and ortho);
99  break;
100  }
101  break;
102 
103  case 3:
104  switch (absOClockDelta) {
105  case 0:
106  return para;
107  break;
108 
109  case 1:
110  return meta;
111  break;
112 
113  case 2:
114  return orthoHard or (not m_param_hardRLCut and ortho);
115  break;
116 
117  case 3:
118  return orthoHard;
119  break;
120  }
121  break;
122 
123  case 4:
124  switch (absOClockDelta) {
125  case 0:
126  return para;
127  break;
128 
129  case 1:
130  return ortho or (not m_param_hardRLCut and meta);
131  break;
132 
133  case 2:
134  return orthoHard;
135  break;
136  }
137  break;
138  }
139  return false;
140 }
The Module parameter list class.
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:32
Type for the different shapes of a triple of neighboring wire hits.
short getMiddleToEndCellDistance() const
Getter for the middle to end cell distance.
short getCellExtend() const
Getter for the sum of cell distances from start to middle and middle to end.
short getOClockDelta() const
Getter for the o'clock direction difference from start to middle compared to middle to end.
short getStartToMiddleCellDistance() const
Getter for the start to middle cell distance.
Class representing a triple of neighboring wire hits.
ERightLeft getMiddleRLInfo() const
Getter for the right left passage information of the second oriented wire hit.
ERightLeft getStartRLInfo() const
Getter for the right left passage information of the first oriented wire hit.
ERightLeft getEndRLInfo() const
Getter for the right left passage information of the third oriented wire hit.
Shape getShape() const
Getter for the shape of this tiple if all three oriented wire hits are neighbors. Else ILLSHAPE.
FeasibleRLFacetFilter(bool hardRLCut=true)
Constructor taking a flag if boarderline feasable cases should be excluded.
Weight operator()(const CDCFacet &facet) final
Main filter method returning the weight of the facet.
bool isFeasible(const CDCRLWireHitTriple &rlWireHitTriple) const
Check if the hit triplet is a feasible combination for shape and rl passage information.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the set of parameters of the filter to the module parameter list.
virtual void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Expose the set of parameters of the filter to the module parameter list.
Definition: Filter.icc.h:40
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.