Belle II Software development
StereoHitContained.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/trackingUtilities/eventdata/segments/CDCSegment2D.h>
11#include <tracking/trackingUtilities/eventdata/hits/CDCRLWireHit.h>
12#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
13
14#include <cdc/topology/CDCWire.h>
15
16#include <tracking/trackingUtilities/numerics/ESign.h>
17#include <tracking/trackingUtilities/numerics/Weight.h>
18
19#include <Math/Vector2D.h>
20
21#include <numeric>
22
23namespace 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 TrackingUtilities::Weight operator()(const TrackingUtilities::CDCSegment2D* segment2D,
50 const HoughBox* houghBox)
51 {
52 size_t nHits = segment2D->size();
53 auto weightOfHit = [this, &houghBox](const TrackingUtilities::Weight & totalWeight,
54 const TrackingUtilities::CDCRecoHit2D & recoHit2D) -> TrackingUtilities::Weight {
55 TrackingUtilities::Weight hitWeight = this->operator()(&recoHit2D, houghBox);
56 return std::isnan(hitWeight) ? totalWeight : totalWeight + hitWeight;
57 };
58
59 TrackingUtilities::Weight totalWeight = std::accumulate(segment2D->begin(),
60 segment2D->end(),
61 static_cast<TrackingUtilities::Weight>(0.0),
62 weightOfHit);
63
64 // Require a efficiency of 66%
65 constexpr const TrackingUtilities::Weight minEfficiency = 2.0 / 3;
66 if (totalWeight > nHits * minEfficiency) {
67 return totalWeight;
68 } else {
69 return NAN;
70 }
71 }
72
76 TrackingUtilities::Weight operator()(const TrackingUtilities::CDCRecoHit2D* recoHit2D,
77 const HoughBox* houghBox)
78 {
79 const CDC::CDCWire& wire = recoHit2D->getWire();
80 const double signedDriftLength = recoHit2D->getSignedRefDriftLength();
81 bool isIn = contains(*houghBox, wire, signedDriftLength);
82 TrackingUtilities::ERightLeft rlInfo = recoHit2D->getRLInfo();
83 return isIn ? 1.0 + isValid(rlInfo) * m_rlWeightGain : NAN;
84 }
85
86
92 TrackingUtilities::Weight operator()(const TrackingUtilities::CDCWireHit* wireHit,
93 const HoughBox* houghBox)
94 {
95 const CDC::CDCWire& wire = wireHit->getWire();
96 const double driftLength = wireHit->getRefDriftLength();
97
98 TrackingUtilities::ERightLeft rlInfo = containsRightOrLeft(*houghBox, wire, driftLength);
99 return isValid(rlInfo) ? 1.0 + std::abs(rlInfo) * m_rlWeightGain : NAN;
100 }
101
113 TrackingUtilities::Weight operator()(TrackingUtilities::CDCRLWireHit& rlTaggedWireHit,
114 const HoughBox* houghBox)
115 {
116 const CDC::CDCWire& wire = rlTaggedWireHit.getWire();
117 const TrackingUtilities::ERightLeft rlInfo = rlTaggedWireHit.getRLInfo();
118 const double driftLength = rlTaggedWireHit.getRefDriftLength();
119
120 TrackingUtilities::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 TrackingUtilities::ERightLeft containsRightOrLeft(const HoughBox& houghBox,
139 const CDC::CDCWire& wire,
140 double driftLength,
141 TrackingUtilities::ERightLeft rlInfo = TrackingUtilities::ERightLeft::c_Unknown)
142 {
143 bool isRightIn = rlInfo != TrackingUtilities::ERightLeft::c_Left and contains(houghBox, wire, driftLength);
144 bool isLeftIn = rlInfo != TrackingUtilities::ERightLeft::c_Right and contains(houghBox, wire, -driftLength);
145
146 if (isRightIn and isLeftIn) {
147 return TrackingUtilities::ERightLeft::c_Unknown;
148 } else if (isRightIn) {
149 return TrackingUtilities::ERightLeft::c_Right;
150 } else if (isLeftIn) {
151 return TrackingUtilities::ERightLeft::c_Left;
152 } else {
153 return TrackingUtilities::ERightLeft::c_Invalid;
154 }
155 }
156
158 bool contains(const HoughBox& houghBox, const CDC::CDCWire& wire, double signedDriftLength)
159 {
160 const ROOT::Math::XYVector& pos2D = wire.getRefPos2D();
161 //const ROOT::Math::XYVector& pos2D = wire.getWirePos2DAtZ(0);
162 const ROOT::Math::XYVector& movePerZ = wire.getMovePerZ();
163 CDC::ILayer iCLayer(wire.getICLayer());
164 //B2INFO("movePerZ = " << movePerZ);
165 const TrackingUtilities::ESign distSign = this->getDistanceSign(houghBox,
166 pos2D.x(), pos2D.y(),
167 signedDriftLength,
168 movePerZ.x(), movePerZ.y(),
169 iCLayer);
170 const bool isIn = distSign == TrackingUtilities::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}
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
const ROOT::Math::XYVector & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
Definition CDCWire.h:221
ROOT::Math::XYVector getMovePerZ() const
Getter for the vector describing the nominal positional change in the xy plane per unit z.
Definition CDCWire.h:244
ILayer getICLayer() const
Getter for the continuous layer id ranging from 0 - 55.
Definition CDCWire.h:142
Predicate class to check for the containment of axial and stereo hits in some hough space part.
typename AInBox::HoughBox HoughBox
The hough box which represents the hough space part to be investigated.
TrackingUtilities::Weight operator()(TrackingUtilities::CDCRLWireHit &rlTaggedWireHit, const HoughBox *houghBox)
Checks if the wire hit is contained in a phi0 curv hough space.
float m_rlWeightGain
Weight gain for a hit which right left passage hypotheses could be uniquely resolved.
TrackingUtilities::ERightLeft containsRightOrLeft(const HoughBox &houghBox, const CDC::CDCWire &wire, double driftLength, TrackingUtilities::ERightLeft rlInfo=TrackingUtilities::ERightLeft::c_Unknown)
Checks if a wire hit at a drift length is contained in the hough space part It investigates both righ...
TrackingUtilities::Weight operator()(const TrackingUtilities::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...
TrackingUtilities::Weight operator()(const TrackingUtilities::CDCWireHit *wireHit, const HoughBox *houghBox)
Checks if the wire hit is contained in a phi0 curv hough space.
void setRLWeightGain(float rlWeightGain)
Setter for the gain in weight for hits which rl passage could be uniquly resolved.
bool contains(const HoughBox &houghBox, const CDC::CDCWire &wire, double signedDriftLength)
Checks if a wire hit at a signed drift length is contained in the hough space part.
TrackingUtilities::Weight operator()(const TrackingUtilities::CDCRecoHit2D *recoHit2D, const HoughBox *houghBox)
Checks if the two dimensional reconstructed hit is contained in a phi0 curv hough space.
float setRLWeightGain() const
Getter for the gain in weight for hits which rl passage could be uniquly resolved.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
const CDC::CDCWire & getWire() const
Getter for the wire the oriented hit associated to.
void setRLInfo(const ERightLeft rlInfo)
Setter for the right left passage information.
ERightLeft getRLInfo() const
Getter for the right left passage information.
Class representing a two dimensional reconstructed hit in the central drift chamber.
const CDC::CDCWire & getWire() const
Getter for the wire the reconstructed hit associated to.
double getSignedRefDriftLength() const
Getter for the drift length at the wire reference position signed with the right left passage hypothe...
ERightLeft getRLInfo() const
Getter for the right left passage information.
A reconstructed sequence of two dimensional hits in one super layer.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:56
signed short ILayer
The type of the layer ids enumerating layers within a superlayer.
Definition ILayer.h:18
Abstract base class for different kinds of events.