12 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
13 #include <tracking/trackFindingCDC/eventdata/hits/CDCRLWireHit.h>
14 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
16 #include <tracking/trackFindingCDC/topology/CDCWire.h>
18 #include <tracking/trackFindingCDC/numerics/ESign.h>
19 #include <tracking/trackFindingCDC/numerics/Weight.h>
28 namespace TrackFindingCDC {
36 template<
class AInBox>
37 class StereoHitContained :
public AInBox {
44 using HoughBox =
typename AInBox::HoughBox;
52 size_t nHits = segment2D->size();
53 auto weightOfHit = [
this, &houghBox](
const Weight & totalWeight,
55 Weight hitWeight = this->
operator()(&recoHit2D, houghBox);
56 return std::isnan(hitWeight) ? totalWeight : totalWeight + hitWeight;
59 Weight totalWeight = std::accumulate(segment2D->begin(),
61 static_cast<Weight
>(0.0),
65 constexpr
const Weight minEfficiency = 2.0 / 3;
66 if (totalWeight > nHits * minEfficiency) {
76 Weight
operator()(
const CDCRecoHit2D* recoHit2D,
79 const CDCWire& wire = recoHit2D->getWire();
80 const double signedDriftLength = recoHit2D->getSignedRefDriftLength();
81 bool isIn =
contains(*houghBox, wire, signedDriftLength);
95 const CDCWire& wire = wireHit->getWire();
96 const double driftLength = wireHit->getRefDriftLength();
99 return isValid(rlInfo) ? 1.0 + std::abs(rlInfo) *
m_rlWeightGain : NAN;
124 return isValid(newRLInfo) ? 1.0 + std::abs(newRLInfo) *
m_rlWeightGain : NAN;
143 bool isRightIn = rlInfo != ERightLeft::c_Left and
contains(houghBox, wire, driftLength);
144 bool isLeftIn = rlInfo != ERightLeft::c_Right and
contains(houghBox, wire, -driftLength);
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;
153 return ERightLeft::c_Invalid;
158 bool contains(
const HoughBox& houghBox,
const CDCWire& wire,
double signedDriftLength)
160 const Vector2D& pos2D = wire.getRefPos2D();
162 const Vector2D& movePerZ = wire.getMovePerZ();
163 ILayer iCLayer(wire.getICLayer());
165 const ESign distSign = this->getDistanceSign(houghBox,
166 pos2D.x(), pos2D.y(),
168 movePerZ.x(), movePerZ.y(),
170 const bool isIn = distSign == ESign::c_Zero;