Belle II Software  release-05-01-25
StereoHitContained.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
13 #include <tracking/trackFindingCDC/eventdata/hits/CDCRLWireHit.h>
14 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
15 
16 #include <tracking/trackFindingCDC/topology/CDCWire.h>
17 
18 #include <tracking/trackFindingCDC/numerics/ESign.h>
19 #include <tracking/trackFindingCDC/numerics/Weight.h>
20 
21 #include <numeric>
22 
23 namespace Belle2 {
28  namespace TrackFindingCDC {
29 
36  template<class AInBox>
37  class StereoHitContained : public AInBox {
38 
39  public:
41  using AInBox::AInBox;
42 
44  using HoughBox = typename AInBox::HoughBox;
45 
46 
49  Weight operator()(const CDCSegment2D* segment2D,
50  const HoughBox* houghBox)
51  {
52  size_t nHits = segment2D->size();
53  auto weightOfHit = [this, &houghBox](const Weight & totalWeight,
54  const CDCRecoHit2D & recoHit2D) -> Weight {
55  Weight hitWeight = this->operator()(&recoHit2D, houghBox);
56  return std::isnan(hitWeight) ? totalWeight : totalWeight + hitWeight;
57  };
58 
59  Weight totalWeight = std::accumulate(segment2D->begin(),
60  segment2D->end(),
61  static_cast<Weight>(0.0),
62  weightOfHit);
63 
64  // Require a efficiency of 66%
65  constexpr const Weight minEfficiency = 2.0 / 3;
66  if (totalWeight > nHits * minEfficiency) {
67  return totalWeight;
68  } else {
69  return NAN;
70  }
71  }
72 
76  Weight operator()(const CDCRecoHit2D* recoHit2D,
77  const HoughBox* houghBox)
78  {
79  const CDCWire& wire = recoHit2D->getWire();
80  const double signedDriftLength = recoHit2D->getSignedRefDriftLength();
81  bool isIn = contains(*houghBox, wire, signedDriftLength);
82  ERightLeft rlInfo = recoHit2D->getRLInfo();
83  return isIn ? 1.0 + isValid(rlInfo) * m_rlWeightGain : NAN;
84  }
85 
86 
92  Weight operator()(const CDCWireHit* wireHit,
93  const HoughBox* houghBox)
94  {
95  const CDCWire& wire = wireHit->getWire();
96  const double driftLength = wireHit->getRefDriftLength();
97 
98  ERightLeft rlInfo = containsRightOrLeft(*houghBox, wire, driftLength);
99  return isValid(rlInfo) ? 1.0 + std::abs(rlInfo) * m_rlWeightGain : NAN;
100  }
101 
113  Weight operator()(CDCRLWireHit& rlTaggedWireHit,
114  const HoughBox* houghBox)
115  {
116  const CDCWire& wire = rlTaggedWireHit.getWire();
117  const ERightLeft rlInfo = rlTaggedWireHit.getRLInfo();
118  const double driftLength = rlTaggedWireHit.getRefDriftLength();
119 
120  ERightLeft newRLInfo =
121  containsRightOrLeft(*houghBox, wire, driftLength, rlInfo);
122 
123  rlTaggedWireHit.setRLInfo(newRLInfo);
124  return isValid(newRLInfo) ? 1.0 + std::abs(newRLInfo) * m_rlWeightGain : NAN;
125  }
126 
138  ERightLeft containsRightOrLeft(const HoughBox& houghBox,
139  const CDCWire& wire,
140  double driftLength,
141  ERightLeft rlInfo = ERightLeft::c_Unknown)
142  {
143  bool isRightIn = rlInfo != ERightLeft::c_Left and contains(houghBox, wire, driftLength);
144  bool isLeftIn = rlInfo != ERightLeft::c_Right and contains(houghBox, wire, -driftLength);
145 
146  if (isRightIn and isLeftIn) {
147  return ERightLeft::c_Unknown;
148  } else if (isRightIn) {
149  return ERightLeft::c_Right;
150  } else if (isLeftIn) {
151  return ERightLeft::c_Left;
152  } else {
153  return ERightLeft::c_Invalid;
154  }
155  }
156 
158  bool contains(const HoughBox& houghBox, const CDCWire& wire, double signedDriftLength)
159  {
160  const Vector2D& pos2D = wire.getRefPos2D();
161  //const Vector2D& pos2D = wire.getWirePos2DAtZ(0);
162  const Vector2D& movePerZ = wire.getMovePerZ();
163  ILayer iCLayer(wire.getICLayer());
164  //B2INFO("movePerZ = " << movePerZ);
165  const ESign distSign = this->getDistanceSign(houghBox,
166  pos2D.x(), pos2D.y(),
167  signedDriftLength,
168  movePerZ.x(), movePerZ.y(),
169  iCLayer);
170  const bool isIn = distSign == ESign::c_Zero;
171  return isIn;
172  }
173 
174  public:
176  void setRLWeightGain(float rlWeightGain)
177  { m_rlWeightGain = rlWeightGain;}
178 
180  float setRLWeightGain() const
181  { return m_rlWeightGain; }
182 
183  private:
185  float m_rlWeightGain = 0;
186  };
187 
188  }
190 }
Belle2::TrackFindingCDC::CDCRLWireHit::setRLInfo
void setRLInfo(const ERightLeft rlInfo)
Setter for the right left passage information.
Definition: CDCRLWireHit.h:250
Belle2::TrackFindingCDC::StereoHitContained::contains
bool contains(const HoughBox &houghBox, const CDCWire &wire, double signedDriftLength)
Checks if a wire hit at a signed drift length is contained in the hough space part.
Definition: StereoHitContained.h:166
Belle2::TrackFindingCDC::CDCRLWireHit::getWire
const CDCWire & getWire() const
Getter for the wire the oriented hit associated to.
Definition: CDCRLWireHit.cc:133
Belle2::TrackFindingCDC::CDCRLWireHit::getRefDriftLength
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:214
Belle2::TrackFindingCDC::StereoHitContained::containsRightOrLeft
ERightLeft containsRightOrLeft(const HoughBox &houghBox, const CDCWire &wire, double driftLength, ERightLeft rlInfo=ERightLeft::c_Unknown)
Checks if a wire hit at a drift length is contained in the hough space part It investigates both righ...
Definition: StereoHitContained.h:146
Belle2::TrackFindingCDC::NForwardBackward::isValid
bool isValid(EForwardBackward eForwardBackward)
Check whether the given enum instance is one of the valid values.
Definition: EForwardBackward.h:55
Belle2::TrackFindingCDC::ESignUtil::ESign
ESign
Enumeration for the distinct sign values of floating point variables.
Definition: ESign.h:37
Belle2::TrackFindingCDC::CDCRecoHit2D
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:57
Belle2::TrackFindingCDC::CDCRLWireHit::getRLInfo
ERightLeft getRLInfo() const
Getter for the right left passage information.
Definition: CDCRLWireHit.h:244
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCRLWireHit
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:51
Belle2::TrackFindingCDC::NRightLeft::ERightLeft
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:35
Belle2::TrackFindingCDC::CDCWire
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:60
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::StereoHitContained::setRLWeightGain
float setRLWeightGain() const
Getter for the gain in weight for hits which rl passage could be uniquly resolved.
Definition: StereoHitContained.h:188
Belle2::TrackFindingCDC::StereoHitContained::operator()
Weight operator()(const CDCSegment2D *segment2D, const HoughBox *houghBox)
Checks if more than 66% of the hits in this segment are contained in the phi0 curv hough space Return...
Definition: StereoHitContained.h:57
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::TrackFindingCDC::StereoHitContained::HoughBox
typename AInBox::HoughBox HoughBox
The hough box which represents the hough space part to be investigated.
Definition: StereoHitContained.h:52
Belle2::TrackFindingCDC::StereoHitContained::m_rlWeightGain
float m_rlWeightGain
Weight gain for a hit which right left passage hypotheses could be uniquely resolved.
Definition: StereoHitContained.h:193